pub struct GammaPosterior {
pub shape: f64,
pub rate: f64,
pub shape0: f64,
pub rate0: f64,
}Expand description
Gamma posterior for the rate λ of an Exponential(λ) likelihood.
With a Gamma(α, β) prior on λ (shape α, rate β), observing exponential
data xᵢ gives the conjugate update α → α + n, β → β + Σxᵢ. Accordingly:
mean= α / βis the posterior mean of the rateλ.posterior_mean_of_mean= β / (α − 1)is the posterior mean of the mean1/λ(since1/λ ~ Inverse-Gamma(α, β)).
Note the two differ by a reciprocal: for exponential data with sample mean m
the rate posterior concentrates near 1/m, while the mean posterior
concentrates near m. Callers that want “the average of the observed values”
must use posterior_mean_of_mean, not
mean. Feeding an arbitrary positive parameter value in as if
it were exponential data (as the old learner did) is not a coherent model —
tune positive parameters with ThompsonSamplingTuner instead.
Fields§
§shape: f64Shape parameter (α)
rate: f64Rate parameter (β)
shape0: f64Prior shape (α₀)
rate0: f64Prior rate (β₀)
Implementations§
Source§impl GammaPosterior
impl GammaPosterior
Sourcepub fn posterior_mean_of_mean(&self) -> Option<f64>
pub fn posterior_mean_of_mean(&self) -> Option<f64>
Posterior mean of the mean 1/λ (= β / (α − 1), defined for α > 1).
1/λ ~ Inverse-Gamma(α, β) has mean β / (α − 1). This is the quantity to
use when you want the posterior estimate of the average of the observed
positive values.
Sourcepub fn observations(&self) -> f64
pub fn observations(&self) -> f64
Number of observed exponential data points, α − α₀.
Trait Implementations§
Source§impl Clone for GammaPosterior
impl Clone for GammaPosterior
Source§fn clone(&self) -> GammaPosterior
fn clone(&self) -> GammaPosterior
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for GammaPosterior
impl Debug for GammaPosterior
Auto Trait Implementations§
impl Freeze for GammaPosterior
impl RefUnwindSafe for GammaPosterior
impl Send for GammaPosterior
impl Sync for GammaPosterior
impl Unpin for GammaPosterior
impl UnsafeUnpin for GammaPosterior
impl UnwindSafe for GammaPosterior
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read more§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.