
    doiN"                     ,   S r SSKrSSKJr  / SQrS rS rS rS r	S	 r
S
 rS rS rS rS rS r " S S\5      r\" 5       rS r " S S\5      r\" 5       rS rS rS rS rS rS rS rS r " S S\5      r\" 5       r " S S \5      r \ " 5       r!g)!zHCollection of Model instances for use with the odrpack fitting package.
    N)Model)r   exponentialmultilinear	unilinear	quadratic
polynomialc                 |    U S   U SS  p2UR                  UR                  S   S45      nX!U-  R                  SS9-   $ Nr      axis)reshapeshapesum)Bxabs       M/var/www/html/land-ocr/venv/lib/python3.13/site-packages/scipy/odr/_models.py_lin_fcnr   
   sE    Q412q			1771:q/"A!yyay       c                     [         R                  " UR                  S   [        5      n[         R                  " X!R                  5       45      nUR                  U R                  S   UR                  S   45      $ N)nponesr   floatconcatenateravelr   )r   r   r   ress       r   _lin_fjbr!      sT    
U#A
..!WWY
(C;;QWWR[122r   c                     U SS  n[         R                  " X!R                  S   4UR                  S   -  SS9nUR                  UR                  5      $ )Nr   r   r   r   )r   repeatr   r   )r   r   r   s      r   _lin_fjdr$      sG    	!"A
		!ggbk^AGGBK/a8A99QWWr   c                     [        U R                  R                  5      S:X  a  U R                  R                  S   nOSn[        R                  " US-   4[
        5      $ N   r   r   )lenr   r   r   r   r   )datams     r   _lin_estr+      sF    
 466<<AFFLLO77AE8U##r   c                     U S   U SS  pCUR                  UR                  S   S45      nU[        R                  " U[        R                  " X5      -  SS9-   $ r
   r   r   r   r   power)r   r   powersr   r   s        r   	_poly_fcnr0   *   sQ    Q412q			1771:q/"Arvva"((1--A666r   c                    [         R                  " [         R                  " UR                  S   [        5      [         R
                  " X5      R                  45      nUR                  U R                  S   UR                  S   45      $ r   )r   r   r   r   r   r.   flatr   )r   r   r/   r    s       r   _poly_fjacbr3   1   s`    
.."''!''"+u5((1-224 5C;;QWWR[122r   c                     U SS  nUR                  UR                  S   S45      nX2-  n[        R                  " U[        R                  " XS-
  5      -  SS9$ )Nr   r   r   r-   )r   r   r/   r   s       r   _poly_fjacdr5   7   sQ    	!"A			1771:q/"A	
A66!bhhq(++!44r   c                 F    U S   [         R                  " U S   U-  5      -   $ Nr   r   r   expr   r   s     r   _exp_fcnr;   @   "    Q4"&&1"""r   c                 F    U S   [         R                  " U S   U-  5      -  $ )Nr   r8   r:   s     r   _exp_fjdr>   D   r<   r   c                     [         R                  " [         R                  " UR                  S   [        5      U[         R
                  " U S   U-  5      -  45      nUR                  SUR                  S   45      $ )Nr   r   r'   )r   r   r   r   r   r9   r   )r   r   r    s      r   _exp_fjbr@   H   sZ    
.."''!''"+u5q266!A$(;K7KL
MC;;1772;'((r   c                 2    [         R                  " SS/5      $ )N      ?)r   arrayr)   s    r   _exp_estrE   M   s    88RHr   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )_MultilinearModelR   a~  
Arbitrary-dimensional linear model

.. deprecated:: 1.17.0
    `scipy.odr` is deprecated and will be removed in SciPy 1.19.0. Please use
    `pypi.org/project/odrpack/ <https://pypi.org/project/odrpack/>`_
    instead.


This model is defined by :math:`y=\beta_0 + \sum_{i=1}^m \beta_i x_i`

Examples
--------
We can calculate orthogonal distance regression with an arbitrary
dimensional linear model:

>>> from scipy import odr
>>> import numpy as np
>>> x = np.linspace(0.0, 5.0)
>>> y = 10.0 + 5.0 * x
>>> data = odr.Data(x, y)
>>> odr_obj = odr.ODR(data, odr.multilinear)
>>> output = odr_obj.run()
>>> print(output.beta)
[10.  5.]

c           
      P   > [         TU ]  [        [        [        [
        SSSS.S9  g )NzArbitrary-dimensional Linearz y = B_0 + Sum[i=1..m, B_i * x_i]z&$y=\beta_0 + \sum_{i=1}^m \beta_i x_i$nameequTeXequ)fjacbfjacdestimatemeta)super__init__r   r!   r$   r+   self	__class__s    r   rS   _MultilinearModel.__init__o   s.    HHx8;EG 	 	Hr    __name__
__module____qualname____firstlineno____doc__rS   __static_attributes____classcell__rV   s   @r   rG   rG   R   s    8H Hr   rG   c                 6   [         R                  " U 5      nUR                  S:X  a  [         R                  " SUS-   5      nUR	                  [        U5      S45      n[        U5      S-   nU4S jn[        [        [        [        X14SSUS-
  -  SUS-
  -  S.S9$ )	a  
Factory function for a general polynomial model.

.. deprecated:: 1.17.0
    `scipy.odr` is deprecated and will be removed in SciPy 1.19.0. Please use
    `pypi.org/project/odrpack/ <https://pypi.org/project/odrpack/>`_
    instead.

Parameters
----------
order : int or sequence
    If an integer, it becomes the order of the polynomial to fit. If
    a sequence of numbers, then these are the explicit powers in the
    polynomial.
    A constant term (power 0) is always included, so don't include 0.
    Thus, polynomial(n) is equivalent to polynomial(range(1, n+1)).

Returns
-------
polynomial : Model instance
    Model instance.

Examples
--------
We can fit an input data using orthogonal distance regression (ODR) with
a polynomial model:

>>> import numpy as np
>>> import matplotlib.pyplot as plt
>>> from scipy import odr
>>> x = np.linspace(0.0, 5.0)
>>> y = np.sin(x)
>>> poly_model = odr.polynomial(3)  # using third order polynomial model
>>> data = odr.Data(x, y)
>>> odr_obj = odr.ODR(data, poly_model)
>>> output = odr_obj.run()  # running ODR fitting
>>> poly = np.poly1d(output.beta[::-1])
>>> poly_y = poly(x)
>>> plt.plot(x, y, label="input data")
>>> plt.plot(x, poly_y, label="polynomial ODR")
>>> plt.legend()
>>> plt.show()

rX   r   c                 :    [         R                  " U4[        5      $ )N)r   r   r   )r)   len_betas     r   	_poly_estpolynomial.<locals>._poly_est   s    ww{E**r   zSorta-general Polynomialz$y = B_0 + Sum[i=1..%s, B_i * (x**i)]z)$y=\beta_0 + \sum_{i=1}^{%s} \beta_i x^i$rJ   )rO   rN   rP   
extra_argsrQ   )
r   asarrayr   aranger   r(   r   r0   r5   r3   )orderr/   rd   re   s       r   r   r   z   s    \ ZZF||r1fqj)^^S[!,-F6{QH!) + +[#	9>(1*MG!!%&' 'r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )_ExponentialModel   a[  
Exponential model

.. deprecated:: 1.17.0
    `scipy.odr` is deprecated and will be removed in SciPy 1.19.0. Please use
    `pypi.org/project/odrpack/ <https://pypi.org/project/odrpack/>`_
    instead.

This model is defined by :math:`y=\beta_0 + e^{\beta_1 x}`

Examples
--------
We can calculate orthogonal distance regression with an exponential model:

>>> from scipy import odr
>>> import numpy as np
>>> x = np.linspace(0.0, 5.0)
>>> y = -10.0 + np.exp(0.5*x)
>>> data = odr.Data(x, y)
>>> odr_obj = odr.ODR(data, odr.exponential)
>>> output = odr_obj.run()
>>> print(output.beta)
[-10.    0.5]

c           
      P   > [         TU ]  [        [        [        [
        SSSS.S9  g )NExponentialzy= B_0 + exp(B_1 * x)z$y=\beta_0 + e^{\beta_1 x}$rJ   rO   rN   rP   rQ   )rR   rS   r;   r>   r@   rE   rT   s    r   rS   _ExponentialModel.__init__   s.    "*'4&=)GI 	 	Jr   rX   rY   ra   s   @r   rl   rl          4J Jr   rl   c                     XS   -  U S   -   $ r7   rX   r:   s     r   _unilinrt      s    qT6AaD=r   c                 X    [         R                  " UR                  [        5      U S   -  $ )Nr   )r   r   r   r   r:   s     r   _unilin_fjdrv      s     77177E"QqT))r   c                     [         R                  " U[         R                  " UR                  [        5      45      nUR                  SUR                  -   5      $ )N)r'   r   r   r   r   r   r   r   r   _rets      r   _unilin_fjbr{      s;    >>1bggaggu567D<<qww''r   c                     g)N)rB   rB   rX   rD   s    r   _unilin_estr}      s    r   c                 .    XU S   -  U S   -   -  U S   -   $ )Nr   r   r'   rX   r:   s     r   
_quadraticr      s$    !fqtmqt##r   c                 $    SU-  U S   -  U S   -   $ r&   rX   r:   s     r   	_quad_fjdr      s    Q3qt8ad?r   c                     [         R                  " X-  U[         R                  " UR                  [        5      45      nUR                  SUR                  -   5      $ )N)   rx   ry   s      r   	_quad_fjbr      s?    >>13277177E#:;<D<<qww''r   c                     g)N)rB   rB   rB   rX   rD   s    r   	_quad_estr      s    r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )_UnilinearModeli  aM  
Univariate linear model

.. deprecated:: 1.17.0
    `scipy.odr` is deprecated and will be removed in SciPy 1.19.0. Please use
    `pypi.org/project/odrpack/ <https://pypi.org/project/odrpack/>`_
    instead.

This model is defined by :math:`y = \beta_0 x + \beta_1`

Examples
--------
We can calculate orthogonal distance regression with an unilinear model:

>>> from scipy import odr
>>> import numpy as np
>>> x = np.linspace(0.0, 5.0)
>>> y = 1.0 * x + 2.0
>>> data = odr.Data(x, y)
>>> odr_obj = odr.ODR(data, odr.unilinear)
>>> output = odr_obj.run()
>>> print(output.beta)
[1. 2.]

c           
      P   > [         TU ]  [        [        [        [
        SSSS.S9  g )NzUnivariate Linearzy = B_0 * x + B_1z$y = \beta_0 x + \beta_1$rJ   rp   )rR   rS   rt   rv   r{   r}   rT   s    r   rS   _UnilinearModel.__init__  s.    ;"-':&9)FH 	 	Ir   rX   rY   ra   s   @r   r   r     s    4I Ir   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )_QuadraticModeli*  ad  
Quadratic model

.. deprecated:: 1.17.0
    `scipy.odr` is deprecated and will be removed in SciPy 1.19.0. Please use
    `pypi.org/project/odrpack/ <https://pypi.org/project/odrpack/>`_
    instead.

This model is defined by :math:`y = \beta_0 x^2 + \beta_1 x + \beta_2`

Examples
--------
We can calculate orthogonal distance regression with a quadratic model:

>>> from scipy import odr
>>> import numpy as np
>>> x = np.linspace(0.0, 5.0)
>>> y = 1.0 * x ** 2 + 2.0 * x + 3.0
>>> data = odr.Data(x, y)
>>> odr_obj = odr.ODR(data, odr.quadratic)
>>> output = odr_obj.run()
>>> print(output.beta)
[1. 2. 3.]

c           
      P   > [         TU ]  [        [        [        [
        SSSS.S9  g )N	Quadraticzy = B_0*x**2 + B_1*x + B_2z&$y = \beta_0 x^2 + \beta_1 x + \beta_2rJ   rp   )rR   rS   r   r   r   r   rT   s    r   rS   _QuadraticModel.__init__E  s.    iy9%5GI 	 	Jr   rX   rY   ra   s   @r   r   r   *  rr   r   r   )"r^   numpyr   scipy.odr._odrpackr   __all__r   r!   r$   r+   r0   r3   r5   r;   r>   r@   rE   rG   r   r   rl   r   rt   rv   r{   r}   r   r   r   r   r   r   r   r   rX   r   r   <module>r      s     $!3
$735##)

"H "HJ  !?'D J  JF  !*(
$(
 Ie  IF 	 Je  JF 	r   