python - square of a number using gaussian distribution -
is there way calculate square of number (closest approximation), 4, using gaussian distribution mu number , sigma 0.16. , 1000 random points?
i searched internet lot, couldn't find solution this. piece of code helpful new python.
assuming have data generated find approximation of mu (which square of number) taking mean of data. law of large numbers can sure size of data grow approximation become more accurate. example:
import random def generate_data(size): mu, sigma = 4 ** 2, 0.16 return [random.gauss(mu, sigma) _ in range(size)] def mean(ls): return sum(ls) / len(ls) print(mean(generate_data(10))) #15.976644889526114 print(mean(generate_data(100))) #16.004123848232233 print(mean(generate_data(1000))) #16.00164187802018 print(mean(generate_data(10000))) #16.001000022147206
Comments
Post a Comment