public LemerSequenceModel(LemerGenerator generator, int sequenceLength)
        {
            Array = new double[sequenceLength];
            for (int i = 0; i < Array.Length; i++)
            {
                Array[i] = generator.GetNext();
            }
            ExpectedValue     = Array.Average();
            Dispersion        = 1.0 / (sequenceLength - 1) * Array.Sum(e => Math.Pow(e - ExpectedValue, 2));
            StandardDeviation = Math.Sqrt(Dispersion);

            var tempArray = new List <long>(sequenceLength);

            for (int i = 0; i < sequenceLength; i++)
            {
                tempArray.Add(generator.GetNextLong());
            }
            var tempGen    = new LemerGenerator(generator.A, generator.M, tempArray[100]);
            var tempArray2 = new List <long>(sequenceLength);

            for (int i = 0; i < sequenceLength; i++)
            {
                tempArray2.Add(tempGen.GetNextLong());
            }
            AperiodicLength = tempArray2.FindIndex(1, e => e == tempArray[0]);
            AperiodicLength = AperiodicLength < 0 ? sequenceLength : AperiodicLength;


            var tempIndex = tempArray.FindIndex(e => e == tempArray[sequenceLength - 1]);

            PeriodLength = tempArray.FindIndex(tempIndex + 1, e => e == tempArray[sequenceLength - 1]) - tempIndex;
            PeriodLength = PeriodLength < 0 ? sequenceLength : PeriodLength;
        }
Ejemplo n.º 2
0
        private void StartButtonPressed(object sender, RoutedEventArgs args)
        {
            try
            {
                Int32 aCoeff = ReadInt32(ACoeffInput);
                Int32 mCoeff = ReadInt32(MCoeffInput);
                if (mCoeff == 0)
                {
                    throw new Exception("M coefficient must be a positive value!");
                }
                Int32 startingNumber = ReadInt32(StartingValueInput);

                LemerGenerator lg = new LemerGenerator(aCoeff, mCoeff, startingNumber);
                lg.GenerateRealization();
                IList<Double> lemerRealization = lg.Realization;

                StatisticsResults sr = new StatisticsResults();
                sr.Calculate(lemerRealization);

                OutStatisticsResults(sr);
                DrawHistogram(sr);
            }
            catch (Exception e)
            {
                MessageWindow mw = new MessageWindow(this, e.Message);
                mw.ShowDialog();
                
            }
        }
        private void magicButton_Click(object sender, EventArgs e)
        {
            generator = new LemerGenerator(model.ParamA.Value, model.ParamM.Value, model.ParamR0.Value);
            LemerSequenceModel sequence = new LemerSequenceModel(generator, Length);

            pictureBox.Image = new HinstogramDrawer().DrawHistogram(new Size(pictureBox.Width, pictureBox.Height),
                                                                    sequence.Array, RowCount, 0, 1);
            ShowResult(sequence);
        }
Ejemplo n.º 4
0
        static void Main(string[] args)
        {
            System.Console.WriteLine("aCoeff");
            Int32 aCoeff = ReadInt32();
            System.Console.WriteLine("mCoeff");
            Int32 mCoeff = ReadInt32();
            System.Console.WriteLine("startingNumber");
            Int32 startingNumber = ReadInt32();

            LemerGenerator lg = new LemerGenerator(aCoeff, mCoeff, startingNumber);
            lg.GenerateRealization();
            IList<Double> lemerRealization = lg.Realization;

            StatisticsResults sr = new StatisticsResults();
            sr.Calculate(lemerRealization);

            OutStatitisticsResults(sr);
        }