Random r = new Random();
int[] datas = new int[10000];
for(int i = 0; i < 10000; i++)
{
datas.SetValue(r.Next(500, 3000), i);
}
// 합계
int sum = 0;
for(int i = 0; i < 10000; i++)
{
sum += datas[i];
}
// 평균
double m = sum / 10000;
// 분산
double b = 0;
// 표준편차
double s = 0;
for(int i = 0; i < 10000; i++)
{
b += Math.Pow(Math .Abs(Math.Abs(datas[i] - m)), 2);
}
b = b / 10000;
s = Math.Sqrt(b);
SeriesList sl = new SeriesList();
sl.AxisFactor.YAxis.Decimalpoint = 1;
sl.AxisFactor.XAxis.DataType = AxisDataType.Number;
sl.GraphArea.Grid.ZeroLineColor = Color.LightGray;
sl.AxisFactor.BackColor = Color.White;
sl.GraphArea.Grid.IsBackGridColor = false;
sl.SeriesCollection.Add( new Series ());
sl.SeriesCollection[0].Points.Width = 0;
for(int i = (int)(m - 5000); i < m + 5000; i++)
{
//double x = datas[i];
double y = Math .Exp((-1) * (Math.Pow( Math.Abs(i - m), 2)) / (2 * Math.Pow(s, 2))); //(1 / (Math.Sqrt(2 * Math.PI) * s) ) *
SeriesItem item = new SeriesItem();
item.XValue = i;
item.YValue = y;
if (i == 2500)
{
item.Balloon = new Balloon ();
item.Balloon.Label.Text = "표준편차 : " + s.ToString();
}
sl.SeriesCollection[0].items.Add(item);
}
// 평균
AxisTick TKM = new AxisTick(m);
TKM.IsShowGridLine = true;
//TKM.Label.Text = m.ToString();
sl.AxisFactor.XAxis.ExtraTicks.Add(TKM);
this.hHippoChart1.Designer.InnerBackColor = Color.WhiteSmoke;
this.hHippoChart1.DrawChart(sl);
Dim r As New. Random()
Dim datas As Integer() = New Integer(9999) {}
For i As Integer = 0 To 9999
datas.SetValue(r.[Next](500, 3000), i)
Next
` 합계
Dim sum As Integer = 0
For i As Integer = 0 To 9999
sum += datas(i)
Next
` 평균
Dim m As Double = sum / 10000
` 분산
Dim b As Double = 0
` 표준편차
Dim s As Double = 0
For i As Integer = 0 To 9999
b += Math.Pow(Math.Abs(Math.Abs(datas(i) - m)), 2)
Next
b = b / 10000
s = Math.Sqrt(b)
Dim sl As New. SeriesList()
sl.AxisFactor.YAxis.Decimalpoint = 1
sl.AxisFactor.XAxis.DataType = AxisDataType.Number
sl.GraphArea.Grid.ZeroLineColor = Color.LightGray
sl.AxisFactor.BackColor = Color.White
sl.GraphArea.Grid.IsBackGridColor = False
sl.SeriesCollection.Add(New Series())
sl.SeriesCollection(0).Points.Width = 0
For i As Integer = CInt(m - 5000) To m + 4999
`double x = datas[i];
Dim y As Double = Math.Exp((-1) * (Math.Pow(Math.Abs(i - m), 2)) / (2 * Math.Pow(s, 2)))
`(1 / (Math.Sqrt(2 * Math.PI) * s) ) *
Dim item As New. SeriesItem()
item.XValue = i
item.YValue = y
If i = 2500 Then
item.Balloon = New Balloon()
item.Balloon.Label.Text = "표준편차 : " + s.ToString()
End If
sl.SeriesCollection(0).items.Add(item)
Next
` 평균
Dim TKM As New. AxisTick(m)
TKM.IsShowGridLine = True
`TKM.Label.Text = m.ToString();
sl.AxisFactor.XAxis.ExtraTicks.Add(TKM)
Me.hHippoChart1.Designer.InnerBackColor = Color.WhiteSmoke
Me.hHippoChart1.DrawChart(sl)