[SciPy-user] Fitting a distribution to some data
oliphant.travis at ieee.org
Wed Sep 6 14:29:45 CDT 2006
Jose Luis Gomez Dans wrote:
> I am trying to fit a distribution to some data points (actually, I want to test which distribution is best to model the data). Moreover, I want to estimate the distributions parameters. I am sure that the stats module has many functions to help me with this, but I am not sure I understand how to use them.
> As a test, I create some RVs using say y=stats.distributions.norm.rvs ( size=100).
> I can then find the mean and standard deviation using
> which works fine. However, some methods do not work. For example, the pdf(self,x..) method returns an array of 0s, and similarly for the cdf() method.
Are you using these functions correctly? They seem to work for me.
For example, you don't pass in "self" as the first argument.
Here is a usage
x = r_[-10:10:100j]
y = stats.distribution.norm.pdf(x, loc=0.3, scale=2.0)
> Also, is there some example of how to use kstest? it might be related, but if I try to test the previous data, I get the following error:
Hmm.. This works for me.
mu,sigma = stats.distributions.norm.fit(y)
I am running scipy 0.5.1, but I don't know if that should matter in this
More information about the SciPy-user