コード例 #1
0
ファイル: ChannelChart.cs プロジェクト: KeeeQ/TDC
        public void paintGraph()
        {
            int count = Form1.data[channel].Count();

            if (count < 500)
            {
                return;
            }
            //int i = count > 500 ? count - 500 : 0;
            //List<double> data = Form1.data[channel].GetRange(i, count - i);
            List <double> data       = Form1.data[channel].GetRange(count - 500, 500);
            NormalData    normalData = new NormalData();

            if (count > 500)
            {
                Form1.data[channel].RemoveRange(0, count - 500);
            }
            //求当前数据的平均值 方差 标准差
            normalData.dealWithData(data);
            readyNormalGraphData(normalData);

            //if (basedata != 0)
            //{
            //    readyNormalGraphData(normalData);
            //}
        }
コード例 #2
0
ファイル: ChannelChart.cs プロジェクト: KeeeQ/TDC
        public void data_pant()
        {
            double PowOfE = 0;
            double result = 0;

            NormalData    normalData = new NormalData();
            int           count      = Form1.data[channel].Count();
            int           i          = count > 100 ? count - 100 : 0;
            List <double> data       = Form1.data[channel].GetRange(i, count - i);

            if (count > 100)
            {
                Form1.data[channel].RemoveRange(0, count - 100);
            }
            //求当前数据的平均值 方差 标准差
            normalData.dealWithData(data);

            int    intA = 0;
            string str  = tBx_X_value.Text;
            bool   rst  = Int32.TryParse(str, out intA); // return bool value hint y/n

            if (rst)
            {
                data_pic_X[0] = intA - 0.98;
            }
            else
            {
                data_pic_X[0] = 999982 - 0.98;
            }
            if (normalData.mDataVariance != 0 && normalData.mDataVarianceSqrt != 0)
            {
                PowOfE = -(Math.Pow(Math.Abs(data_pic_X[0] - normalData.mDataMean), 2) / (2 * normalData.mDataVariance));
                result = ((1 / Math.Sqrt(2 * Math.PI)) / normalData.mDataVarianceSqrt) * Math.Pow(Math.E, PowOfE);
            }
            data_pic_Y[0] = result;

            for (int k = 1; k < 102; k++)
            {
                data_pic_X[k] = data_pic_X[k - 1] + 0.02;

                PowOfE = -(Math.Pow(Math.Abs(data_pic_X[k] - normalData.mDataMean), 2) / (2 * normalData.mDataVariance));
                result = ((1 / Math.Sqrt(2 * Math.PI)) / normalData.mDataVarianceSqrt) * Math.Pow(Math.E, PowOfE);

                data_pic_Y[k] = result;
            }

            //*****************画图*****************************************
            chart.Series["概率密度"].Points.Clear();
            for (int pointIndex = 0; pointIndex < 102; pointIndex++)
            {
                chart.Series["概率密度"].Points.AddXY(data_pic_X[pointIndex], data_pic_Y[pointIndex]);
                //chart.Series["概率密度"].Points.c
            }
            // Set fast line chart type
            chart.Series["概率密度"].ChartType = SeriesChartType.FastLine;
        }