pub enum Distribution {
Uniform(UniformDistribution),
Exponential(ExponentialDistribution),
Gaussian(GaussianDistribution),
Bernoulli(BernoulliDistribution),
Generic(GenericDistribution),
}
Expand description
This object defines probabilistic distributions that encode uncertain information about a single, scalar value. Currently, we support five core statistical distributions. New variants will be added over time.
This object is the lowest-level object in the statistics hierarchy, and it is the main unit of calculus when evaluating expressions in a statistical context. Notions like column and table statistics are built on top of this object and the operations it supports.
Variants§
Uniform(UniformDistribution)
Exponential(ExponentialDistribution)
Gaussian(GaussianDistribution)
Bernoulli(BernoulliDistribution)
Generic(GenericDistribution)
Implementations§
Source§impl Distribution
impl Distribution
Sourcepub fn new_uniform(interval: Interval) -> Result<Distribution, DataFusionError>
pub fn new_uniform(interval: Interval) -> Result<Distribution, DataFusionError>
Sourcepub fn new_exponential(
rate: ScalarValue,
offset: ScalarValue,
positive_tail: bool,
) -> Result<Distribution, DataFusionError>
pub fn new_exponential( rate: ScalarValue, offset: ScalarValue, positive_tail: bool, ) -> Result<Distribution, DataFusionError>
Constructs a new Exponential
distribution from the given rate/offset
pair, and validates the given parameters.
Sourcepub fn new_gaussian(
mean: ScalarValue,
variance: ScalarValue,
) -> Result<Distribution, DataFusionError>
pub fn new_gaussian( mean: ScalarValue, variance: ScalarValue, ) -> Result<Distribution, DataFusionError>
Constructs a new Gaussian
distribution from the given mean/variance
pair, and validates the given parameters.
Sourcepub fn new_bernoulli(p: ScalarValue) -> Result<Distribution, DataFusionError>
pub fn new_bernoulli(p: ScalarValue) -> Result<Distribution, DataFusionError>
Constructs a new Bernoulli
distribution from the given success
probability, and validates the given parameters.
Sourcepub fn new_generic(
mean: ScalarValue,
median: ScalarValue,
variance: ScalarValue,
range: Interval,
) -> Result<Distribution, DataFusionError>
pub fn new_generic( mean: ScalarValue, median: ScalarValue, variance: ScalarValue, range: Interval, ) -> Result<Distribution, DataFusionError>
Constructs a new Generic
distribution from the given mean, median,
variance, and range values after validating the given parameters.
Sourcepub fn new_from_interval(
range: Interval,
) -> Result<Distribution, DataFusionError>
pub fn new_from_interval( range: Interval, ) -> Result<Distribution, DataFusionError>
Constructs a new Generic
distribution from the given range. Other
parameters (mean, median and variance) are initialized with null values.
Sourcepub fn mean(&self) -> Result<ScalarValue, DataFusionError>
pub fn mean(&self) -> Result<ScalarValue, DataFusionError>
Extracts the mean value of this uncertain quantity, depending on its distribution:
- A
Uniform
distribution’s interval determines its mean value, which is the arithmetic average of the interval endpoints. - An
Exponential
distribution’s mean is calculable by the formulaoffset + 1 / λ
, whereλ
is the (non-negative) rate. - A
Gaussian
distribution contains the mean explicitly. - A
Bernoulli
distribution’s mean is equal to its success probabilityp
. - A
Generic
distribution may have it explicitly, or this information may be absent.
Sourcepub fn median(&self) -> Result<ScalarValue, DataFusionError>
pub fn median(&self) -> Result<ScalarValue, DataFusionError>
Extracts the median value of this uncertain quantity, depending on its distribution:
- A
Uniform
distribution’s interval determines its median value, which is the arithmetic average of the interval endpoints. - An
Exponential
distribution’s median is calculable by the formulaoffset + ln(2) / λ
, whereλ
is the (non-negative) rate. - A
Gaussian
distribution’s median is equal to its mean, which is specified explicitly. - A
Bernoulli
distribution’s median is1
ifp > 0.5
and0
otherwise, wherep
is the success probability. - A
Generic
distribution may have it explicitly, or this information may be absent.
Sourcepub fn variance(&self) -> Result<ScalarValue, DataFusionError>
pub fn variance(&self) -> Result<ScalarValue, DataFusionError>
Extracts the variance value of this uncertain quantity, depending on its distribution:
- A
Uniform
distribution’s interval determines its variance value, which is calculable by the formula(upper - lower) ^ 2 / 12
. - An
Exponential
distribution’s variance is calculable by the formula1 / (λ ^ 2)
, whereλ
is the (non-negative) rate. - A
Gaussian
distribution’s variance is specified explicitly. - A
Bernoulli
distribution’s median is given by the formulap * (1 - p)
wherep
is the success probability. - A
Generic
distribution may have it explicitly, or this information may be absent.
Sourcepub fn range(&self) -> Result<Interval, DataFusionError>
pub fn range(&self) -> Result<Interval, DataFusionError>
Extracts the range of this uncertain quantity, depending on its distribution:
- A
Uniform
distribution’s range is simply its interval. - An
Exponential
distribution’s range is[offset, +∞)
. - A
Gaussian
distribution’s range is unbounded. - A
Bernoulli
distribution’s range isInterval::UNCERTAIN
, ifp
is neither0
nor1
. Otherwise, it isInterval::CERTAINLY_FALSE
andInterval::CERTAINLY_TRUE
, respectively. - A
Generic
distribution is unbounded by default, but more information may be present.
Sourcepub fn data_type(&self) -> DataType
pub fn data_type(&self) -> DataType
Returns the data type of the statistical parameters comprising this distribution.
pub fn target_type(args: &[&ScalarValue]) -> Result<DataType, DataFusionError>
Trait Implementations§
Source§impl Clone for Distribution
impl Clone for Distribution
Source§fn clone(&self) -> Distribution
fn clone(&self) -> Distribution
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for Distribution
impl Debug for Distribution
Source§impl PartialEq for Distribution
impl PartialEq for Distribution
impl StructuralPartialEq for Distribution
Auto Trait Implementations§
impl Freeze for Distribution
impl !RefUnwindSafe for Distribution
impl Send for Distribution
impl Sync for Distribution
impl Unpin for Distribution
impl !UnwindSafe for Distribution
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more