package scipy

  1. Overview
  2. Docs
Legend:
Library
Module
Module type
Parameter
Class
Class type
type tag = [
  1. | `Uniform_gen
]
type t = [ `Object | `Rv_continuous | `Rv_generic | `Uniform_gen ] Obj.t
val of_pyobject : Py.Object.t -> t
val to_pyobject : [> tag ] Obj.t -> Py.Object.t
val as_rv_generic : t -> [ `Rv_generic ] Obj.t
val as_rv_continuous : t -> [ `Rv_continuous ] Obj.t
val create : ?momtype:Py.Object.t -> ?a:Py.Object.t -> ?b:Py.Object.t -> ?xtol:Py.Object.t -> ?badvalue:Py.Object.t -> ?name:Py.Object.t -> ?longname:Py.Object.t -> ?shapes:Py.Object.t -> ?extradoc:Py.Object.t -> ?seed:Py.Object.t -> unit -> t

A uniform continuous random variable.

In the standard form, the distribution is uniform on ``0, 1``. Using the parameters ``loc`` and ``scale``, one obtains the uniform distribution on ``loc, loc + scale``.

%(before_notes)s

%(example)s

val cdf : ?kwds:(string * Py.Object.t) list -> x:[> `Ndarray ] Np.Obj.t -> Py.Object.t list -> [> tag ] Obj.t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Cumulative distribution function of the given RV.

Parameters ---------- x : array_like quantiles arg1, arg2, arg3,... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information) loc : array_like, optional location parameter (default=0) scale : array_like, optional scale parameter (default=1)

Returns ------- cdf : ndarray Cumulative distribution function evaluated at `x`

val entropy : ?kwds:(string * Py.Object.t) list -> Py.Object.t list -> [> tag ] Obj.t -> Py.Object.t

Differential entropy of the RV.

Parameters ---------- arg1, arg2, arg3,... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information). loc : array_like, optional Location parameter (default=0). scale : array_like, optional (continuous distributions only). Scale parameter (default=1).

Notes ----- Entropy is defined base `e`:

>>> drv = rv_discrete(values=((0, 1), (0.5, 0.5))) >>> np.allclose(drv.entropy(), np.log(2.0)) True

val expect : ?func:Py.Object.t -> ?args:Py.Object.t -> ?loc:float -> ?scale:float -> ?lb:Py.Object.t -> ?ub:Py.Object.t -> ?conditional:bool -> ?kwds:(string * Py.Object.t) list -> [> tag ] Obj.t -> float

Calculate expected value of a function with respect to the distribution by numerical integration.

The expected value of a function ``f(x)`` with respect to a distribution ``dist`` is defined as::

ub Ef(x) = Integral(f(x) * dist.pdf(x)), lb

where ``ub`` and ``lb`` are arguments and ``x`` has the ``dist.pdf(x)`` distribution. If the bounds ``lb`` and ``ub`` correspond to the support of the distribution, e.g. ``-inf, inf`` in the default case, then the integral is the unrestricted expectation of ``f(x)``. Also, the function ``f(x)`` may be defined such that ``f(x)`` is ``0`` outside a finite interval in which case the expectation is calculated within the finite range ``lb, ub``.

Parameters ---------- func : callable, optional Function for which integral is calculated. Takes only one argument. The default is the identity mapping f(x) = x. args : tuple, optional Shape parameters of the distribution. loc : float, optional Location parameter (default=0). scale : float, optional Scale parameter (default=1). lb, ub : scalar, optional Lower and upper bound for integration. Default is set to the support of the distribution. conditional : bool, optional If True, the integral is corrected by the conditional probability of the integration interval. The return value is the expectation of the function, conditional on being in the given interval. Default is False.

Additional keyword arguments are passed to the integration routine.

Returns ------- expect : float The calculated expected value.

Notes ----- The integration behavior of this function is inherited from `scipy.integrate.quad`. Neither this function nor `scipy.integrate.quad` can verify whether the integral exists or is finite. For example ``cauchy(0).mean()`` returns ``np.nan`` and ``cauchy(0).expect()`` returns ``0.0``.

Examples --------

To understand the effect of the bounds of integration consider

>>> from scipy.stats import expon >>> expon(1).expect(lambda x: 1, lb=0.0, ub=2.0) 0.6321205588285578

This is close to

>>> expon(1).cdf(2.0) - expon(1).cdf(0.0) 0.6321205588285577

If ``conditional=True``

>>> expon(1).expect(lambda x: 1, lb=0.0, ub=2.0, conditional=True) 1.0000000000000002

The slight deviation from 1 is due to numerical integration.

val fit : ?kwds:(string * Py.Object.t) list -> data:[> `Ndarray ] Np.Obj.t -> Py.Object.t list -> [> tag ] Obj.t -> Py.Object.t

Maximum likelihood estimate for the location and scale parameters.

`uniform.fit` uses only the following parameters. Because exact formulas are used, the parameters related to optimization that are available in the `fit` method of other distributions are ignored here. The only positional argument accepted is `data`.

Parameters ---------- data : array_like Data to use in calculating the maximum likelihood estimate. floc : float, optional Hold the location parameter fixed to the specified value. fscale : float, optional Hold the scale parameter fixed to the specified value.

Returns ------- loc, scale : float Maximum likelihood estimates for the location and scale.

Notes ----- An error is raised if `floc` is given and any values in `data` are less than `floc`, or if `fscale` is given and `fscale` is less than ``data.max() - data.min()``. An error is also raised if both `floc` and `fscale` are given.

Examples -------- >>> from scipy.stats import uniform

We'll fit the uniform distribution to `x`:

>>> x = np.array(2, 2.5, 3.1, 9.5, 13.0)

For a uniform distribution MLE, the location is the minimum of the data, and the scale is the maximum minus the minimum.

>>> loc, scale = uniform.fit(x) >>> loc 2.0 >>> scale 11.0

If we know the data comes from a uniform distribution where the support starts at 0, we can use `floc=0`:

>>> loc, scale = uniform.fit(x, floc=0) >>> loc 0.0 >>> scale 13.0

Alternatively, if we know the length of the support is 12, we can use `fscale=12`:

>>> loc, scale = uniform.fit(x, fscale=12) >>> loc 1.5 >>> scale 12.0

In that last example, the support interval is 1.5, 13.5. This solution is not unique. For example, the distribution with ``loc=2`` and ``scale=12`` has the same likelihood as the one above. When `fscale` is given and it is larger than ``data.max() - data.min()``, the parameters returned by the `fit` method center the support over the interval ``data.min(), data.max()``.

val fit_loc_scale : data:[> `Ndarray ] Np.Obj.t -> Py.Object.t list -> [> tag ] Obj.t -> float * float

Estimate loc and scale parameters from data using 1st and 2nd moments.

Parameters ---------- data : array_like Data to fit. arg1, arg2, arg3,... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information).

Returns ------- Lhat : float Estimated location parameter for the data. Shat : float Estimated scale parameter for the data.

val freeze : ?kwds:(string * Py.Object.t) list -> Py.Object.t list -> [> tag ] Obj.t -> Py.Object.t

Freeze the distribution for the given arguments.

Parameters ---------- arg1, arg2, arg3,... : array_like The shape parameter(s) for the distribution. Should include all the non-optional arguments, may include ``loc`` and ``scale``.

Returns ------- rv_frozen : rv_frozen instance The frozen distribution.

val interval : ?kwds:(string * Py.Object.t) list -> alpha:[> `Ndarray ] Np.Obj.t -> Py.Object.t list -> [> tag ] Obj.t -> Py.Object.t

Confidence interval with equal areas around the median.

Parameters ---------- alpha : array_like of float Probability that an rv will be drawn from the returned range. Each value should be in the range 0, 1. arg1, arg2, ... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information). loc : array_like, optional location parameter, Default is 0. scale : array_like, optional scale parameter, Default is 1.

Returns ------- a, b : ndarray of float end-points of range that contain ``100 * alpha %`` of the rv's possible values.

val isf : ?kwds:(string * Py.Object.t) list -> q:[> `Ndarray ] Np.Obj.t -> Py.Object.t list -> [> tag ] Obj.t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Inverse survival function (inverse of `sf`) at q of the given RV.

Parameters ---------- q : array_like upper tail probability arg1, arg2, arg3,... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information) loc : array_like, optional location parameter (default=0) scale : array_like, optional scale parameter (default=1)

Returns ------- x : ndarray or scalar Quantile corresponding to the upper tail probability q.

val logcdf : ?kwds:(string * Py.Object.t) list -> x:[> `Ndarray ] Np.Obj.t -> Py.Object.t list -> [> tag ] Obj.t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Log of the cumulative distribution function at x of the given RV.

Parameters ---------- x : array_like quantiles arg1, arg2, arg3,... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information) loc : array_like, optional location parameter (default=0) scale : array_like, optional scale parameter (default=1)

Returns ------- logcdf : array_like Log of the cumulative distribution function evaluated at x

val logpdf : ?kwds:(string * Py.Object.t) list -> x:[> `Ndarray ] Np.Obj.t -> Py.Object.t list -> [> tag ] Obj.t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Log of the probability density function at x of the given RV.

This uses a more numerically accurate calculation if available.

Parameters ---------- x : array_like quantiles arg1, arg2, arg3,... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information) loc : array_like, optional location parameter (default=0) scale : array_like, optional scale parameter (default=1)

Returns ------- logpdf : array_like Log of the probability density function evaluated at x

val logsf : ?kwds:(string * Py.Object.t) list -> x:[> `Ndarray ] Np.Obj.t -> Py.Object.t list -> [> tag ] Obj.t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Log of the survival function of the given RV.

Returns the log of the 'survival function,' defined as (1 - `cdf`), evaluated at `x`.

Parameters ---------- x : array_like quantiles arg1, arg2, arg3,... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information) loc : array_like, optional location parameter (default=0) scale : array_like, optional scale parameter (default=1)

Returns ------- logsf : ndarray Log of the survival function evaluated at `x`.

val mean : ?kwds:(string * Py.Object.t) list -> Py.Object.t list -> [> tag ] Obj.t -> float

Mean of the distribution.

Parameters ---------- arg1, arg2, arg3,... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information) loc : array_like, optional location parameter (default=0) scale : array_like, optional scale parameter (default=1)

Returns ------- mean : float the mean of the distribution

val median : ?kwds:(string * Py.Object.t) list -> Py.Object.t list -> [> tag ] Obj.t -> float

Median of the distribution.

Parameters ---------- arg1, arg2, arg3,... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information) loc : array_like, optional Location parameter, Default is 0. scale : array_like, optional Scale parameter, Default is 1.

Returns ------- median : float The median of the distribution.

See Also -------- rv_discrete.ppf Inverse of the CDF

val moment : ?kwds:(string * Py.Object.t) list -> n:[ `N_1 of Py.Object.t | `I of int ] -> Py.Object.t list -> [> tag ] Obj.t -> Py.Object.t

n-th order non-central moment of distribution.

Parameters ---------- n : int, n >= 1 Order of moment. arg1, arg2, arg3,... : float The shape parameter(s) for the distribution (see docstring of the instance object for more information). loc : array_like, optional location parameter (default=0) scale : array_like, optional scale parameter (default=1)

val nnlf : theta:Py.Object.t -> x:Py.Object.t -> [> tag ] Obj.t -> Py.Object.t

Return negative loglikelihood function.

Notes ----- This is ``-sum(log pdf(x, theta), axis=0)`` where `theta` are the parameters (including loc and scale).

val pdf : ?kwds:(string * Py.Object.t) list -> x:[> `Ndarray ] Np.Obj.t -> Py.Object.t list -> [> tag ] Obj.t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Probability density function at x of the given RV.

Parameters ---------- x : array_like quantiles arg1, arg2, arg3,... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information) loc : array_like, optional location parameter (default=0) scale : array_like, optional scale parameter (default=1)

Returns ------- pdf : ndarray Probability density function evaluated at x

val ppf : ?kwds:(string * Py.Object.t) list -> q:[> `Ndarray ] Np.Obj.t -> Py.Object.t list -> [> tag ] Obj.t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Percent point function (inverse of `cdf`) at q of the given RV.

Parameters ---------- q : array_like lower tail probability arg1, arg2, arg3,... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information) loc : array_like, optional location parameter (default=0) scale : array_like, optional scale parameter (default=1)

Returns ------- x : array_like quantile corresponding to the lower tail probability q.

val rvs : ?kwds:(string * Py.Object.t) list -> Py.Object.t list -> [> tag ] Obj.t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Random variates of given type.

Parameters ---------- arg1, arg2, arg3,... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information). loc : array_like, optional Location parameter (default=0). scale : array_like, optional Scale parameter (default=1). size : int or tuple of ints, optional Defining number of random variates (default is 1). random_state : None or int or ``np.random.RandomState`` instance, optional If int or RandomState, use it for drawing the random variates. If None, rely on ``self.random_state``. Default is None.

Returns ------- rvs : ndarray or scalar Random variates of given `size`.

val sf : ?kwds:(string * Py.Object.t) list -> x:[> `Ndarray ] Np.Obj.t -> Py.Object.t list -> [> tag ] Obj.t -> [ `ArrayLike | `Ndarray | `Object ] Np.Obj.t

Survival function (1 - `cdf`) at x of the given RV.

Parameters ---------- x : array_like quantiles arg1, arg2, arg3,... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information) loc : array_like, optional location parameter (default=0) scale : array_like, optional scale parameter (default=1)

Returns ------- sf : array_like Survival function evaluated at x

val stats : ?kwds:(string * Py.Object.t) list -> Py.Object.t list -> [> tag ] Obj.t -> Py.Object.t

Some statistics of the given RV.

Parameters ---------- arg1, arg2, arg3,... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information) loc : array_like, optional location parameter (default=0) scale : array_like, optional (continuous RVs only) scale parameter (default=1) moments : str, optional composed of letters 'mvsk' defining which moments to compute: 'm' = mean, 'v' = variance, 's' = (Fisher's) skew, 'k' = (Fisher's) kurtosis. (default is 'mv')

Returns ------- stats : sequence of requested moments.

val std : ?kwds:(string * Py.Object.t) list -> Py.Object.t list -> [> tag ] Obj.t -> float

Standard deviation of the distribution.

Parameters ---------- arg1, arg2, arg3,... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information) loc : array_like, optional location parameter (default=0) scale : array_like, optional scale parameter (default=1)

Returns ------- std : float standard deviation of the distribution

val support : ?kwargs:(string * Py.Object.t) list -> Py.Object.t list -> [> tag ] Obj.t -> Py.Object.t

Return the support of the distribution.

Parameters ---------- arg1, arg2, ... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information). loc : array_like, optional location parameter, Default is 0. scale : array_like, optional scale parameter, Default is 1. Returns ------- a, b : float end-points of the distribution's support.

val var : ?kwds:(string * Py.Object.t) list -> Py.Object.t list -> [> tag ] Obj.t -> float

Variance of the distribution.

Parameters ---------- arg1, arg2, arg3,... : array_like The shape parameter(s) for the distribution (see docstring of the instance object for more information) loc : array_like, optional location parameter (default=0) scale : array_like, optional scale parameter (default=1)

Returns ------- var : float the variance of the distribution

val to_string : t -> string

Print the object to a human-readable representation.

val show : t -> string

Print the object to a human-readable representation.

val pp : Format.formatter -> t -> unit

Pretty-print the object to a formatter.

OCaml

Innovation. Community. Security.