Exemple #1
0
        public void Visualize(IEnumerable <RateAtDate> data, int numPoints)
        {
            const string LinearFile = "Lin.csv";
            const string CosineFile = "Cos.csv";
            const string CubicFile  = "Cub.csv";

            DateTime start = data.First().Date;

            LinearInterpolation lin = new LinearInterpolation(data);
            CosineInterpolation cos = new CosineInterpolation(data);
            CubicInterpolation  cub = new CubicInterpolation(data);

            using (StreamWriter linsw = new StreamWriter(fileRoot + LinearFile))
                using (StreamWriter cossw = new StreamWriter(fileRoot + CosineFile))
                    using (StreamWriter cubsw = new StreamWriter(fileRoot + CubicFile))
                    {
                        double increment = ((double)(data.Last().Date - data.First().Date).TotalMilliseconds) / (double)numPoints;
                        for (int i = 0; i < numPoints; i++)
                        {
                            DateTime writeDate = start + TimeSpan.FromMilliseconds((i * increment));
                            linsw.WriteLine(lin.GetRate(writeDate));
                            cossw.WriteLine(cos.GetRate(writeDate));
                            cubsw.WriteLine(cub.GetRate(writeDate));
                        }
                    }

            ShowData(fileRoot + LinearFile);
            ShowData(fileRoot + CosineFile);
            ShowData(fileRoot + CubicFile);
        }