public string ToString(IDistribution distribution) { DistributionAdapter adapter; if (!this.map.TryGetValue(distribution.GetType(), out adapter)) { throw new DistributionFormatException($"No adapter set for type {distribution.GetType()}"); } string[] parameters = adapter.ToParameters(distribution); return(string.Concat(adapter.Category, ',', string.Join(",", parameters))); }
/// <summary> /// Determines if the properties of the actual <see cref="IDistribution"/> are the same /// as the expected <see cref="IDistribution"/>. /// </summary> /// <param name="expectedDistribution">The expected <see cref="IDistribution"/>.</param> /// <param name="actualDistribution">The actual <see cref="IDistribution"/>.</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 and/or the standard deviation.</item> /// <item>The precision for the mean and/or the standard deviation.</item> /// </list></exception> public static void AreEqual(IDistribution expectedDistribution, IDistribution actualDistribution) { Assert.AreEqual(expectedDistribution.GetType(), actualDistribution.GetType()); AreEqualValue(expectedDistribution.Mean, actualDistribution.Mean); AreEqualValue(expectedDistribution.StandardDeviation, actualDistribution.StandardDeviation); }