internal void NormalCdfIntegralTest2() { double x = 0.0093132267868981222; double y = -0.0093132247056551785; double r = -1; y = -2499147.006377392; x = 2499147.273918618; //MMath.TraceConFrac = true; //MMath.TraceConFrac2 = true; for (int i = 0; i < 100; i++) { //x = 2.1 * (i + 1); //y = -2 * (i + 1); //x = -2 * (i + 1); //y = 2.1 * (i + 1); //x = -System.Math.Pow(10, -i); //y = -x * 1.1; x = -0.33333333333333331; y = -1.5; r = 0.16666666666666666; x = -0.4999; y = 0.5; x = -0.1; y = 0.5; r = -0.1; x = -824.43680216388009; y = -23300.713731480908; r = -0.99915764591723821; x = -0.94102098773740084; x = 1 + i * 0.01; y = 2; r = 1; x = 0.021034851174404436; y = -0.37961242087533614; //x = -0.02; //y += -1; //x -= -1; r = -1 + System.Math.Pow(10, -i); //x = i * 0.01; //y = -1; //r = -1 + 1e-8; // 1.81377005549484E-40 with exponent // flipped is 1.70330340479022E-40 //x = -1; //y = -8.9473684210526319; //x = System.Math.Pow(10, -i); //y = x; //r = -0.999999999999999; //x = -0.94102098773740084; //y = -1.2461486442846208; //r = 0.5240076921033775; x = 790.80368892437889; y = -1081776354979.6719; y = -System.Math.Pow(10, i); r = -0.94587440643473975; x = -39062.492380206008; y = 39062.501110681893; r = -0.99999983334056686; //x = -2; //y = 1.5789473684210522; //r = -0.78947368421052622; //x = -1.1; //y = -1.1; //r = 0.052631578947368474; //x = 0.001; //y = -0.0016842105263157896; //r = -0.4; //x = 0.1; //x = 2000; //y = -2000; //r = -0.99999999999999989; x = double.MinValue; y = double.MinValue; r = 0.1; Trace.WriteLine($"(x,y,r) = {x:g17}, {y:g17}, {r:g17}"); double intZOverZ; try { intZOverZ = MMath.NormalCdfIntegralRatio(x, y, r); } catch { intZOverZ = double.NaN; } Trace.WriteLine($"intZOverZ = {intZOverZ:g17}"); double intZ0 = NormalCdfIntegralBasic(x, y, r); double intZ1 = 0; // NormalCdfIntegralFlip(x, y, r); double intZr = 0; // NormalCdfIntegralBasic2(x, y, r); ExtendedDouble intZ; double sqrtomr2 = System.Math.Sqrt((1 - r) * (1 + r)); try { intZ = MMath.NormalCdfIntegral(x, y, r, sqrtomr2); } catch { intZ = ExtendedDouble.NaN(); } //double intZ = intZ0; Trace.WriteLine($"intZ = {intZ:g17} {intZ.ToDouble():g17} {intZ0:g17} {intZ1:g17} {intZr:g17}"); if (intZ.Mantissa < 0) { throw new Exception(); } //double intZ2 = NormalCdfIntegralBasic(y, x, r); //Trace.WriteLine($"intZ2 = {intZ2} {r*intZ}"); double Z = MMath.NormalCdf(x, y, r); if (Z < 0) { throw new Exception(); } } }