public static WithMeanStDev ( double mean, double stDev ) : |
||
mean | double | |
stDev | double | |
Результат |
public void ValidateInverseCumulativeDistribution( [Values(Double.NegativeInfinity, -5.0, -2.0, -0.0, 0.0, 4.0, 5.0, 6.0, 10.0, Double.PositiveInfinity)] double x, [Values(0.0, 0.00000028665157187919391167375233287464535385442301361187883, 0.0002326290790355250363499258867279847735487493358890356, 0.0062096653257761351669781045741922211278977469230927036, .0062096653257761351669781045741922211278977469230927036, .30853753872598689636229538939166226011639782444542207, .5, .69146246127401310363770461060833773988360217555457859, 0.9937903346742238648330218954258077788721022530769078, 1.0)] double f) { var n = Normal.WithMeanStDev(5.0, 2.0); n.InverseCumulativeDistribution(f).Clamp(x, 1e-10).Should().Be(x); }
public void DensityLnTest([Values(0.0, 10.0, -5.0)] double mean, [Values(0.0, 0.1, 1.0, 10.0, 100.0, Double.PositiveInfinity)] double sdev) { var n = Normal.WithMeanStDev(mean, sdev); for (var i = 0; i < 11; i++) { var x = i - 5.0; var d = (mean - x) / sdev; var pdfln = (-0.5 * (d * d)) - Math.Log(sdev) - MathTool.LnSqrtPi2; n.DensityLn(x).Should().Be(pdfln); } }
public void DensityTest([Values(0.0, 10.0, -5.0)] double mean, [Values(0.0, 0.1, 1.0, 10.0, 100.0, Double.PositiveInfinity)] double sdev) { var n = Normal.WithMeanStDev(mean, sdev); for (var i = 0; i < 11; i++) { var x = i - 5.0; var d = (mean - x) / sdev; var pdf = Math.Exp(-0.5 * d * d) / (sdev * MathTool.SqrtPi2); n.Density(x).Should().Be(pdf); } }