public void TestStudentTDistribution() { double[][] para = { new double[] { 12, 0, -0.6954828655117925816605449, 0.3022177430388599749597682, 1.782287555649320074526381, 0.08490359467537564413509914 } }; for (int i = 0; i < para.Length; i++) { var tester = new ContDistTester(para[i], delegate(double a, double b) { var ret = new StudentTDistribution { Nu = (int)a }; return(ret); } ); tester.Test(1e-7); } }
public void TestStudentTRoundTrip() { // arrange var expected = new StudentTDistribution(0d, 1d, 2d, 0.3, 0.7); // act var serialized = expected.ToString(); var deserialized = Distribution.DeserializeDistribution(serialized); var distribution = deserialized.IfNone(() => { Assert.Fail(); return(default !); });
public void TestStudentTDistributionQuantile() { // N[Quantile[StudentTDistribution[12], 1/10], 25] Assert.AreEqual(-1.356217334023205433796216, StudentTDistribution.Quantile(0.1, 12), 1e-14); // N[Quantile[StudentTDistribution[12], 5/10], 25] Assert.AreEqual(0, StudentTDistribution.Quantile(0.5, 12)); // N[Quantile[StudentTDistribution[12], 9/10], 25] Assert.AreEqual(1.356217334023205433796216, StudentTDistribution.Quantile(0.9, 12), 1e-14); }
public void TestStudentTWithBoundsGetSample() { // arrange var subject = new StudentTDistribution(0d, 1d, 2d, 0.3, 0.7); // act var sample = subject.GetSample(); // assert Assert.IsTrue(sample > 0.3 && sample < 0.7); }
public void TestStudentTWithBoundsFillSamples() { // arrange var subject = new StudentTDistribution(0d, 1d, 2d, 0.3, 0.7); var samples = Range(0, 42).Map(_ => NaN).ToArray(); // act subject.FillSamples(samples); // assert Assert.IsTrue(samples.All(d => d > 0.3 && d < 0.7)); }
public void TestStudentTDistributionCDF() { // N[CDF[StudentTDistribution[12], 1/10], 25 Assert.AreEqual(0.5390022147715870702517874, StudentTDistribution.CDF(0.1, 12), 1e-14); // N[CDF[StudentTDistribution[12], 5/10], 25 Assert.AreEqual(0.6869412618873379592985154, StudentTDistribution.CDF(0.5, 12), 1e-14); // N[CDF[StudentTDistribution[12], 9/10], 25 Assert.AreEqual(0.8070872841025491107351673, StudentTDistribution.CDF(0.9, 12), 1e-14); // N[CDF[StudentTDistribution[12], -9/10], 25 Assert.AreEqual(0.1929127158974508892648327, StudentTDistribution.CDF(-0.9, 12), 1e-14); }
public void TestStudentTDistributionPDF() { // N[PDF[StudentTDistribution[12], 1/10], 25] Assert.AreEqual(0.3886164693412969119684949, StudentTDistribution.PDF(0.1, 12), 1e-14); // N[PDF[StudentTDistribution[12], 5/10], 25] Assert.AreEqual(0.3417166761526545973157284, StudentTDistribution.PDF(0.5, 12), 1e-14); // N[PDF[StudentTDistribution[12], 9/10], 25] Assert.AreEqual(0.2555532488891510539167125, StudentTDistribution.PDF(0.9, 12), 1e-14); // N[PDF[StudentTDistribution[12], -9/10], 25] Assert.AreEqual(0.2555532488891510539167125, StudentTDistribution.PDF(-0.9, 12), 1e-14); }
public async Task TestStudentTCumulativeDistributionAtBounds() { // arrange var subject = new StudentTDistribution(0d, 1d, 2d, 0.3, 0.7); var expectedLowerP = (await GetNumDataAsync("pt(0.3, 2)"))[0].Data[0]; var expectedUpperP = (await GetNumDataAsync("pt(0.7, 2)"))[0].Data[0]; // act var(actualLowerP, actualUpperP) = subject.CumulativeDistributionAtBounds; // assert Assert.AreEqual(expectedLowerP, actualLowerP, Base.Constant.TOLERANCE); Assert.AreEqual(expectedUpperP, actualUpperP, Base.Constant.TOLERANCE); }
public async Task TestStudentTGetDensities() { // arrange var subject = new StudentTDistribution(0d, 1d, 2d); var expected = (await GetNumDataAsync( "sapply(seq(qt(0.3, 2), qt(0.7, 2), length.out = 5), function(cd){dt(cd, 2)})" ))[0].Data.ToArr(); // act var(_, actual) = subject.GetDensities(0.3, 0.7, 5); // assert Assert.IsTrue(actual.Count == 5); expected.Iter((i, d) => Assert.AreEqual(d, actual[i], Base.Constant.TOLERANCE)); }
public void TestInitialize() { tDistributionDouble = new StudentTDistribution(n, tDouble); tDistributionFloat = new StudentTDistribution(n, tFloat); tDistributionDecimal = new StudentTDistribution(n, tDecimal); }
public void ShouldThrowAnEceptioWhenTypeIsNotSupported() { StudentTDistribution testObject = new StudentTDistribution(31, string.Empty); }
public void ShouldThrowAnEceptioWhenNIsFreaerThanThirty() { StudentTDistribution testObject = new StudentTDistribution(31, tDouble); }
public void ShouldThrowAnEceptioWhenNIsEqualZero() { StudentTDistribution testObject = new StudentTDistribution(0, tDouble); }
public void ShouldReturnCorrectValueForTParameter_StaticDouble() { Assert.AreEqual(2.55, Convert.ToDouble(StudentTDistribution.GetTParameter(98, 18)), 0.001); }
public void ShouldThrowAnEceptioWhenWhenConfidenceLevelIsLessGreaterNightyNine() { StudentTDistribution testObject = new StudentTDistribution(25, tDouble); testObject.GetTParameter(99.01); }
public void ShouldThrowAnEceptioWhenTypeNIsTwoForVarianceCalculation() { StudentTDistribution testObject = new StudentTDistribution(2, tDouble); testObject.GetVariance(); }
public void ShouldThrowAnEceptioWhenNIsOneForMeanCalculation() { StudentTDistribution testObject = new StudentTDistribution(1, tDouble); testObject.GetMean(); }
public void ShouldThrowAnEceptioWhenTypeNIsTwoForStandardDeviationCalculation() { StudentTDistribution testObject = new StudentTDistribution(2, tDouble); testObject.GetStandardDeviation(); }
public void ShouldReturnCorrectValueForConfidenceInterval_StaticDecimal() { Assert.AreEqual(2.65M, Convert.ToDecimal(StudentTDistribution.GetConfidenceInterval(95, 5, 16))); }
public void ShouldThrowAnEceptioWhenWhenConfidenceLevelIsLessThanEigthy() { StudentTDistribution testObject = new StudentTDistribution(25, tDouble); testObject.GetTParameter(79.99); }
public void ShouldReturnCorrectValueForTParameter_StaticDecimal() { Assert.AreEqual(2.54999999999999M, Convert.ToDecimal(StudentTDistribution.GetTParameter(98, 18))); }
public void ShouldReturnCorrectValueForConfidenceInterval_StaticDouble() { Assert.AreEqual(2.65, Convert.ToDouble(StudentTDistribution.GetConfidenceInterval(95, 5, 16)), 0.001); }
public void ShouldReturnCorrectValueForTTestValue_StaticDecimal() { Assert.AreEqual(6.09721295301628M, Convert.ToDecimal(StudentTDistribution.GetTTestValue(arrayDouble1, arrayDouble2))); }
public void ShouldReturnCorrectValueForTTestValue_StaticDouble() { Assert.AreEqual(6.0972, Convert.ToDouble(StudentTDistribution.GetTTestValue(arrayDouble1, arrayDouble2)), 0.001); }
public void ShouldThrowAnEceptioWhenNIsLessThanZero() { StudentTDistribution testObject = new StudentTDistribution(-1, tDouble); }