ó
    |ñ:ira  ã                   ó  • S r SSKJr  SSKJr  SSKrSSKr SSK	J
r
  SrSS	KJr  SS
KJr   " S S5      r " S S5      r " S S5      r " S S5      r " S S5      r " S S5      rS rS rg! \ a    SSKJ
r
  Sr N_f = f)aV  Statistical transformations for visualization.

This module is currently private, but is being written to eventually form part
of the public API.

The classes should behave roughly in the style of scikit-learn.

- All data-independent parameters should be passed to the class constructor.
- Each class should implement a default transformation that is exposed through
  __call__. These are currently written for vector arguments, but I think
  consuming a whole `plot_data` DataFrame and return it with transformed
  variables would make more sense.
- Some class have data-dependent preprocessing that should be cached and used
  multiple times (think defining histogram bins off all data and then counting
  observations within each bin multiple times per data subsets). These currently
  have unique names, but it would be good to have a common name. Not quite
  `fit`, but something similar.
- Alternatively, the transform interface could take some information about grouping
  variables and do a groupby internally.
- Some classes should define alternate transforms that might make the most sense
  with a different function. For example, KDE usually evaluates the distribution
  on a regular grid, but it would be useful for it to transform at the actual
  datapoints. Then again, this could be controlled by a parameter at  the time of
  class instantiation.

é    )ÚNumber)Ú
NormalDistN)Úgaussian_kdeFé   T)Ú	bootstrap)Ú_check_argumentc                   ót   • \ rS rSrSrSSSSSSS.S	 jrS
 rS rS rSS jr	SS jr
SS jrSS jrSS jrSrg)ÚKDEé*   z2Univariate and bivariate kernel density estimator.Nr   éÈ   é   F)Ú	bw_methodÚ	bw_adjustÚgridsizeÚcutÚclipÚ
cumulativec                óž   • Uc  SnXl         X l        X0l        X@l        XPl        X`l        U(       a  [        (       a  [        S5      eSU l        g)a�  Initialize the estimator with its parameters.

Parameters
----------
bw_method : string, scalar, or callable, optional
    Method for determining the smoothing bandwidth to use; passed to
    :class:`scipy.stats.gaussian_kde`.
bw_adjust : number, optional
    Factor that multiplicatively scales the value chosen using
    ``bw_method``. Increasing will make the curve smoother. See Notes.
gridsize : int, optional
    Number of points on each dimension of the evaluation grid.
cut : number, optional
    Factor, multiplied by the smoothing bandwidth, that determines how
    far the evaluation grid extends past the extreme datapoints. When
    set to 0, truncate the curve at the data limits.
clip : pair of numbers or None, or a pair of such pairs
    Do not evaluate the density outside of these limits.
cumulative : bool, optional
    If True, estimate a cumulative distribution function. Requires scipy.

N©NNz(Cumulative KDE evaluation requires scipy)	r   r   r   r   r   r   Ú	_no_scipyÚRuntimeErrorÚsupport)Úselfr   r   r   r   r   r   s          ÚV/srv/projetos/modelo_ml_acdoc/venv/lib/python3.13/site-packages/seaborn/_statistics.pyÚ__init__ÚKDE.__init__,   sF   € ð> ‰<ØˆDà"ŒØ"ŒØ ŒØŒØŒ	Ø$ŒæŸ)š)ÜÐIÓJÐJàˆ�ó    c                 ó  • US   c  [         R                  * OUS   nUS   c  [         R                  7OUS   n[        UR                  5       X#-  -
  U5      n[        UR                  5       X#-  -   U5      n	[         R                  " X‰U5      $ )z<Create the grid of evaluation points depending for vector x.r   r   )ÚnpÚinfÚmaxÚminÚlinspace)
r   ÚxÚbwr   r   r   Úclip_loÚclip_hiÚgridminÚgridmaxs
             r   Ú_define_support_gridÚKDE._define_support_gridZ   sw   € à! !™W™_”2—6‘6‘'°$°q±'ˆØ! !™W™_”2—6‘6‘'°$°q±'ˆÜ�a—e‘e“g ¡Ñ(¨'Ó2ˆÜ�a—e‘e“g ¡Ñ(¨'Ó2ˆÜ�{Š{˜7¨XÓ6Ð6r   c                 óè   • U R                  X5      n[        R                  " UR                  R	                  5       5      nU R                  XU R                  U R                  U R                  5      nU$ )z&Create a 1D grid of evaluation points.)	Ú_fitr   ÚsqrtÚ
covarianceÚsqueezer*   r   r   r   )r   r$   ÚweightsÚkder%   Úgrids         r   Ú_define_support_univariateÚKDE._define_support_univariateb   sW   € à�i‰i˜Ó#ˆÜ�WŠW�S—^‘^×+Ñ+Ó-Ó.ˆØ×(Ñ(Ø�4—8‘8˜TŸY™Y¨¯©ó
ˆð ˆr   c                 óÐ  • U R                   nUS   b  [        R                  " US   5      (       a  XD4nU R                  X/U5      n[        R                  " [        R
                  " UR                  5      R                  5       5      nU R                  XS   U R                  US   U R                  5      nU R                  X&S   U R                  US   U R                  5      nXx4$ )z&Create a 2D grid of evaluation points.r   r   )r   r   Úisscalarr-   r.   Údiagr/   r0   r*   r   r   )	r   Úx1Úx2r1   r   r2   r%   Úgrid1Úgrid2s	            r   Ú_define_support_bivariateÚKDE._define_support_bivariatek   sÁ   € à�y‰yˆØ�‰7‰?œbŸkšk¨$¨q©'×2Ñ2Ø�<ˆDà�i‰i˜˜ 'Ó*ˆÜ�WŠW”R—W’W˜SŸ^™^Ó,×4Ñ4Ó6Ó7ˆà×)Ñ)Ø�1‘�t—x‘x  a¡¨$¯-©-ó
ˆð ×)Ñ)Ø�1‘�t—x‘x  a¡¨$¯-©-ó
ˆð ˆ|Ðr   c                 ón   • Uc  U R                  X5      nOU R                  XU5      nU(       a  XPl        U$ )z0Create the evaluation grid for a given data set.)r4   r=   r   )r   r9   r:   r1   Úcacher   s         r   Údefine_supportÚKDE.define_support}   s6   € à‰:Ø×5Ñ5°bÓB‰Gà×4Ñ4°R¸WÓEˆGæØ"ŒLàˆr   c                 ó˜   • SU R                   0nUb  X#S'   [        U40 UD6nUR                  UR                  U R                  -  5        U$ )zAFit the scipy kde while adding bw_adjust logic and version check.r   r1   )r   r   Úset_bandwidthÚfactorr   )r   Úfit_datar1   Úfit_kwsr2   s        r   r-   ÚKDE._fit‰   sM   € à §¡Ð/ˆØÑØ!(�IÑä˜8Ñ/ wÑ/ˆØ×Ñ˜#Ÿ*™* t§~¡~Ñ5Ô6àˆ
r   c           	      ó  • U R                   nUc  U R                  USS9nU R                  X5      nU R                  (       a=  US   n[        R
                  " U Vs/ s H  odR                  XV5      PM     sn5      nXs4$ U" U5      nXs4$ s  snf )z1Fit and evaluate a univariate on univariate data.F©r@   r   )r   rA   r-   r   r   ÚarrayÚintegrate_box_1d)r   r$   r1   r   r2   Ús_0Ús_iÚdensitys           r   Ú_eval_univariateÚKDE._eval_univariate”   s•   € à—,‘,ˆØ‰?Ø×)Ñ)¨!°5Ð)Ð9ˆGà�i‰i˜Ó#ˆà�?�?Ø˜!‘*ˆCÜ—h’hÙ:Aó Ú:A°3×$Ñ$ SÖ.¹'ñ ó ˆGð ÐÐñ ˜'“lˆGàÐÐùò s   ÁB
c                 óZ  • U R                   nUc  U R                  XSS9nU R                  X/U5      nU R                  (       a’  Uu  pg[        R
                  " UR                  UR                  45      nUR                  5       UR                  5       4n	[        U5       H0  u  p«[        U5       H  u  pÍUR                  X›U45      XŠU4'   M     M2     X„4$ [        R                  " U6 u  pïU" UR                  5       UR                  5       /5      R                  UR                  5      nX„4$ )z0Fit and evaluate a univariate on bivariate data.FrJ   )r   rA   r-   r   r   ÚzerosÚsizer"   Ú	enumerateÚintegrate_boxÚmeshgridÚravelÚreshapeÚshape)r   r9   r:   r1   r   r2   r;   r<   rO   Úp0ÚiÚxiÚjÚxjÚxx1Úxx2s                   r   Ú_eval_bivariateÚKDE._eval_bivariate¦   s  € à—,‘,ˆØ‰?Ø×)Ñ)¨"¸Ð)Ð>ˆGà�i‰i˜˜ 'Ó*ˆà�?�?à"‰LˆEÜ—h’h §
¡
¨E¯J©JÐ7Ó8ˆGØ—‘“˜eŸi™i›kÐ)ˆBÜ" 5Ö)‘�Ü& uÖ-‘E�AØ$'×$5Ñ$5°b¸r¸(Ó$C�G˜q˜D“Mó .ñ *ð ÐÐô —{’{ GÐ,‰HˆCÙ˜3Ÿ9™9›;¨¯	©	«Ð4Ó5×=Ñ=¸c¿i¹iÓHˆGàÐÐr   c                 óN   • Uc  U R                  X5      $ U R                  XU5      $ )z1Fit and evaluate on univariate or bivariate data.©rP   rb   ©r   r9   r:   r1   s       r   Ú__call__ÚKDE.__call__¾   ó+   € à‰:Ø×(Ñ(¨Ó5Ð5à×'Ñ'¨°Ó8Ð8r   )r   r   r   r   r   r   r   ©NNT©Nr   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r*   r4   r=   rA   r-   rP   rb   rg   Ú__static_attributes__© r   r   r
   r
   *   sG   † Ù<ð ØØØØØõ,ò\7òòô$
ô	ô ô$ ÷09r   r
   c                   óT   • \ rS rSrSr      SS jrS rSS jrS rS r	SS	 jr
S
rg)Ú	Histogramr   z-Univariate and bivariate histogram estimator.Nc                 óz   • / SQn[        SXq5        Xl        X l        X0l        X@l        XPl        X`l        SU l        g)a­  Initialize the estimator with its parameters.

Parameters
----------
stat : str
    Aggregate statistic to compute in each bin.

    - `count`: show the number of observations in each bin
    - `frequency`: show the number of observations divided by the bin width
    - `probability` or `proportion`: normalize such that bar heights sum to 1
    - `percent`: normalize such that bar heights sum to 100
    - `density`: normalize such that the total area of the histogram equals 1

bins : str, number, vector, or a pair of such values
    Generic bin parameter that can be the name of a reference rule,
    the number of bins, or the breaks of the bins.
    Passed to :func:`numpy.histogram_bin_edges`.
binwidth : number or pair of numbers
    Width of each bin, overrides ``bins`` but can be used with
    ``binrange``.
binrange : pair of numbers or a pair of pairs
    Lowest and highest value for bin edges; can be used either
    with ``bins`` or ``binwidth``. Defaults to data extremes.
discrete : bool or pair of bools
    If True, set ``binwidth`` and ``binrange`` such that bin
    edges cover integer values in the dataset.
cumulative : bool
    If True, return the cumulative statistic.

)ÚcountÚ	frequencyrO   ÚprobabilityÚ
proportionÚpercentÚstatN)r   r{   ÚbinsÚbinwidthÚbinrangeÚdiscreter   Úbin_kws)r   r{   r|   r}   r~   r   r   Ústat_choicess           r   r   ÚHistogram.__init__Ê   s;   € òN
ˆô 	˜ Ô3àŒ	ØŒ	Ø ŒØ ŒØ ŒØ$Œàˆ�r   c                 ó¤  • Uc   UR                  5       UR                  5       p‡OUu  pxU(       a  [        R                  " US-
  US-   5      n	U	$ Ubh  Un
[        R                  " XxU
-   U
5      n	U	R                  5       U:  d  [	        U	5      S:  a'  [        R
                  " X™R                  5       U
-   5      n	U	$ [        R                  " XXR5      n	U	$ )z6Inner function that takes bin parameters as arguments.ç      à?g      ø?é   )r"   r!   r   ÚarangeÚlenÚappendÚhistogram_bin_edges)r   r$   r1   r|   r}   r~   r   ÚstartÚstopÚ	bin_edgesÚsteps              r   Ú_define_bin_edgesÚHistogram._define_bin_edgesÿ   s¿   € àÑØŸ%™%›' 1§5¡5£7‘4à"‰KˆEæÜŸ	š	 %¨"¡*¨d°S©jÓ9ˆIð Ðð Ñ!ØˆDÜŸ	š	 %°©°dÓ;ˆIà�}‰}‹ Ó%¬¨Y«¸!Ó);ÜŸIšI i·±³À4Ñ1GÓH�	ð
 Ðô ×.Ò.Ø˜óˆIð Ðr   c                 ó¼  • Uc¦  U R                  XU R                  U R                  U R                  U R                  5      n[        U R                  [        [        45      (       a9  [        U5      S-
  nUR                  5       UR                  5       4n[        XgS9nGO0[        US9nGO%/ n[        X/5       GH   u  pšU R                  nU(       a  [        U[        [        45      (       a  O/[        X¹   [        5      (       a  X¹   nO[        U5      S:X  a  X¹   nU R                  nUc  O[        U[        5      (       d  XÉ   nU R                  nUc  O[        US   [        5      (       d  XÙ   nU R                  n[        U[        5      (       d  Xé   nUR                  U R                  X£X¼XÞ5      5        GM     [        [        U5      S9nU(       a  X€l        U$ )z=Given data, return numpy.histogram parameters to define bins.r   )r|   Úrange)r|   r…   r   )rŽ   r|   r}   r~   r   Ú
isinstanceÚstrr   r‡   r"   r!   ÚdictrU   Úboolrˆ   Útupler€   )r   r9   r:   r1   r@   rŒ   Ún_binsÚ	bin_ranger€   r\   r$   r|   r}   r~   r   s                  r   Údefine_bin_paramsÚHistogram.define_bin_params  s”  € à‰:à×.Ñ.Ø˜TŸY™Y¨¯©°t·}±}ÀdÇmÁmóˆIô ˜$Ÿ)™)¤c¬6 ]×3Ñ3Ü˜Y›¨!Ñ+�Ø%ŸM™M›O¨Y¯]©]«_Ð<�	Ü FÑ<’ä IÑ.’ð ˆIÜ! 2 (×+‘�ð
 —y‘y�Þœz¨$´´f°×>Ñ>ØÜ ¡¬×-Ñ-Ø™7‘DÜ˜“Y !“^Ø™7�DàŸ=™=�ØÑ#ØÜ# H¬f×5Ñ5Ø'™{�HàŸ=™=�ØÑ#ØÜ# H¨Q¡K´×8Ñ8Ø'™{�HàŸ=™=�Ü! (¬D×1Ñ1Ø'™{�Hð × Ñ  ×!7Ñ!7Ø °ó"÷ ñ? ,ôF ¤ iÓ 0Ñ1ˆGæØ"ŒLàˆr   c                 ó4  • U R                   nUc  U R                  XSS9nU R                  S:H  n[        R                  " X40 UDX5S.D6tpg[        R
                  " [        R                  " US   5      [        R                  " US   5      5      nU R                  S:X  d  U R                  S:X  a'  UR                  [        5      UR                  5       -  nObU R                  S	:X  a*  UR                  [        5      UR                  5       -  S
-  nO(U R                  S:X  a  UR                  [        5      U-  nU R                  (       aM  U R                  S;   a!  Xh-  R                  SS9R                  SS9nXg4$ UR                  SS9R                  SS9nXg4$ )z.Inner function for histogram of two variables.FrJ   rO   ©r1   rO   r   r   rx   ry   rz   éd   rw   ©rO   rw   )Úaxis)r€   r™   r{   r   Úhistogram2dÚouterÚdiffÚastypeÚfloatÚsumr   Úcumsum)	r   r9   r:   r1   r€   rO   ÚhistrŒ   Úareas	            r   rb   ÚHistogram._eval_bivariateP  sk  € à—,‘,ˆØ‰?Ø×,Ñ,¨R¸5Ð,ÐAˆGà—)‘)˜yÑ(ˆäŸ>š>Øñ
Øð
Ø'.ó
Ðˆô �xŠxÜ�GŠG�I˜a‘LÓ!Ü�GŠG�I˜a‘LÓ!ó
ˆð
 �9‰9˜Ó%¨¯©°lÓ)BØ—;‘;œuÓ%¨¯©«
Ñ2‰DØ�Y‰Y˜)Ó#Ø—;‘;œuÓ%¨¯©«
Ñ2°SÑ8‰DØ�Y‰Y˜+Ó%Ø—;‘;œuÓ%¨Ñ,ˆDà�?�?Ø�y‰yÐ4Ó4Ø™×+Ñ+°Ð+Ð3×:Ñ:ÀÐ:ÐB�ð ˆÐð —{‘{¨�{Ð*×1Ñ1°qÐ1Ð9�àˆÐr   c                 óÎ  • U R                   nUc  U R                  XSS9nU R                  S:H  n[        R                  " U40 UDX$S.D6u  pVU R                  S:X  d  U R                  S:X  a'  UR                  [        5      UR                  5       -  nOvU R                  S:X  a*  UR                  [        5      UR                  5       -  S-  nO<U R                  S	:X  a,  UR                  [        5      [        R                  " U5      -  nU R                  (       aJ  U R                  S
;   a*  U[        R                  " U5      -  R                  5       nXV4$ UR                  5       nXV4$ )z-Inner function for histogram of one variable.F)r1   r@   rO   rœ   rx   ry   rz   r�   rw   rž   )r€   r™   r{   r   Ú	histogramr£   r¤   r¥   r¢   r   r¦   )r   r$   r1   r€   rO   r§   rŒ   s          r   rP   ÚHistogram._eval_univariatep  s)  € à—,‘,ˆØ‰?Ø×,Ñ,¨QÀuÐ,ÐMˆGà—)‘)˜yÑ(ˆÜŸ,š,Øñ
Øð
Ø")ó
‰ˆð �9‰9˜Ó%¨¯©°lÓ)BØ—;‘;œuÓ%¨¯©«
Ñ2‰DØ�Y‰Y˜)Ó#Ø—;‘;œuÓ%¨¯©«
Ñ2°SÑ8‰DØ�Y‰Y˜+Ó%Ø—;‘;œuÓ%¬¯ª°	Ó(:Ñ:ˆDà�?�?Ø�y‰yÐ4Ó4ØœrŸwšw yÓ1Ñ1×9Ñ9Ó;�ð ˆÐð —{‘{“}�àˆÐr   c                 óN   • Uc  U R                  X5      $ U R                  XU5      $ )z3Count the occurrences in each bin, maybe normalize.re   rf   s       r   rg   ÚHistogram.__call__Š  ri   r   )r€   r~   r|   r}   r   r   r{   )rv   ÚautoNNFFrj   r   )rl   rm   rn   ro   rp   r   rŽ   r™   rb   rP   rg   rq   rr   r   r   rt   rt   È   s:   † Ù7ð ØØØØØô3òjô*:òxò@÷49r   rt   c                   ó8   • \ rS rSrSrS	S jrS rS rS
S jrSr	g)ÚECDFi’  z7Univariate empirical cumulative distribution estimator.c                 ó:   • [        S/ SQU5        Xl        X l        g)zÚInitialize the class with its parameters

Parameters
----------
stat : {{"proportion", "percent", "count"}}
    Distribution statistic to compute.
complementary : bool
    If True, use the complementary CDF (1 - CDF)

r{   )rv   rz   ry   N)r   r{   Úcomplementary)r   r{   r³   s      r   r   ÚECDF.__init__”  s   € ô 	˜Ò BÀDÔIØŒ	Ø*Õr   c                 ó   • [        S5      e)z)Inner function for ECDF of two variables.z!Bivariate ECDF is not implemented)ÚNotImplementedErrorrf   s       r   rb   ÚECDF._eval_bivariate£  s   € ä!Ð"EÓFÐFr   c                 ó€  • UR                  5       nX   nX#   nUR                  5       nU R                  S;   a  XDR                  5       -  nU R                  S:X  a  US-  n[        R
                  [        R                  * U4   n[        R
                  SU4   nU R                  (       a  UR                  5       U-
  nXA4$ )z(Inner function for ECDF of one variable.)rz   ry   rz   r�   r   )Úargsortr¦   r{   r!   r   Úr_r    r³   )r   r$   r1   ÚsorterÚys        r   rP   ÚECDF._eval_univariate§  sž   € à—‘“ˆØ‰IˆØ‘/ˆØ�N‰NÓˆà�9‰9Ð1Ó1Ø—E‘E“G‘ˆAØ�9‰9˜	Ó!Ø�C‘ˆAä�E‰E”2—6‘6�'˜1�*ÑˆÜ�E‰E�!�Q�$‰Kˆà××Ø—‘“˜!‘ˆAàˆtˆr   Nc                 óÚ   • [         R                  " U5      nUc  [         R                  " U5      nO[         R                  " U5      nUc  U R                  X5      $ U R	                  XU5      $ )zGReturn proportion or count of observations below each sorted datapoint.)r   ÚasarrayÚ	ones_likerP   rb   rf   s       r   rg   ÚECDF.__call__»  sY   € ä�ZŠZ˜‹^ˆØ‰?Ü—l’l 2Ó&‰Gä—j’j Ó)ˆGà‰:Ø×(Ñ(¨Ó5Ð5à×'Ñ'¨°Ó8Ð8r   )r³   r{   )ry   Fr   )
rl   rm   rn   ro   rp   r   rb   rP   rg   rq   rr   r   r   r±   r±   ’  s   † ÙAô+òGò÷(9r   r±   c                   ó$   • \ rS rSrSS jrS rSrg)ÚEstimateAggregatoriÉ  Nc                 óN   • Xl         [        U5      u  pEX@l        XPl        X0l        g)al  
Data aggregator that produces an estimate and error bar interval.

Parameters
----------
estimator : callable or string
    Function (or method name) that maps a vector to a scalar.
errorbar : string, (string, number) tuple, or callable
    Name of errorbar method (either "ci", "pi", "se", or "sd"), or a tuple
    with a method name and a level parameter, or a function that maps from a
    vector to a (min, max) interval, or None to hide errorbar. See the
    :doc:`errorbar tutorial </tutorial/error_bars>` for more information.
boot_kws
    Additional keywords are passed to bootstrap when error_method is "ci".

N)Ú	estimatorÚ_validate_errorbar_argÚerror_methodÚerror_levelÚboot_kws©r   rÅ   ÚerrorbarrÉ   ÚmethodÚlevels         r   r   ÚEstimateAggregator.__init__Ë  s&   € ð" #Œä.¨xÓ8‰ˆØ"ÔØ Ôà �r   c                 ó”  • X   n[        U R                  5      (       a  U R                  U5      nOUR                  U R                  5      nU R                  c  [        R
                  =pVGO=[        U5      S::  a  [        R
                  =pVGO[        U R                  5      (       a  U R                  U5      u  pVOíU R                  S:X  a%  UR                  5       U R                  -  nXG-
  XG-   peO¸U R                  S:X  a%  UR                  5       U R                  -  nXG-
  XG-   peOƒU R                  S:X  a  [        X0R                  5      u  pVO[U R                  S:X  aK  UR                  SS5      n[        U4X€R                  S.U R                  D6n	[        X�R                  5      u  pV[        R                  " X$U S	3WU S
3W05      $ )úGAggregate over `var` column of `data` with estimate and error interval.Nr   ÚsdÚseÚpiÚciÚunits)rÕ   Úfuncr"   r!   )ÚcallablerÅ   ÚaggrÇ   r   Únanr‡   ÚstdrÈ   ÚsemÚ_percentile_intervalÚgetr   rÉ   ÚpdÚSeries)
r   ÚdataÚvarÚvalsÚestimateÚerr_minÚerr_maxÚhalf_intervalrÕ   Úbootss
             r   rg   ÚEstimateAggregator.__call__ä  s“  € à‰yˆÜ�D—N‘N×#Ñ#ð —~‘~ dÓ+‰Hà—x‘x §¡Ó/ˆHð ×ÑÑ$Ü "§¡Ð&ˆG‘gÜ�‹Y˜!‹^Ü "§¡Ð&ˆG‘gô �d×'Ñ'×(Ñ(Ø#×0Ñ0°Ó6ÑˆG�Wð ×Ñ $Ó&Ø ŸH™H›J¨×)9Ñ)9Ñ9ˆMØ'Ñ7¸Ñ9Q‘WØ×Ñ $Ó&Ø ŸH™H›J¨×)9Ñ)9Ñ9ˆMØ'Ñ7¸Ñ9Q‘Wð ×Ñ $Ó&Ü3°D×:JÑ:JÓKÑˆG�WØ×Ñ $Ó&Ø—H‘H˜W dÓ+ˆEÜ˜dÐV¨%·n±nÑVÈÏÉÑVˆEÜ3°E×;KÑ;KÓLÑˆGä�yŠy˜#¨C¨5°¨°gÀ#ÀÀc¸{ÈGÐTÓUÐUr   ©rÉ   rÈ   rÇ   rÅ   rk   ©rl   rm   rn   ro   r   rg   rq   rr   r   r   rÃ   rÃ   É  s   † ô!õ2$Vr   rÃ   c                   ó$   • \ rS rSrSS jrS rSrg)ÚWeightedAggregatori  Nc                 ó¬   • US:w  a  [        SU< S35      eXl        [        U5      u  pEUb  US:w  a  [        SU< S35      eX@l        XPl        X0l        g)aÚ  
Data aggregator that produces a weighted estimate and error bar interval.

Parameters
----------
estimator : string
    Function (or method name) that maps a vector to a scalar. Currently
    supports only "mean".
errorbar : string or (string, number) tuple
    Name of errorbar method or a tuple with a method name and a level parameter.
    Currently the only supported method is "ci".
boot_kws
    Additional keywords are passed to bootstrap when error_method is "ci".

Úmeanz'Weighted estimator must be 'mean', not Ú.NrÔ   z#Error bar method must be 'ci', not )Ú
ValueErrorrÅ   rÆ   rÇ   rÈ   rÉ   rÊ   s         r   r   ÚWeightedAggregator.__init__  si   € ð  ˜Óô ÐFÀyÁmÐSTÐUÓVÐVØ"Œä.¨xÓ8‰ˆØÑ &¨D£.ô ÐBÀ6Á*ÈAÐNÓOÐOØ"ÔØ Ôà �r   c                 óB  • X   nUS   n[         R                  " X4S9nU R                  S:X  aB  [        U5      S:”  a3  S n[	        X44SU0U R
                  D6n[        XpR                  5      u  p‰O[         R                  =p‰[        R                  " X%U S3X‚ S3U	05      $ )	rÐ   Úweight©r1   rÔ   r   c                 ó*   • [         R                  " XS9$ )Nrô   )r   Úaverage)r$   Úws     r   Ú
error_funcÚ/WeightedAggregator.__call__.<locals>.error_func7  s   € Ü—z’z !Ñ/Ð/r   rÖ   r"   r!   )r   rö   rÇ   r‡   r   rÉ   rÜ   rÈ   rÙ   rÞ   rß   )
r   rà   rá   râ   r1   rã   rø   rç   rä   rå   s
             r   rg   ÚWeightedAggregator.__call__.  sž   € à‰yˆØ�x‘.ˆä—:’:˜dÑ4ˆà×Ñ Ó$¬¨T«°Q«ò0ô ˜dÑN°*ÐNÀÇÁÑNˆEÜ3°E×;KÑ;KÓLÑˆG�Wô !#§¡Ð&ˆGä�yŠy˜#¨C¨5°¨°gÀÀc¸{ÈGÐTÓUÐUr   ré   rk   rê   rr   r   r   rì   rì     s   † ô!õBVr   rì   c                   ó&   • \ rS rSrS rS rS rSrg)ÚLetterValuesiC  c                 óÈ   • / SQn[        U[        5      (       a  [        SXA5        O*[        U[        5      (       d  SU SU< S3n[	        U5      eXl        X l        X0l        g)aÓ  
Compute percentiles of a distribution using various tail stopping rules.

Parameters
----------
k_depth: "tukey", "proportion", "trustworthy", or "full"
    Stopping rule for choosing tail percentiled to show:

    - tukey: Show a similar number of outliers as in a conventional boxplot.
    - proportion: Show approximately `outlier_prop` outliers.
    - trust_alpha: Use `trust_alpha` level for most extreme tail percentile.

outlier_prop: float
    Parameter for `k_depth="proportion"` setting the expected outlier rate.
trust_alpha: float
    Parameter for `k_depth="trustworthy"` setting the confidence threshold.

Notes
-----
Based on the proposal in this paper:
https://vita.had.co.nz/papers/letter-value-plot.pdf

)Útukeyry   ÚtrustworthyÚfullÚk_depthzDThe `k_depth` parameter must be either an integer or string (one of z), not rï   N)r’   r“   r   ÚintÚ	TypeErrorr  Úoutlier_propÚtrust_alpha)r   r  r  r  Ú	k_optionsÚerrs         r   r   ÚLetterValues.__init__E  sg   € ò0 Cˆ	Ü�gœs×#Ñ#Ü˜I yÕ:Ü˜G¤S×)Ñ)ðØ$˜+ W¨W©K°qð:ð ô ˜C“.Ð àŒØ(ÔØ&Õr   c                 óÆ  • U R                   S:X  a$  [        [        R                  " U5      5      S-   nGO"U R                   S:X  a#  [        [        R                  " U5      5      S-
  nOïU R                   S:X  aO  [        [        R                  " U5      5      [        [        R                  " XR                  -  5      5      -
  S-   nO�U R                   S:X  ak  [        R
                  " [        5       R                  5      nSU" SU R                  S-  -
  5      S-  -  n[        [        R                  " X-  5      5      S-   nO[        U R                   5      n[        US5      $ )Nr   r   rþ   r   ry   rÿ   r…   )
r  r  r   Úlog2r  Ú	vectorizer   Úinv_cdfr  r!   )r   ÚnÚkÚnormal_quantile_funcÚ
point_confs        r   Ú
_compute_kÚLetterValues._compute_kk  s  € ð �<‰<˜6Ó!ä”B—G’G˜A“J“ !Ñ#ŠAØ�\‰\˜WÓ$ä”B—G’G˜A“J“ !Ñ#‰AØ�\‰\˜\Ó)Ü”B—G’G˜A“J“¤#¤b§g¢g¨a×2CÑ2CÑ.CÓ&DÓ"EÑEÈÑI‰AØ�\‰\˜]Ó*Ü#%§<¢<´
³×0DÑ0DÓ#EÐ ØÑ1°!°d×6FÑ6FÈÑ6JÑ2JÓKÈqÑPÑPˆJÜ”B—G’G˜A™NÓ+Ó,¨qÑ0‰Aô �D—L‘LÓ!ˆAä�1�a‹yÐr   c                 óZ  • U R                  [        U5      5      n[        R                  " US-   SS5      [        R                  " SUS-   5      4nUS-   [        R                  " US   US   SS /5      -
  nS[        R                  " SUS   -  SSUS   -  -
  /5      -  nU R
                  S:X  a
  SUS'   SUS'   [        R                  " X5      n[        R                  " XUR                  5       :  XR                  5       :„  -     5      n[        R                  " US	5      nUUUUUUS
.$ )zEvaluate the letter values.r   éÿÿÿÿr…   r   Nr�   r„   r   é2   )r  ÚlevelsÚpercsÚvaluesÚfliersÚmedian)
r  r‡   r   r†   Úconcatenater  Ú
percentiler¿   r"   r!   )	r   r$   r  Úexpr  Úpercentilesr  r  r  s	            r   rg   ÚLetterValues.__call__€  s  € à�O‰OœC ›FÓ#ˆÜ�iŠi˜˜A™˜q "Ó%¤r§y¢y°°A¸±EÓ':Ð:ˆØ�Q‘œŸš¨¨Q©°°Q±¸¸°Ð(<Ó=Ñ=ˆØœBŸNšN¨C°3°q±6©M¸1¸sÀcÈ!Áf¹}Ñ;LÐ+MÓNÑNˆØ�<‰<˜6Ó!ØˆK˜‰NØ!ˆK˜‰OÜ—’˜qÓ.ˆÜ—’˜A 6§:¡:£<Ñ/°A¿
¹
»Ñ4DÑEÑFÓGˆÜ—’˜q "Ó%ˆð ØØ ØØØñ
ð 	
r   )r  r  r  N)rl   rm   rn   ro   r   r  rg   rq   rr   r   r   rü   rü   C  s   † ò$'òLõ*
r   rü   c                 óL   • SU-
  S-  nUSU-
  4n[         R                  " X5      $ )z8Return a percentile interval from data of a given width.r�   r…   )r   Únanpercentile)rà   ÚwidthÚedger  s       r   rÜ   rÜ   —  s/   € à�%‰K˜1Ñ€DØ˜˜d™
Ð"€KÜ×Ò˜DÓ.Ð.r   c                 ón  • SSSSS.nSnU c  g[        U 5      (       a  U S4$ [        U [        5      (       a  U nUR                  US5      nO U u  p4[        S[        U5      U5        Ub   [        U[        5      (       d  [        U5      eX44$ ! [        [
        4 a  nUR                  U5      UeSnAff = f)zCCheck type and value of errorbar argument and assign default level.é_   r   )rÔ   rÓ   rÒ   rÑ   z@`errorbar` must be a callable, string, or (string, number) tupleNr   rË   )
r×   r’   r“   rÝ   rð   r  Ú	__class__r   Úlistr   )ÚargÚDEFAULT_LEVELSÚusagerÌ   rÍ   r  s         r   rÆ   rÆ   ž  sÊ   € ð ØØØñ	€Nð O€Eà
�{ØÜ	�#�‰Ø�DˆyÐÜ	�Cœ×	Ñ	ØˆØ×"Ñ" 6¨4Ó0‰ð	0Ø‰MˆFô �J¤ ^Ó 4°fÔ=ØÑ¤¨E´6×!:Ñ!:Ü˜ÓÐàˆ=Ðøô œIÐ&ó 	0Ø—-‘- Ó&¨CÐ/ûð	0ús   ÁB ÂB4ÂB/Â/B4)rp   Únumbersr   Ú
statisticsr   Únumpyr   ÚpandasrÞ   Úscipy.statsr   r   ÚImportErrorÚexternal.kdeÚ
algorithmsr   Úutilsr   r
   rt   r±   rÃ   rì   rü   rÜ   rÆ   rr   r   r   Ú<module>r4     s�   ðñõ4 Ý !Û Û ðÝ(Ø€Iõ
 "Ý "÷Y9ñ Y9÷|G9ñ G9÷T49ñ 49÷n?Vñ ?V÷D5Vñ 5V÷pQ
ñ Q
òh/óøðy ó Ý*Ø‚Iðús   ˜A/ Á/B Á?B 