pub struct CircularGaussianFit2d { /* private fields */ }Expand description
Maximum-likelihood fit of a Gaussian-blurred circle in two dimensions.
The generative model is
X = center + radius * U + epsilon,
where U is uniform on the unit circle and
epsilon ~ N(0, noise_variance * I_2). Integrating out U gives the proper
Cartesian density
p(x) = exp(-(r^2 + R^2)/(2s)) I0(Rr/s) / (2 pi s).
Unlike a Gaussian density assigned directly to the nonnegative radius, this
density is normalized on the plane, remains finite at the center, and has no
artificial 1/r singularity. The center is fitted jointly with (R, s) by
latent-angle EM instead of being frozen at the coordinate mean.
Implementations§
Source§impl CircularGaussianFit2d
impl CircularGaussianFit2d
Sourcepub const NUM_FREE_PARAMETERS: usize = 4
pub const NUM_FREE_PARAMETERS: usize = 4
Two center coordinates, one radius, and one isotropic noise variance.
Sourcepub fn from_parameters(
center: [f64; 2],
radius: f64,
noise_variance: f64,
) -> Result<Self, String>
pub fn from_parameters( center: [f64; 2], radius: f64, noise_variance: f64, ) -> Result<Self, String>
Construct a circular Gaussian from validated model parameters.
Sourcepub fn fit(coords: ArrayView2<'_, f64>, rows: &[usize]) -> Result<Self, String>
pub fn fit(coords: ArrayView2<'_, f64>, rows: &[usize]) -> Result<Self, String>
Fit selected rows of a finite two-column coordinate matrix.
Sourcepub const fn noise_variance(self) -> f64
pub const fn noise_variance(self) -> f64
Fitted isotropic Cartesian noise variance per coordinate.
Sourcepub fn log_density(self, x: f64, y: f64) -> f64
pub fn log_density(self, x: f64, y: f64) -> f64
Proper Cartesian log density at (x, y).
Sourcepub fn log_likelihood(
self,
coords: ArrayView2<'_, f64>,
rows: &[usize],
) -> Result<f64, String>
pub fn log_likelihood( self, coords: ArrayView2<'_, f64>, rows: &[usize], ) -> Result<f64, String>
Sum the fitted log density over selected rows.
Sourcepub fn fit_with_bic(
coords: ArrayView2<'_, f64>,
rows: &[usize],
) -> Result<(Self, f64), String>
pub fn fit_with_bic( coords: ArrayView2<'_, f64>, rows: &[usize], ) -> Result<(Self, f64), String>
Fit selected rows and return both the fit and its BIC/2 (lower is better). Keeping fitting and evidence evaluation in one operation makes it impossible to label a likelihood on unrelated data as fitted BIC.
Trait Implementations§
Source§impl Clone for CircularGaussianFit2d
impl Clone for CircularGaussianFit2d
Source§fn clone(&self) -> CircularGaussianFit2d
fn clone(&self) -> CircularGaussianFit2d
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for CircularGaussianFit2d
Auto Trait Implementations§
impl Freeze for CircularGaussianFit2d
impl RefUnwindSafe for CircularGaussianFit2d
impl Send for CircularGaussianFit2d
impl Sync for CircularGaussianFit2d
impl Unpin for CircularGaussianFit2d
impl UnsafeUnpin for CircularGaussianFit2d
impl UnwindSafe for CircularGaussianFit2d
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.