public Image visualizeTables(int width, int height, bool showState = false)
        {
            double currentIndicatorValue = indicator.getIndicator();
            Image  outcomeImg            = OutcomeSamplingVisualizer.visualizeOutcomeSamplingTable(outcomeSamplingTable, width, height / 2, showState ? currentIndicatorValue : double.NaN);
            Image  outcomeCodeImg        = OutcomeSamplingVisualizer.visualizeOutcomeCodeSamplingTable(outcomeCodeSamplingTable, width, height / 2, showState ? currentIndicatorValue : double.NaN);

            Image    o = new Bitmap(width, height);
            Graphics g = Graphics.FromImage(o);

            g.Clear(Color.White);
            g.DrawImage(outcomeImg, 0, 0);
            g.DrawImage(outcomeCodeImg, 0, outcomeImg.Height);
            g.DrawLine(new Pen(Color.Blue, 3), 0, outcomeImg.Height, outcomeImg.Width, outcomeImg.Height);

            return(o);
        }
Example #2
0
        public void OutcomeSamplingTableVisualizer_Test()
        {
            double[]   values   = new double[100];
            double[][] outcomes = new double[100][];
            double[][] prices   = new double[100][];
            DateTime   dt       = DateTime.Now.ToUniversalTime();

            Random z = new Random();

            for (int i = 0; i < values.Length; i++)
            {
                //Min max actual
                double d = z.NextDouble();
                if (d > 0.7)
                {
                    outcomes[i] = new double[] { 1 - z.NextDouble() * 1, 1 + z.NextDouble() * 1, z.NextDouble() * 2 }
                }
                ;
                else
                {
                    outcomes[i] = new double[] { 1 - z.NextDouble() * 0.5, 1 + z.NextDouble() * 0.5, z.NextDouble() * 1 + 0.5 }
                };

                values[i] = d;

                dt        = dt.AddMilliseconds(1000);
                prices[i] = new double[] { Timestamp.dateTimeToMilliseconds(dt), 1, 1, 0 };
            }

            double validOut;

            double[][] samples = IndicatorSampler.sampleValuesOutcome(values, prices, outcomes, 0, 1, out validOut, 10);

            samples[3] = null;

            Image image = OutcomeSamplingVisualizer.visualizeOutcomeSamplingTable(samples, 500, 300, 0.3);
            //ArrayVisualizer.showImg(image); //Todo: Test somehow
        }
    }