Documentation updated

This commit is contained in:
fjosw 2021-11-07 21:45:25 +00:00
parent bf3eda40c2
commit eec13a754e
9 changed files with 744 additions and 670 deletions

View file

@ -175,7 +175,7 @@
<span class="k">def</span> <span class="nf">least_squares</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">func</span><span class="p">,</span> <span class="n">priors</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">silent</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Performs a non-linear fit to y = func(x).</span>
<span class="sd"> Arguments:</span>
<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> x : list</span>
<span class="sd"> list of floats.</span>
@ -203,22 +203,23 @@
<span class="sd"> enough.</span>
<span class="sd"> silent : bool, optional</span>
<span class="sd"> If true all output to the console is omitted (default False).</span>
<span class="sd"> Keyword arguments</span>
<span class="sd"> -----------------</span>
<span class="sd"> initial_guess -- can provide an initial guess for the input parameters. Relevant for</span>
<span class="sd"> initial_guess : list</span>
<span class="sd"> can provide an initial guess for the input parameters. Relevant for</span>
<span class="sd"> non-linear fits with many parameters.</span>
<span class="sd"> method -- can be used to choose an alternative method for the minimization of chisquare.</span>
<span class="sd"> The possible methods are the ones which can be used for scipy.optimize.minimize and</span>
<span class="sd"> migrad of iminuit. If no method is specified, Levenberg-Marquard is used.</span>
<span class="sd"> Reliable alternatives are migrad, Powell and Nelder-Mead.</span>
<span class="sd"> resplot -- If true, a plot which displays fit, data and residuals is generated (default False).</span>
<span class="sd"> qqplot -- If true, a quantile-quantile plot of the fit result is generated (default False).</span>
<span class="sd"> expected_chisquare -- If true prints the expected chisquare which is</span>
<span class="sd"> corrected by effects caused by correlated input data.</span>
<span class="sd"> This can take a while as the full correlation matrix</span>
<span class="sd"> has to be calculated (default False).</span>
<span class="sd"> method : str</span>
<span class="sd"> can be used to choose an alternative method for the minimization of chisquare.</span>
<span class="sd"> The possible methods are the ones which can be used for scipy.optimize.minimize and</span>
<span class="sd"> migrad of iminuit. If no method is specified, Levenberg-Marquard is used.</span>
<span class="sd"> Reliable alternatives are migrad, Powell and Nelder-Mead.</span>
<span class="sd"> resplot : bool</span>
<span class="sd"> If true, a plot which displays fit, data and residuals is generated (default False).</span>
<span class="sd"> qqplot : bool</span>
<span class="sd"> If true, a quantile-quantile plot of the fit result is generated (default False).</span>
<span class="sd"> expected_chisquare : bool</span>
<span class="sd"> If true prints the expected chisquare which is</span>
<span class="sd"> corrected by effects caused by correlated input data.</span>
<span class="sd"> This can take a while as the full correlation matrix</span>
<span class="sd"> has to be calculated (default False).</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">priors</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">return</span> <span class="n">_prior_fit</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">func</span><span class="p">,</span> <span class="n">priors</span><span class="p">,</span> <span class="n">silent</span><span class="o">=</span><span class="n">silent</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
@ -370,6 +371,8 @@
<span class="k">def</span> <span class="nf">total_least_squares</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">func</span><span class="p">,</span> <span class="n">silent</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Performs a non-linear fit to y = func(x) and returns a list of Obs corresponding to the fit parameters.</span>
<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> x : list</span>
<span class="sd"> list of Obs, or a tuple of lists of Obs</span>
<span class="sd"> y : list</span>
@ -392,15 +395,14 @@
<span class="sd"> silent : bool, optional</span>
<span class="sd"> If true all output to the console is omitted (default False).</span>
<span class="sd"> Based on the orthogonal distance regression module of scipy</span>
<span class="sd"> Keyword arguments</span>
<span class="sd"> -----------------</span>
<span class="sd"> initial_guess -- can provide an initial guess for the input parameters. Relevant for non-linear</span>
<span class="sd"> fits with many parameters.</span>
<span class="sd"> expected_chisquare -- If true prints the expected chisquare which is</span>
<span class="sd"> corrected by effects caused by correlated input data.</span>
<span class="sd"> This can take a while as the full correlation matrix</span>
<span class="sd"> has to be calculated (default False).</span>
<span class="sd"> initial_guess : list</span>
<span class="sd"> can provide an initial guess for the input parameters. Relevant for non-linear</span>
<span class="sd"> fits with many parameters.</span>
<span class="sd"> expected_chisquare : bool</span>
<span class="sd"> If true prints the expected chisquare which is</span>
<span class="sd"> corrected by effects caused by correlated input data.</span>
<span class="sd"> This can take a while as the full correlation matrix</span>
<span class="sd"> has to be calculated (default False).</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">output</span> <span class="o">=</span> <span class="n">Fit_result</span><span class="p">()</span>
@ -1044,7 +1046,7 @@ also accesible via indices.</li>
<div class="codehilite"><pre><span></span><span class="k">def</span> <span class="nf">least_squares</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">func</span><span class="p">,</span> <span class="n">priors</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span> <span class="n">silent</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Performs a non-linear fit to y = func(x).</span>
<span class="sd"> Arguments:</span>
<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> x : list</span>
<span class="sd"> list of floats.</span>
@ -1072,22 +1074,23 @@ also accesible via indices.</li>
<span class="sd"> enough.</span>
<span class="sd"> silent : bool, optional</span>
<span class="sd"> If true all output to the console is omitted (default False).</span>
<span class="sd"> Keyword arguments</span>
<span class="sd"> -----------------</span>
<span class="sd"> initial_guess -- can provide an initial guess for the input parameters. Relevant for</span>
<span class="sd"> initial_guess : list</span>
<span class="sd"> can provide an initial guess for the input parameters. Relevant for</span>
<span class="sd"> non-linear fits with many parameters.</span>
<span class="sd"> method -- can be used to choose an alternative method for the minimization of chisquare.</span>
<span class="sd"> The possible methods are the ones which can be used for scipy.optimize.minimize and</span>
<span class="sd"> migrad of iminuit. If no method is specified, Levenberg-Marquard is used.</span>
<span class="sd"> Reliable alternatives are migrad, Powell and Nelder-Mead.</span>
<span class="sd"> resplot -- If true, a plot which displays fit, data and residuals is generated (default False).</span>
<span class="sd"> qqplot -- If true, a quantile-quantile plot of the fit result is generated (default False).</span>
<span class="sd"> expected_chisquare -- If true prints the expected chisquare which is</span>
<span class="sd"> corrected by effects caused by correlated input data.</span>
<span class="sd"> This can take a while as the full correlation matrix</span>
<span class="sd"> has to be calculated (default False).</span>
<span class="sd"> method : str</span>
<span class="sd"> can be used to choose an alternative method for the minimization of chisquare.</span>
<span class="sd"> The possible methods are the ones which can be used for scipy.optimize.minimize and</span>
<span class="sd"> migrad of iminuit. If no method is specified, Levenberg-Marquard is used.</span>
<span class="sd"> Reliable alternatives are migrad, Powell and Nelder-Mead.</span>
<span class="sd"> resplot : bool</span>
<span class="sd"> If true, a plot which displays fit, data and residuals is generated (default False).</span>
<span class="sd"> qqplot : bool</span>
<span class="sd"> If true, a quantile-quantile plot of the fit result is generated (default False).</span>
<span class="sd"> expected_chisquare : bool</span>
<span class="sd"> If true prints the expected chisquare which is</span>
<span class="sd"> corrected by effects caused by correlated input data.</span>
<span class="sd"> This can take a while as the full correlation matrix</span>
<span class="sd"> has to be calculated (default False).</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="k">if</span> <span class="n">priors</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">return</span> <span class="n">_prior_fit</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">func</span><span class="p">,</span> <span class="n">priors</span><span class="p">,</span> <span class="n">silent</span><span class="o">=</span><span class="n">silent</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">)</span>
@ -1099,51 +1102,53 @@ also accesible via indices.</li>
<div class="docstring"><p>Performs a non-linear fit to y = func(x).</p>
<h2 id="arguments">Arguments:</h2>
<h6 id="parameters">Parameters</h6>
<p>x : list
list of floats.
y : list
list of Obs.
func : object
fit function, has to be of the form</p>
<ul>
<li><strong>x</strong> (list):
list of floats.</li>
<li><strong>y</strong> (list):
list of Obs.</li>
<li><p><strong>func</strong> (object):
fit function, has to be of the form</p>
<pre><code>def func(a, x):
return a[0] + a[1] * x + a[2] * anp.sinh(x)
<p>def func(a, x):
return a[0] + a[1] * x + a[2] * anp.sinh(x)</p>
For multiple x values func can be of the form
<p>For multiple x values func can be of the form</p>
def func(a, x):
(x1, x2) = x
return a[0] * x1 ** 2 + a[1] * x2
<p>def func(a, x):
(x1, x2) = x
return a[0] * x1 ** 2 + a[1] * x2</p>
It is important that all numpy functions refer to autograd.numpy, otherwise the differentiation
will not work
</code></pre>
<p>priors : list, optional
priors has to be a list with an entry for every parameter in the fit. The entries can either be
Obs (e.g. results from a previous fit) or strings containing a value and an error formatted like
0.548(23), 500(40) or 0.5(0.4)
It is important for the subsequent error estimation that the e_tag for the gamma method is large
enough.
silent : bool, optional
If true all output to the console is omitted (default False).</p>
<h6 id="keyword-arguments">Keyword arguments</h6>
<p>initial_guess -- can provide an initial guess for the input parameters. Relevant for
non-linear fits with many parameters.
method -- can be used to choose an alternative method for the minimization of chisquare.
The possible methods are the ones which can be used for scipy.optimize.minimize and
migrad of iminuit. If no method is specified, Levenberg-Marquard is used.
Reliable alternatives are migrad, Powell and Nelder-Mead.
resplot -- If true, a plot which displays fit, data and residuals is generated (default False).
qqplot -- If true, a quantile-quantile plot of the fit result is generated (default False).
expected_chisquare -- If true prints the expected chisquare which is
corrected by effects caused by correlated input data.
This can take a while as the full correlation matrix
has to be calculated (default False).</p>
<p>It is important that all numpy functions refer to autograd.numpy, otherwise the differentiation
will not work</p></li>
<li><strong>priors</strong> (list, optional):
priors has to be a list with an entry for every parameter in the fit. The entries can either be
Obs (e.g. results from a previous fit) or strings containing a value and an error formatted like
0.548(23), 500(40) or 0.5(0.4)
It is important for the subsequent error estimation that the e_tag for the gamma method is large
enough.</li>
<li><strong>silent</strong> (bool, optional):
If true all output to the console is omitted (default False).</li>
<li><strong>initial_guess</strong> (list):
can provide an initial guess for the input parameters. Relevant for
non-linear fits with many parameters.</li>
<li><strong>method</strong> (str):
can be used to choose an alternative method for the minimization of chisquare.
The possible methods are the ones which can be used for scipy.optimize.minimize and
migrad of iminuit. If no method is specified, Levenberg-Marquard is used.
Reliable alternatives are migrad, Powell and Nelder-Mead.</li>
<li><strong>resplot</strong> (bool):
If true, a plot which displays fit, data and residuals is generated (default False).</li>
<li><strong>qqplot</strong> (bool):
If true, a quantile-quantile plot of the fit result is generated (default False).</li>
<li><strong>expected_chisquare</strong> (bool):
If true prints the expected chisquare which is
corrected by effects caused by correlated input data.
This can take a while as the full correlation matrix
has to be calculated (default False).</li>
</ul>
</div>
@ -1201,6 +1206,8 @@ expected_chisquare -- If true prints the expected chisquare which is
<div class="codehilite"><pre><span></span><span class="k">def</span> <span class="nf">total_least_squares</span><span class="p">(</span><span class="n">x</span><span class="p">,</span> <span class="n">y</span><span class="p">,</span> <span class="n">func</span><span class="p">,</span> <span class="n">silent</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="o">**</span><span class="n">kwargs</span><span class="p">):</span>
<span class="sd">&quot;&quot;&quot;Performs a non-linear fit to y = func(x) and returns a list of Obs corresponding to the fit parameters.</span>
<span class="sd"> Parameters</span>
<span class="sd"> ----------</span>
<span class="sd"> x : list</span>
<span class="sd"> list of Obs, or a tuple of lists of Obs</span>
<span class="sd"> y : list</span>
@ -1223,15 +1230,14 @@ expected_chisquare -- If true prints the expected chisquare which is
<span class="sd"> silent : bool, optional</span>
<span class="sd"> If true all output to the console is omitted (default False).</span>
<span class="sd"> Based on the orthogonal distance regression module of scipy</span>
<span class="sd"> Keyword arguments</span>
<span class="sd"> -----------------</span>
<span class="sd"> initial_guess -- can provide an initial guess for the input parameters. Relevant for non-linear</span>
<span class="sd"> fits with many parameters.</span>
<span class="sd"> expected_chisquare -- If true prints the expected chisquare which is</span>
<span class="sd"> corrected by effects caused by correlated input data.</span>
<span class="sd"> This can take a while as the full correlation matrix</span>
<span class="sd"> has to be calculated (default False).</span>
<span class="sd"> initial_guess : list</span>
<span class="sd"> can provide an initial guess for the input parameters. Relevant for non-linear</span>
<span class="sd"> fits with many parameters.</span>
<span class="sd"> expected_chisquare : bool</span>
<span class="sd"> If true prints the expected chisquare which is</span>
<span class="sd"> corrected by effects caused by correlated input data.</span>
<span class="sd"> This can take a while as the full correlation matrix</span>
<span class="sd"> has to be calculated (default False).</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">output</span> <span class="o">=</span> <span class="n">Fit_result</span><span class="p">()</span>
@ -1366,39 +1372,40 @@ expected_chisquare -- If true prints the expected chisquare which is
<div class="docstring"><p>Performs a non-linear fit to y = func(x) and returns a list of Obs corresponding to the fit parameters.</p>
<p>x : list
list of Obs, or a tuple of lists of Obs
y : list
list of Obs. The dvalues of the Obs are used as x- and yerror for the fit.
func : object
func has to be of the form</p>
<h6 id="parameters">Parameters</h6>
<pre><code>def func(a, x):
y = a[0] + a[1] * x + a[2] * anp.sinh(x)
return y
<ul>
<li><strong>x</strong> (list):
list of Obs, or a tuple of lists of Obs</li>
<li><strong>y</strong> (list):
list of Obs. The dvalues of the Obs are used as x- and yerror for the fit.</li>
<li><p><strong>func</strong> (object):
func has to be of the form</p>
For multiple x values func can be of the form
<p>def func(a, x):
y = a[0] + a[1] * x + a[2] * anp.sinh(x)
return y</p>
def func(a, x):
(x1, x2) = x
return a[0] * x1 ** 2 + a[1] * x2
<p>For multiple x values func can be of the form</p>
It is important that all numpy functions refer to autograd.numpy, otherwise the differentiation
will not work.
</code></pre>
<p>def func(a, x):
(x1, x2) = x
return a[0] * x1 ** 2 + a[1] * x2</p>
<p>silent : bool, optional
If true all output to the console is omitted (default False).
Based on the orthogonal distance regression module of scipy</p>
<h6 id="keyword-arguments">Keyword arguments</h6>
<p>initial_guess -- can provide an initial guess for the input parameters. Relevant for non-linear
fits with many parameters.
expected_chisquare -- If true prints the expected chisquare which is
corrected by effects caused by correlated input data.
This can take a while as the full correlation matrix
has to be calculated (default False).</p>
<p>It is important that all numpy functions refer to autograd.numpy, otherwise the differentiation
will not work.</p></li>
<li><strong>silent</strong> (bool, optional):
If true all output to the console is omitted (default False).</li>
<li><strong>Based on the orthogonal distance regression module of scipy</strong></li>
<li><strong>initial_guess</strong> (list):
can provide an initial guess for the input parameters. Relevant for non-linear
fits with many parameters.</li>
<li><strong>expected_chisquare</strong> (bool):
If true prints the expected chisquare which is
corrected by effects caused by correlated input data.
This can take a while as the full correlation matrix
has to be calculated (default False).</li>
</ul>
</div>