Beispiel #1
0
        public CorrelationResponse Post([FromBody] CorrelationRequestAnalytic request)
        {
            CorrelationResponse result = new CorrelationResponse();

            var watch = Stopwatch.StartNew();

            try
            {
                var correlationCalculator = CorrelationCalculator.Create(request.Type);
                var scriptCompilator      = new ScriptCompiler();

                var function1 = Function.Create(scriptCompilator.GetFunc(request.Function1),
                                                request.LeftBorder,
                                                request.RightBorder,
                                                request.PointsCount);
                var function2 = Function.Create(scriptCompilator.GetFunc(request.Function2),
                                                request.LeftBorder,
                                                request.RightBorder,
                                                request.PointsCount);

                result.Value = correlationCalculator.GetCorrelation(function1, function2);
            }
            catch (Exception e)
            {
                result.Error = e.Message;
            }
            finally
            {
                watch.Stop();
                result.ExecutionTime = watch.ElapsedMilliseconds;
            }

            return(result);
        }
Beispiel #2
0
        public void TestLienNorminalBorneInferieure()
        {
            const string lienNorminalTest = " très forte à parfaite";

            string lienNorminal = CorrelationCalculator.getNorminalLink(0.888);

            Assert.Equal(lienNorminal, lienNorminalTest);
        }
        public void AutoCorrelationKendall()
        {
            Function function = Function.Create(x => 2 * x, 0, 10, 100);
            CorrelationCalculator correlationCalculator = CorrelationCalculator.Create(CorrelationType.Kendall);
            double corr = correlationCalculator.GetCorrelation(function, function);

            Assert.Equal(corr, 1);
        }
Beispiel #4
0
        public void TestLienNorminalBorneInvalide()
        {
            const string lienNorminalTest = "nulle";

            string lienNorminal = CorrelationCalculator.getNorminalLink(2);

            Assert.Equal(lienNorminal, lienNorminalTest);
        }
Beispiel #5
0
        public void TestLienNorminalBorneSuperieure()
        {
            const string lienNorminalTest = " moyenne à forte";

            string lienNorminal = CorrelationCalculator.getNorminalLink(0.5);

            Assert.Equal(lienNorminal, lienNorminalTest);
        }
Beispiel #6
0
        public void TestPlusOneCorrelation()
        {
            CorrelationCalculator calc = new CorrelationCalculator();

            calc.AddData(this.GetMaleStudent(), this.GetUnsatisfactoryMark());
            calc.AddData(this.GetFemaleStudent(), this.GetExcellentMark());

            Assert.AreEqual(+1.0d, (double)calc.ComputeCorrelation());
        }
Beispiel #7
0
        public void TestNumerateurCorrelationInvalide()
        {
            double sommeX         = double.NaN;
            double sommeY         = double.NaN;
            double sommeXY        = double.NaN;
            int    nbrPairDonnees = 2;

            double numerateur = CorrelationCalculator.calculNumerateurCorrelation(sommeX, sommeY, sommeXY, nbrPairDonnees);

            Assert.Equal(double.NaN, numerateur);
        }
Beispiel #8
0
        public void TestNumerateurCorrelationSuperieure()
        {
            const double numerateurTest = 401.44;

            double sommeX         = 10;
            double sommeY         = 20;
            double sommeXY        = 200.48;
            int    nbrPairDonnees = 3;

            double numerateur = CorrelationCalculator.calculNumerateurCorrelation(sommeX, sommeY, sommeXY, nbrPairDonnees);

            Assert.Equal(Math.Round(numerateur, 2), numerateurTest);
        }
Beispiel #9
0
        public void TestNumerateurCorrelationInferieure()
        {
            const double numerateurTest = 200;

            double sommeX         = 10;
            double sommeY         = 20;
            double sommeXY        = 200;
            int    nbrPairDonnees = 2;

            double numerateur = CorrelationCalculator.calculNumerateurCorrelation(sommeX, sommeY, sommeXY, nbrPairDonnees);

            Assert.Equal(numerateur, numerateurTest);
        }
Beispiel #10
0
        public void TestDenominateurCorrelationInvalide()
        {
            double sommeExposantX = double.NaN;
            double sommePowX      = double.NaN;

            double sommeExposantY = double.NaN;
            double sommePowY      = double.NaN;

            int nbrPairDonnees = 1;

            double denominateur = CorrelationCalculator.calculDenominateurCorrelation(sommeExposantX, sommeExposantY, sommePowX, sommePowY, nbrPairDonnees);

            Assert.Equal(double.NaN, denominateur);
        }
Beispiel #11
0
        public void TestDenominateurCorrelationInferieure()
        {
            const double denominateurTest = 144;

            double sommeExposantX = 68;
            double sommePowX      = 100;

            double sommeExposantY = 34;
            double sommePowY      = 64;

            int nbrPairDonnees = 2;

            double denominateur = CorrelationCalculator.calculDenominateurCorrelation(sommeExposantX, sommeExposantY, sommePowX, sommePowY, nbrPairDonnees);

            Assert.Equal(denominateur, denominateurTest);
        }
Beispiel #12
0
        public void TestDenominateurCorrelationSuperieure()
        {
            const double denominateurTest = 195.64;

            double sommeExposantX = 34.83;
            double sommePowX      = 64.3;

            double sommeExposantY = 68.7;
            double sommePowY      = 100.9;

            int nbrPairDonnees = 2;

            double denominateur = CorrelationCalculator.calculDenominateurCorrelation(sommeExposantX, sommeExposantY, sommePowX, sommePowY, nbrPairDonnees);

            Assert.Equal(denominateur, denominateurTest);
        }
 protected override void OnContentChanged()
 {
     base.OnContentChanged();
     CorrelationCalculator.TryCancelCalculation();
     if (Content != null)
     {
         CalculateCorrelation();
     }
     else
     {
         progressPanel.Visible = false;
         dataView.Maximum      = 0;
         dataView.Minimum      = 0;
         dataView.Content      = null;
         dataView.ResetVisibility();
     }
 }
        public void Handle()
        {
            this.calculator = new CorrelationCalculator();

            LoginRequest lr = new LoginRequest("viea16u008", "[password here]");

            lr.Perform();

            this.client = lr.Client;

            MainPageRequest mpr = new MainPageRequest(client);

            mpr.Perform();

            EUMainPageRequest eumpr = new EUMainPageRequest(client, mpr.EULink);

            eumpr.Perform();

            this.sessionCache = new SessionCache(this.client, eumpr.SessionLink);

            EUProgressPageRequest euppr = new EUProgressPageRequest(client, eumpr.ProgressLink);

            euppr.Perform();

            logger.Log("Начинаем...");

            var semesters = euppr.SemesterLinks;

            logger.SetStepsCount(semesters.Count - 1);

            foreach (var semester in semesters)
            {
                if (semester.Year > 2016)
                {
                    break;
                }

                HandleSemester(semester);
                logger.Step();
            }

            double result = calculator.ComputeCorrelation();

            // " (+1 это перекос в сторону отличных оценок у девушек, -1 - у парней)
            logger.LogCorrelation(result);
        }
Beispiel #15
0
        public void TestCorrelationBorneInvalide()
        {
            const double correlationTest = 200;

            List <double> listNumberX = new List <double>();

            listNumberX.Add(double.NaN);
            listNumberX.Add(double.NaN);
            listNumberX.Add(double.NaN);

            List <double> listNumberY = new List <double>();

            listNumberY.Add(double.NaN);
            listNumberY.Add(double.NaN);
            listNumberY.Add(double.NaN);

            double correlation = CorrelationCalculator.calculCorrelation(listNumberX, listNumberY);

            Assert.Equal(double.NaN, correlation);
        }
Beispiel #16
0
        public void TestCorrelationBorneSuperieure()
        {
            const double correlationTest = 1;

            List <double> listNumberX = new List <double>();

            listNumberX.Add(0);
            listNumberX.Add(0.01);
            listNumberX.Add(30.5);

            List <double> listNumberY = new List <double>();

            listNumberY.Add(-60);
            listNumberY.Add(-70.99);
            listNumberY.Add(90.74);

            double correlation = CorrelationCalculator.calculCorrelation(listNumberX, listNumberY);

            Assert.Equal(correlation, correlationTest);
        }
Beispiel #17
0
        public void TestCorrelationBorneInferieure()
        {
            const double correlationTest = 0.98;

            List <double> listNumberX = new List <double>();

            listNumberX.Add(10);
            listNumberX.Add(20);
            listNumberX.Add(30);

            List <double> listNumberY = new List <double>();

            listNumberY.Add(60);
            listNumberY.Add(70);
            listNumberY.Add(90);

            double correlation = CorrelationCalculator.calculCorrelation(listNumberX, listNumberY);

            Assert.Equal(correlation, correlationTest);
        }
Beispiel #18
0
        public CorrelationResponse Post([FromBody] CorrelationRequestNumeric request)
        {
            CorrelationResponse result = new CorrelationResponse();

            var watch = Stopwatch.StartNew();

            try
            {
                var correlationCalculator = CorrelationCalculator.Create(request.Type);
                result.Value = correlationCalculator.GetCorrelation(request.Function1, request.Function2);
            }
            catch (Exception e)
            {
                result.Error = e.Message;
            }
            finally
            {
                watch.Stop();
                result.ExecutionTime = watch.ElapsedMilliseconds;
            }

            return(result);
        }
Beispiel #19
0
        public void CorrelationIsFractionOfCodeWordsContainedInRequirements(string[] codeWords, string[] requirementsWords, double expected)
        {
            double correlation = new CorrelationCalculator().Calculate(codeWords, requirementsWords);

            Assert.That(correlation, Is.EqualTo(expected));
        }
 protected override void OnClosing(FormClosingEventArgs e)
 {
     base.OnClosing(e);
     CorrelationCalculator.TryCancelCalculation();
 }