[SciPy-User] scipy.stats.norm strange doc string

Daniel Lepage dplepage@gmail....
Sun Mar 13 15:24:16 CDT 2011


Also, I believe EM for fitting Gaussian Mixture Models is implemented
in scikits.learn; check out
<http://scikit-learn.sourceforge.net/modules/generated/scikits.learn.mixture.GMM.html>

Hope that helps!

-- 
Dan Lepage

On Sun, Mar 13, 2011 at 3:52 PM, nicky van foreest <vanforeest@gmail.com> wrote:
> Hi,
>
> The doc string of scipy.stats.norm tells me that the location and
> scale parameters are array-like. However, when I try to pass arrays to
> the loc and scale keywords I get an error. Specifically:
>
>
> In [1]: from scipy.stats import norm
>
> In [2]: import numpy as np
>
> In [3]: mu = np.array([1,1])
>
> In [4]: simga = np.array([1,1])
>
> In [5]: x = [0,1,2,3]
>
> In [6]: norm.pdf(x, loc = mu, scale = simga)
>
>
> results in :
>
> ValueError: shape mismatch: objects cannot be broadcast to a single shape
>
> I do understand how to resolve this problem, but for my specific
> purpose I would have liked to pass mu and sigma as arrays, that is, I
> would have liked to achieve
>
>        tau = np.zeros([g,m])
>        for i in range(g):
>            tau[i] = p[i]*norm.pdf(x, loc=mu[i], scale = sigma[i])
>
>
> in one pass.
>
> BTW:
>
> I am using this code to fit a set of normal distributions to a given
> (quite) general distribution function by using the EM algorithm. Is
> this already coded somewhere in scipy? If not, is somebody interested
> in me making this available on the scipy cookbook?
>
> bye
>
> Nicky
> _______________________________________________
> SciPy-User mailing list
> SciPy-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/scipy-user
>


More information about the SciPy-User mailing list