L iddlZddlmZddlmZgdZgdZeedddZeedddZdZ gdZ gd Z ee dddZ ee dddZ d Zy) N)poly1d)beta)gSbQ @go|-a?g_3 L/g|A"?gCUG)?g<*x @gy@g`B{dA?g-~?cbtj|}|j}tj|j tj }d}|dk}|dk(}tj ||k}||z|z}||}||}tj|} tj| |<tj| |<|jdkDrt|t|z | |<|jdkDr*d|dzz ddd|zzz t|dz|dzz z| |<|| _| S)aVariance of the Tukey Lambda distribution. Parameters ---------- lam : array_like The lambda values at which to compute the variance. Returns ------- v : ndarray The variance. For lam < -0.5, the variance is not defined, so np.nan is returned. For lam = 0.5, np.inf is returned. Notes ----- In an interval around lambda=0, this function uses the [4,4] Pade approximation to compute the variance. Otherwise it uses the standard formula (https://en.wikipedia.org/wiki/Tukey_lambda_distribution). The Pade approximation is used because the standard formula has a removable discontinuity at lambda = 0, and does not produce accurate numerical results near lambda = 0. g333333?grg@r)npasarrayshape atleast_1dastypefloat64abs empty_likenaninfsize_tukeylambda_var_p_tukeylambda_var_qr) lamshp thresholdlow_mask neghalf_mask small_maskreg_masksmallregvs d/mnt/ssd/data/python-lab/Trading/venv/lib/python3.12/site-packages/scipy/stats/_tukeylambda_stats.pytukeylambda_variancer"+s,. **S/C ))C --  # #BJJ /CI TzH$;Ly(JL(:56H  OE h-C cA&&AhKffAlO zzA~*514Fu4MM*  xx!|S!V|sQW}(=(,S1WcAg(>)?@( AG H)g333333?g6|igeSH6gѐ환^?g˝)kPd@)rg?ݻA@gID@)@gPr?g`2fQctj|}|j}tj|j tj }d}|dk}|dk(}tj ||k}||z|z}||}||}tj|} tj| |<tj| |<|jdkDrt|t|z | |<|jdkDrodd|zdzz dtd|zdz|dzzz dtd|zdzd|zdzzz} ddd|zdzz t|dz|dzz dzz} | | z dz | |<|| _| S) aRKurtosis of the Tukey Lambda distribution. Parameters ---------- lam : array_like The lambda values at which to compute the variance. Returns ------- v : ndarray The variance. For lam < -0.25, the variance is not defined, so np.nan is returned. For lam = 0.25, np.inf is returned. g)\(?gпrrr r)r r r r rrrrrrr_tukeylambda_kurt_p_tukeylambda_kurt_qr) rrrr negqrtr_maskrrrrknumerdenoms r!tukeylambda_kurtosisr-s **S/C ))C --  # #BJJ /CIU{H%r5s8-? /"56/"569 z?A 1$B$781$B$784 r#