§
    fŠtjH  ã                   ó>   — d dl mZmZmZmZmZ d dlmZ d
d„Zdd„Z	d	S )é    )ÚarangeÚnewaxisÚhstackÚprodÚarray)Úlinalgé   c                 óŒ  — | |dz   k     rt          d¦  «        ‚| dz  dk    rt          d¦  «        ‚| dz	  }t          | |dz   ¦  «        }|dd…t          f         }|dz  }t          d| ¦  «        D ]}t	          |||z  g¦  «        }Œt          t          d|dz   ¦  «        d¬	¦  «        t          j        |¦  «        |         z  }|S )
a¯  
    Return weights for an Np-point central derivative.

    Assumes equally-spaced function points.

    If weights are in the vector w, then
    derivative is w[0] * f(x-ho*dx) + ... + w[-1] * f(x+h0*dx)

    Parameters
    ----------
    Np : int
        Number of points for the central derivative.
    ndiv : int, optional
        Number of divisions. Default is 1.

    Returns
    -------
    w : ndarray
        Weights for an Np-point central derivative. Its size is `Np`.

    Notes
    -----
    Can be inaccurate for a large number of points.

    Examples
    --------
    We can calculate a derivative value of a function.

    >>> def f(x):
    ...     return 2 * x**2 + 3
    >>> x = 3.0 # derivative point
    >>> h = 0.1 # differential step
    >>> Np = 3 # point number for central derivative
    >>> weights = _central_diff_weights(Np) # weights for first derivative
    >>> vals = [f(x + (i - Np/2) * h) for i in range(Np)]
    >>> sum(w * v for (w, v) in zip(weights, vals))/h
    11.79999999999998

    This value is close to the analytical solution:
    f'(x) = 4x, so f'(3) = 12

    References
    ----------
    .. [1] https://en.wikipedia.org/wiki/Finite_difference

    r	   z;Number of points must be at least the derivative order + 1.é   r   z!The number of points must be odd.ç      ð?Nç        ©Úaxis)Ú
ValueErrorr   r   Úranger   r   r   Úinv)ÚNpÚndivÚhoÚxÚXÚkÚws          ú]/var/www/html/CA-Chatbot/venv/lib/python3.11/site-packages/scipy/stats/_finite_differences.pyÚ_central_diff_weightsr      sâ   € ð^ 
ˆD�1‰H‚}€}ÝØIñ
ô 
ð 	
ð 
ˆA�v�‚{€{ÝÐ<Ñ=Ô=Ð=à	ˆq‰€BÝ�ˆs�B˜‘HÑÔ€AØ	ˆ!ˆ!ˆ!�Wˆ*Œ€AØ	ˆ3‰€AÝ�1�b‰\Œ\ð ð ˆÝ�A�q˜!‘t�9ÑÔˆˆÝ�V�A�t˜a‘xÑ Ô  qÐ)Ñ)Ô)­F¬J°q©M¬M¸$Ô,?Ñ?€AØ€Hó    r   © é   c                 ó&  — ||dz   k     rt          d¦  «        ‚|dz  dk    rt          d¦  «        ‚|dk    r}|dk    rt          g d¢¦  «        dz  }nò|d	k    rt          g d
¢¦  «        dz  }n×|dk    rt          g d¢¦  «        dz  }n¼|dk    rt          g d¢¦  «        dz  }n¡t          |d¦  «        }n�|dk    rz|dk    rt          g d¢¦  «        }nr|d	k    rt          g d¢¦  «        dz  }nW|dk    rt          g d¢¦  «        dz  }n<|dk    rt          g d¢¦  «        dz  }n!t          |d¦  «        }nt          ||¦  «        }d}|dz	  }t          |¦  «        D ] }	|||	          | ||	|z
  |z  z   g|¢R Ž z  z  }Œ!|t	          |f|z  d¬¦  «        z  S )a
  
    Find the nth derivative of a function at a point.

    Given a function, use a central difference formula with spacing `dx` to
    compute the nth derivative at `x0`.

    Parameters
    ----------
    func : function
        Input function.
    x0 : float
        The point at which the nth derivative is found.
    dx : float, optional
        Spacing.
    n : int, optional
        Order of the derivative. Default is 1.
    args : tuple, optional
        Arguments
    order : int, optional
        Number of points to use, must be odd.

    Notes
    -----
    Decreasing the step size too small can result in round-off error.

    Examples
    --------
    >>> def f(x):
    ...     return x**3 + x**2
    >>> _derivative(f, 1.0, dx=1e-6)
    4.9999999999217337

    r	   zm'order' (the number of points used to compute the derivative), must be at least the derivative order 'n' + 1.r   r   zJ'order' (the number of points used to compute the derivative) must be odd.r   )éÿÿÿÿr   r	   g       @é   )r	   iøÿÿÿr   é   r    g      (@é   )r    é	   iÓÿÿÿr   é-   é÷ÿÿÿr	   g      N@r$   )	r   iàÿÿÿé¨   i`ýÿÿr   i   iXÿÿÿé    éýÿÿÿg     @Š@)r	   g       Àr	   )r    é   iâÿÿÿr*   r    )r   éåÿÿÿé  iþÿÿr,   r+   r   g     €f@)	r&   é€   éüÿÿé€  iòÇÿÿr/   r.   r-   r&   g     °³@r   r   )r   r   r   r   r   )
ÚfuncÚx0ÚdxÚnÚargsÚorderÚweightsÚvalr   r   s
             r   Ú_derivativer8   E   s&  € ðD ˆq�1‰u‚}€}Ýð=ñ
ô 
ð 	
ð ˆq�y�A‚~€~Ýðñ
ô 
ð 	
ð
 	ˆA‚v€vØ�AŠ:ˆ:Ý˜J˜J˜JÑ'Ô'¨#Ñ-ˆGˆGØ�aŠZˆZÝÐ-Ð-Ð-Ñ.Ô.°Ñ5ˆGˆGØ�aŠZˆZÝÐ6Ð6Ð6Ñ7Ô7¸$Ñ>ˆGˆGØ�aŠZˆZÝÐEÐEÐEÑFÔFÈÑNˆGˆGå+¨E°1Ñ5Ô5ˆGˆGØ	
ˆaŠˆØ�AŠ:ˆ:Ý˜L˜L˜LÑ)Ô)ˆGˆGØ�aŠZˆZÝÐ1Ð1Ð1Ñ2Ô2°TÑ9ˆGˆGØ�aŠZˆZÝÐ<Ð<Ð<Ñ=Ô=ÀÑEˆGˆGØ�aŠZˆZåÐJÐJÐJÑKÔKØñð ˆGõ
 ,¨E°1Ñ5Ô5ˆGˆGå'¨¨qÑ1Ô1ˆØ
€CØ	�!‰€BÝ�5‰\Œ\ð <ð <ˆØˆw�qŒz˜D˜D  q¨2¡v°¡mÑ!3Ð;°dÐ;Ð;Ð;Ñ;Ñ;ˆˆØ•�r�e˜a‘i aÐ(Ñ(Ô(Ñ(Ð(r   N)r	   )r   r	   r   r   )
Únumpyr   r   r   r   r   Úscipyr   r   r8   r   r   r   ú<module>r;      sz   ðØ 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ð 6Ø Ð Ð Ð Ð Ð ð=ð =ð =ð =ð@L)ð L)ð L)ð L)ð L)ð L)r   