Let A, B and C each be random real numbers chosen from the uniform interval (0,1) and z=A+B+C.
If z is written in scientific notation, define X as the second digit of z.
Find the probability distribution of X.
Simulation with 100,000,000 iterations:
[0.1143, 0.1138, 0.1122, 0.1097, 0.1062, 0.1017, 0.0962, 0.0898, 0.0823, 0.0738]
----
import random
data = [0 for i in range(10)]
reps = 100000000
for i in range(reps):
a = random.random()
b = random.random()
c = random.random()
sm = a+b+c
st = str(sm)
st = st.replace('.','')
leading_zero = True
while leading_zero:
if st[0] == '0':
st = st[1:]
else:
leading_zero = False
z = int(st[1])
data[z] += 1
histo = [d/sum(data) for d in data]
print(histo)
|
Posted by Larry
on 2025-03-07 09:06:58 |