Hi, Is Scipy able to calculate empirical CDF (calculating a CDF from a sequence of random samples)? I have searched the documentation for quite a while, but have found nothing useful.
Well, it can make a histogram (numpy.histogram), and then you could just sum the bins to make a cdf. On Sun, Oct 14, 2012 at 11:03 AM, Degang Wu <samuelandjw@gmail.com> wrote:
Hi,
Is Scipy able to calculate empirical CDF (calculating a CDF from a sequence of random samples)? I have searched the documentation for quite a while, but have found nothing useful. _______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
On Sun, Oct 14, 2012 at 12:12 PM, Kevin Gullikson <kevin.gullikson.signup@gmail.com> wrote:
Well, it can make a histogram (numpy.histogram), and then you could just sum the bins to make a cdf.
On Sun, Oct 14, 2012 at 11:03 AM, Degang Wu <samuelandjw@gmail.com> wrote:
Hi,
Is Scipy able to calculate empirical CDF (calculating a CDF from a sequence of random samples)? I have searched the documentation for quite a while, but have found nothing useful.
depends on what you want to do with it in the simplest case it's just sorting and (np.arange(len(data)) + 1) / (len(data) + 1) or similar scipy.stats.mstats has plotting positions statsmodels has a class for it https://github.com/statsmodels/statsmodels/blob/master/statsmodels/distribut... which is not in the docs. but for example qqplot, Probability plots code it directly http://statsmodels.sourceforge.net/devel/_modules/statsmodels/graphics/gofpl... Josef
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
_______________________________________________ SciPy-User mailing list SciPy-User@scipy.org http://mail.scipy.org/mailman/listinfo/scipy-user
On Sun, Oct 14, 2012 at 12:03 PM, Degang Wu <samuelandjw@gmail.com> wrote:
Hi,
Is Scipy able to calculate empirical CDF (calculating a CDF from a sequence of random samples)? I have searched the documentation for quite a while, but have found nothing useful.
We have an empirical distribution class in statsmodels. http://statsmodels.sourceforge.net/ The sm.nonparametric.KDE class also has the ability to return a CDF for a fitted density estimator. If you're feeling ambitious and want to make a pull request the ECDF needs a little clean-up. The ECDF class could use a plot method that incorporates the private _conf_set, and there is finished code to use interpolation instead of the step function but it's not available in the API yet. import urllib from statsmodels.distributions import ECDF from statsmodels.distributions.empirical_distribution import _conf_set import matplotlib.pyplot as plt print ECDF.__doc__ nerve_data = urllib.urlopen('http://www.statsci.org/data/general/nerve.txt') nerve_data = np.loadtxt(nerve_data) x = nerve_data / 50. # was in 1/50 seconds cdf = ECDF(x) x.sort() F = cdf(x) fig, ax = plt.subplots() ax.step(x, F) lower, upper = _conf_set(F) ax.step(x, lower, 'r') ax.step(x, upper, 'r') ax.set_xlim(0, 1.5) ax.set_ylim(0, 1.05) ax.vlines(x, 0, .05) plt.show() Skipper
participants (4)
-
Degang Wu -
josef.pktd@gmail.com -
Kevin Gullikson -
Skipper Seabold