0

I know that if I want to get a probability values from inteval a to b i have to calculate integaral from pdf my distribution. I know that my data has The Cauchy distribution, but i don't understand how can I get prob of interval for example from 95 to 100. How i can do it easy way or easy is not possible?

My code for hist of distribution:

# Display
plt.figure(figsize=(15,10))
ax = pdf.plot(lw=2, label='PDF', legend=True)
data.plot(kind='hist', bins=50, normed=True, label='Data', legend=True, 
ax=ax, lw=2, color='g', alpha=0.4)
mu, std = norm.fit(data)
param_names = (best_dist.shapes + ', loc, scale').split(', ') if 
best_dist.shapes else ['loc', 'scale']
param_str = ', '.join(['{}={:0.2f}'.format(k,v) for k,v in zip(param_names, 
best_fir_paramms)])
dist_str = '{}(mu = {:0.2f}, std = {:0.2f})'.format(best_fit_name, mu, std)
ax.set_title(u'Distribution \n' + dist_str)
ax.set_ylabel('F(x)')

hist of distribution

My code for hist values:

ser = Series(df)
out = pd.cut(ser, bins=[0, 85, 90, 92, 94, 96, 98, 100], include_lowest=True)
ax = out.value_counts(sort=False).plot.bar(rot=0, color='g', alpha=0.4, 
title='Values', figsize=(10,8))
ax.set_xticklabels([c[1:-1].replace(',',' to') for c in out.cat.categories])
plt.show()

hist values

I want to get value of probability interval from 90 to 100. How can i do it by dint of python. Thank you.

LazyTitan
  • 43
  • 9
Aleksandr
  • 13
  • 4

1 Answers1

0

to see if the number is between say 118 and 154 :

from scipy.stats import cauchy
print(cauchy.cdf(154) - cauchy.cdf(118));

answer 0.000630558571138, the probability that your RV is between these two numbers

  • Yes, but how can i count it in my case? How can I get cdf plot and count integral? – Aleksandr Feb 06 '18 at 16:50
  • what do you mean count the integral ? to plot it do sth like `pd.Series(range(-200,200)).apply(lambda x:cauchy.cdf(x)).plot();` – stressed_quant Feb 08 '18 at 10:47
  • I mean that you can calculate cdf for pdf of Cauchy distribution for my case. I don't understand how I can get probability for my data. If I have the most examples in interval 98 to 100, I have to get the tall probability, aren't I? – Aleksandr Feb 08 '18 at 13:16
  • so you want to fit the data to a Cauchy distribution ? try this [https://stackoverflow.com/questions/6620471/fitting-empirical-distribution-to-theoretical-ones-with-scipy-python](https://stackoverflow.com/questions/6620471/fitting-empirical-distribution-to-theoretical-ones-with-scipy-python) – stressed_quant Feb 08 '18 at 13:50
  • or [https://stackoverflow.com/questions/38711541/how-to-compute-the-probability-of-a-value-given-a-list-of-samples-from-a-distrib](https://stackoverflow.com/questions/38711541/how-to-compute-the-probability-of-a-value-given-a-list-of-samples-from-a-distrib) – stressed_quant Feb 08 '18 at 13:56