
    M/Ph
                     ,    d Z ddlZ G d d          ZdS )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dS )	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.
       NTc                    t          j        |          }|                    d          | _        |                    dd          | _        |Zt          j        | j        dk              d         }t          |          dk    rd}n!t          t          j        |                    }|dk    rd| j        |<   d| j        |<   |du rd | _        || _	        d S )Nr   r   )ddofnF)
npasarraymeanstdscalenonzerolenintsqueeze	const_idx)selfdatar   r   demeans        a/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/statsmodels/tools/transform_model.py__init__zStandardizeTransform.__init__*   s    z$IIaLL	XXaaX((
 
4:?33A6I9~~""		
9 5 566	#$DIi $%DJy!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@   sA     9:d##dj00Jt$$ty0DJ>>r   c                     || j         z  }| j        dk    r/|| j        xx         || j        z                                  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   sT     dj(
>S  t~&&&:	+A*F*F*H*HH&&&r   )r   NT)__name__
__module____qualname____doc__r   r   r   __call__ r   r   r   r      sQ         :# # # #,? ? ?  * HHHr   r   )r#   numpyr	   r   r%   r   r   <module>r'      sY        R R R R R R R R R Rr   