
    !g5                     @    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	y)	zM
Created on Mon Oct  5 12:36:54 2020

Author: Josef Perktold
License: BSD-3

    N)special)Holderc           	      F   |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              Z/var/www/dash_apps/app1/venv/lib/python3.12/site-packages/statsmodels/stats/effect_size.py_noncentrality_chisquarer      s    J J2~H	Ha	 BZZ)rAv"67FZZ)a-26":;F!!)R5I			9b1z>:*F	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ZZ#'S1W"5q"ABF!!#sC8I			3a*nj%A6	JB
B"$GC Jr   c                 b   |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66'//"R%),wr"u/EEFD
''"R%.4
C	#B!!"c62I			2J
;V	DB
B$GC
 Jr   )g?)
__doc__numpyr   scipyr   statsmodels.stats.baser   r   r"   r+    r   r   <module>r1      s&      )6r.b+r   