I guess it is showing, but you have many data points, so the gaussian
is too small down there. You have to increase its values to make both
areas fit:

plt.plot(bins, N*(bins[1]-bins[0])*y, 'r--', linewidth=1)


And you will get a nice gaussian fitting your data.

On Fri, Jul 27, 2012 at 11:12 PM, surfcast23 <surfcas...@gmail.com> wrote:
>
> Thanks for catching that sigma was still a vector! I am no longer getting the
> errors, but the best fit line is not showing up.Is there something else I am
> missing ?
> BTW thanks for the heads up on the np.mean and np.standard functions.
>
> Khary
>
> Daπid wrote:
>>
>> On Fri, Jul 27, 2012 at 9:57 PM, surfcast23 <surfcas...@gmail.com> wrote:
>>> y = mlab.normpdf( nbins, avg, sigma)
>>> l = plt.plot(nbins, y, 'r--', linewidth=1)
>>> plt.show()
>>
>> You should not change bins there, as you are evaluating the gaussian
>> function at different values.
>>
>> Also, sigma is a vector, but it should be an scalar:
>>
>> sigma = np.sqrt((1./len(C))*(diff**2))
>>
>> should be
>>
>> sigma = np.sum(np.sqrt((1./len(C))*(diff**2)))    # The sum of the
>> previous
>>
>> But, much better, you can change the three lines of code by:
>>
>> avg=np.mean(C)
>> sigma=np.std(C)
>>
>> They are way faster and more numerically accurate and stable.
>>
>>
>> As a rule of thumb, if you want to do something simple, think that
>> there should be an easy way of doing it. And if it is something people
>> do every day (like taking the mean or the std of a vector, or loading
>> from a txt file), there should be a very easy way of doing it. :-) And
>> it would probably be faster and more flexible than any naive
>> implementation.
>>
>>
>> Good luck with your galaxies!
>>
>> ------------------------------------------------------------------------------
>> Live Security Virtual Conference
>> Exclusive live event will cover all the ways today's security and
>> threat landscape has changed and how IT managers can respond. Discussions
>> will include endpoint security, mobile security and the latest in malware
>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>> _______________________________________________
>> Matplotlib-users mailing list
>> Matplotlib-users@lists.sourceforge.net
>> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>>
>>
>
> --
> View this message in context: 
> http://old.nabble.com/ValueError%3A-x-and-y-must-have-same-first-dimension-tp34218704p34222788.html
> Sent from the matplotlib - users mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
> Live Security Virtual Conference
> Exclusive live event will cover all the ways today's security and
> threat landscape has changed and how IT managers can respond. Discussions
> will include endpoint security, mobile security and the latest in malware
> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
> _______________________________________________
> Matplotlib-users mailing list
> Matplotlib-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to