# PDF of $(1+X)^N$ where $X \sim \operatorname{uniform}(-0.01, 0.01)$ [closed]

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()


• Please add the self-study tag & read its wiki. Then tell us what you understand thus far, what you've tried & where you're stuck. We'll provide hints to help you get unstuck. Please make these changes as just posting your homework & hoping someone will do it for you is grounds for closing. Commented Mar 11 at 16:23
• @kjetilbhalvorsen This is not a homework question. I googled and asked ChatGPT, but couldn't find answers, this is all I got so far. Commented Mar 11 at 16:27
• stats.stackexchange.com/questions/3707 is a closely related question.
– whuber
Commented Mar 11 at 17:43
• Re "surprising:" Consider the simplest possible non-trivial instance of this phenomenon where the price changes independently twice, increasing or decreasing 50% with equal chances each time. The four possible outcomes, each with chance $1/4,$ are relative prices of $(1-0.5)^2=0.25,$ $(1-0.5)(1.5)=0.75,$ $(1+0.5)(1-0.5)=0.75,$ and $(1+0.5)(1+0.5)=2.25.$ Please contemplate (a) what the expected outcome is and (b) what proportion of outcomes are net decreases from the original price.
– whuber
Commented Mar 11 at 20:39
• There’s a difference between taking the same random variable and raising it to a power and taking many random variables (even if they are identically distributed) and multiplying them @em1971 Commented Mar 11 at 23:50