• + 4 comments

    Here is how I did figure it out. If somebody want to dig into this task and learn step by step solution.

    from math import erf
    n = 100
    # map mean and sigma to normal distribution with
    # the following parameters by The Centeral Limit Theorem
    mean = n*500
    sigma = n**0.5*80
    # Defining Phi function for CDF of our 
    # retrieved Normal Distribution 
    phi = lambda x: 0.5*(1+erf((x-mean)/(2**0.5*sigma)))
    target = 0.95  # initiating target of 95 %
    # Probability of our confidance interval
    # given z-score value
    ci_prob = lambda z: phi(z*sigma+mean)-phi(-z*sigma+mean)
    # True if our CI of z-score achieved desired probability
    found = lambda z: target <= round(ci_prob(z), 3)
    z = 0.01  # initial z-score
    # interating z until our CI satisfies our target
    while not found(z): z += 0.01 
    # getting left and right interval values and mapping
    # back from normal distribution to initial distribution 
    # by multiplying both values by 1/n, i.e. values in
    # initial distribution where n times less due to additive
    # property of an EV
    print(round((-z*sigma+mean)/n, 2))
    print(round((z*sigma+mean)/n, 2))
    

    Additionaly you may need those sources: