+
    i                         ^ RI Ht ^ RIHt ^ RIHt ^ RIHt ^ RIH	t	 ^ RI
HtHtHtHtHtHtHt ^ RIHtHt ^ RIHtHt ^ R	IHtHt ^ R
IHt ^ RIHt ^ RIH t   ! R R]4      t! ! R R]]4      t"R# )    )Sum)Basic)Lambda)Dummy)Integral)NamedArgsMixinrandom_symbols_symbol_converterPSpaceRandomSymbol	is_randomDistribution)ContinuousDistributionSingleContinuousPSpace)DiscreteDistributionSingleDiscretePSpace)SingleFiniteDistributionSingleFinitePSpace)ContinuousDistributionHandmade)DiscreteDistributionHandmade)FiniteDistributionHandmadec                     a  ] tR t^t o RtR t]R 4       t]R 4       t]R 4       t	]R 4       t
]R 4       t]R 4       t]R	 4       t]R
 4       t]R 4       tRR ltR tRR/R ltRR/R ltRR ltRR/R ltRR/R ltRtV tR# )CompoundPSpacez
A temporary Probability Space for the Compound Distribution. After
Marginalization, this returns the corresponding Probability Space of the
parent distribution.
c                \   \        V4      p\        V\        4      '       d   \        W4      # \        V\        4      '       d   \        W4      # \        V\        4      '       d   \        W4      # \        V\        4      '       g   \        R V,          4      h\        P                  ! WV4      # )z2%s should be an isinstance of CompoundDistribution)r
   
isinstancer   r   r   r   r   r   CompoundDistribution
ValueErrorr   __new__)clssdistributions   &&&w/Users/tonyclaw/.openclaw/workspace/skills/math-calculator/venv/lib/python3.14/site-packages/sympy/stats/compound_rv.pyr   CompoundPSpace.__new__   s    a l$:;;)!::l$899'88l$<==%a66,(<== /0<> ? ?}}S\22    c                .    \        V P                  V 4      # N)r   symbolselfs   &r"   valueCompoundPSpace.value$   s    DKK..r$   c                (    V P                   ^ ,          # r   argsr(   s   &r"   r'   CompoundPSpace.symbol(       yy|r$   c                .    V P                   P                  # r&   )r!   is_Continuousr(   s   &r"   r3   CompoundPSpace.is_Continuous,   s      ...r$   c                .    V P                   P                  # r&   )r!   	is_Finiter(   s   &r"   r6   CompoundPSpace.is_Finite0   s      ***r$   c                .    V P                   P                  # r&   )r!   is_Discreter(   s   &r"   r9   CompoundPSpace.is_Discrete4   s      ,,,r$   c                (    V P                   ^,          # )   r.   r(   s   &r"   r!   CompoundPSpace.distribution8   r1   r$   c                L    V P                   P                  V P                  4      # r&   )r!   pdfr'   r(   s   &r"   r?   CompoundPSpace.pdf<   s      $$T[[11r$   c                .    V P                   P                  # r&   )r!   setr(   s   &r"   rB   CompoundPSpace.set@   s      $$$r$   c                6    V P                  4       P                  # r&   )_get_newpspacedomainr(   s   &r"   rF   CompoundPSpace.domainD   s    ""$+++r$   c                   \        R 4      pV P                  P                  ^ ,          p\        W P                  P	                  W!4      4      pV P                  V P                  W44      pVe   V# R\        V4      ,          p\        V4      h)x3Compound Distribution for %s is not implemented yet)	r   r!   r/   r   r?   _transform_pspacer'   strNotImplementedError)r)   evaluaterI   parent_distfunc
new_pspacemessages   &&     r"   rE   CompoundPSpace._get_newpspaceH   sx    #J'',,Q/a**..q;<++DKKK
!H3{K[[!'**r$   c                z   \        W! V4      4      pVP                  p\        V\        4      '       d   \	        V\        W44      4      # \        V\        4      '       d   \        V\        W44      4      # \        V\        4      '       d-   V Uu/ uF  qUV! V4      bK  	  pp\        V\        V4      4      # R# u upi )zw
This function returns the new pspace of the distribution using handmade
Distributions and their corresponding pspace.
N)r   rB   r   r   r   r   r   r   r   r   r   r   )r)   symdistr?   _setkdenss   &&&&   r"   rK    CompoundPSpace._transform_pspaceR   s    
 S#c(#xxd233)#/Mc/XYY233'-I#-TUU677'+,t!s1vItD,%c+Ed+KLL 8,s   B8compound_evaluateTc                   V P                  V4      pVP                  V P                  VP                  /4      pVP                  ! V3/ VB # r&   )rE   subsr*   compute_densityr)   exprr[   kwargsrQ   s   &&$, r"   r^   CompoundPSpace.compute_densitya   sF    (():;
yy$**j&6&678))$9&99r$   c                   V P                  V4      pVP                  V P                  VP                  /4      pVP                  ! V3/ VB # r&   )rE   r]   r*   compute_cdfr_   s   &&$, r"   rd   CompoundPSpace.compute_cdff   sF    (():;
yy$**j&6&678%%d5f55r$   Nc                J   V P                  V4      pVP                  V P                  VP                  /4      pV'       d(   VP                  V P                  VP                  /4      p\        V\        4      '       d   VP
                  ! W3/ VB # VP
                  ! WV3/ VB # r&   )rE   r]   r*   r   r   compute_expectation)r)   r`   rvsrN   ra   rQ   s   &&&&, r"   rg   "CompoundPSpace.compute_expectationk   s    ((2
yy$**j&6&678((DJJ
(8(89:Cj"45511$FvFF--dLVLLr$   c                   V P                  V4      pVP                  V P                  VP                  /4      pVP                  V4      # r&   )rE   r]   r*   probabilityr)   	conditionr[   ra   rQ   s   &&$, r"   rk   CompoundPSpace.probabilityt   sA    (():;
NNDJJ
0@0@#AB	%%i00r$   c                   V P                  V4      pVP                  V P                  VP                  /4      pVP                  V4      # r&   )rE   r]   r*   conditional_spacerl   s   &&$, r"   rp    CompoundPSpace.conditional_spacey   sA    (():;
NNDJJ
0@0@#AB	++I66r$    F)NF)__name__
__module____qualname____firstlineno____doc__r   propertyr*   r'   r3   r6   r9   r!   r?   rB   rF   rE   rK   r^   rd   rg   rk   rp   __static_attributes____classdictcell____classdict__s   @r"   r   r      s	    3 / /   / / + + - -   2 2 % % , ,+M: :
6T 6
M1$ 1
7 7 7r$   r   c                      a  ] tR t^t o RtR t]R 4       t]R 4       t]R 4       t	]R 4       t
RR ltR t]R	 4       tR
tV tR# )r   ap  
Class for Compound Distributions.

Parameters
==========

dist : Distribution
    Distribution must contain a random parameter

Examples
========

>>> from sympy.stats.compound_rv import CompoundDistribution
>>> from sympy.stats.crv_types import NormalDistribution
>>> from sympy.stats import Normal
>>> from sympy.abc import x
>>> X = Normal('X', 2, 4)
>>> N = NormalDistribution(X, 4)
>>> C = CompoundDistribution(N)
>>> C.set
Interval(-oo, oo)
>>> C.pdf(x, evaluate=True).simplify()
exp(-x**2/64 + x/16 - 1/16)/(8*sqrt(pi))

References
==========

.. [1] https://en.wikipedia.org/wiki/Compound_probability_distribution

c                    \        V\        \        \        34      '       g   R \	        V4      ,          p\        V4      hV P                  V4      '       g   V# \        P                  ! W4      # )rJ   )	r   r   r   r   rL   rM   _compound_checkr   r   )r   rV   rR   s   && r"   r   CompoundDistribution.__new__   sa    $!7(*>!@ A AKcRViWG%g..""4((K}}S''r$   c                <    V P                   ^ ,          P                  # r-   )r/   rB   r(   s   &r"   rB   CompoundDistribution.set   s    yy|r$   c                D    \        V P                  ^ ,          \        4      # r-   )r   r/   r   r(   s   &r"   r3   "CompoundDistribution.is_Continuous   s    $))A,(>??r$   c                D    \        V P                  ^ ,          \        4      # r-   )r   r/   r   r(   s   &r"   r6   CompoundDistribution.is_Finite   s    $))A,(@AAr$   c                D    \        V P                  ^ ,          \        4      # r-   )r   r/   r   r(   s   &r"   r9    CompoundDistribution.is_Discrete   s    $))A,(<==r$   c                   V P                   ^ ,          pVP                    Uu. uF  p\        V4      '       g   K  VNK  	  pp\        V\        4      '       d!   \	        RRRR7      pVP                  V4      pM\	        R4      pVP                  V4      pV F  pV P                  WtV4      pK  	  \        Wg4      ! V4      # u upi )r   yTF)integernegative)	r/   r   r   r   r   pmfr?   _marginaliser   )r)   rI   rN   rV   rvrandomsr   r`   s   &&&     r"   r?   CompoundDistribution.pdf   s    yy| $		;	"Yr]22	;d455c4%8A88A;Dc
A88A;DB$$Tx8D aq!! <s
   C C c                r   \        VP                  P                  \        4      '       d'   VP                  P                  P	                  V4      pM%VP                  P                  P                  V4      pVP                  P                  P                  pVP                  P                  '       g   VP                  P                  '       d*   \        W,          W%P                  VP                  34      pM(\        W,          W%P                  VP                  34      pV'       d   VP                  4       # V# r&   )r   pspacer!   r   r   r?   rF   rB   r9   r6   r   _inf_supr   doit)r)   r`   r   rN   rv_densrv_doms   &&&&  r"   r   !CompoundDistribution._marginalise   s    bii,,.FGGii,,004Gii,,004G!!%%99   BII$7$7$7t|b++KK&! "D DL2{{KK+! "D99;r$   c                    . pVP                    F  pVP                  \        V4      4       K  	  \        V4      ^ 8X  d   R# R# )z>
Checks if the given distribution contains random parameters.
FT)r/   extendr	   len)r)   rV   r   args   &&  r"   r   $CompoundDistribution._compound_check   s:    
 99CNN>#./ w<1r$   rr   Nrs   )rt   ru   rv   rw   rx   r   ry   rB   r3   r6   r9   r?   r   classmethodr   rz   r{   r|   s   @r"   r   r      s     >(     @ @ B B > >"  	 	r$   r   N)#sympy.concrete.summationsr   sympy.core.basicr   sympy.core.functionr   sympy.core.symbolr   sympy.integrals.integralsr   sympy.stats.rvr   r	   r
   r   r   r   r   sympy.stats.crvr   r   sympy.stats.drvr   r   sympy.stats.frvr   r   sympy.stats.crv_typesr   sympy.stats.drv_typesr   sympy.stats.frv_typesr   r   r   rr   r$   r"   <module>r      sW    ) " & # .G G G J F H @ > <l7V l7^`< `r$   