Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import scipy.stats as stats
- '''
- Formula for calculating area under the graph for distribution
- stats.norm.cdf(x, loc, scale)
- where
- x: the value of interest
- loc: the mean of the probability distribution
- scale: the standard deviation of the probability distribution
- '''
- # to calculate a randomly chosen woman is less than 175 cm tall.
- # given Normal(167.64, 8) - mean = 167.64, standard deviation = 8 cm
- prob = stats.norm.cdf(175, 167.64, 8)
- print(prob)
- # given normal distribution with a mean of 20 degrees Celcius and a standard deviation of 3 degrees
- # calculate probability that the weather on a randomly selected day will be between 18 to 25 degrees
- temp_prob_1 = stats.norm.cdf(25, 20, 3) - stats.norm.cdf(18, 20, 3)
- print(temp_prob_1)
- # calculate probability that the weather on a randomly selected day will be greater than 24 degrees Celsius.
- temp_prob_2 = 1 - stats.norm.cdf(24, 20, 3)
- print(temp_prob_2)
Add Comment
Please, Sign In to add comment