pub enum NoiseModel {
Gaussian {
sigma: Array1<f64>,
},
Poisson,
Tweedie {
p: f64,
phi: Array1<f64>,
},
NegativeBinomial {
theta: Array1<f64>,
},
Beta {
phi: Array1<f64>,
},
Gamma {
shape: Array1<f64>,
},
Bernoulli,
TransformationNormalQuantile {
grid_y: Array1<f64>,
h_grid: Array2<f64>,
},
}Expand description
Observation-noise model used for generative sampling.
Variants§
Gaussian
Poisson
Tweedie
Fields
NegativeBinomial
Beta
Gamma
Fields
Bernoulli
TransformationNormalQuantile
Inverse-transform sampling for a conditional transformation-normal (CTM)
model (issue #1613). The fitted latent transform h(·|x_i) is strictly
increasing in y and h(Y|x) ~ N(0, 1), so a response-scale draw is
Y = h⁻¹(Z | x_i) with Z ~ N(0, 1). The earlier generate path drew
Gaussian noise around the mean, which produced latent-scale draws whose
per-row mean moved the wrong way with the covariate; this variant instead
samples from the genuine conditional law F(·|x).
Both this sampler and the response-scale conditional mean E[Y|x] used by
predict (#1612) invert the SAME per-row monotone curve, materialized on
a shared response grid, so the two paths cannot disagree on the underlying
transform.
Implementations§
Source§impl NoiseModel
impl NoiseModel
Sourcepub fn from_likelihood(
likelihood: &LikelihoodSpec,
nobs: usize,
gaussian_scale: Option<f64>,
) -> Result<NoiseModel, EstimationError>
pub fn from_likelihood( likelihood: &LikelihoodSpec, nobs: usize, gaussian_scale: Option<f64>, ) -> Result<NoiseModel, EstimationError>
Single canonical mapping from a fitted LikelihoodSpec (response
distribution + dispersion gaussian_scale) to the observation
NoiseModel used for generative sampling. Both simulation
(FamilyStrategy::simulate_noise) and generative inference
(generativespec_from_predict) route through this one helper so the
set of supported likelihoods and the interpretation of dispersion
parameters can never diverge between the two paths.
nobs is the number of observations the resulting per-observation
Gaussian sigma vector should span; it is ignored for families whose
noise carries no per-observation state.
Sourcepub fn from_likelihood_with_per_row_dispersion(
likelihood: &LikelihoodSpec,
dispersion: Array1<f64>,
) -> Result<NoiseModel, EstimationError>
pub fn from_likelihood_with_per_row_dispersion( likelihood: &LikelihoodSpec, dispersion: Array1<f64>, ) -> Result<NoiseModel, EstimationError>
Build the observation NoiseModel for a dispersion location-scale fit
(#1125) from a fitted PER-ROW dispersion surface dispersion[i] (the
predictor’s exp(eta_d(x_i)) mapped into NoiseModel units — NB θ, Gamma
shape, Beta φ directly, Tweedie φ as the reciprocal). Unlike
from_likelihood, which broadcasts a single scalar dispersion to every
row, this threads the genuine per-observation precision channel so
generated data reproduces the fitted non-constant dispersion instead of
coming out homoscedastic at the seed.
Trait Implementations§
Source§impl Clone for NoiseModel
impl Clone for NoiseModel
Source§fn clone(&self) -> NoiseModel
fn clone(&self) -> NoiseModel
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for NoiseModel
impl RefUnwindSafe for NoiseModel
impl Send for NoiseModel
impl Sync for NoiseModel
impl Unpin for NoiseModel
impl UnsafeUnpin for NoiseModel
impl UnwindSafe for NoiseModel
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
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> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§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).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.