/// <summary> /// Determines if the properties of the actual <see cref="TruncatedNormalDistribution"/> are the same /// as the expected <see cref="TruncatedNormalDistribution"/>. /// </summary> /// <param name="expectedDistribution">The expected <see cref="TruncatedNormalDistribution"/>.</param> /// <param name="actualDistribution">The actual <see cref="TruncatedNormalDistribution"/>.</param> /// <exception cref="AssertionException">Thrown when the following differences are found between /// the <paramref name="expectedDistribution"/> and <paramref name="actualDistribution"/>: /// <list type="bullet"> /// <item>The probabilistic distribution types.</item> /// <item>The values for the mean, the standard deviation, the lower boundary and/or the upper boundary.</item> /// <item>The precision for the mean, the standard deviation, the lower boundary and/or the upper boundary.</item> /// </list></exception> public static void AreEqual(TruncatedNormalDistribution expectedDistribution, TruncatedNormalDistribution actualDistribution) { AreEqual((IDistribution)expectedDistribution, actualDistribution); AreEqualValue(expectedDistribution.LowerBoundary, actualDistribution.LowerBoundary); AreEqualValue(expectedDistribution.UpperBoundary, actualDistribution.UpperBoundary); }
/// <summary> /// Initializes a new instance of the <see cref="GeneralGrassCoverErosionInwardsInput"/> class. /// </summary> public GeneralGrassCoverErosionInwardsInput() { n = new RoundedDouble(numberOfDecimalPlacesN, 2.0); CriticalOvertoppingModelFactor = 1.0; FbFactor = new TruncatedNormalDistribution(2) { Mean = (RoundedDouble)4.75, StandardDeviation = (RoundedDouble)0.5, LowerBoundary = (RoundedDouble)0.0, UpperBoundary = (RoundedDouble)99.0 }; FnFactor = new TruncatedNormalDistribution(2) { Mean = (RoundedDouble)2.6, StandardDeviation = (RoundedDouble)0.35, LowerBoundary = (RoundedDouble)0.0, UpperBoundary = (RoundedDouble)99.0 }; OvertoppingModelFactor = 1.0; FrunupModelFactor = new TruncatedNormalDistribution(2) { Mean = (RoundedDouble)1, StandardDeviation = (RoundedDouble)0.07, LowerBoundary = (RoundedDouble)0.0, UpperBoundary = (RoundedDouble)99.0 }; FshallowModelFactor = new TruncatedNormalDistribution(2) { Mean = (RoundedDouble)0.92, StandardDeviation = (RoundedDouble)0.24, LowerBoundary = (RoundedDouble)0.0, UpperBoundary = (RoundedDouble)99.0 }; }
public void UpperBoundary_SetNewValue_GetValueRoundedToGivenNumberOfDecimalPlaces() { const double value = 1.23456789; const int numberOfDecimalPlaces = 4; var distribution = new TruncatedNormalDistribution(numberOfDecimalPlaces); // Call distribution.UpperBoundary = (RoundedDouble)value; // Assert Assert.AreEqual(numberOfDecimalPlaces, distribution.UpperBoundary.NumberOfDecimalPlaces); Assert.AreEqual(value, distribution.UpperBoundary, distribution.UpperBoundary.GetAccuracy()); }
public void Constructor_ExpectedValues() { // Setup var fbFactor = new TruncatedNormalDistribution(2) { Mean = (RoundedDouble)4.75, StandardDeviation = (RoundedDouble)0.5, LowerBoundary = (RoundedDouble)0.0, UpperBoundary = (RoundedDouble)99.0 }; var fnFactor = new TruncatedNormalDistribution(2) { Mean = (RoundedDouble)2.6, StandardDeviation = (RoundedDouble)0.35, LowerBoundary = (RoundedDouble)0.0, UpperBoundary = (RoundedDouble)99.0 }; var fshallow = new TruncatedNormalDistribution(2) { Mean = (RoundedDouble)0.92, StandardDeviation = (RoundedDouble)0.24, LowerBoundary = (RoundedDouble)0.0, UpperBoundary = (RoundedDouble)99.0 }; var frunupModelFactor = new TruncatedNormalDistribution(2) { Mean = (RoundedDouble)1, StandardDeviation = (RoundedDouble)0.07, LowerBoundary = (RoundedDouble)0.0, UpperBoundary = (RoundedDouble)99.0 }; // Call var inputParameters = new GeneralGrassCoverErosionInwardsInput(); // Assert Assert.AreEqual(2, inputParameters.N.NumberOfDecimalPlaces); Assert.AreEqual(2.0, inputParameters.N, inputParameters.N.GetAccuracy()); Assert.IsFalse(inputParameters.ApplyLengthEffectInSection); DistributionAssert.AreEqual(fbFactor, inputParameters.FbFactor); DistributionAssert.AreEqual(fnFactor, inputParameters.FnFactor); DistributionAssert.AreEqual(fshallow, inputParameters.FshallowModelFactor); DistributionAssert.AreEqual(frunupModelFactor, inputParameters.FrunupModelFactor); Assert.AreEqual(1, inputParameters.CriticalOvertoppingModelFactor); Assert.AreEqual(1, inputParameters.OvertoppingModelFactor); }
public void Constructor_WithDistribution_ExpectedValues() { // Setup var distribution = new TruncatedNormalDistribution(new Random(21).Next(3, RoundedDouble.MaximumNumberOfDecimalPlaces)); // Call var properties = new TruncatedNormalDistributionProperties(distribution); // Assert Assert.IsInstanceOf <DistributionPropertiesBase <TruncatedNormalDistribution> >(properties); Assert.AreSame(distribution, properties.Data); Assert.AreEqual("Normaal (afgekapt)", properties.DistributionType); AssertPropertiesInState(properties, true, true); }
public void DefaultConstructor_ExpectedValues(int numberOfDecimalPlaces) { // Call var distribution = new TruncatedNormalDistribution(numberOfDecimalPlaces); // Assert Assert.IsInstanceOf <NormalDistribution>(distribution); Assert.AreEqual(0.0, distribution.Mean.Value); Assert.AreEqual(numberOfDecimalPlaces, distribution.Mean.NumberOfDecimalPlaces); Assert.AreEqual(1.0, distribution.StandardDeviation.Value); Assert.AreEqual(numberOfDecimalPlaces, distribution.StandardDeviation.NumberOfDecimalPlaces); Assert.AreEqual(0.0, distribution.LowerBoundary.Value); Assert.AreEqual(numberOfDecimalPlaces, distribution.LowerBoundary.NumberOfDecimalPlaces); Assert.AreEqual(0.0, distribution.UpperBoundary.Value); Assert.AreEqual(numberOfDecimalPlaces, distribution.UpperBoundary.NumberOfDecimalPlaces); }
public void Clone_Always_ReturnNewInstanceWithCopiedValues() { // Setup var random = new Random(21); var original = new TruncatedNormalDistribution(random.Next(1, 16)) { Mean = random.NextRoundedDouble(), StandardDeviation = random.NextRoundedDouble(), LowerBoundary = random.NextRoundedDouble(), UpperBoundary = random.NextRoundedDouble() }; // Call object clone = original.Clone(); // Assert CoreCloneAssert.AreObjectClones(original, clone, DistributionAssert.AreEqual); }
public void Constructor_WithParameters_ExpectedValues() { // Setup var mocks = new MockRepository(); var handler = mocks.Stub <IObservablePropertyChangeHandler>(); mocks.ReplayAll(); var distribution = new TruncatedNormalDistribution(new Random(21).Next(3, RoundedDouble.MaximumNumberOfDecimalPlaces)); // Call var properties = new TruncatedNormalDistributionProperties(DistributionReadOnlyProperties.None, distribution, handler); // Assert Assert.IsInstanceOf <DistributionPropertiesBase <TruncatedNormalDistribution> >(properties); Assert.AreSame(distribution, properties.Data); Assert.AreEqual("Normaal (afgekapt)", properties.DistributionType); AssertPropertiesInState(properties, false, false); mocks.VerifyAll(); }