Exemplo n.º 1
0
        public void Can_Identify_Outliers()
        {
            IStatistics stats = new Statistics.Statistics(_outlierVehiclesList.ToList());

            Assert.AreEqual(1, stats.OutlierVehicles.Count);
            Assert.AreEqual(15, stats.OutlierVehicles.First().Vehicle.Price);
        }
Exemplo n.º 2
0
 public void Test_DepreciationByYearCumulative()
 {
     IStatistics stats = new Statistics.Statistics(_depreciationVehicles.ToList());
     Assert.AreEqual(0, stats.DepreciationByYearCumulative.First(y => y.Item1 == 2014).Item2);
     Assert.AreEqual(-10, stats.DepreciationByYearCumulative.First(y => y.Item1 == 2013).Item2);
     Assert.AreEqual(-20, Math.Round(stats.DepreciationByYearCumulative.First(y => y.Item1 == 2012).Item2, 2));
     Assert.AreEqual(-30, Math.Round(stats.DepreciationByYearCumulative.First(y => y.Item1 == 2011).Item2, 2));
 }
Exemplo n.º 3
0
        /// <summary>
        /// Gets the collar PCE.
        /// </summary>
        /// <param name="ratedays">The ratedays.</param>
        /// <param name="rateamts">The rateamts.</param>
        /// <param name="divdays">The divdays.</param>
        /// <param name="divamts">The divamts.</param>
        /// <param name="volSurface">The vol surface.</param>
        /// <param name="spot">The spot.</param>
        /// <param name="callstrike">The callstrike.</param>
        /// <param name="putstrike">The putstrike.</param>
        /// <param name="maturity">The maturity of the collar</param>
        /// <param name="meanrev">The meanrev parameter used in the OU dynamics.</param>
        /// <param name="histvol">The historical vol estimate used in the OU dynamics.</param>
        /// <param name="timeSlice">The time slice.</param>
        /// <returns></returns>
        public static double[,] GetCollarPCE(string payoff,
                                             int[] ratedays,
                                             double[] rateamts,
                                             int[] divdays,
                                             double[] divamts,
                                             List <OrcWingParameters> volSurface,
                                             double spot,
                                             double callstrike,
                                             double putstrike,
                                             double maturity,
                                             double kappa,
                                             double theta,
                                             double sigma,
                                             double[] profiletimes,
                                             double confidence,
                                             double tstepSize,
                                             int simulations,
                                             int seed)

        {
            int nprofile = profiletimes.Length;

            double[,] results = new double[nprofile, 3];
            List <double>         profileList   = new List <double>(profiletimes);
            List <double>         _profiletimes = profileList.FindAll(delegate(double item) { return(item <= maturity); });
            List <RiskStatistics> res           = Euler(payoff,
                                                        ratedays,
                                                        rateamts,
                                                        divdays,
                                                        divamts,
                                                        volSurface,
                                                        spot,
                                                        callstrike,
                                                        putstrike,
                                                        maturity,
                                                        _profiletimes.ToArray(),
                                                        kappa,
                                                        theta,
                                                        sigma,
                                                        confidence,
                                                        tstepSize,
                                                        simulations,
                                                        seed);

            for (int idx = 0; idx < _profiletimes.Count; idx++)
            {
                Statistics.Statistics stats = new Statistics.Statistics();
                double[] sample             = res[idx].Sample();
                double   mean     = res[idx].Mean;
                double   sterrEst = res[idx].ErrorEstimate;
                results[idx, 0] = mean;
                results[idx, 1] = stats.Percentile(ref sample, cPercentile);
                results[idx, 2] = sterrEst;
            }

            return(results);
        }
Exemplo n.º 4
0
        private static void Main()
        {
            XmlConfigurator.Configure();
            Log.Info("start");
            try
            {
                _signalHandler += HandleConsoleSignal;
                ConsoleHelper.SetSignalHandler(_signalHandler, true);

                var errors = Configurator.Config();

                _atm = CashMachine.Deserialize(ConfigurationManager.AppSettings["SerializationAtm"]) ??
                       new CashMachine(new GreedyAlgorithm());
                _statistics = Statistics.Statistics.Deserialize(ConfigurationManager.AppSettings["SerializationStatistics"]) ??
                              new Statistics.Statistics();

                AtmEvent.InsertCassettesEvent += _statistics.InsertCassettes;
                AtmEvent.WithdrawMoneyEvent   += _statistics.WithdrawMoney;
                AtmEvent.RemoveCassettesEvent += _statistics.RemoveCassettes;

                var commandPerfomer = new Commands.CommandPerfomer(_atm, errors, _statistics);
                Console.WriteLine(ConsoleLanguagePack.MainMessage);

                while (true)
                {
                    var input = Console.ReadLine();
                    Log.Debug(input);
                    if (string.IsNullOrEmpty(input))
                    {
                        continue;
                    }
                    if (ConsoleLanguagePack.ExitFlags.Contains(input))
                    {
                        break;
                    }

                    if (!commandPerfomer.TryPerform(input))
                    {
                        Console.WriteLine(ConsoleLanguagePack.CommandNotFound);
                    }
                }
                _atm.Serialize(ConfigurationManager.AppSettings["SerializationAtm"]);
                _statistics.Serialize(ConfigurationManager.AppSettings["SerializationStatistics"]);
            }
            catch (Exception ex)
            {
                Log.Fatal(ex);
            }

            Log.Info("end");
        }
        //private static double CalculateSurviveEnemyPrice(Statistics.Statistics statistics)
        //{
        //    double surviveEnemyPrice = 0;
        //    for(int i=0; i <statistics.MinDefenderResult.EnemyCounts.Length; i++)
        //    {
        //        double health = statistics.MinDefenderResult.EnemyCounts[i] * battle.EnemyUnits[i].Health;
        //        surviveEnemyPrice += health *
        //                  (battle.EnemyUnits[i].MinDamage * (1 - (double)battle.EnemyUnits[i].Accuracy / 100) +
        //                   battle.EnemyUnits[i].MaxDamage * (double) battle.EnemyUnits[i].Accuracy / 100);
        //    }

        //    double allEnemyPrice = 0;
        //    for(int i = 0; i < battle.EnemyCounts.Length; i++)
        //    {
        //        double health = battle.EnemyCounts[i] * battle.EnemyUnits[i].Health;

        //        allEnemyPrice += health *
        //                  (battle.EnemyUnits[i].MinDamage * (1 - (double)battle.EnemyUnits[i].Accuracy / 100) +
        //                   battle.EnemyUnits[i].MaxDamage * (double)battle.EnemyUnits[i].Accuracy / 100);
        //    }

        //    return surviveEnemyPrice;
        //}

        private static double CalculatePrice(Statistics.Statistics statistics)
        {
            double result = 0;

            for (int i = 0; i < statistics.AvgAttackerLosses.Length; i++)
            {
                if (statistics.AvgAttackerLosses[i] > 0)
                {
                    //result += statistics.AvgAttackerLosses[i] * CalculatePlayerLossesPrice(statistics.Battle.Units[i]);
                }
            }

            return(result);
        }
        private Dictionary<long, string> GetPureQuestionAnswersTexts(int count)
        {
            var statistics = new Statistics.Statistics(QuestionList);
            var orderedFrequentWords = statistics.WordFrequencyDistribution(new EmptyStemmer()).Where(item => item.Value >= 10).OrderBy(item => item.Value);
            var frequentWords = orderedFrequentWords.Take(orderedFrequentWords.Count() - 70).ToDictionary(item => item.Key, item => item.Value);

            return QuestionList.GetAllQuestions()
                    .Take(count)
                    .Select(q => Tuple.Create(q, q.WholeText))
                    .Select(item => Tuple.Create(item.Item1, item.Item2 + " " + String.Join(" ", item.Item1.GetAnswers().Select(a => a.Text))))
                    .Select(item => Tuple.Create(item.Item1, item.Item2.SplitInWordsAndStripHTML()))
                    .Select(item => Tuple.Create(item.Item1, String.Join("\t", item.Item2.Where(frequentWords.ContainsKey))))
                    .Where(item => item.Item2.Length > 0)
                    .ToDictionary(item => item.Item1.Id, item => item.Item2);
        }
Exemplo n.º 7
0
        public CommandPerfomer(CashMachine atm, Dictionary <AtmState, string> errors, Statistics.Statistics statistics)
        {
            _atm        = atm;
            _errors     = errors;
            _statistics = statistics;

            _commands = new Dictionary <string, Action>
            {
                { ConsoleLanguagePack.HelpFlag, HelpCommand },
                { ConsoleLanguagePack.InsertFlag, InsertCassettesCommand },
                { ConsoleLanguagePack.LanguageFlag, RefreshLanguageCommand },
                { ConsoleLanguagePack.RemoveFlag, RemoveCasssettesCommand },
                { ConsoleLanguagePack.StatisticsFlag, StatisticsCommand }
            };
            _userViewer = new UserViewer(errors);
        }
        internal void CalculateBattleTime(
            Statistics.Statistics statistics,
            out double minBattleTime,
            out double maxBattleTime,
            out double avgBattleTime)
        {
            minBattleTime = double.MaxValue;
            maxBattleTime = 0;
            avgBattleTime = 0;
            double battleCount = 0;

            foreach (KeyValuePair <int, int> roundStatistic in statistics.RoundStatistics)
            {
                double time = CalculateBattleTime(statistics.Battle, roundStatistic.Key);
                minBattleTime = Math.Min(minBattleTime, time);
                maxBattleTime = Math.Max(maxBattleTime, time);
                avgBattleTime = battleCount / (battleCount + roundStatistic.Value) * avgBattleTime +
                                roundStatistic.Value / (battleCount + roundStatistic.Value) * time;
                battleCount += roundStatistic.Value;
            }
        }
        public static string Prepare(Statistics.Statistics statistics, Dictionary <AtmState, string> errors)
        {
            var sb = new StringBuilder();

            sb.Append(ConsoleLanguagePack.TimeOfInsert + statistics.StartTime + "\n");
            UserViewer userViewer = new UserViewer(errors);

            foreach (var variable in statistics.Records)
            {
                sb.Append(variable.TimeOfOperation.ToString(CultureInfo.InvariantCulture) +
                          ConsoleLanguagePack.RequestedSum + variable.RequestedSum + ConsoleLanguagePack.AtmAnswer +
                          userViewer.ToString(variable.Money, variable.ResultOfOperation) + "\n");
            }
            sb.Append(ConsoleLanguagePack.TotalSum + statistics.TotalSum);
            sb.Append(ConsoleLanguagePack.Remainder + statistics.Remainder + "\n");
            sb.Append(ConsoleLanguagePack.AtmContext + "\n");
            foreach (var variable in statistics.Cassettes)
            {
                sb.Append(variable.Banknote.Nominal + " " + variable.Number + "\n");
            }
            return(sb.ToString());
        }
        private static BattleLosses GenerateBattleLosses(Statistics.Statistics statistics, IList <Unit> units, IList <Unit> enemyUnits)
        {
            if (statistics.MinAttackerLosses == null || statistics.MinDefenderLosses == null)
            {
                return(new BattleLosses(new List <Losses>(), new List <Losses>(), null));
            }

            List <Losses> playerLosses = new List <Losses>(statistics.MinAttackerLosses.Length);
            List <Losses> enemyLosses  = new List <Losses>(statistics.MinDefenderLosses.Length);

            for (int i = 0; i < statistics.MinAttackerLosses.Length; i++)
            {
                if (statistics.MaxAttackerLosses[i] > 0)
                {
                    playerLosses.Add(new Losses(
                                         units[i],
                                         statistics.MinAttackerLosses[i],
                                         statistics.AvgAttackerLosses[i],
                                         statistics.MaxAttackerLosses[i]));
                }
            }

            for (int i = 0; i < statistics.MinDefenderLosses.Length; i++)
            {
                if (statistics.MaxDefenderLosses[i] > 0)
                {
                    enemyLosses.Add(new Losses(
                                        enemyUnits[i],
                                        statistics.MinDefenderLosses[i],
                                        statistics.AvgDefenderLosses[i],
                                        statistics.MaxDefenderLosses[i]));
                }
            }

            return(new BattleLosses(playerLosses, enemyLosses, statistics));
        }
        private short[] GetEnemyLosses(Statistics.Statistics statistics)
        {
            switch (m_battleType)
            {
            case MultiWaveBattleType.TakeWorstWave:
                return(statistics.MinDefenderLosses);

            case MultiWaveBattleType.TakeAverageWave:
                short[] result = new short[statistics.AvgDefenderLosses.Length];
                for (int i = 0; i < statistics.AvgDefenderLosses.Length; i++)
                {
                    result[i] = (short)Math.Round(statistics.AvgDefenderLosses[i]);
                }
                return(result);

            case MultiWaveBattleType.TakeAllWaves:
                return(statistics.MinDefenderLosses);

            default:
                break;
            }

            return(null);
        }
Exemplo n.º 12
0
        public void Test_MeanPriceByYear()
        {
            IStatistics stats = new Statistics.Statistics(_depreciationVehicles.ToList());

            Assert.AreEqual(100000, stats.MeanPriceByYear.First(y => y.Item1 == 2014).Item2);
            Assert.AreEqual(90000, stats.MeanPriceByYear.First(y => y.Item1 == 2013).Item2);
            Assert.AreEqual(80000, stats.MeanPriceByYear.First(y => y.Item1 == 2012).Item2);
            Assert.AreEqual(70000, stats.MeanPriceByYear.First(y => y.Item1 == 2011).Item2);
        }
Exemplo n.º 13
0
 private void btnSideNavStatistics_Click(object sender, EventArgs e)
 {
     this.Hide();
     Statistics.Statistics stat = new Statistics.Statistics();
     stat.ShowDialog();
 }
Exemplo n.º 14
0
 public MultiWaveBatleWaveCompleteArgs(WaveKey key, Statistics.Statistics statistics)
 {
     m_key        = key;
     m_statistics = statistics;
 }
Exemplo n.º 15
0
 private static void WriteStatistics(Statistics.Statistics statistics, Dictionary <AtmState, string> errors)
 {
     Console.WriteLine(StatisticsPreparer.Prepare(statistics, errors));
 }
Exemplo n.º 16
0
        public static bool TryPerfom(string command, CashMachine atm, Dictionary <AtmState, string> errors, Statistics.Statistics statistics)
        {
            if (command == ConsoleLanguagePack.HelpFlag)
            {
                OutHelp();
                return(true);
            }

            if (command == ConsoleLanguagePack.RemoveFlag)
            {
                RemoveCassettes(atm);
                return(true);
            }
            if (command == ConsoleLanguagePack.StatisticsFlag)
            {
                WriteStatistics(statistics, errors);
                return(true);
            }

            var strs = command.Split(' ');

            if (strs.Count() == 2 && strs[0] == ConsoleLanguagePack.InsertFlag)
            {
                strs = strs[1].Split('.');
                if (strs.Count() != 2)
                {
                    return(false);
                }
                InsertCassette(command.Split(' ')[1], atm);
                return(true);
            }
            if (strs.Count() == 2 && strs[0] == ConsoleLanguagePack.LanguageFlag)
            {
                RefreshLanguage(strs[1]);
                return(true);
            }
            return(false);
        }
Exemplo n.º 17
0
        public static string[] GetFrequentWords(QuestionList questionList)
        {
            var getDataFunction = new Func<string[]>(
                () =>
                    {
                        var statistics = new Statistics.Statistics(questionList);
                        return statistics.WordFrequencyDistribution(new EmptyStemmer())
                            .Where(item => item.Value > 10)
                            .Select(item => item.Key)
                            .ToArray();
                    });

            return DataActualityChecker.Check
                (
                    new Lazy<string[]>(getDataFunction),
                    t => t,
                    s => s,
                    new FileDependencies(String.Format("FrequentWords_{0}.txt", questionList.GetHashCode()),
                                         Program.QuestionsFileName,
                                         Program.AnswersFileName)
                ).ToArray();
        }
        internal void Calculate(ICalculator calculator)
        {
            Random random         = new Random(Options.SEED);
            int    iterationCount = GetRepeatCount();

            for (int iter = 0; iter < iterationCount; iter++)
            {
                int playerIndex = 0;
                int enemyIndex  = 0;
                IList <UnitSquad> playerSquads  = null;
                General           playerGeneral = null;
                IList <UnitSquad> enemySquads   = null;
                General           enemyGeneral  = null;
                int destroyEnemyCampTime        = 0;

                while (playerIndex < m_playerWaves.Count && enemyIndex < m_enemyWaves.Count)
                {
                    if (iterationCount == 1)
                    {
                        random = new Random(Options.SEED);
                    }

                    if (playerSquads == null)
                    {
                        playerSquads = new List <UnitSquad>();
                        foreach (UnitSquad squad  in m_playerWaves[playerIndex].Squads)
                        {
                            playerSquads.Add(new UnitSquad(squad.Unit, squad.Count));
                        }

                        playerGeneral = m_playerWaves[playerIndex].General;
                        bool emptyWave = true;
                        foreach (UnitSquad squad in playerSquads)
                        {
                            if (squad.Count > 0)
                            {
                                emptyWave = false;
                                break;
                            }
                        }

                        if (emptyWave)
                        {
                            playerSquads = null;
                            playerIndex++;
                            continue;
                        }
                    }

                    if (enemySquads == null)
                    {
                        enemySquads = new List <UnitSquad>();
                        foreach (UnitSquad squad in m_enemyWaves[enemyIndex].Squads)
                        {
                            enemySquads.Add(new UnitSquad(squad.Unit, squad.Count));
                        }
                        enemyGeneral         = m_enemyWaves[enemyIndex].General;
                        destroyEnemyCampTime = (int)m_enemyWaves[enemyIndex].DestroyCampTime;

                        bool emptyWave = true;
                        foreach (UnitSquad squad in enemySquads)
                        {
                            if (squad.Count > 0)
                            {
                                emptyWave = false;
                                break;
                            }
                        }

                        if (emptyWave)
                        {
                            enemySquads = null;
                            enemyIndex++;
                            continue;
                        }
                    }

                    Battle battle = new Battle(playerSquads, playerGeneral, enemySquads, enemyGeneral);
                    battle.PlayerTowerBonus   = m_playerWaves[playerIndex].TowerBonus;
                    battle.EnemyTowerBonus    = m_enemyWaves[enemyIndex].TowerBonus;
                    battle.WinBattleTime      = destroyEnemyCampTime;
                    battle.StatisticsType     = m_statisticsType;
                    calculator.IterationCount = GetBattleIterationCount();
                    Statistics.Statistics statistics = new Statistics.Statistics(battle);
                    calculator.OnBattleComplete += statistics.BattleComplete;
                    calculator.Calculate(battle, random);
                    calculator.OnBattleComplete -= statistics.BattleComplete;
                    if (m_waveCompleteHandler != null)
                    {
                        m_waveCompleteHandler(this, new MultiWaveBatleWaveCompleteArgs(new WaveKey(playerIndex, enemyIndex), statistics));
                    }

                    statistics.Calculate();
                    bool    empty          = true;
                    short[] defenderLosses = GetEnemyLosses(statistics);
                    int     i = 0;
                    int     j = 0;
                    while (i < defenderLosses.Length)
                    {
                        if (enemySquads[j].Count <= 0)
                        {
                            j++;
                            continue;
                        }

                        enemySquads[j].Count -= defenderLosses[i];
                        if (enemySquads[j].Count > 0)
                        {
                            empty = false;
                        }
                        i++;
                        j++;
                    }

                    if (empty)
                    {
                        enemySquads = null;
                        enemyIndex++;
                    }

                    bool enemyEmpty = empty;
                    empty = true;
                    short[] attackerLosses = GetPlayerLosses(statistics);
                    i = 0;
                    j = 0;
                    while (i < attackerLosses.Length)
                    {
                        if (playerSquads[j].Count <= 0)
                        {
                            j++;
                            continue;
                        }

                        playerSquads[j].Count -= attackerLosses[i];
                        if (playerSquads[j].Count > 0)
                        {
                            empty = false;
                        }
                        i++;
                        j++;
                    }

                    if (empty || !enemyEmpty)
                    {
                        playerSquads = null;
                        playerIndex++;
                    }
                }

                //iteration complete
                if (m_battleCompleteHandler != null)
                {
                    m_battleCompleteHandler(this, new EventArgs());
                }
            }
        }
Exemplo n.º 19
0
        public double Evaluate(Statistics.Statistics statistics)
        {
            double calculatePrice = CalculatePrice(statistics);

            return(calculatePrice);
        }
Exemplo n.º 20
0
        //=====================================// OTHER WINDOWS //=====================================//

        private void ShowStatistics(object sender, RoutedEventArgs args)
        {
            Statistics.Statistics statistics = new Statistics.Statistics();
            statistics.Show();
        }
Exemplo n.º 21
0
 public void Test_LowestPrice()
 {
     IStatistics stats = new Statistics.Statistics(_outlierVehiclesList.ToList());
     Assert.AreEqual(2, stats.LowestPrice);
 }
 private static BattleLosses GenerateBattleLosses(Statistics.Statistics statistics, Battle battle)
 {
     return(GenerateBattleLosses(statistics, battle.Units, battle.EnemyUnits));
 }
 public double Evaluate(Statistics.Statistics statistics)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 24
0
        /// <summary>
        /// Property changed
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void propertyChangedEvent(object sender, System.ComponentModel.PropertyChangedEventArgs e)
        {
            var force = e.PropertyName == "" || e.PropertyName == "Currency" || e.PropertyName == "Distance"  || e.PropertyName == "Unit";

            //create new statsi f its reset
            if (e.PropertyName == "")
            {
                //stats
                this.baseStats = new Statistics.Statistics(DataController.Records);
                this.speedwayStats = new Statistics.Statistics(DataController.Circuits);
            }

            if (force || e.PropertyName == "Fills")
            {
                RaisePropertyChanged("PaidForFuel");
            }

            if (force || e.PropertyName == "Repairs")
            {
                RaisePropertyChanged("PaidForRepairs");
            }

            if (force || e.PropertyName == "Speed")
            {
                RaisePropertyChanged("AverageSpeed");
            }

            if (force || e.PropertyName == "Fills")
            {
                RaisePropertyChanged("TrendFuelPrices");
            }

            if (force || e.PropertyName == "Fills")
            {
                RaisePropertyChanged("TrendUnitsPerRefill");
            }

            if (force || e.PropertyName == "Circuits")
            {
                RaisePropertyChanged("CountOfLaps");
                RaisePropertyChanged("LengthOfLaps");
            }
        }
Exemplo n.º 25
0
 public void Test_SampleSize_WithoutOutliers()
 {
     IStatistics stats = new Statistics.Statistics(_outlierVehiclesList.ToList());
     Assert.AreEqual(7, stats.SampleSize);
 }
Exemplo n.º 26
0
 public void Test_StandardDeviation()
 {
     IStatistics stats = new Statistics.Statistics(_outlierVehiclesList.ToList());
     IStatistics statsDepreciation = new Statistics.Statistics(_depreciationVehicles.ToList());
     Assert.AreEqual(1.05, Math.Round(stats.StandardDeviation, 2));
     Assert.AreEqual(15000, statsDepreciation.StandardDeviation);
 }
Exemplo n.º 27
0
        /// <summary>
        /// Get settings
        /// </summary>
        /// <returns></returns>
        private Settings createSettings()
        {
            var controller = this.dataController;
            var stats = new Statistics.Statistics(controller.Records);
            var speedWayStats = new Statistics.Statistics(this.dataController.Circuits);

            //settings
            var setting = new Settings();
            setting.Consumption = controller.Consumption.ToString();
            setting.Currency = controller.Currency.ToString();
            setting.Distance = controller.Distance.ToString();
            setting.Unit = controller.Unit.ToString();
            setting.Fills = controller.Fills.Count;
            setting.Maintenances = controller.Maintenances.Count;
            setting.Repairs = controller.Repairs.Count;
            setting.Videos = controller.Videos.Count;
            setting.Pictures = controller.Pictures.Count;
            setting.Paths = stats.getRoutes().Count;
            setting.SummaryFuelPrice = stats.getFuelStats().PaidForFuel(controller.Currency);
            setting.SummaryRepairPrice = stats.getRepairStats().PaidForRepairs(controller.Currency);
            setting.Liters = stats.getFuelStats().TotalRefueled();
            setting.Circuits = controller.Circuits.Times.Circuits.Count;
            setting.Times = speedWayStats.getGroupedCircuits().Count;
            return setting;
        }
Exemplo n.º 28
0
        public void If_Statistics_Is_CreatedWith_RemoveOutliersFalse_ShouldHaveNoOutliers()
        {
            IStatistics stats = new Statistics.Statistics(_outlierVehiclesList.ToList(), false);

            Assert.AreEqual(0, stats.OutlierVehicles.Count);
        }
Exemplo n.º 29
0
 /// <summary>
 /// Stats
 /// </summary>
 public Stats(Data dataController, CoPilot.View.CoPilot copilot)
 {
     //data controller
     this.DataController = dataController;
     this.DataController.PropertyChanged += propertyChangedEvent;
     //menu controller
     this.MenuController = new Menu();
     this.MenuController.Context = MenuContext.Statistics;
     //copilot
     this.CoPilot = copilot;
     //stats
     this.baseStats = new Statistics.Statistics(DataController.Records);
     this.speedwayStats = new Statistics.Statistics(DataController.Circuits);
 }
Exemplo n.º 30
0
 public void Test_HighestPrice_With_Ourliers()
 {
     IStatistics stats = new Statistics.Statistics(_outlierVehiclesList.ToList(), false);
     Assert.AreEqual(15, stats.HighestPrice);
 }
Exemplo n.º 31
0
        /// <summary>
        /// Create paths
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        private object createPath(DateTime from, DateTime to, int page)
        {
            var stat = new Statistics.Statistics(this.dataController.Records);
            var states = stat.getStateStats(from, to).getStates();

            var route = new Statistics.Data.RouteStats(stat, from, states);
            route.States = states;

            return route;
        }
Exemplo n.º 32
0
 public void Test_MeanPrice()
 {
     IStatistics stats = new Statistics.Statistics(_depreciationVehicles.ToList());
     Assert.AreEqual(85000, stats.MeanPrice);
 }
Exemplo n.º 33
0
 /// <summary>
 /// Create path list
 /// </summary>
 /// <returns></returns>
 private object createPathList()
 {
     var stat = new Statistics.Statistics(this.dataController.Records);
     return stat.getRoutes();
 }
Exemplo n.º 34
0
        internal BattleLosses(IEnumerable <Losses> playerLosses, IEnumerable <Losses> enemyLosses, Statistics.Statistics statistics)
        {
            m_playerLosses = playerLosses;
            m_enemyLosses  = enemyLosses;

            if (statistics != null)
            {
                m_minLossesRecoveryTime = statistics.MinLossesRecoveryTime;
                m_maxLossesRecoveryTime = statistics.MaxLossesRecoveryTime;
                m_avgLossesRecoveryTime = statistics.AvgLossesRecoveryTime;

                m_minBattleTime        = statistics.MinBattleTime;
                m_minBattleTimeChance  = statistics.MinBattleTimeChance;
                m_maxBattleTime        = statistics.MaxBattleTime;
                m_maxBattleTimeChance  = statistics.MaxBattleTimeChance;
                m_avgBattleTime        = statistics.AvgBattleTime;
                m_battleTimeStatistics = statistics.BattleTimeStatistics;

                m_losesPrice = statistics.LosesPrice;
            }
        }
Exemplo n.º 35
0
        /// <summary>
        /// Create times
        /// </summary>
        /// <param name="from"></param>
        /// <param name="to"></param>
        /// <param name="page"></param>
        /// <returns></returns>
        private object createTimes(int from, int to, int page)
        {
            var stats = new Statistics.Statistics(this.dataController.Circuits);
            var grouped = stats.getGroupedCircuits();
            var total = grouped.Count();

            try
            {
                if (from == -1 && to == -1)
                {
                    var take = page == -1 ? total : this.pageSize;
                    var skip = page == -1 ? 0 : this.pageSize * page;
                    return grouped.Skip(skip).Take(take).ToArray();
                }
                else
                {
                    from = from == -1 ? 0 : from;
                    to = to == -1 ? total - from : to - from;
                    return grouped.Skip(from).Take(to).ToArray();
                }
            }
            catch
            {
                return new Statistics.Utils.CircuitGroup[0];
            }
        }