<p>To follow up on @Robert Dodier 's comment, reading <a href="http://arxiv.org/pdf/1207.6002.pdf" rel="nofollow noreferrer">http://arxiv.org/pdf/1207.6002.pdf</a> you'll find a recipe for Maximum Likelihood estimation, which I adapt here:</p>

<pre><code>import scipy
import scipy.stats as sciStat
import scipy.optimize as sciOpt

def myMleEstimate(myFunc, par, data):
    def lnL_av(x, par):
        N = len(x)
        lnL = 0.
        for i in range(N):
            lnL += scipy.log(myFunc(par, x[i]))
        return lnL/N

    objFunc = lambda s: -lnL_av(data, s)
    par_mle = sciOpt.fmin(objFunc, par, disp=0)
    return par_mle
</code></pre>

<p>If you'd want to model a Rayleigh, you'd:</p>

<pre><code>from scipy.stats import rayleigh
Rayleigh = lambda par, x: sciStat.rayleigh.pdf(x, loc=par[0], scale=par[1])
</code></pre>

<p>And estimate from your <em>data</em>:</p>

<pre><code>estimated = myMleEstimate(Rayleigh, [0, 1], data)
</code></pre>

<p>(Here I chose 0, 1 starting parameters).</p>

<p>To test the last line, you could first sample a thousand data points using:</p>

<pre><code># parameters
params = {
    'loc': 1,
    'scale': 2
}
data = rayleigh.rvs(loc=params['loc'], scale=params['scale'], size=1000)
</code></pre>

<hr>

<p>And yes, I understand that a K-distro is a compound of two gammas, not a Rayleigh. But sources such as <a href="http://oai.dtic.mil/oai/oai?verb=getRecord&amp;metadataPrefix=html&amp;identifier=ADA368069" rel="nofollow noreferrer">Estimating the Parameters of the K Distribution in the Intensity Domain</a> point out that it is quite difficult with ML estimation.</p>

<p><em>So you got what you asked, a Python recipe, but this may not be what you need.</em></p>
Python fit K distribution (defined by me) on data
<p>I have a sample distribution of data which I would like to fit with some not Python embedded statistics in scipy.stats, such as the K pdf.
Is it then possible to do so? Are there, by chance other modules that have the k distribution or other not gaussian pdfs available?</p>

<p>Thanks for your help!</p>