Anomalies when trying to fit student's t distribution using scipy
<p>I am trying to fit a t distribution to some data that I have. In order to test it out I first tried to generate a sample from a fixed distribution and try to fit on it. Below is the code that I am using.</p>

<pre><code>samp = t.rvs(loc=0, scale=0.6, df=1.3, size=150)

param = t.fit(samp)

x = linspace(-5,5,100)

pdf_fitted = t.pdf(x,loc=param[0],scale=param[1],df=param[2])
pdf = t.pdf(x,loc=0,scale=0.6,df=1.3)

title('Student\'s t Distribution')
plot(x,pdf_fitted,'r-',x,pdf,'b-')
hist(samp, normed=1,alpha=0.3)
show()
print(param)
</code></pre>

<p>Now, one would expect that <code>pdf</code> and <code>pdf_fitted</code> be essentially the same. However, that is not the case. When the plots are shown the original and fitted distributions look very different. Moreover, the parameters obtained do not match the ones specified (loc=0, scale=0.6, df=1.3) at all! This confuses me because I am simply adapting the code from <a href="http://glowingpython.blogspot.com/2012/07/distribution-fitting-with-scipy.html" rel="nofollow">http://glowingpython.blogspot.com/2012/07/distribution-fitting-with-scipy.html</a> to work with t distributions. Can someone tell me if there are any nuances with fitting t distributions? Thanks</p>