
    'YHh
                     $    d Z ddlZ G d d      Zy)zM
Created on Tue May 27 13:23:24 2014

Author: Josef Perktold
License: BSD-3

    Nc                   (    e Zd ZdZddZd Zd ZeZy)StandardizeTransformaB  class to reparameterize a model for standardized exog

    Parameters
    ----------
    data : array_like
        data that is standardized along axis=0
    ddof : None or int
        degrees of freedom for calculation of standard deviation.
        default is 1, in contrast to numpy.std
    const_idx : None or int
        If None, then the presence of a constant is detected if the standard
        deviation of a column is **equal** to zero. A constant column is
        not transformed. If this is an integer, then the corresponding column
        will not be transformed.
    demean : bool, default is True
        If demean is true, then the data will be demeaned, otherwise it will
        only be rescaled.

    Notes
    -----
    Warning: Not all options are tested and it is written for one use case.
    API changes are expected.

    This can be used to transform only the design matrix, exog, in a model,
    which is required in some discrete models when the endog cannot be rescaled
    or demeaned.
    The transformation is full rank and does not drop the constant.
    Nc                    t        j                  |      }|j                  d      | _        |j                  dd      | _        |Tt        j
                  | j                  dk(        d   }t        |      dk(  rd}nt        t        j                  |            }|dk7  rd| j                  |<   d| j                  |<   |du rd | _        || _	        y )Nr      )ddofnF)
npasarraymeanstdscalenonzerolenintsqueeze	const_idx)selfdatar   r   demeans        Z/var/www/html/planif/env/lib/python3.12/site-packages/statsmodels/tools/transform_model.py__init__zStandardizeTransform.__init__*   s    zz$IIaL	XXaaX(
 

4::?3A6I9~"	

9 56	#$DIIi $%DJJy!U?DI"    c                     | j                   "t        j                  |      | j                  z  S t        j                  |      | j                   z
  | j                  z  S )z=standardize the data using the stored transformation
        )r   r	   r
   r   )r   r   s     r   	transformzStandardizeTransform.transform@   sG     99::d#djj00JJt$tyy0DJJ>>r   c                     || j                   z  }| j                  dk7  r2|| j                  xx   || j                  z  j                         z  cc<   |S )ae  Transform parameters of the standardized model to the original model

        Parameters
        ----------
        params : ndarray
            parameters estimated with the standardized model

        Returns
        -------
        params_new : ndarray
            parameters transformed to the parameterization of the original
            model
        r   )r   r   r   sum)r   params
params_news      r   transform_paramsz%StandardizeTransform.transform_paramsI   sJ     djj(
>>S t~~&:		+A*F*F*HH&r   )r   NT)__name__
__module____qualname____doc__r   r   r   __call__ r   r   r   r      s    :#,?* Hr   r   )r#   numpyr	   r   r%   r   r   <module>r'      s    R Rr   