public TruncatedDistribution(ITruncatableDistribution <double> distribution, double lowerBound, double upperBound) { if (lowerBound > upperBound) { throw new ArgumentOutOfRangeException($"lowerBound ({lowerBound}) > upperBound ({upperBound})"); } this.Distribution = distribution; this.LowerBound = lowerBound; this.UpperBound = upperBound; this.TotalProbability = distribution.GetProbBetween(lowerBound, upperBound); this.LowerProbability = distribution.GetProbLessThan(lowerBound); }
/// <inheritdoc/> public double GetProbLessThan(double x) { return(Math.Min(1, Math.Max(0, Distribution.GetProbLessThan(x) - LowerProbability) / TotalProbability)); }