I have generated 10 random exponential functions with some restrictions. I chose the lower and higher values of the a, b and c (see below) randomly.
a = random.uniform(0, 5)
b = random.uniform(1, 6)
c = random.uniform(-5, 5)
Actually I used the random uniform ranges from another example. Now I need to explain why I used this ranges, does somebody know how these ranges are dependent on the exponential functions? I only figured out that the computational cost is higher when these values are very high, but otherwise I can use any number that I want and the outputs are exactly the same..
# Restrictions
max_value = 2
min_length = 10
n_functions = 10
# Noise
mu = 0
sigma = 0.01
#%% Create exponentials
curve_list = []
curve_count = 0
id_count = 0
df = pd.DataFrame(columns=['x', 'y', 'id'])
while(1):
df_ = pd.DataFrame(columns=['x', 'y', 'id'])
a = random.uniform(0, 5)
b = random.uniform(1, 6)
c = random.uniform(-5, 5)
if (max_value-c) > 0:
len_func = np.log((max_value-c)/a)/np.log(b)
else:
len_func = 0
if len_func > min_length:
x = np.arange(0, len_func, 0.1)
func = a*(b**x)+c
if func[0] > 0:
noise = np.random.normal(mu, sigma, [len(func)])
df_.x = func+noise
df_.y = np.arange(len(func)-1, -1, -1)
df_.id = id_count
df = pd.concat([df, df_])
id_count = id_count + 1
curve_count = curve_count + 1
if curve_count == n_functions+1:
break
Aucun commentaire:
Enregistrer un commentaire