Is there a way to calculate the square of a number (closest approximation), say 4, using Gaussian distribution where mu is the number and sigma is 0.16. and for 1000 random points?
I searched the internet a lot, but couldn't find a solution to this. Any piece of code would be very much helpful as i am new to python.
Assuming that you have your data generated you could find an approximation of your mu (which is the square of your number) by taking the mean of your data. By the law of the large numbers you can be sure that as the size of your data grow the approximation become more accurate. Example:
import random
def generate_data(size):
mu, sigma = 4 ** 2, 0.16
return [random.gauss(mu, sigma) for _ 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
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments