Created
June 19, 2015 17:08
-
-
Save awesomebytes/c6ce7018b397480d111b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env python | |
# -*- coding: utf-8 -*- | |
""" | |
Created on 6/19/15 | |
@author: sampfeiffer | |
exponential_array_creator.py contains... | |
""" | |
__author__ = 'sampfeiffer' | |
def create_exponential_list(number_of_values, base_number=1.9): | |
""" | |
:param number_of_values: how many values in between 0.0 and 1.0 you want the resulting array | |
:param base_number: The bigger base_number is, the more is the curve hugging the right vertical axis, try from 1.X to 5.0 | |
:return: list of values following an exponential curve from 0.0 to 1.0 | |
""" | |
initial_list = [] | |
for i in range(1, number_of_values): | |
initial_list.append(base_number**i) | |
#print "initial_list: " + str(initial_list) | |
final_list = [] | |
for elem in initial_list: | |
# this is a "regla de 3" in spanish | |
final_list.append((elem * 1.0)/initial_list[-1]) | |
return final_list | |
if __name__ == '__main__': | |
# print "I want 8 values following an exponential curve in between 0 and 1" | |
# expo_list = create_exponential_list(8, base_number=5.0) | |
# print "Here you go:\n[", | |
# for elem in expo_list: | |
# print str(round(elem, 3)) + ", ", | |
# print "]\n" | |
# | |
# from pylab import * | |
# time = range(len(expo_list)) | |
# plot(time, expo_list) | |
# show() | |
# print "I want 100 values following an exponential curve in between 0 and 1" | |
# expo_list = create_exponential_list(100, base_number=1.3) | |
# print "Here you go:\n[", | |
# for elem in expo_list: | |
# print str(round(elem, 3)) + ", ", | |
# print "]\n" | |
# | |
# from pylab import * | |
# time = range(len(expo_list)) | |
# plot(time, expo_list) | |
# show() | |
from numpy import arange | |
for base_number in arange(1.0, 5.0, 0.25): | |
expo_list = create_exponential_list(10, base_number=base_number) | |
print "base_number: " + str(base_number) | |
print "Here you go:\n[", | |
for elem in expo_list: | |
print str(round(elem, 3)) + ", ", | |
print "]\n" | |
from pylab import * | |
time = range(len(expo_list)) | |
plot(time, expo_list) | |
show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment