I want to simulate price with the following code:
import numpy as np
import matplotlib.pyplot as plt
final_price = []
for i in range(1000):
amp = 0.01
length = 10000
diff = np.random.uniform(-0.01, 0.01, length)
price = np.cumprod(1 + diff)
final_price.append(price[-1])
plt.hist(final_price, bins=100)
plt.show()
the final price has the following distribution:
I found the following from this paper for question 2.
update
I ran the simulation with the following code and the result is very surprising: at each step, the change is uniformly distributed between -1% and 1%, but at the end, 810 / 1000 ends up smaller than 1, and 190 bigger than 1. This is very counter-intuitive
import matplotlib.pyplot as plt
import numpy as np
Y = []
for i in range(1000):
X = np.random.uniform(0.99, 1.01, 100000)
Y.append(np.prod(X))
Y = np.array(Y)
bigger = sum(Y > 1)
smaller = sum(Y < 1)
plt.title(f"bigger than 1: {bigger}, smaller than 1: {smaller}")
plt.hist(Y, 100)
plt.show()


