Exemplo n.º 1
0
        private UrnPolya.Urn selected_urn_process()
        {
            UrnPolya.Urn a = null;
            switch (this.selectSimulationType)
            {
            case "Random Urn":
                if (this.probabilityMatrix == null)
                {
                    MessageBox.Show("Please first insert the probabilityMatrix");
                    return(a);
                }
                a = new UrnPolya.Urn_probability(this.repositionMatrix, this.Colorsnumbers, this.probabilityMatrix);
                break;

            case "Memory Lapse":
                if (this.probabilities == null)
                {
                    MessageBox.Show("Please first insert the probabilities");
                    return(a);
                }
                a = new UrnPolya.Urn_memory_lapse(this.repositionMatrix, this.Colorsnumbers, this.memorylapse_probability[0], this.probabilities);
                break;

            default:
                a = new UrnPolya.Urn(this.repositionMatrix, this.Colorsnumbers);
                break;
            }
            return(a);
        }
Exemplo n.º 2
0
        public static double[,] colors_AvarageRatio(Urn u, int steps, int iterations, BackgroundWorker b)
        {
            double[,] result = new double[iterations, u.totalcolorsnumber];
            int valor_pos = u.getTotalColorsNumber();

            for (int i = 0; i < iterations; i++)
            {
                u.simulation(steps);
                for (int color = 0; color < valor_pos; color++)
                {
                    result[i, color] = u.getProportionOfBall(color);
                }


                u.reset();
                b.ReportProgress((i + 1 * 100) / iterations);
            }


            return(result);
        }
Exemplo n.º 3
0
        public void printColorRunChart(BackgroundWorker b)
        {
            if (!int.TryParse(this.tb_Steps.Text, out this.steps))
            {
                MessageBox.Show("Please insert a valid value to the steps box");
                b.CancelAsync();
                return;
            }
            UrnPolya.Urn a = this.selected_urn_process();
            if (a == null)
            {
                return;
            }
            a.simulation(steps, this.backgroundWorker2);
            if (a == null)
            {
                return;
            }
            double[,] result = a.getProportions();

            F_grafico f_grafico = new F_grafico(result, this.ColorsUsedList, steps + 1);

            f_grafico.ShowDialog();
        }
Exemplo n.º 4
0
        public void PrintChart(BackgroundWorker b)
        {
            if (!int.TryParse(this.tb_Steps.Text, out this.steps))
            {
                MessageBox.Show("Please insert a valid value to the steps box");
                b.CancelAsync();
                return;
            }
            if (!int.TryParse(this.tb_simulations.Text, out this.simulations))
            {
                MessageBox.Show("Please insert a valid value to the simulations box");
                b.CancelAsync();
                return;
            }
            UrnPolya.Urn a = this.selected_urn_process();
            if (a == null)
            {
                return;
            }
            double[,] r = UrnPolya.Urn.colors_AvarageRatio(a, steps, simulations, b);
            F_grafico f = new F_grafico(r, this.ColorsUsedList);

            f.ShowDialog();
        }