예제 #1
0
        private void getResult(ObservablePoint[] ret, GearedValues <ObservablePoint> shortWave)
        {
            if (ret.Length == 4)
            {
                t1Ret = (ret[1].X - ret[0].X).ToString("N2") + " ms";
                t2Ret = (ret[2].X - ret[1].X).ToString("N2") + " ms";
                t3Ret = (ret[3].X - ret[2].X).ToString("N2") + " ms";
                t4Ret = (ret[3].X - ret[0].X).ToString("N2") + " ms";

                var arr1 = shortWave.Skip((int)(ret[0].X / 300 * 6000)).Take((int)((ret[1].X - ret[0].X) / 300 * 6000)).Select(x => Math.Round(x.Y, 2));
                var arr2 = shortWave.Skip((int)(ret[2].X / 300 * 6000)).Take((int)((ret[3].X - ret[2].X) / 300 * 6000)).Select(x => Math.Round(x.Y, 2));
                var arr3 = shortWave.Skip((int)(ret[1].X / 300 * 6000)).Take((int)((ret[2].X - ret[1].X) / 300 * 6000)).Select(x => Math.Round(x.Y, 2));

                //double r1 = LogNormal.Estimate(arr1).Mean;
                //double r2 = LogNormal.Estimate(arr2).Mean;
                //double r3 = LogNormal.Estimate(arr3).Mean;

                double r1 = GetElevationMode(arr1.ToList());
                double r2 = GetElevationMode(arr2.ToList());
                //double r3 = GetElevationMode(arr3.ToList());
                double r3 = LogNormal.Estimate(arr3).Mean;

                //var sss = new MathNet.Numerics.Differentiation.NumericalDerivative(20, 2);
                R1Ret = r1.ToString("N2") + " Ω";
                R2Ret = r2.ToString("N2") + " Ω";

                R1AndR2Ret = r3.ToString("N2") + " Ω";;
            }
        }
예제 #2
0
        public void CanEstimateParameters(double mu, double sigma)
        {
            var original  = new LogNormal(mu, sigma, new Random(100));
            var estimated = LogNormal.Estimate(original.Samples().Take(10000));

            AssertHelpers.AlmostEqual(mu, estimated.Mu, 2);
            AssertHelpers.AlmostEqual(sigma, estimated.Sigma, 2);
        }