Exemple #1
0
        public bivariate_distribution(IntervalList x_interval, IntervalList y_interval)
        {
            m_x_intervals = x_interval;
            m_y_intervals = y_interval;

            m_frequency          = new int[m_x_intervals.m_count + 1, m_y_intervals.m_count + 1];
            m_relative_frequency = new double[m_x_intervals.m_count + 1, m_y_intervals.m_count + 1];
        }
Exemple #2
0
        public override void draw(Graphics G, IntervalList interval)
        {
            Pen   blackPen  = new Pen(Color.Black, 1);
            Brush blueBrush = new SolidBrush(Color.BlueViolet);
            Brush fontBrush = new SolidBrush(Color.Black);
            Pen   redPen    = new Pen(Color.Red, 2);

            float font_size = 9;
            Font  font      = new Font(FontFamily.GenericMonospace, font_size, FontStyle.Bold);

            G.DrawRectangle(blackPen, m_rectangle);


            blackPen.Width = 2f;

            //AXIS
            G.DrawLine(blackPen, m_vertical_axis.m_A, m_vertical_axis.m_B);
            G.DrawLine(blackPen, m_horizontal_axis.m_A, m_horizontal_axis.m_B);
            G.DrawString(interval.m_name, font, fontBrush, m_horizontal_axis.m_B.X - (m_horizontal_axis.m_B.X - m_horizontal_axis.m_A.X) / 2, m_horizontal_axis.m_A.Y + m_pad / 3);

            //BARS

            int n_bars     = interval.m_count;
            int max_height = Math.Abs(m_vertical_axis.m_A.Y - m_vertical_axis.m_B.Y);
            int width      = Math.Abs(m_horizontal_axis.m_A.X - m_horizontal_axis.m_B.X) / n_bars;

            for (int i = 0; i < n_bars; ++i)
            {
                float height = interval.m_intervals[i].m_density * max_height / interval.m_max_density;

                int x = m_vertical_axis.m_A.X + width * i;
                int y = m_vertical_axis.m_A.Y + (max_height - (int)height);
                G.FillRectangle(blueBrush, new Rectangle(x, y, width, (int)height));

                double x_mean = (interval.m_intervals[i].m_mean - (double)interval.m_intervals[i].m_starting_point) * width / interval.m_intervals[i].m_size;

                G.DrawLine(redPen, (float)(x + x_mean), m_vertical_axis.m_A.Y, (float)(x + x_mean), m_vertical_axis.m_B.Y);
            }



            blackPen.Dispose();
            blueBrush.Dispose();
            redPen.Dispose();
            fontBrush.Dispose();
        }
Exemple #3
0
        public void process_data(int x_intervals, int y_intervals)
        {
            m_x_mean      = m_points[0].m_x;
            m_x_min_value = m_points[0].m_x;
            m_x_max_value = m_points[0].m_x;

            m_y_mean      = m_points[0].m_y;
            m_y_min_value = m_points[0].m_y;
            m_y_max_value = m_points[0].m_y;

            for (int i = 1; i < m_count; ++i)
            {
                m_x_mean += Math.Round((double)(m_points[i].m_x - m_x_mean) / (i + 1), 2);
                m_y_mean += Math.Round((double)(m_points[i].m_y - m_y_mean) / (i + 1), 2);

                m_x_min_value = m_points[i].m_x < m_x_min_value ? m_points[i].m_x : m_x_min_value;
                m_x_max_value = m_points[i].m_x > m_x_max_value ? m_points[i].m_x : m_x_max_value;

                m_y_min_value = m_points[i].m_y < m_y_min_value ? m_points[i].m_y : m_y_min_value;
                m_y_max_value = m_points[i].m_y > m_y_max_value ? m_points[i].m_y : m_y_max_value;
            }

            m_x_range = m_x_max_value - m_x_min_value;
            m_y_range = m_y_max_value - m_y_min_value;

            m_x_intervals = new IntervalList(x_intervals, m_x_name);
            m_y_intervals = new IntervalList(y_intervals, m_y_name);

            m_x_intervals.populate(m_x_min_value, m_x_max_value);
            m_y_intervals.populate(m_y_min_value, m_y_max_value);

            for (int i = 0; i < m_count; ++i)
            {
                m_x_intervals.check_intervals(m_points[i].m_x);
                m_y_intervals.check_intervals(m_points[i].m_y);
            }
            m_x_intervals.find_densities();
            m_y_intervals.find_densities();
            m_distribution = new bivariate_distribution(m_x_intervals, m_y_intervals);
            m_distribution.compute_frequencies(m_points);
        }
Exemple #4
0
 public virtual void draw(Graphics G, IntervalList interval)
 {
 }