Will_smith12
Will_smith12

Reputation: 51

Confidence interval in python

Is there a function or a package in python to get the 95% or 99% confidence interval of the distributions present in scipy.stats.

If not what is easiest alternative for that

Here are the distributions (but my priority is halfgennorm and loglaplace)

    st.alpha,st.anglit,st.arcsine,st.beta,st.betaprime,st.bradford,st.burr,st.cauchy,st.chi,st.chi2,st.cosine,
    st.dgamma, st.dweibull,st.erlang,st.expon,st.exponnorm,st.exponweib,st.exponpow,st.f,st.fatiguelife,st.fisk,
    st.foldcauchy,st.foldnorm,st.frechet_r,st.frechet_l,st.genlogistic,st.genpareto,st.gennorm,st.genexpon,
    st.genextreme,st.gausshyper,st.gamma,st.gengamma,st.genhalflogistic,st.gilbrat,st.gompertz,st.gumbel_r,
    st.gumbel_l,st.halfcauchy,st.halflogistic,st.halfnorm,st.halfgennorm,st.hypsecant,st.invgamma,st.invgauss,
    st.invweibull,st.johnsonsb,st.johnsonsu,st.ksone,st.kstwobign,st.laplace,st.levy,st.levy_l,st.levy_stable,
    st.logistic,st.loggamma,st.loglaplace,st.lognorm,st.lomax,st.maxwell,st.mielke,st.nakagami,st.ncx2,st.ncf,
    st.nct,st.norm,st.pareto,st.pearson3,st.powerlaw,st.powerlognorm,st.powernorm,st.rdist,st.reciprocal,
    st.rayleigh,st.rice,st.recipinvgauss,st.semicircular,st.t,st.triang,st.truncexpon,st.truncnorm,st.tukeylambda,
    st.uniform,st.vonmises,st.vonmises_line,st.wald,st.weibull_min,st.weibull_max,st.wrapcauchy

Upvotes: 3

Views: 2332

Answers (2)

Sadaf Shafi
Sadaf Shafi

Reputation: 1428

here

import statsmodels.api as sm
sm.stats.proportion_confint(906, 906+2066) 

Upvotes: 1

Andi
Andi

Reputation: 1273

You can get confidence intervals from the percent point function (inverse of the cumulative distribution function). You can do something like the following to get lower and upper confidence bounds of a distribution:

lower = rv_continuous.ppf(alpha/2.)
upper = rv_continuous.ppf(1.-alpha/2.)

[rv_continuous can be any of the distributions in scipy.stats.]

Upvotes: 1

Related Questions