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
Uniformdistribution’s interval determines its mean value, which is the arithmetic average of the interval endpoints. - An
Exponentialdistribution’s mean is calculable by the formulaoffset + 1 / λ, whereλis the (non-negative) rate. - A
Gaussiandistribution contains the mean explicitly. - A
Bernoullidistribution’s mean is equal to its success probabilityp. - A
Genericdistribution 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
Uniformdistribution’s interval determines its median value, which is the arithmetic average of the interval endpoints. - An
Exponentialdistribution’s median is calculable by the formulaoffset + ln(2) / λ, whereλis the (non-negative) rate. - A
Gaussiandistribution’s median is equal to its mean, which is specified explicitly. - A
Bernoullidistribution’s median is1ifp > 0.5and0otherwise, wherepis the success probability. - A
Genericdistribution 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
Uniformdistribution’s interval determines its variance value, which is calculable by the formula(upper - lower) ^ 2 / 12. - An
Exponentialdistribution’s variance is calculable by the formula1 / (λ ^ 2), whereλis the (non-negative) rate. - A
Gaussiandistribution’s variance is specified explicitly. - A
Bernoullidistribution’s median is given by the formulap * (1 - p)wherepis the success probability. - A
Genericdistribution 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
Uniformdistribution’s range is simply its interval. - An
Exponentialdistribution’s range is[offset, +∞). - A
Gaussiandistribution’s range is unbounded. - A
Bernoullidistribution’s range isInterval::UNCERTAIN, ifpis neither0nor1. Otherwise, it isInterval::CERTAINLY_FALSEandInterval::CERTAINLY_TRUE, respectively. - A
Genericdistribution 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> AlignerFor<1> for T
impl<T> AlignerFor<1> for T
Source§impl<T> AlignerFor<1024> for T
impl<T> AlignerFor<1024> for T
Source§type Aligner = AlignTo1024<T>
type Aligner = AlignTo1024<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<128> for T
impl<T> AlignerFor<128> for T
Source§type Aligner = AlignTo128<T>
type Aligner = AlignTo128<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<16> for T
impl<T> AlignerFor<16> for T
Source§impl<T> AlignerFor<16384> for T
impl<T> AlignerFor<16384> for T
Source§type Aligner = AlignTo16384<T>
type Aligner = AlignTo16384<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<2> for T
impl<T> AlignerFor<2> for T
Source§impl<T> AlignerFor<2048> for T
impl<T> AlignerFor<2048> for T
Source§type Aligner = AlignTo2048<T>
type Aligner = AlignTo2048<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<256> for T
impl<T> AlignerFor<256> for T
Source§type Aligner = AlignTo256<T>
type Aligner = AlignTo256<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<32> for T
impl<T> AlignerFor<32> for T
Source§impl<T> AlignerFor<32768> for T
impl<T> AlignerFor<32768> for T
Source§type Aligner = AlignTo32768<T>
type Aligner = AlignTo32768<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<4> for T
impl<T> AlignerFor<4> for T
Source§impl<T> AlignerFor<4096> for T
impl<T> AlignerFor<4096> for T
Source§type Aligner = AlignTo4096<T>
type Aligner = AlignTo4096<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<512> for T
impl<T> AlignerFor<512> for T
Source§type Aligner = AlignTo512<T>
type Aligner = AlignTo512<T>
AlignTo* type which aligns Self to ALIGNMENT.Source§impl<T> AlignerFor<64> for T
impl<T> AlignerFor<64> for T
Source§impl<T> AlignerFor<8> for T
impl<T> AlignerFor<8> for T
Source§impl<T> AlignerFor<8192> for T
impl<T> AlignerFor<8192> for T
Source§type Aligner = AlignTo8192<T>
type Aligner = AlignTo8192<T>
AlignTo* type which aligns Self to ALIGNMENT.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, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
impl<T, W> HasTypeWitness<W> for Twhere
W: MakeTypeWitness<Arg = T>,
T: ?Sized,
Source§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
impl<'a, T> RCowCompatibleRef<'a> for Twhere
T: Clone + 'a,
Source§fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
fn as_c_ref(from: &'a T) -> <T as RCowCompatibleRef<'a>>::RefC
Source§fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
fn as_rust_ref(from: <T as RCowCompatibleRef<'a>>::RefC) -> &'a T
Source§impl<S> ROExtAcc for S
impl<S> ROExtAcc for S
Source§fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
fn f_get<F>(&self, offset: FieldOffset<S, F, Aligned>) -> &F
offset. Read moreSource§fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
fn f_get_mut<F>(&mut self, offset: FieldOffset<S, F, Aligned>) -> &mut F
offset. Read moreSource§fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
fn f_get_ptr<F, A>(&self, offset: FieldOffset<S, F, A>) -> *const F
offset. Read moreSource§fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
fn f_get_mut_ptr<F, A>(&mut self, offset: FieldOffset<S, F, A>) -> *mut F
offset. Read moreSource§impl<S> ROExtOps<Aligned> for S
impl<S> ROExtOps<Aligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Aligned>, value: F) -> F
offset) with value,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Aligned>) -> Fwhere
F: Copy,
Source§impl<S> ROExtOps<Unaligned> for S
impl<S> ROExtOps<Unaligned> for S
Source§fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
fn f_replace<F>(&mut self, offset: FieldOffset<S, F, Unaligned>, value: F) -> F
offset) with value,
returning the previous value of the field. Read moreSource§fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
fn f_get_copy<F>(&self, offset: FieldOffset<S, F, Unaligned>) -> Fwhere
F: Copy,
Source§impl<T> SelfOps for Twhere
T: ?Sized,
impl<T> SelfOps for Twhere
T: ?Sized,
Source§fn piped<F, U>(self, f: F) -> U
fn piped<F, U>(self, f: F) -> U
Source§fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
fn piped_ref<'a, F, U>(&'a self, f: F) -> Uwhere
F: FnOnce(&'a Self) -> U,
piped except that the function takes &Self
Useful for functions that take &Self instead of Self. Read moreSource§fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
fn piped_mut<'a, F, U>(&'a mut self, f: F) -> Uwhere
F: FnOnce(&'a mut Self) -> U,
piped, except that the function takes &mut Self.
Useful for functions that take &mut Self instead of Self.Source§fn mutated<F>(self, f: F) -> Self
fn mutated<F>(self, f: F) -> Self
Source§fn observe<F>(self, f: F) -> Self
fn observe<F>(self, f: F) -> Self
Source§fn as_ref_<T>(&self) -> &T
fn as_ref_<T>(&self) -> &T
AsRef,
using the turbofish .as_ref_::<_>() syntax. Read more