/// <summary> /// Represents the target for the adapter. /// </summary> //public Distributions() //{ //} public double NormCdf(double x) { double cdf; NormalDistribution normCdf = new NormalDistribution(0, 1); cdf = normCdf.CumulativeDistribution(x); return cdf; }
/// <summary> /// Represents the target for the adapter. /// </summary> //public Distributions() //{ //} public double NormCdf(double x) { double cdf; Debug.Assert(!double.IsNaN(x)); var normCdf = new NormalDistribution(0, 1); cdf = normCdf.CumulativeDistribution(x); return cdf; }
public IGraphInfo GetGraphInfo(int projectId, string locatie, string root) { DataGraph distribution = new DataGraph(); DataPoint prestatiepeilPunt; DataPoint toetspeilPunt; try { // Get a random number generator Random rand = new Random(); double x; double y; for (int i = 0; i < 1000; i++) { MathNet.Numerics.Distributions.NormalDistribution bin = new NormalDistribution(0, 1000); y = bin.CumulativeDistribution(i); distribution.Add(new DataPoint(i, y)); } x = rand.NextDouble() * 20.0 + 1; y = Math.Log(10.0 * (x - 1.0) + 1.0) * (rand.NextDouble() * 0.2 + 0.9); prestatiepeilPunt = new DataPoint(x, y); x = rand.NextDouble() * 20.0 + 1; y = Math.Log(10.0 * (x - 1.0) + 1.0) * (rand.NextDouble() * 0.2 + 0.9); toetspeilPunt = new DataPoint(x, y); } catch (Exception ex) { throw new CheckedException(ErrorType.ParseFailure, ex.Message); } ///NOTE: met GraphInfoSimple(distribution, toetspeilPunt, prestatiepeilPunt) is loosely-coupling onmogelijk ///(assemblies scheiden zonder interfaces te kopieren in de de bussiness layer). ///Gebruik minimaal een pattern. IGraphInfo result = new Factory<MyAccess>().CreateGraphInfo(); result.OverschrijdingsKansen = distribution; result.PrestatiePeil = prestatiepeilPunt; result.ToetsPeil = toetspeilPunt; return result; }
public void AdapterConstructorTargetTest() { Distributions target1 = new Distributions(); Adapter target = new Adapter(target1); Adaptee adaptee = new Adaptee(); NormalDistribution normCdf = new NormalDistribution(0, 1); Func<double, double> expected = target1.NormCdf; Func<double, double> actual = target.NormCdf; Assert.AreNotEqual(expected(1), adaptee.NormCdf(1), "Should NOT be equal function behaviour."); Assert.AreEqual(expected(1), actual(1), "Should be equal function behaviour."); Assert.AreEqual( normCdf.CumulativeDistribution(1), actual(1), "Should be equal function behaviour."); Func<double, double> normCdf2 = arg => { arg = arg - 1; return arg; }; Assert.AreNotEqual(expected, normCdf2); }