From b6a1e48b72ab9b47241787248fbf2a364df8d07e Mon Sep 17 00:00:00 2001 From: louisPoulain Date: Fri, 6 Sep 2024 11:35:46 +0200 Subject: [PATCH] Add description for mean of censored --- mlpp_lib/probabilistic_layers.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mlpp_lib/probabilistic_layers.py b/mlpp_lib/probabilistic_layers.py index 615e4c2..3928b47 100644 --- a/mlpp_lib/probabilistic_layers.py +++ b/mlpp_lib/probabilistic_layers.py @@ -362,6 +362,15 @@ def _sample_n(self, n, seed=None): return chosen_samples def _mean(self): + """ + Original: X ~ N(mu, sigma) + Censored: Y = X if 0 <= X <= 1 else 0 if X < 0 else 1 + + Law of total expectations: E[Y] = E[Y | X > 1] * P(X > 1) + E[Y | X < 0] * P(X < 0) + E[Y | 0 <= X <= 1] * P(0 <= X <= 1) + = P(X > 1) * 1 + P(X < 0) * 0 + E[X | 0 <= X <= 1] * P(0 <= X <= 1) + = 1 - Phi((1 - mu) / sigma) + E[Z ~ TruncNormal(mu, sigma, 0, 1)] * (Phi((1 - mu) / sigma) - Phi(-mu / sigma)) + Ref for TruncatedNormal mean: https://en.wikipedia.org/wiki/Truncated_normal_distribution + """ original_mean = self.normal.mean() low_bound_standard = (0 - original_mean) / self.normal.stddev() high_bound_standard = (1 - original_mean) / self.normal.stddev()