Composite.sample (function)
def sample(self, size=None, unit=None, as_quantity=False, wrap_at=None, seed={}, as_univariate=False, cache_sample=True)
Sample from the Composite distribution.
Arguments
size
(int or tuple or None, optional, default=None): size/shape of the resulting array.unit
(astropy.unit, optional, default=None): unit to convert the resulting sample(s). Astropy must be installed in order to convert units.as_quantity
(bool, optional, default=False): whether to return an astropy quantity object instead of just the value. Astropy must be installed.wrap_at
(float, None, or False, optional, default=None): value to use for wrapping. See Composite.wrap. If not provided or None, will use the value from Composite.wrap_at. Note: wrapping is computed before changing units, sowrap_at
must be provided according to Composite.unit notunit
.seed
(dict, optional, default={}): seeds (as uniqueid: seed pairs) to pass to underlying distributions.as_univariate
(bool, optional, default=False): whether to draw from the flattend Composite.pdf rather than from the children distributions. If True, any underlying covariances from BaseMultivariateSliceDistribution objects will be ignored. This may be slightly faster, especially with repeated calls. Note thatas_univariate
is ignored for Composite distributions with 'and' logic as these are always sampled from the combined pdf.cache_sample
(bool, optional, default=True): whether to override the existing Composite.cached_sample.
Returns
- float or array: float if
size=None
, otherwise a numpy array with shape defined bysize
.