// Copyright (C) Stichting Deltares 2017. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using MathNet.Numerics.Distributions; namespace Ringtoets.Common.Data.Probabilistics { /// /// Base calculator for design variables based on percentile and parameters of a distribution. /// internal abstract class PercentileBasedDesignVariableCalculator { /// /// Creates a base calculator. /// /// The mean of the distribution. /// The standard deviation of the distribution. /// The coefficient of variation of the distribution. protected PercentileBasedDesignVariableCalculator(double mean, double standardDeviation, double coefficientOfVariation) { Mean = mean; StandardDeviation = standardDeviation; CoefficientOfVariation = coefficientOfVariation; } /// /// Gets the mean of the distribution. /// protected double Mean { get; } /// /// Gets the standard deviation of the distribution. /// protected double StandardDeviation { get; } /// /// Gets the coefficient of variation of the distribution. /// protected double CoefficientOfVariation { get; } /// /// Determines the design value based on a 'normal space' expected value and standard deviation. /// /// The expected value. /// The standard deviation. /// The percentile. /// The design value. protected static double DetermineDesignValue(double expectedValue, double standardDeviation, double percentile) { // Design factor is determined using the 'probit function', which is the inverse // CDF function of the standard normal distribution. For more information see: // "Quantile function" https://en.wikipedia.org/wiki/Normal_distribution double designFactor = Normal.InvCDF(0.0, 1.0, percentile); return expectedValue + designFactor * standardDeviation; } /// /// Calculates and returns the design value. /// /// The percentile to obtain the value for. /// The design value at the given . internal abstract double GetDesignValue(double percentile); } }