
<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" /><meta name="generator" content="Docutils 0.18.1: http://docutils.sourceforge.net/" />

    <title>GSL Routines &#8212; lsqfit 13.0.1 documentation</title>
    <link rel="stylesheet" type="text/css" href="_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="_static/pyramid.css" />
    <script data-url_root="./" id="documentation_options" src="_static/documentation_options.js"></script>
    <script src="_static/jquery.js"></script>
    <script src="_static/underscore.js"></script>
    <script src="_static/_sphinx_javascript_frameworks_compat.js"></script>
    <script src="_static/doctools.js"></script>
    <link rel="index" title="Index" href="genindex.html" />
    <link rel="search" title="Search" href="search.html" />
    <link rel="next" title="scipy Routines" href="scipy.html" />
    <link rel="prev" title="lsqfit - Nonlinear Least Squares Fitting" href="lsqfit.html" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Neuton&amp;subset=latin" type="text/css" media="screen" charset="utf-8" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Nobile:regular,italic,bold,bolditalic&amp;subset=latin" type="text/css" media="screen" charset="utf-8" />
<!--[if lte IE 6]>
<link rel="stylesheet" href="_static/ie6.css" type="text/css" media="screen" charset="utf-8" />
<![endif]-->

  </head><body>

    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="scipy.html" title="scipy Routines"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="lsqfit.html" title="lsqfit - Nonlinear Least Squares Fitting"
             accesskey="P">previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">lsqfit 13.0.1 documentation</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">GSL Routines</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <section id="gsl-routines">
<h1>GSL Routines<a class="headerlink" href="#gsl-routines" title="Permalink to this heading">¶</a></h1>
<section id="fitters">
<h2>Fitters<a class="headerlink" href="#fitters" title="Permalink to this heading">¶</a></h2>
<p><a class="reference internal" href="lsqfit.html#module-lsqfit" title="lsqfit: Nonlinear least squares fitting."><code class="xref py py-mod docutils literal notranslate"><span class="pre">lsqfit</span></code></a> uses routines from the GSL C-library provided it is
installed; GSL is the open-source Gnu Scientific Library. There are two
fitters that are available for use by <a class="reference internal" href="lsqfit.html#lsqfit.nonlinear_fit" title="lsqfit.nonlinear_fit"><code class="xref py py-class docutils literal notranslate"><span class="pre">lsqfit.nonlinear_fit</span></code></a>.</p>
<dl class="py class">
<dt class="sig sig-object py" id="lsqfit.gsl_multifit">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">lsqfit.</span></span><span class="sig-name descname"><span class="pre">gsl_multifit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tol</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">(1e-5,</span> <span class="pre">0.0,</span> <span class="pre">0.0)</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">maxit</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alg</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'lm'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">solver</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'qr'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">scaler</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'more'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">factor_up</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">3.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">factor_down</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">2.0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">avmax</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">0.75</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#lsqfit.gsl_multifit" title="Permalink to this definition">¶</a></dt>
<dd><p>GSL fitter for nonlinear least-squares multidimensional fits.</p>
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">gsl_multifit</span></code> is a function-class whose constructor does a
least-squares fit by minimizing <code class="docutils literal notranslate"><span class="pre">sum_i</span> <span class="pre">f_i(x)**2</span></code> as a function of
vector <code class="docutils literal notranslate"><span class="pre">x</span></code>.</p>
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">gsl_multifit</span></code> is a wrapper for the <code class="docutils literal notranslate"><span class="pre">multifit</span></code> GSL routine.</p>
<dl class="field-list">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul>
<li><p><strong>x0</strong> (<em>array of floats</em>): Starting point for minimization.</p></li>
<li><p><strong>n</strong> (<em>positive int</em>): Length of vector returned by the fit function <code class="docutils literal notranslate"><span class="pre">f(x)</span></code>.</p></li>
<li><dl class="simple">
<dt><strong>f</strong> (<em>array-valued function</em>): <code class="docutils literal notranslate"><span class="pre">sum_i</span> <span class="pre">f_i(x)**2</span></code> is minimized</dt><dd><p>by varying parameters <code class="docutils literal notranslate"><span class="pre">x</span></code>. The parameters are a 1-d
<code class="xref py py-class docutils literal notranslate"><span class="pre">numpy</span></code> array of either numbers or <code class="xref py py-class docutils literal notranslate"><span class="pre">gvar.GVar</span></code>s.</p>
</dd>
</dl>
</li>
<li><dl>
<dt><strong>tol</strong> (<em>float or tuple</em>): Assigning <code class="docutils literal notranslate"><span class="pre">tol=(xtol,</span> <span class="pre">gtol,</span> <span class="pre">ftol)</span></code> causes the</dt><dd><p>fit to stop searching for a minimum when any of</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre">xtol</span> <span class="pre">&gt;=</span></code> relative change in parameters between iterations</p>
<p><code class="docutils literal notranslate"><span class="pre">gtol</span> <span class="pre">&gt;=</span></code> relative size of gradient of <code class="docutils literal notranslate"><span class="pre">chi**2</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">ftol</span> <span class="pre">&gt;=</span></code> relative change in <code class="docutils literal notranslate"><span class="pre">chi**2</span></code> between iterations</p>
</div></blockquote>
<p>is statisfied. See the GSL documentation for detailed
definitions of the stopping conditions. Typically one sets
<code class="docutils literal notranslate"><span class="pre">xtol=1/10**d</span></code> where <code class="docutils literal notranslate"><span class="pre">d</span></code> is the number of digits of precision
desired in the result, while <code class="docutils literal notranslate"><span class="pre">gtol&lt;&lt;1</span></code> and <code class="docutils literal notranslate"><span class="pre">ftol&lt;&lt;1</span></code>. Setting
<code class="docutils literal notranslate"><span class="pre">tol=eps</span></code> where <code class="docutils literal notranslate"><span class="pre">eps</span></code> is a number is equivalent to setting
<code class="docutils literal notranslate"><span class="pre">tol=(eps,1e-10,1e-10)</span></code>. Setting <code class="docutils literal notranslate"><span class="pre">tol=(eps1,eps2)</span></code> is
equivlent to setting <code class="docutils literal notranslate"><span class="pre">tol=(eps1,eps2,1e-10)</span></code>. Default is
<code class="docutils literal notranslate"><span class="pre">tol=1e-5</span></code>. (Note: <code class="docutils literal notranslate"><span class="pre">ftol</span></code> option is disabled in some versions
of  the GSL library.)</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><strong>maxit</strong> (<em>int</em>): Maximum number of iterations in search for minimum;</dt><dd><p>default is 1000.</p>
</dd>
</dl>
</li>
<li><dl>
<dt><strong>alg</strong> (<em>str</em>): GSL algorithm to use for minimization. The following</dt><dd><p>options are supported (see GSL documentation for more
information):</p>
<blockquote>
<div><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">'lm'</span></code></dt><dd><p>Levenberg-Marquardt algorithm (default).</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">'lmaccel'</span></code></dt><dd><p>Levenberg-Marquardt algorithm with geodesic
acceleration. Can be faster than <code class="docutils literal notranslate"><span class="pre">'lm'</span></code> but
less stable. Stability is controlled by damping
parameter <code class="docutils literal notranslate"><span class="pre">avmax</span></code>; setting it to zero turns
acceleration off.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">'subspace2D'</span></code></dt><dd><p>2D generalization of dogleg algorithm. This
can be substantially faster than the two <code class="docutils literal notranslate"><span class="pre">'lm'</span></code>
algorithms.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">'dogleg'</span></code></dt><dd><p>dogleg algorithm.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">'ddogleg'</span></code></dt><dd><p>double dogleg algorithm.</p>
</dd>
</dl>
</div></blockquote>
</dd>
</dl>
</li>
<li><dl>
<dt><strong>scaler</strong> (<em>str</em>): Scaling method used in minimization. The following</dt><dd><p>options are supported (see GSL documentation for more
information):</p>
<blockquote>
<div><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">'more'</span></code></dt><dd><p>More rescaling, which makes the problem scale
invariant. Default.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">'levenberg'</span></code></dt><dd><p>Levenberg rescaling, which is not scale
invariant but may be more efficient in certain problems.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">'marquardt'</span></code></dt><dd><p>Marquardt rescaling. Probably not as good as
the other two options.</p>
</dd>
</dl>
</div></blockquote>
</dd>
</dl>
</li>
<li><dl>
<dt><strong>solver</strong> (<em>str</em>): Method use to solve the linear equations for the</dt><dd><p>solution from a given step. The following options
are supported (see GSL documentation for more information):</p>
<blockquote>
<div><dl class="simple">
<dt><code class="docutils literal notranslate"><span class="pre">'qr'</span></code></dt><dd><p>QR decomposition of the Jacobian. Default.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">'cholesky'</span></code></dt><dd><p>Cholesky decomposition of the Jacobian. Can
be substantially faster than <code class="docutils literal notranslate"><span class="pre">'qr'</span></code> but not as reliable
for singular Jacobians.</p>
</dd>
<dt><code class="docutils literal notranslate"><span class="pre">'svd'</span></code></dt><dd><p>SVD decomposition. The most robust for singular
situations, but also the slowest.</p>
</dd>
</dl>
</div></blockquote>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><strong>factor_up</strong> (<em>float</em>): Factor by which search region is increased</dt><dd><p>when a search step is accepted. Values that are too large
destablize the search; values that are too small slow down
the search. Default is <code class="docutils literal notranslate"><span class="pre">factor_up=3</span></code>.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><strong>factor_down</strong> (<em>float</em>): Factor by which search region is decreased</dt><dd><p>when a search step is rejected. Values that are too large
destablize the search; values that are too small slow down
the search. Default is <code class="docutils literal notranslate"><span class="pre">factor_up=2</span></code>.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><strong>avmax</strong> (<em>float</em>): Damping parameter for geodesic acceleration. It</dt><dd><p>is the maximum allowed value for the acceleration divided
by the velocity. Smaller values imply less acceleration.
Default is <code class="docutils literal notranslate"><span class="pre">avmax=0.75</span></code>.</p>
</dd>
</dl>
</li>
</ul>
</dd>
</dl>
<p><strong>Attributes:</strong></p>
<blockquote>
<div><dl>
<dt><strong>x</strong> (<em>array</em>):</dt><dd><p>Location of the most recently computed (best) fit point.</p>
</dd>
<dt><strong>cov</strong> (<em>array</em>):</dt><dd><p>Covariance matrix at the minimum point.</p>
</dd>
<dt><strong>description</strong> (<em>str</em>):</dt><dd><p>Short description of internal fitter settings.</p>
</dd>
<dt><strong>f</strong> (<em>array</em>):</dt><dd><p>Fit function value <code class="docutils literal notranslate"><span class="pre">f(x)</span></code> at the minimum in
the most recent fit.</p>
</dd>
<dt><strong>J</strong> (<em>array</em>):</dt><dd><p>Gradient <code class="docutils literal notranslate"><span class="pre">J_ij</span> <span class="pre">=</span> <span class="pre">df_i/dx[j]</span></code> for most recent fit.</p>
</dd>
<dt><strong>nit</strong> (<em>int</em>):</dt><dd><p>Number of function evaluations used in last fit to find
the minimum.</p>
</dd>
<dt><strong>stopping_criterion</strong> (<em>int</em>):</dt><dd><p>Criterion used to
stop fit:</p>
<blockquote>
<div><ol class="arabic simple" start="0">
<li><p>didn’t converge</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">xtol</span> <span class="pre">&gt;=</span></code> relative change in parameters between iterations</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">gtol</span> <span class="pre">&gt;=</span></code> relative size of gradient of <code class="docutils literal notranslate"><span class="pre">chi**2</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ftol</span> <span class="pre">&gt;=</span></code> relative change in <code class="docutils literal notranslate"><span class="pre">chi**2</span></code> between iterations</p></li>
</ol>
</div></blockquote>
</dd>
<dt><strong>error</strong> (<em>str or None</em>):</dt><dd><p><code class="docutils literal notranslate"><span class="pre">None</span></code> if fit successful; an error
message otherwise.</p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

<dl class="py class">
<dt class="sig sig-object py" id="lsqfit.gsl_v1_multifit">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">lsqfit.</span></span><span class="sig-name descname"><span class="pre">gsl_v1_multifit</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">n</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tol</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1e-5</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">maxit</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alg</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'lmsder'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">analyzer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#lsqfit.gsl_v1_multifit" title="Permalink to this definition">¶</a></dt>
<dd><p>Fitter for nonlinear least-squares multidimensional fits. (GSL v1.)</p>
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">gsl_v1_</span> <span class="pre">multifit</span></code> is a function-class whose constructor does a
least-squares fit by minimizing <code class="docutils literal notranslate"><span class="pre">sum_i</span> <span class="pre">f_i(x)**2</span></code> as a function of
vector <code class="docutils literal notranslate"><span class="pre">x</span></code>.</p>
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">gsl_v1_multifit</span></code> is a wrapper for the (older, v1) <code class="docutils literal notranslate"><span class="pre">multifit</span></code>
GSL routine (see <code class="docutils literal notranslate"><span class="pre">nlin.h</span></code>). This package was used in earlier
versions of <a class="reference internal" href="lsqfit.html#module-lsqfit" title="lsqfit: Nonlinear least squares fitting."><code class="xref py py-mod docutils literal notranslate"><span class="pre">lsqfit</span></code></a> (&lt;9.0) and is typically not as
effective as <code class="xref py py-class docutils literal notranslate"><span class="pre">gsl_multifit</span></code>. It is included for legacy
code.</p>
<dl class="field-list">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul>
<li><p><strong>x0</strong> (<em>array of floats</em>): Starting point for minimization.</p></li>
<li><p><strong>n</strong> (<em>positive int</em>): Length of vector returned by the fit function <code class="docutils literal notranslate"><span class="pre">f(x)</span></code>.</p></li>
<li><dl class="simple">
<dt><strong>f</strong> (<em>array-valued function</em>): <code class="docutils literal notranslate"><span class="pre">sum_i</span> <span class="pre">f_i(x)**2</span></code> is minimized</dt><dd><p>by varying parameters <code class="docutils literal notranslate"><span class="pre">x</span></code>. The parameters are a 1-d
<code class="xref py py-class docutils literal notranslate"><span class="pre">numpy</span></code> array of either numbers or <code class="xref py py-class docutils literal notranslate"><span class="pre">gvar.GVar</span></code>s.</p>
</dd>
</dl>
</li>
<li><dl>
<dt><strong>tol</strong> (<em>float or tuple</em>): Assigning <code class="docutils literal notranslate"><span class="pre">tol=(xtol,</span> <span class="pre">gtol,</span> <span class="pre">ftol)</span></code> causes the</dt><dd><p>fit to stop searching for a minimum when any of</p>
<blockquote>
<div><p><code class="docutils literal notranslate"><span class="pre">xtol</span> <span class="pre">&gt;=</span></code> relative change in parameters between iterations</p>
<p><code class="docutils literal notranslate"><span class="pre">gtol</span> <span class="pre">&gt;=</span></code> relative size of gradient of <code class="docutils literal notranslate"><span class="pre">chi**2</span></code></p>
<p><code class="docutils literal notranslate"><span class="pre">ftol</span> <span class="pre">&gt;=</span></code> relative change in <code class="docutils literal notranslate"><span class="pre">chi**2</span></code> between iterations</p>
</div></blockquote>
<p>is statisfied. See the GSL documentation for detailed
definitions of the stopping conditions. Typically one sets
<code class="docutils literal notranslate"><span class="pre">xtol=1/10**d</span></code> where <code class="docutils literal notranslate"><span class="pre">d</span></code> is the number of digits of precision
desired in the result, while <code class="docutils literal notranslate"><span class="pre">gtol&lt;&lt;1</span></code> and <code class="docutils literal notranslate"><span class="pre">ftol&lt;&lt;1</span></code>. Setting
<code class="docutils literal notranslate"><span class="pre">tol=eps</span></code> where <code class="docutils literal notranslate"><span class="pre">eps</span></code> is a number is equivalent to setting
<code class="docutils literal notranslate"><span class="pre">tol=(eps,1e-10,1e-10)</span></code>. Setting <code class="docutils literal notranslate"><span class="pre">tol=(eps1,eps2)</span></code> is
equivlent to setting <code class="docutils literal notranslate"><span class="pre">tol=(eps1,eps2,1e-10)</span></code>. Default is
<code class="docutils literal notranslate"><span class="pre">tol=1e-5</span></code>. (Note: the <code class="docutils literal notranslate"><span class="pre">ftol</span></code> option is disabled in some
versions of  the GSL library.)</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><strong>maxit</strong> (<em>int</em>): Maximum number of iterations in search for minimum;</dt><dd><p>default is 1000.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><strong>alg</strong> (<em>str</em>): GSL algorithm to use for minimization. Two options are</dt><dd><p>currently available: <code class="docutils literal notranslate"><span class="pre">&quot;lmsder&quot;</span></code>, the scaled LMDER algorithm
(default); and <code class="docutils literal notranslate"><span class="pre">&quot;lmder&quot;</span></code>, the unscaled LMDER algorithm.
With version 2 of the GSL library, another option is <code class="docutils literal notranslate"><span class="pre">&quot;lmniel&quot;</span></code>,
which can be useful when there is much more data than parameters.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><strong>analyzer</strong> (<em>callable</em>): Optional function of <code class="docutils literal notranslate"><span class="pre">x,</span></code> <code class="docutils literal notranslate"><span class="pre">[...f_i(x)...],</span></code></dt><dd><p><code class="docutils literal notranslate"><span class="pre">[[..df_ij(x)..]]</span></code>
which is called after each iteration. This can be used to inspect
intermediate steps in the minimization, if needed.</p>
</dd>
</dl>
</li>
</ul>
</dd>
</dl>
<p><strong>Attributes:</strong></p>
<blockquote>
<div><dl>
<dt><strong>x</strong> (<em>array</em>):</dt><dd><p>Location of the most recently computed (best) fit point.</p>
</dd>
<dt><strong>cov</strong> (<em>array</em>):</dt><dd><p>Covariance matrix at the minimum point.</p>
</dd>
<dt><strong>f</strong> (<em>callable</em>):</dt><dd><p>Fit function value <code class="docutils literal notranslate"><span class="pre">f(x)</span></code> at the minimum in
the most recent fit.</p>
</dd>
<dt><strong>J</strong> (<em>array</em>):</dt><dd><p>Gradient <code class="docutils literal notranslate"><span class="pre">J_ij</span> <span class="pre">=</span> <span class="pre">df_i/dx[j]</span></code> for most recent fit.</p>
</dd>
<dt><strong>nit</strong> (<em>int</em>):</dt><dd><p>Number of function evaluations used in last fit to find
the minimum.</p>
</dd>
<dt><strong>stopping_criterion</strong> (<em>int</em>):</dt><dd><p>Criterion used to
stop fit:</p>
<blockquote>
<div><ol class="arabic simple" start="0">
<li><p>didn’t converge</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">xtol</span> <span class="pre">&gt;=</span></code> relative change in parameters between iterations</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">gtol</span> <span class="pre">&gt;=</span></code> relative size of gradient of <code class="docutils literal notranslate"><span class="pre">chi**2</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">ftol</span> <span class="pre">&gt;=</span></code> relative change in <code class="docutils literal notranslate"><span class="pre">chi**2</span></code> between iterations</p></li>
</ol>
</div></blockquote>
</dd>
<dt><strong>error</strong> (<em>str or None</em>):</dt><dd><p><code class="docutils literal notranslate"><span class="pre">None</span></code> if fit successful; an error
message otherwise.</p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

</section>
<section id="minimizer">
<h2>Minimizer<a class="headerlink" href="#minimizer" title="Permalink to this heading">¶</a></h2>
<p>The <a class="reference internal" href="lsqfit.html#lsqfit.empbayes_fit" title="lsqfit.empbayes_fit"><code class="xref py py-func docutils literal notranslate"><span class="pre">lsqfit.empbayes_fit()</span></code></a> uses a minimizer from the GSL library
to minimize <code class="docutils literal notranslate"><span class="pre">logGBF</span></code>.</p>
<dl class="py class">
<dt class="sig sig-object py" id="lsqfit.gsl_multiminex">
<em class="property"><span class="pre">class</span><span class="w"> </span></em><span class="sig-prename descclassname"><span class="pre">lsqfit.</span></span><span class="sig-name descname"><span class="pre">gsl_multiminex</span></span><span class="sig-paren">(</span><em class="sig-param"><span class="n"><span class="pre">x0</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">f</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">tol</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1e-4</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">maxit</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1000</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">step</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">1</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">alg</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">'nmsimplex2'</span></span></em>, <em class="sig-param"><span class="n"><span class="pre">analyzer</span></span><span class="o"><span class="pre">=</span></span><span class="default_value"><span class="pre">None</span></span></em><span class="sig-paren">)</span><a class="headerlink" href="#lsqfit.gsl_multiminex" title="Permalink to this definition">¶</a></dt>
<dd><p>Minimizer for multidimensional functions.</p>
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">multiminex</span></code> is a function-class whose constructor minimizes a
multidimensional function <code class="docutils literal notranslate"><span class="pre">f(x)</span></code> by varying vector <code class="docutils literal notranslate"><span class="pre">x</span></code>. This routine
does <em>not</em> use user-supplied information about the gradient of <code class="docutils literal notranslate"><span class="pre">f(x)</span></code>.</p>
<p><code class="xref py py-class docutils literal notranslate"><span class="pre">multiminex</span></code> is a wrapper for the <code class="docutils literal notranslate"><span class="pre">multimin</span></code> GSL routine.</p>
<dl class="field-list simple">
<dt class="field-odd">Parameters<span class="colon">:</span></dt>
<dd class="field-odd"><ul class="simple">
<li><p><strong>x0</strong> (<em>array</em>): Starting point for minimization search.</p></li>
<li><p><strong>f</strong> (<em>callable</em>): Function <code class="docutils literal notranslate"><span class="pre">f(x)</span></code> to be minimized by varying vector <code class="docutils literal notranslate"><span class="pre">x</span></code>.</p></li>
<li><dl class="simple">
<dt><strong>tol</strong> (<em>float</em>): Minimization stops when <code class="docutils literal notranslate"><span class="pre">x</span></code> has converged to with</dt><dd><p>tolerance <code class="docutils literal notranslate"><span class="pre">tol</span></code>; default is <code class="docutils literal notranslate"><span class="pre">1e-4</span></code>.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><strong>maxit</strong> (<em>int</em>): Maximum number of iterations in search for minimum;</dt><dd><p>default is 1000.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><strong>step</strong> (<em>float</em>): Initial step size to use in varying components of <code class="docutils literal notranslate"><span class="pre">x</span></code>;</dt><dd><p>default is 1.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><strong>alg</strong> (<em>str</em>): GSL algorithm to use for minimization. Three options are</dt><dd><p>currently available: <code class="docutils literal notranslate"><span class="pre">&quot;nmsimplex&quot;</span></code>, Nelder Mead Simplex
algorithm; <code class="docutils literal notranslate"><span class="pre">&quot;nmsimplex2&quot;</span></code>, an improved version of
<code class="docutils literal notranslate"><span class="pre">&quot;nmsimplex&quot;</span></code> (default); and <code class="docutils literal notranslate"><span class="pre">&quot;nmsimplex2rand&quot;</span></code>, a version
of <code class="docutils literal notranslate"><span class="pre">&quot;nmsimplex2&quot;</span></code> with random shifts in the start position.</p>
</dd>
</dl>
</li>
<li><dl class="simple">
<dt><strong>analyzer</strong> (<em>callable</em>): Optional function of <code class="docutils literal notranslate"><span class="pre">x</span></code>, which is called after</dt><dd><p>each iteration. This can be used to inspect intermediate steps in
the minimization, if needed.</p>
</dd>
</dl>
</li>
</ul>
</dd>
</dl>
<p><strong>Attributes:</strong></p>
<blockquote>
<div><dl class="simple">
<dt><strong>x</strong> (<em>array</em>):</dt><dd><p>Location of the minimum.</p>
</dd>
<dt><strong>f</strong> (<em>float</em>):</dt><dd><p>Value of function <code class="docutils literal notranslate"><span class="pre">f(x)</span></code> at the minimum.</p>
</dd>
<dt><strong>nit</strong> (<em>int</em>):</dt><dd><p>Number of iterations required to find the minimum.</p>
</dd>
<dt><strong>error</strong> (<em>None or str</em>):</dt><dd><p><code class="docutils literal notranslate"><span class="pre">None</span></code> if minimization successful; an error
message otherwise.</p>
</dd>
</dl>
</div></blockquote>
</dd></dl>

</section>
</section>


            <div class="clearer"></div>
          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <div>
    <h3><a href="index.html">Table of Contents</a></h3>
    <ul>
<li><a class="reference internal" href="#">GSL Routines</a><ul>
<li><a class="reference internal" href="#fitters">Fitters</a></li>
<li><a class="reference internal" href="#minimizer">Minimizer</a></li>
</ul>
</li>
</ul>

  </div>
  <div>
    <h4>Previous topic</h4>
    <p class="topless"><a href="lsqfit.html"
                          title="previous chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">lsqfit</span></code> - Nonlinear Least Squares Fitting</a></p>
  </div>
  <div>
    <h4>Next topic</h4>
    <p class="topless"><a href="scipy.html"
                          title="next chapter"><code class="xref py py-mod docutils literal notranslate"><span class="pre">scipy</span></code> Routines</a></p>
  </div>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="_sources/gsl.rst.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>
        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="scipy.html" title="scipy Routines"
             >next</a> |</li>
        <li class="right" >
          <a href="lsqfit.html" title="lsqfit - Nonlinear Least Squares Fitting"
             >previous</a> |</li>
        <li class="nav-item nav-item-0"><a href="index.html">lsqfit 13.0.1 documentation</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">GSL Routines</a></li> 
      </ul>
    </div>
    <div class="footer" role="contentinfo">
        &#169; Copyright 2009-2019, G. P. Lepage.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 5.0.2.
    </div>
  </body>
</html>