From 4bb723ee2f79800a46653c858b3ec28fd4fa009f Mon Sep 17 00:00:00 2001 From: Jim Turner Date: Thu, 8 Apr 2021 19:28:47 -0400 Subject: [PATCH] Add mean and std_dev accessors to Normal --- rand_distr/src/normal.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/rand_distr/src/normal.rs b/rand_distr/src/normal.rs index a34e8e40..c3e99010 100644 --- a/rand_distr/src/normal.rs +++ b/rand_distr/src/normal.rs @@ -189,6 +189,16 @@ where F: Float, StandardNormal: Distribution pub fn from_zscore(&self, zscore: F) -> F { self.mean + self.std_dev * zscore } + + /// Returns the mean (`μ`) of the distribution. + pub fn mean(&self) -> F { + self.mean + } + + /// Returns the standard deviation (`σ`) of the distribution. + pub fn std_dev(&self) -> F { + self.std_dev + } } impl Distribution for Normal