def standard_t(df, size=None): """ Draw samples from a standard Student’s t distribution with df degrees of freedom. :param df: (*float*) Degrees of freedom, should be > 0. :param size: (*int*) Output shape. If size is None (default), a single value is returned. :returns: (*ndarray or scalar*) Drawn samples from the parameterized Student’s t distribution. """ dist = TDistribution(df) if size is None: size = 1 r = DistributionUtil.rvs(dist, size) return NDArray(r)
def weibull(a, size=None): """ Draw samples from a Weibull distribution. :param a: (*float*) Shape parameter of the distribution. Must be nonnegative. :param size: (*int*) Output shape. If size is None (default), a single value is returned. :returns: (*ndarray or scalar*) Drawn samples from the parameterized Weibull distribution. """ dist = WeibullDistribution(a, 1) if size is None: size = 1 r = DistributionUtil.rvs(dist, size) return NDArray(r)
def exponential(scale=1.0, size=None): """ Draw samples from a exponential distribution. :param scale: (*float*) The scale parameter. :param size: (*int*) Output shape. If size is None (default), a single value is returned. :returns: (*ndarray or scalar*) Drawn samples from the parameterized exponential distribution. """ dist = ExponentialDistribution(scale) if size is None: size = 1 r = DistributionUtil.rvs(dist, size) return NDArray(r)
def pareto(a, size=None): """ Draw samples from a Pareto II or Lomax distribution with specified shape. :param a: (*float*) Shape of the distribution. Should be greater than zero. :param size: (*int*) Output shape. If size is None (default), a single value is returned. :returns: (*ndarray or scalar*) Drawn samples from the parameterized Pareto distribution. """ dist = ParetoDistribution(1, a) if size is None: size = 1 r = DistributionUtil.rvs(dist, size) return NDArray(r)
def chisquare(df, size=None): """ Draw samples from a chi-square distribution. :param df: (*float*) Number of degrees of freedom, should be > 0. :param size: (*int*) Output shape. If size is None (default), a single value is returned. :returns: (*ndarray or scalar*) Drawn samples from the parameterized chisquare distribution. """ dist = ChiSquaredDistribution(df) if size is None: size = 1 r = DistributionUtil.rvs(dist, size) return NDArray(r)
def normal(loc=0.0, scale=1.0, size=None): """ Draw random samples from a normal (Gaussian) distribution. :param loc: (*float*) Mean (“centre”) of the distribution. :param scale: (*float*) Standard deviation (spread or “width”) of the distribution. :param size: (*int*) Output shape. If size is None (default), a single value is returned. """ dist = NormalDistribution(loc, scale) if size is None: size = 1 r = DistributionUtil.rvs(dist, size) return NDArray(r)
def rvs(self, *args, **kwargs): ''' Random variates of given type. :param loc: (*float*) location parameter (default=0). :param scale: (*float*) scale parameter (default=1). :param size: (*int*) Size. :returns: Probability density function. ''' dist = self._create_distribution(*args) size = kwargs.pop('size', 1) r = DistributionUtil.rvs(dist, size) return MIArray(r)
def rvs(self, *args, **kwargs): ''' Random variates of given type. :param loc: (*float*) location parameter (default=0). :param scale: (*float*) scale parameter (default=1). :param size: (*int*) Size. :returns: Probability density function. ''' dist = self._create_distribution(*args) size = kwargs.pop('size', 1) r = DistributionUtil.rvs(dist, size) return NDArray(r)
def lognormal(mean=0.0, sigma=1.0, size=None): """ Draw samples from the log-normal distribution. :param mean: (*float*) Mean value of the underlying normal distribution. Default is 0. :param sigma: (*float*) Standard deviation of the underlying normal distribution. Should be greater than zero. Default is 1. :param size: (*int*) Output shape. If size is None (default), a single value is returned. :returns: (*ndarray or scalar*) Drawn samples from the parameterized log-normal distribution. """ dist = LogNormalDistribution(loc, scale) if size is None: size = 1 r = DistributionUtil.rvs(dist, size) return NDArray(r)
def logistic(loc=0.0, scale=1.0, size=None): """ Draw samples from the Logistic distribution. :param loc: (*float*) Mean (“centre”) of the distribution. :param scale: (*float*) Standard deviation (spread or “width”) of the distribution. :param size: (*int*) Output shape. If size is None (default), a single value is returned. :returns: (*ndarray or scalar*) Drawn samples from the parameterized Logistic distribution. """ dist = LogisticDistribution(loc, scale) if size is None: size = 1 r = DistributionUtil.rvs(dist, size) return NDArray(r)
def laplace(loc=0.0, scale=1.0, size=None): """ Draw samples from the Laplace or double exponential distribution with specified location (or mean) and scale (decay). :param loc: (*float*) Mean (“centre”) of the distribution. :param scale: (*float*) Standard deviation (spread or “width”) of the distribution. :param size: (*int*) Output shape. If size is None (default), a single value is returned. :returns: (*ndarray or scalar*) Drawn samples from the parameterized Laplace distribution. """ dist = LaplaceDistribution(loc, scale) if size is None: size = 1 r = DistributionUtil.rvs(dist, size) return NDArray(r)
def gamma(shape, scale=1.0, size=None): """ Draw random samples from a Gamma distribution. :param shape: (*float*) The shape of the gamma distribution. Should be greater than zero. :param scale: (*float*) Standard deviation (spread or “width”) of the distribution. :param size: (*int*) Output shape. If size is None (default), a single value is returned. :returns: (*ndarray or scalar*) Drawn samples from the parameterized Gamma distribution. """ dist = GammaDistribution(shape, scale) if size is None: size = 1 r = DistributionUtil.rvs(dist, size) return NDArray(r)
def f(dfnum, dfden, size=None): """ Draw random samples from a F distribution. :param dfnum: (*float*) Degrees of freedom in numerator, should be > 0. :param dfden: (*float*) Degrees of freedom in denominator, should be > 0. :param size: (*int*) Output shape. If size is None (default), a single value is returned. :returns: (*ndarray or scalar*) Drawn samples from the parameterized Fisher distribution. """ dist = FDistribution(dfnum, dfden) if size is None: size = 1 r = DistributionUtil.rvs(dist, size) return NDArray(r)
def uniform(low=0.0, high=1.0, size=None): """ Draw samples from the uniform distribution. :param low: (*float*) Lower boundary of the output interval. All values generated will be greater than or equal to low. The default value is 0. :param high: (*float*) Upper boundary of the output interval. All values generated will be less than high. The default value is 1.0. :param size: (*int*) Output shape. If size is None (default), a single value is returned. :returns: (*ndarray or scalar*) Drawn samples from the parameterized uniform distribution. """ dist = UniformRealDistribution(low, high) if size is None: size = 1 r = DistributionUtil.rvs(dist, size) return NDArray(r)
def triangular(left, mode, right, size=None): """ Draw samples from the triangular distribution over the interval [left, right]. :param left: (*float*) Lower limit. :param mode: (*float*) The value where the peak of the distribution occurs. The value should fulfill the condition left <= mode <= right. :param right: (*float*) Upper limit, should be larger than left. :param size: (*int*) Output shape. If size is None (default), a single value is returned. :returns: (*ndarray or scalar*) Drawn samples from the parameterized triangular distribution. """ dist = TriangularDistribution(left, mode, right) if size is None: size = 1 r = DistributionUtil.rvs(dist, size) return NDArray(r)