Given the mean and standard deviation of a normal distribution, how in Python can I determine the quartile of a given point?
E.g.:
Which quartile is the value 0.75 in, with Python?
I'm after the quartile itself, not the quartile bounds - i.e. a function should take m, s, and val, and return quartile in the range 0 to 3.
You can define your own function to return the quartile order, being 0,1,2 or 3
def normal_quartile(mu, sigma, value):
quartiles = []
quartiles.append( mu- 0.675*sigma )
quartiles.append( mu )
quartiles.append( mu+ 0.675*sigma )
for i, q in enumerate(quartiles):
if value < q:
return i
return 3
print( normal_quartile(0.7, 0.1, 0.55) )
print( normal_quartile(0.7, 0.1, 0.65) )
print( normal_quartile(0.7, 0.1, 0.75) )
print( normal_quartile(0.7, 0.1, 0.95) )
results are:
0
1
2
3