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