Python commands for dealing with the normal distribution

In this recent forum assignment, we are asked to compute a $(100-s)\%$ confidence interval. How can we use the computer to find the correct $z^*$ multiplier? More generally, what kinds of commands does Python provide to deal with the normal distribution?


  • edited June 18

    To access commands for the normal distribution, first execute the following:

    from scipy.stats import norm

    Now, the norm object has a bunch of methods - three of which are immediately relevant for us:

    • norm.pdf (the Probability Distribution function),
    • norm.cdf (the Cumulative Distribution function), and
    • norm.ppf (The Point Percentile Function)

    We can see the geometric relevance of these in the following picture:

    Note that the PDF function tells us the value of the probability distribution function, i.e. the $y$-coordinate or $0.1295$ in this case. The CDF function tells us how much area has accumulated under the function. The PPF function is the inverse of the CDF function. Thus, it tells us what $z$ value you want to accumulate a specified amount of area. PPF is exactly what you need to find a $z^*$ multiplier.

    # Out:
    # [0.12951759566589174, 0.9331927987311419, 1.4999999997595546]
Sign In or Register to comment.