
    M/Ph5                     B    d Z ddlZddlmZ ddlmZ d	dZd	dZd	dZ	dS )
zM
Created on Mon Oct  5 12:36:54 2020

Author: Josef Perktold
License: BSD-3

    N)special)Holder皙?c           	      D   |dz  }| |z
  }t          j        |d          }t          j        || |dz   z            }t          j        || dz  |dz   z            }t          j        | |d          }t          j        | |d|z
  |g          }	t	          ||	||||d          }
|
S )uw  noncentrality parameter for chi-square statistic

    `nc` is zero-truncated umvue

    Parameters
    ----------
    chi2_stat : float
        Chisquare-statistic, for example from a hypothesis test
    df : int or float
        Degrees of freedom
    alpha : float in (0, 1)
        Significance level for the confidence interval, covarage is 1 - alpha.

    Returns
    -------
    HolderTuple
        The main attributes are

        - ``nc`` : estimate of noncentrality parameter
        - ``confint`` : lower and upper bound of confidence interval for `nc``

        Other attributes are estimates for nc by different methods.

    References
    ----------
    .. [1] Kubokawa, T., C.P. Robert, and A.K.Md.E. Saleh. 1993. “Estimation of
        Noncentrality Parameters.”
        Canadian Journal of Statistics 21 (1): 45–57.
        https://doi.org/10.2307/3315657.

    .. [2] Li, Qizhai, Junjian Zhang, and Shuai Dai. 2009. “On Estimating the
        Non-Centrality Parameter of a Chi-Squared Distribution.”
        Statistics & Probability Letters 79 (1): 98–104.
        https://doi.org/10.1016/j.spl.2008.07.025.

       r            ?z7Noncentrality for chisquare-distributed random variable)ncconfintnc_umvuenc_lzdnc_krs	nc_medianname)npmaximumr   	chndtrincr   )	chi2_statdfalpha
alpha_halfr   r
   r   r   r   ciress              ]/var/www/html/test/jupyter/venv/lib/python3.11/site-packages/statsmodels/stats/effect_size.py_noncentrality_chisquarer      s    J J2~H	Ha	 	 BZ)rAv"677FZ)a-26":;;F!)R55I		9b1z>:*F	G	GB
B"$O  C J    c                 8   |dz  }| |z  |z  }|dz
  |z  |z
  }t          j        |d          }t          j        ||dz  |dz
  z  |dz   z            }t          j        ||d|           }	t          j        ||d|z
  |g|           }
t	          ||
|||	d          }|S )uY  noncentrality parameter for f statistic

    `nc` is zero-truncated umvue

    Parameters
    ----------
    fstat : float
        f-statistic, for example from a hypothesis test
        df : int or float
        Degrees of freedom
    alpha : float in (0, 1)
        Significance level for the confidence interval, covarage is 1 - alpha.

    Returns
    -------
    HolderTuple
        The main attributes are

        - ``nc`` : estimate of noncentrality parameter
        - ``confint`` : lower and upper bound of confidence interval for `nc``

        Other attributes are estimates for nc by different methods.

    References
    ----------
    .. [1] Kubokawa, T., C.P. Robert, and A.K.Md.E. Saleh. 1993. “Estimation of
       Noncentrality Parameters.” Canadian Journal of Statistics 21 (1): 45–57.
       https://doi.org/10.2307/3315657.
    r   r   r   r	   z/Noncentrality for F-distributed random variable)r
   r   r   r   r   r   )r   r   r   	ncfdtrincr   )f_statdf1df2r   r   x_sr   r
   r   r   r   r   s               r   _noncentrality_fr#   F   s    < J
3,
Ca3$H	Ha	 	 BZ#'S1W"5q"ABBF!#sC88I		3a*nj%A6	J	JB
B"$G  C Jr   c                 ^   |dz  }t          j        t          j        |dz  dz
            t          j        |dz            z
            }t          j        |dz            |z  }| |z  }t          j        |d|           }t          j        |d|z
  |g|           }t          |||d          }	|	S )uR  noncentrality parameter for t statistic

    Parameters
    ----------
    fstat : float
        f-statistic, for example from a hypothesis test
        df : int or float
        Degrees of freedom
    alpha : float in (0, 1)
        Significance level for the confidence interval, covarage is 1 - alpha.

    Returns
    -------
    HolderTuple
        The main attributes are

        - ``nc`` : estimate of noncentrality parameter
        - ``confint`` : lower and upper bound of confidence interval for `nc``

        Other attributes are estimates for nc by different methods.

    References
    ----------
    .. [1] Hedges, Larry V. 2016. “Distribution Theory for Glass’s Estimator of
       Effect Size and Related Estimators:”
       Journal of Educational Statistics, November.
       https://doi.org/10.3102/10769986006002107.

    r   g       @r	   r   z/Noncentrality for t-distributed random variable)r
   r   r   r   )r   expr   gammalnsqrt	nctdtrincr   )
t_statr   r   r   gfacc11r
   r   r   r   s
             r   _noncentrality_tr,   w   s    < J6'/"R%),,wr"u/E/EEFFD
'"R%..4
C	#B!"c622I		2J
;V	D	DB
B$G  C
 Jr   )r   )
__doc__numpyr   scipyr   statsmodels.stats.baser   r   r#   r,    r   r   <module>r2      s               ) ) ) ) ) )6 6 6 6r. . . .b+ + + + + +r   