
    (phx                     ,   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                 h    U S   U SS  p2UR                   S   S4Ul         X!U-  R                  SS9-   $ Nr      axis)shapesum)Bxabs       D/var/www/html/venv/lib/python3.13/site-packages/scipy/odr/_models.py_lin_fcnr   
   s>    Q412qwwqz1oAG!yyay       c                     [         R                  " UR                  S   [        5      n[         R                  " X!R                  5       45      nU R                  S   UR                  S   4Ul        U$ N)nponesr   floatconcatenateravel)r   r   r   ress       r   _lin_fjbr       sQ    
U#A
..!WWY
(Caggbk*CIJr   c                     U SS  n[         R                  " X!R                  S   4UR                  S   -  SS9nUR                  Ul        U$ )Nr   r   r   r   )r   repeatr   )r   r   r   s      r   _lin_fjdr#      sD    	!"A
		!ggbk^AGGBK/a8AggAGHr   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                   S   S4Ul         U[        R                  " U[        R                  " X5      -  SS9-   $ r
   r   r   r   power)r   r   powersr   r   s        r   	_poly_fcnr/   ,   sJ    Q412qwwqz1oAGrvva"((1--A666r   c                    [         R                  " [         R                  " UR                  S   [        5      [         R
                  " X5      R                  45      nU R                  S   UR                  S   4Ul        U$ r   )r   r   r   r   r   r-   flat)r   r   r.   r   s       r   _poly_fjacbr2   3   s]    
.."''!''"+u5((1-224 5Caggbk*CIJr   c                     U SS  nUR                   S   S4Ul         X2-  n[        R                  " U[        R                  " XS-
  5      -  SS9$ )Nr   r   r   r,   )r   r   r.   r   s       r   _poly_fjacdr4   :   sJ    	!"Awwqz1oAG	
A66!bhhq(++!44r   c                 F    U S   [         R                  " U S   U-  5      -   $ Nr   r   r   expr   r   s     r   _exp_fcnr:   C   "    Q4"&&1"""r   c                 F    U S   [         R                  " U S   U-  5      -  $ )Nr   r7   r9   s     r   _exp_fjdr=   G   r;   r   c                     [         R                  " [         R                  " UR                  S   [        5      U[         R
                  " U S   U-  5      -  45      nSUR                  S   4Ul        U$ )Nr   r   r&   )r   r   r   r   r   r8   )r   r   r   s      r   _exp_fjbr?   K   sW    
.."''!''"+u5q266!A$(;K7KL
MCAGGBK CIJr   c                 2    [         R                  " SS/5      $ )N      ?)r   arrayr(   s    r   _exp_estrD   Q   s    88RHr   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )_MultilinearModelV   a  
Arbitrary-dimensional linear model

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   rR   _MultilinearModel.__init__m   s.    HHx8;EG 	 	Hr    __name__
__module____qualname____firstlineno____doc__rR   __static_attributes____classcell__rU   s   @r   rF   rF   V   s    ,H Hr   rF   c                 "   [         R                  " U 5      nUR                  S:X  a  [         R                  " SUS-   5      n[	        U5      S4Ul        [	        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.

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()

rW   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$rI   )rN   rM   rO   
extra_argsrP   )	r   asarrayr   aranger'   r   r/   r4   r2   )orderr.   rc   rd   s       r   r   r   x   s    R ZZF||r1fqj)K#FL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

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}$rI   rN   rM   rO   rP   )rQ   rR   r:   r=   r?   rD   rS   s    r   rR   _ExponentialModel.__init__   s.    "*'4&=)GI 	 	Jr   rW   rX   r`   s   @r   rk   rk          *J Jr   rk   c                     XS   -  U S   -   $ r6   rW   r9   s     r   _unilinrs      s    qT6AaD=r   c                 X    [         R                  " UR                  [        5      U S   -  $ )Nr   )r   r   r   r   r9   s     r   _unilin_fjdru      s     77177E"QqT))r   c                     [         R                  " U[         R                  " UR                  [        5      45      nSUR                  -   Ul        U$ )N)r&   r   r   r   r   r   r   r   _rets      r   _unilin_fjbrz      s8    >>1bggaggu567DDJKr   c                     g)N)rA   rA   rW   rC   s    r   _unilin_estr|      s    r   c                 .    XU S   -  U S   -   -  U S   -   $ )Nr   r   r&   rW   r9   s     r   
_quadraticr~      s$    !fqtmqt##r   c                 $    SU-  U S   -  U S   -   $ r%   rW   r9   s     r   	_quad_fjdr      s    Q3qt8ad?r   c                     [         R                  " X-  U[         R                  " UR                  [        5      45      nSUR                  -   Ul        U$ )N)   rw   rx   s      r   	_quad_fjbr      s<    >>13277177E#:;<DDJKr   c                     g)N)rA   rA   rA   rW   rC   s    r   	_quad_estr      s    r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )_UnilinearModel   a  
Univariate linear model

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$rI   ro   )rQ   rR   rs   ru   rz   r|   rS   s    r   rR   _UnilinearModel.__init__  s.    ;"-':&9)FH 	 	Ir   rW   rX   r`   s   @r   r   r      s    *I Ir   r   c                   ,   ^  \ rS rSrSrU 4S jrSrU =r$ )_QuadraticModeli  a  
Quadratic model

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_2rI   ro   )rQ   rR   r~   r   r   r   rS   s    r   rR   _QuadraticModel.__init__3  s.    iy9%5GI 	 	Jr   rW   rX   r`   s   @r   r   r     rq   r   r   )"r]   numpyr   scipy.odr._odrpackr   __all__r   r    r#   r*   r/   r2   r4   r:   r=   r?   rD   rF   r   r   rk   r   rs   ru   rz   r|   r~   r   r   r   r   r   r   r   rW   r   r   <module>r      s     $!
$75##
H H>  !:'zJ J<  !*$Ie I< 	Je J< 	r   