public static void TestPERT() { // compare with graph at https://en.wikipedia.org/wiki/PERT_distribution var min = 0.0; var mod = 10.0; var max = 100.0; for (int k = 0; k != 101; ++k) { var x = (double)k * 1.0; var f = PERT.PDF(x, min, mod, max); Console.WriteLine($" {x} {f}"); } }
public static void ConvolvePERT_PERT(int N) { double[] x = new double[N]; var min = 0.0; var mod = 20.0; // peak at the left var max = 100.0; Complex[] data1 = new Complex[N]; for (int k = 0; k != N; ++k) { x[k] = 0.0 + (double)k * 1.0; data1[k] = new Complex(PERT.PDF(x[k], min, mod, max), 0.0); } min = 0.0; mod = 80.0; // peak at the right max = 100.0; Complex[] data2 = new Complex[N]; for (int k = 0; k != N; ++k) { data2[k] = new Complex(PERT.PDF(x[k], min, mod, max), 0.0); } Fourier.Forward(data1, FourierOptions.Default); Fourier.Forward(data2, FourierOptions.Default); // FT of convolution of the PDSs is just a multiplication Complex[] data = new Complex[N]; for (int k = 0; k != N; ++k) { data[k] = data1[k] * data2[k]; } Fourier.Inverse(data, FourierOptions.Default); // something is wrong with normalization, mmm... for (int k = 0; k != N; ++k) { Console.WriteLine($" {x[k]} {data[k].Real}"); } }