
    IR-eL                         d Z ddlmZ ddlZddlmZ ddlm	Z	 g dZ
ddde	dd	Zej        ej        ej        ej        ej        ej        ej        ej        fZe	fd
Zdddde	ddZdS )z+
Built-in distribution-creation functions.
    )warnN)units   )Distribution)normalpoissonuniform)stdvarivarclsc                   t          j        |           } |)|t          j        |          dz  }nt          d          |)|t          j        |          dz  }nt          d          |t          d          t          j        |          }t          j        ||           j        |fz   }| dt           j        f         t          j        j        | |dt           j        f         z  z   } ||fi |S )u  
    Create a Gaussian/normal distribution.

    Parameters
    ----------
    center : `~astropy.units.Quantity`
        The center of this distribution
    std : `~astropy.units.Quantity` or None
        The standard deviation/σ of this distribution. Shape must match and unit
        must be compatible with ``center``, or be `None` (if ``var`` or ``ivar``
        are set).
    var : `~astropy.units.Quantity` or None
        The variance of this distribution. Shape must match and unit must be
        compatible with ``center``, or be `None` (if ``std`` or ``ivar`` are set).
    ivar : `~astropy.units.Quantity` or None
        The inverse variance of this distribution. Shape must match and unit
        must be compatible with ``center``, or be `None` (if ``std`` or ``var``
        are set).
    n_samples : int
        The number of Monte Carlo samples to use with this distribution
    cls : class
        The class to use to create this distribution.  Typically a
        `Distribution` subclass.

    Remaining keywords are passed into the constructor of the ``cls``

    Returns
    -------
    distr : `~astropy.uncertainty.Distribution` or object
        The sampled Gaussian distribution.
        The type will be the same as the parameter ``cls``.

    Ng      ?z#normal cannot take both std and varg      z/normal cannot take both ivar and and std or varz(normal requires one of std, var, or ivar.)np
asanyarray
ValueError	broadcastshapenewaxisrandomrandn)	centerr
   r   r   	n_samplesr   kwargs	randshapesampless	            Alib/python3.11/site-packages/astropy/uncertainty/distributions.pyr   r      s    H ]6""F
;-$$+CCBCCC;-%%-CCNOOO
{CDDDmC  S&))/9,>IsBJ")/9"=CO@T"TT  3w!!&!!!    c                    d}t          | d          rd}t          j        | j                  }nt          j        |           }|j        |fz   }t          j                            |dt          j        f         |          }|r]| j        t          j
        k    rt          d           n.| j        t          vr t          d| j         dt           d           || j        z  } ||fi |S )	ux  
    Create a Poisson distribution.

    Parameters
    ----------
    center : `~astropy.units.Quantity`
        The center value of this distribution (i.e., λ).
    n_samples : int
        The number of Monte Carlo samples to use with this distribution
    cls : class
        The class to use to create this distribution.  Typically a
        `Distribution` subclass.

    Remaining keywords are passed into the constructor of the ``cls``

    Returns
    -------
    distr : `~astropy.uncertainty.Distribution` or object
        The sampled Poisson distribution.
        The type will be the same as the parameter ``cls``.
    FunitT.zADUs were provided to poisson.  ADUs are not strictly countunits because they need the gain to be applied. It is recommended you apply the gain to convert to e.g. electrons.zUnit z. was provided to poisson, which is not one of zY, and therefore suspect as a "counting" unit.  Ensure you mean to use Poisson statistics.)hasattrr   r   valuer   r   r   r   r   uadur   COUNT_UNITS)r   r   r   r   has_unit
poissonarrr   r   s           r   r   r   X   s   . Hvv +]6<00

]6**
 I</Ii
3
? ;YGGG (;!%O   
 [++7 7 77 7 7   FK'3w!!&!!!r   )lowerupperr   widthr   c                 l   |J|Ht          j        |           } t          j        |          }| j        |j        k    rt          d          nL|;| 9t          j        |          }t          j        |          }||dz  z
  } ||dz  z   }nt          d          | j        |fz   }| j        t	                      k    r|j        t	                      k    r|| z
  }n/|| z
  ddt           j        f         }| ddt           j        f         } | |t           j                            |          z  z   } ||fi |S )a1  
    Create a Uniform distriution from the lower and upper bounds.

    Note that this function requires keywords to be explicit, and requires
    either ``lower``/``upper`` or ``center``/``width``.

    Parameters
    ----------
    lower : array-like
        The lower edge of this distribution. If a `~astropy.units.Quantity`, the
        distribution will have the same units as ``lower``.
    upper : `~astropy.units.Quantity`
        The upper edge of this distribution. Must match shape and if a
        `~astropy.units.Quantity` must have compatible units with ``lower``.
    center : array-like
        The center value of the distribution. Cannot be provided at the same
        time as ``lower``/``upper``.
    width : array-like
        The width of the distribution.  Must have the same shape and compatible
        units with ``center`` (if any).
    n_samples : int
        The number of Monte Carlo samples to use with this distribution
    cls : class
        The class to use to create this distribution.  Typically a
        `Distribution` subclass.

    Remaining keywords are passed into the constructor of the ``cls``

    Returns
    -------
    distr : `~astropy.uncertainty.Distribution` or object
        The sampled uniform distribution.
        The type will be the same as the parameter ``cls``.
    Nz+lower and upper must have consistent shapes   z^either upper/lower or center/width must be given to uniform - other combinations are not valid)size)r   r   r   r   tupler   r   r	   )	r'   r(   r   r)   r   r   r   newshaper   s	            r   r	   r	      sM   X ~%-e$$e$$;%+%%JKKK &	5=v&&e$$""<
 
 	

 {i\)H{egg%+"8"82:.aaam$ebi//X/>>>>G3w!!&!!!r   )__doc__warningsr   numpyr   astropyr   r"   corer   __all__r   countelectrondimensionless_unscaledchanbinvoxbitbyter$   r   r	    r   r   <module>r>      s
                         
*
*
* T\8" 8" 8" 8" 8"x GJFEEEF	 $0 1" 1" 1" 1"l 

D" D" D" D" D" D" D"r   