public void BinomialTestConstructorTest3() { // GNU R (0.096248626708984375) // Wolfram Alpha reports 0.06357 // Tested against Wolfram Alpha BinomialTest target = new BinomialTest(5, 18); Assert.AreEqual(OneSampleHypothesis.ValueIsDifferentFromHypothesis, target.Hypothesis); Assert.AreEqual(DistributionTail.TwoTail, target.Tail); Assert.AreEqual(0.063564300537109319, target.PValue, 1e-4); Assert.IsFalse(target.Significant); /* * // Tested against GNU R * BinomialTest target = new BinomialTest(5, 18); * * Assert.AreEqual(OneSampleHypothesis.ValueIsDifferentFromHypothesis, target.Hypothesis); * Assert.AreEqual(DistributionTail.TwoTail, target.Tail); * * Assert.AreEqual(0.096248626708984375, target.PValue, 1e-4); * Assert.IsFalse(target.Significant); */ }
public void BinomialTestConstructorTest7(int index, double expectedValue) { double p = index / 10.0; BinomialTest target = new BinomialTest(5, 18, p); Assert.AreEqual(DistributionTail.TwoTail, target.Tail); Assert.AreEqual(expectedValue, target.PValue, 5e-4); }
public void BinomialTestConstructorTest6(int index, double expectedValue) { double p = index / 100.0 * 5; BinomialTest target = new BinomialTest(51, 235, p); Assert.AreEqual(DistributionTail.TwoTail, target.Tail); Assert.AreEqual(expectedValue, target.PValue, 1e-5); }
public void BinomialTestConstructorTest3() { BinomialTest target = new BinomialTest(5, 18); Assert.AreEqual(OneSampleHypothesis.ValueIsDifferentFromHypothesis, target.Hypothesis); Assert.AreEqual(DistributionTail.TwoTail, target.Tail); Assert.AreEqual(0.09625, target.PValue, 1e-4); Assert.IsFalse(target.Significant); }
protected override void EndProcessing() { var hypo = TestingHelper.GetOneSampleHypothesis(Alternate); var test = new BinomialTest(SuccesCount, TrialCount, Probability, hypo) { Size = Size }; WriteObject(test); }
public void BinomialTestConstructorTest4() { bool[] trials = { false, false, false, false, false, false, false, false, false, true }; BinomialTest target = new BinomialTest(trials, hypothesizedProbability: 0.5, alternate: OneSampleHypothesis.ValueIsSmallerThanHypothesis); Assert.AreEqual(OneSampleHypothesis.ValueIsSmallerThanHypothesis, target.Hypothesis); Assert.AreEqual(DistributionTail.OneLower, target.Tail); Assert.AreEqual(0.010742, target.PValue, 1e-5); Assert.IsTrue(target.Significant); }
private static int SlideAlignment <T>(List <T> sequence1, List <T> sequence2) { var distinctItems = sequence1.Concat(sequence2).Distinct().Count(); var overlapSums = new List <Tuple <int, double> >(); for (int sequence2Offset = -(sequence2.Count - 1); sequence2Offset <= sequence1.Count - 1; sequence2Offset++) { GetOverlapOfOffsetSequences(sequence1, sequence2, sequence2Offset, out var overlapSequence1, out var overlapSequence2); var overlapLength = overlapSequence1.Count; var matchCount = 0; var lastWasMatch = false; var longestMatch = 0; var matchLength = 0; for (int overlapIdx = 0; overlapIdx < overlapLength; overlapIdx++) { var sequence1Item = overlapSequence1[overlapIdx]; var sequence2Item = overlapSequence2[overlapIdx]; var isOverlap = sequence1Item.Equals(sequence2Item); if (!isOverlap && lastWasMatch) { if (matchLength > longestMatch) { longestMatch = matchLength; } matchLength = 0; } if (isOverlap) { matchCount++; matchLength++; } lastWasMatch = isOverlap; } var matchProbability = 1.0 / distinctItems; var matchCountSignificanceTest = new BinomialTest( successes: matchCount, trials: overlapLength, hypothesizedProbability: matchProbability, alternate: OneSampleHypothesis.ValueIsGreaterThanHypothesis); var overlapLengthSignificanceTest = new BinomialTest( successes: 1, trials: overlapLength - longestMatch + 1, hypothesizedProbability: Math.Pow(matchProbability, longestMatch), alternate: OneSampleHypothesis.ValueIsGreaterThanHypothesis); var changeOfThisBeingRandom = Math.Min(matchCountSignificanceTest.PValue, overlapLengthSignificanceTest.PValue); overlapSums.Add(new Tuple <int, double>(sequence2Offset, changeOfThisBeingRandom)); } var bestOverlapOffset = overlapSums.MinimumItem(x => x.Item2).Item1; return(bestOverlapOffset); }
public void BinomialTestConstructorTest2() { int successes = 5; int trials = 6; double probability = 1 / 4.0; BinomialTest target = new BinomialTest(successes, trials, hypothesizedProbability: probability, alternate: OneSampleHypothesis.ValueIsGreaterThanHypothesis); Assert.AreEqual(OneSampleHypothesis.ValueIsGreaterThanHypothesis, target.Hypothesis); Assert.AreEqual(DistributionTail.OneUpper, target.Tail); Assert.AreEqual(0.004638, target.PValue, 1e-5); Assert.IsTrue(target.Significant); }
public void BinomialTestConstructorTest6() { double[] expected = { 0.000000000000, 0.00000000000, 0.0000001539975, 0.00592949743, 0.514242625443, 0.25905439494, 0.0053806543164, 0.00001078919, 0.000000003115, 0.00000000000, 0.0000000000000 }; for (int i = 0; i <= 10; i++) { double p = i / 100.0 * 5; BinomialTest target = new BinomialTest(51, 235, p); Assert.AreEqual(DistributionTail.TwoTail, target.Tail); Assert.AreEqual(expected[i], target.PValue, 1e-5); } }
public void BinomialTestConstructorTest7() { double[] expected = { 0.00000000000, 0.02819385651, 0.382725376073, 1.00000000000, 0.34347252004, 0.096252441406, 0.00707077678, 0.00026908252, 0.000002519659, 0.00000000052, 0.00000000000 }; for (int i = 0; i <= 10; i++) { double p = i / 10.0; BinomialTest target = new BinomialTest(5, 18, p); Assert.AreEqual(DistributionTail.TwoTail, target.Tail); Assert.AreEqual(expected[i], target.PValue, 5e-4); } }
public void BinomialTestConstructorTest8() { // Example from Jeffrey S. Simonoff, Analyzing Categorical Data, pg 64 // Preview available: http://books.google.com.br/books?id=G8w_rifweAoC BinomialTest target = new BinomialTest(8, 10, hypothesizedProbability: 0.4); Assert.AreEqual(OneSampleHypothesis.ValueIsDifferentFromHypothesis, target.Hypothesis); Assert.AreEqual(DistributionTail.TwoTail, target.Tail); Assert.AreEqual(0.018236313600000005, target.PValue, 1e-4); Assert.IsTrue(target.Significant); target = new BinomialTest(7, 10, hypothesizedProbability: 0.4); Assert.AreEqual(0.1010144256, target.PValue, 1e-4); Assert.IsFalse(target.Significant); target = new BinomialTest(9, 10, hypothesizedProbability: 0.4); Assert.AreEqual(0.0015728640000000009, target.PValue, 1e-4); Assert.IsTrue(target.Significant); }
public void BinomialTestConstructorTest7() { // Wolfram Alpha reports 0.063564300537 // http://www.wolframalpha.com/input/?i=test+for+binomial+parameter+p0%3D0.5%2C+samples%3D18%2C+successes%3D5 // GNU R reports 0.096248626708 double[] expected = { 0.00000000000, 0.02819385651, 0.382725376073, 1.00000000000, 0.34347252004, 0.063564300537, 0.00707077678, 0.00026908252, 0.000002519659, 0.00000000052, 0.00000000000 }; for (int i = 0; i <= 10; i++) { double p = i / 10.0; BinomialTest target = new BinomialTest(5, 18, p); Assert.AreEqual(DistributionTail.TwoTail, target.Tail); Assert.AreEqual(expected[i], target.PValue, 5e-4); } }
private static void Main() //****************************************************************************80 // // Purpose: // // test_values_test() tests test_values(). // // Licensing: // // This code is distributed under the GNU LGPL license. // // Modified: // // 04 January 2019 // // Author: // // John Burkardt // { Console.WriteLine(""); Console.WriteLine("test_values_test():"); Console.WriteLine(" Test test_values()."); AbramsTest.abram0_values_test(); AbramsTest.abram1_values_test(); AbramsTest.abram2_values_test(); AGMTest.agm_values_test(); AiryTest.airy_ai_values_test(); AiryTest.airy_ai_int_values_test(); AiryTest.airy_ai_prime_values_test(); AiryTest.airy_bi_values_test(); AiryTest.airy_bi_int_values_test(); AiryTest.airy_bi_prime_values_test(); AiryTest.airy_cai_values_test(); AiryTest.airy_cbi_values_test(); AiryTest.airy_gi_values_test(); AiryTest.airy_hi_values_test(); ArcTest.arccos_values_test(); ArcTest.arccosh_values_test(); ArcTest.arcsin_values_test(); ArcTest.arcsinh_values_test(); ArcTest.arctan_values_test(); ArcTest.arctan_int_values_test(); ArcTest.arctanh_values_test(); BeiBellTest.bei0_values_test(); BeiBellTest.bei1_values_test(); BeiBellTest.bell_values_test(); BerTest.ber0_values_test(); BerTest.ber1_values_test(); BernoulliTest.bernoulli_number_values_test(); BernoulliTest.bernoulli_poly_values_test(); BernsteinTest.bernstein_poly_01_values_test(); BesselTest.bessel_i0_values_test(); BesselTest.bessel_i0_int_values_test(); BesselTest.bessel_i0_spherical_values_test(); BesselTest.bessel_i1_values_test(); BesselTest.bessel_i1_spherical_values_test(); BesselTest.bessel_in_values_test(); BesselTest.bessel_ix_values_test(); BesselTest.bessel_j_spherical_values_test(); BesselTest.bessel_j0_values_test(); BesselTest.bessel_j0_int_values_test(); BesselTest.bessel_j0_spherical_values_test(); BesselTest.bessel_j0_zero_values_test(); BesselTest.bessel_j1_values_test(); BesselTest.bessel_j1_spherical_values_test(); BesselTest.bessel_jn_values_test(); BesselTest.bessel_jx_values_test(); BesselTest.bessel_k0_values_test(); BesselTest.bessel_k0_int_values_test(); BesselTest.bessel_k1_values_test(); BesselTest.bessel_kn_values_test(); BesselTest.bessel_kx_values_test(); BesselTest.bessel_y0_values_test(); BesselTest.bessel_y0_int_values_test(); BesselTest.bessel_y0_spherical_values_test(); BesselTest.bessel_y1_values_test(); BesselTest.bessel_y1_spherical_values_test(); BesselTest.bessel_yn_values_test(); BesselTest.bessel_yx_values_test(); BetaTest.beta_values_test(); BetaTest.beta_cdf_values_test(); BetaTest.beta_inc_values_test(); BetaTest.beta_log_values_test(); BetaTest.beta_noncentral_cdf_values_test(); BetaTest.beta_pdf_values_test(); BinomialTest.binomial_values_test(); BinomialTest.binomial_cdf_values_test(); BinomialTest.binomial_pdf_values_test(); BivariateTest.bivariate_normal_cdf_values_test(); ComplexTest.c8_log_values_test(); CatalanTest.catalan_values_test(); CauchyTest.cauchy_cdf_values_test(); CubeRootTest.cbrt_values_test(); ChebyshevTest.cheby_t_poly_values_test(); ChebyshevTest.cheby_t01_poly_values_test(); ChebyshevTest.cheby_u_poly_values_test(); ChebyshevTest.cheby_u01_poly_values_test(); ChebyshevTest.cheby_v_poly_values_test(); ChebyshevTest.cheby_v01_poly_values_test(); ChebyshevTest.cheby_w_poly_values_test(); ChebyshevTest.cheby_w01_poly_values_test(); ChiTest.chi_values_test(); ChiTest.chi_square_cdf_values_test(); ChiTest.chi_square_pdf_values_test(); ChiTest.chi_square_noncentral_cdf_values_test(); CosineTest.ci_values_test(); CosineTest.cin_values_test(); CosineTest.cinh_values_test(); ClausenTest.clausen_values_test(); ClebschGordanTest.clebsch_gordan_values_test(); CollatzTest.collatz_count_values_test(); CosineTest.cos_values_test(); CosineTest.cos_degree_values_test(); CosineTest.cos_power_int_values_test(); CosineTest.cosh_values_test(); CotTest.cot_values_test(); ConstPressureTest.cp_values_test(); DateTest.datenum_values_test(); DawsonTest.dawson_values_test(); DebyeTest.debye1_values_test(); DebyeTest.debye2_values_test(); DebyeTest.debye3_values_test(); DebyeTest.debye4_values_test(); DedekindTest.dedekind_sum_values_test(); DielectricTest.dielectric_values_test(); DilogarithmTest.dilogarithm_values_test(); ExpIntegralTest.e1_values_test(); DateTest.easter_gregorian_values_test(); DateTest.easter_julian_values_test(); ExpIntegralTest.ei_values_test(); EllipticTest.elliptic_ea_values_test(); EllipticTest.elliptic_ek_values_test(); EllipticTest.elliptic_em_values_test(); EllipticTest.elliptic_fa_values_test(); EllipticTest.elliptic_fk_values_test(); EllipticTest.elliptic_fm_values_test(); EllipticTest.elliptic_inc_ea_values_test(); EllipticTest.elliptic_inc_ek_values_test(); EllipticTest.elliptic_inc_em_values_test(); EllipticTest.elliptic_inc_fa_values_test(); EllipticTest.elliptic_inc_fk_values_test(); EllipticTest.elliptic_inc_fm_values_test(); EllipticTest.elliptic_inc_pia_values_test(); EllipticTest.elliptic_inc_pik_values_test(); EllipticTest.elliptic_inc_pim_values_test(); EllipticTest.elliptic_pia_values_test(); EllipticTest.elliptic_pik_values_test(); EllipticTest.elliptic_pim_values_test(); ErrorFuncTest.erf_values_test(); ErrorFuncTest.erfc_values_test(); EulerTest.euler_number_values_test(); EulerTest.euler_poly_values_test(); ExponentialTest.exp_values_test(); ExponentialTest.exp3_int_values_test(); ExponentialTest.exponential_01_pdf_values_test(); ExponentialTest.exponential_cdf_values_test(); ExponentialTest.exponential_pdf_values_test(); ExtremeTest.extreme_values_cdf_values_test(); FTest.f_cdf_values_test(); FTest.f_noncentral_cdf_values_test(); FresnelTest.fresnel_cos_values_test(); FresnelTest.fresnel_sin_values_test(); FrobeniusTest.frobenius_number_data_values_test(); FrobeniusTest.frobenius_number_order_values_test(); FrobeniusTest.frobenius_number_order2_values_test(); GammaTest.gamma_values_test(); GammaTest.gamma_01_pdf_values_test(); GammaTest.gamma_cdf_values_test(); GammaTest.gamma_inc_values_test(); GammaTest.gamma_inc_p_values_test(); GammaTest.gamma_inc_q_values_test(); GammaTest.gamma_inc_tricomi_values_test(); GammaTest.gamma_log_values_test(); GammaTest.gamma_pdf_values_test(); GegenbauerTest.gegenbauer_poly_values_test(); GeometricTest.geometric_cdf_values_test(); GoodwinTest.goodwin_values_test(); GudermannianTest.gud_values_test(); HermiteTest.hermite_function_values_test(); HermiteTest.hermite_poly_phys_values_test(); HermiteTest.hermite_poly_prob_values_test(); HyperTest.hyper_1f1_values_test(); HyperTest.hyper_2f1_values_test(); HyperTest.hypergeometric_cdf_values_test(); HyperTest.hypergeometric_pdf_values_test(); HyperTest.hypergeometric_u_values_test(); ITest.i0ml0_values_test(); ITest.i1ml1_values_test(); FactorialTest.i4_factorial_values_test(); FactorialTest.i4_factorial2_values_test(); FactorialTest.i4_fall_values_test(); FactorialTest.i4_rise_values_test(); IntgrTest.int_values_test(); ChiTest.inverse_chi_square_pdf_values_test(); GammaTest.inverse_gamma_pdf_values_test(); JacobiTest.jacobi_cn_values_test(); JacobiTest.jacobi_dn_values_test(); JacobiTest.jacobi_poly_values_test(); JacobiTest.jacobi_sn_values_test(); DateTest.jed_ce_values_test(); DateTest.jed_mjd_values_test(); DateTest.jed_rd_values_test(); DateTest.jed_weekday_values_test(); KelvinTest.kei0_values_test(); KelvinTest.kei1_values_test(); KelvinTest.ker0_values_test(); KelvinTest.ker1_values_test(); LaguerreTest.laguerre_associated_values_test(); LaguerreTest.laguerre_general_values_test(); LaguerreTest.laguerre_polynomial_values_test(); LambertTest.lambert_w_values_test(); LaplaceTest.laplace_cdf_values_test(); LegendreTest.legendre_associated_values_test(); LegendreTest.legendre_associated_normalized_values_test(); LegendreTest.legendre_associated_normalized_sphere_values_test(); LegendreTest.legendre_function_q_values_test(); LegendreTest.legendre_normalized_polynomial_values_test(); LegendreTest.legendre_polynomial_values_test(); LegendreTest.legendre_shifted_polynomial_values_test(); LerchTest.lerch_values_test(); LobachevskyTest.lobachevsky_values_test(); LobattoTest.lobatto_polynomial_values_test(); LobattoTest.lobatto_polynomial_derivatives_test(); LogarithmTest.log_values_test(); LogarithmTest.log_normal_cdf_values_test(); LogarithmTest.log_series_cdf_values_test(); LogarithmTest.log10_values_test(); LogarithmTest.logarithmic_integral_values_test(); LogisticTest.logistic_cdf_values_test(); MertensTest.mertens_values_test(); MittagLefflerTest.mittag_leffler_ea_values_test(); MoebiusTest.moebius_values_test(); MultinomialTest.multinomial_pdf_values_test(); BinomialTest.negative_binomial_cdf_values_test(); WignerTest.nine_j_values_test(); NormalTest.normal_01_cdf_values_test(); NormalTest.normal_01_pdf_values_test(); NormalTest.normal_cdf_values_test(); NormalTest.normal_pdf_values_test(); OmegaTest.omega_values_test(); OwenTest.owen_values_test(); PartitionTest.partition_count_values_test(); PartitionTest.partition_distinct_count_values_test(); PhiTest.phi_values_test(); PiTest.pi_values_test(); PoissionTest.poisson_cdf_values_test(); LogarithmTest.polylogarithm_values_test(); PolyominoTest.polyomino_chiral_count_values_test(); PolyominoTest.polyomino_fixed_count_values_test(); PolyominoTest.polyomino_free_count_values_test(); PrandtlTest.prandtl_values_test(); PrimeTest.prime_values_test(); PsatTest.psat_values_test(); PsiTest.psi_values_test(); FactorialTest.r8_factorial_values_test(); FactorialTest.r8_factorial_log_values_test(); FactorialTest.r8_factorial2_values_test(); FactorialTest.r8_fall_values_test(); FactorialTest.r8_rise_values_test(); RayleighTest.rayleigh_cdf_values_test(); ChiTest.scaled_inverse_chi_square_pdf_values_test(); SecVirTest.secvir_values_test(); ShiTest.shi_values_test(); SineTest.si_values_test(); SigmaTest.sigma_values_test(); SineTest.sin_values_test(); SineTest.sin_degree_values_test(); SineTest.sin_power_int_values_test(); SineTest.sinh_values_test(); WignerTest.six_j_values_test(); SoundTest.sound_values_test(); SphereTest.sphere_unit_area_values_test(); SphereTest.sphere_unit_volume_values_test(); SphericalHarmonicTest.spherical_harmonic_values_test(); SqrtTest.sqrt_values_test(); StirlingTest.stirling1_values_test(); StirlingTest.stirling2_values_test(); StromgenTest.stromgen_values_test(); StruveTest.struve_h0_values_test(); StruveTest.struve_h1_values_test(); StruveTest.struve_l0_values_test(); StruveTest.struve_l1_values_test(); StudentTest.student_cdf_values_test(); StudentTest.student_noncentral_cdf_values_test(); FactorialTest.subfactorial_values_test(); SurfTensionTest.surten_values_test(); SynchTest.synch1_values_test(); SynchTest.synch2_values_test(); TangentTest.tan_values_test(); TangentTest.tanh_values_test(); TauTest.tau_values_test(); ThermCondTest.thercon_values_test(); WignerTest.three_j_values_test(); TransportationTest.tran02_values_test(); TransportationTest.tran03_values_test(); TransportationTest.tran04_values_test(); TransportationTest.tran05_values_test(); TransportationTest.tran06_values_test(); TransportationTest.tran07_values_test(); TransportationTest.tran08_values_test(); TransportationTest.tran09_values_test(); TrigammaTest.trigamma_values_test(); TruncatedTest.truncated_normal_ab_cdf_test(); TruncatedTest.truncated_normal_ab_pdf_test(); TruncatedTest.truncated_normal_a_cdf_test(); TruncatedTest.truncated_normal_a_pdf_test(); TruncatedTest.truncated_normal_b_cdf_test(); TruncatedTest.truncated_normal_b_pdf_test(); TsatTest.tsat_values_test(); VanDerCorputTest.van_der_corput_values_test(); ViscosityTest.viscosity_values_test(); VonMisesTest.von_mises_cdf_values_test(); DateTest.weekday_values_test(); WeibullTest.weibull_cdf_values_test(); WrightOmegaTest.wright_omega_values_test(); ZetaTest.zeta_values_test(); ZetaTest.zeta_m1_values_test(); Console.WriteLine(""); Console.WriteLine("test_values_test():"); Console.WriteLine(" Normal end of execution."); Console.WriteLine(""); }
public void BinomialTestConstructorTest3() { // GNU R (0.096248626708984375) // Wolfram Alpha reports 0.06357 BinomialTest target = new BinomialTest(5, 18); Assert.AreEqual(OneSampleHypothesis.ValueIsDifferentFromHypothesis, target.Hypothesis); Assert.AreEqual(DistributionTail.TwoTail, target.Tail); Assert.AreEqual(0.063564300537109319, target.PValue, 1e-4); Assert.IsFalse(target.Significant); }