<p dir="auto">I am testing the fitting functionality of scipy. I noticed that I can fix certain shape parametrs, fix the <code class="notranslate">loc</code> and <code class="notranslate">scale</code>, as well as give starting points for <code class="notranslate">scale</code> and <code class="notranslate">loc</code>. Is it also possible to give starting positions for shape parameters? Simply put I'd like to be able to specify <code class="notranslate">s</code> in the following example</p>
<div class="highlight highlight-source-python notranslate position-relative overflow-auto" dir="auto" data-snippet-clipboard-copy-content="from scipy.stats import lognorm

scale = 1.0
loc = 1.0
s = 2.0

data = lognorm(s=s, loc=loc, scale=scale).rvs(100)

params = lognorm.fit(data, loc=loc, scale=scale)
print(params)"><pre class="notranslate"><span class="pl-k">from</span> <span class="pl-s1">scipy</span>.<span class="pl-s1">stats</span> <span class="pl-k">import</span> <span class="pl-s1">lognorm</span>

<span class="pl-s1">scale</span> <span class="pl-c1">=</span> <span class="pl-c1">1.0</span>
<span class="pl-s1">loc</span> <span class="pl-c1">=</span> <span class="pl-c1">1.0</span>
<span class="pl-s1">s</span> <span class="pl-c1">=</span> <span class="pl-c1">2.0</span>

<span class="pl-s1">data</span> <span class="pl-c1">=</span> <span class="pl-en">lognorm</span>(<span class="pl-s1">s</span><span class="pl-c1">=</span><span class="pl-s1">s</span>, <span class="pl-s1">loc</span><span class="pl-c1">=</span><span class="pl-s1">loc</span>, <span class="pl-s1">scale</span><span class="pl-c1">=</span><span class="pl-s1">scale</span>).<span class="pl-en">rvs</span>(<span class="pl-c1">100</span>)

<span class="pl-s1">params</span> <span class="pl-c1">=</span> <span class="pl-s1">lognorm</span>.<span class="pl-en">fit</span>(<span class="pl-s1">data</span>, <span class="pl-s1">loc</span><span class="pl-c1">=</span><span class="pl-s1">loc</span>, <span class="pl-s1">scale</span><span class="pl-c1">=</span><span class="pl-s1">scale</span>)
<span class="pl-en">print</span>(<span class="pl-s1">params</span>)</pre></div>
<p dir="auto">I've got a numpy.ndarray of shape (24569,) (also tried with (24569,1)) with samples of random variables (not the distribution)</p>
<p dir="auto"><code class="notranslate">fit_alpha, fit_loc, fit_beta=stats.gamma.fit(data)</code></p>
<p dir="auto">results in fit_alpha and fit_loc being nans, while fit_beta = 1</p>
<p dir="auto"><code class="notranslate">I've tried to suggest starting parameters by using stats.gamma.fit(data,a=k,loc=0,scale=theta)</code><br>
where k = 4/skew^2, theta=variance/mean are the shape and scale parameters respectively.</p>
<p dir="auto">But I got the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="
/usr/local/lib/python2.7/dist-packages/scipy/stats/_continuous_distns.pyc in fit(self, data, *args, **kwds)
   1916         if floc is None:
   1917             # loc is not fixed.  Use the default fit method.
-&gt; 1918             return super(gamma_gen, self).fit(data, *args, **kwds)
   1919 
   1920         # Special case: loc is fixed.

/usr/local/lib/python2.7/dist-packages/scipy/stats/_distn_infrastructure.pyc in fit(self, data, *args, **kwds)
   2126         # by now kwds must be empty, since everybody took what they needed
   2127         if kwds:
-&gt; 2128             raise TypeError(&quot;Unknown arguments: %s.&quot; % kwds)
   2129 
   2130         vals = optimizer(func, x0, args=(ravel(data),), disp=0)

TypeError: Unknown arguments: {'a': 0.14115690248522836}.
"><pre class="notranslate"><code class="notranslate">
/usr/local/lib/python2.7/dist-packages/scipy/stats/_continuous_distns.pyc in fit(self, data, *args, **kwds)
   1916         if floc is None:
   1917             # loc is not fixed.  Use the default fit method.
-&gt; 1918             return super(gamma_gen, self).fit(data, *args, **kwds)
   1919 
   1920         # Special case: loc is fixed.

/usr/local/lib/python2.7/dist-packages/scipy/stats/_distn_infrastructure.pyc in fit(self, data, *args, **kwds)
   2126         # by now kwds must be empty, since everybody took what they needed
   2127         if kwds:
-&gt; 2128             raise TypeError("Unknown arguments: %s." % kwds)
   2129 
   2130         vals = optimizer(func, x0, args=(ravel(data),), disp=0)

TypeError: Unknown arguments: {'a': 0.14115690248522836}.

</code></pre></div>
<p dir="auto">after using floc=0 as a parameter (which is not documented anywhere as far as I can tell) I got an exception pointing out that negative values are not allowed in data (I got one negative "error" value in the data) - after fixing this, I got results which made sense...</p>
<p dir="auto">The documentation on that fit function is lacking - it also does not mention that the parameters returned are shape, loc, scale, as well as that fa, floc and fscale are not suggestions of initial fit, but are constraints on the fit to keep these values fixed. There appears to be no way to suggest initial parameters.</p>