title: Create Normal Distribution chart (Gauss Bell Curve) vb.net
body: <p>I want to create a bell curve chart for the following data:</p>
  
  <pre><code>+--------------------+
  | SCORE  |Normal Dist|
  |--------------------+
  |   1    |0.02194562 |
  | 1.125  |0.029935308|
  | 1.5    |0.068504536|
  | 1.625  |0.087211517|
  | 1.625  |0.087211517|
  | 1.875  |0.134213698|
  | 2      |0.162242762|
  | 2      |0.162242762|
  | 2.25   |0.225121142|
  | 2.375  |0.258403711|
  | 2.375  |0.258403711|
  | 2.458  |0.280491635|
  | 2.583  |0.312845655|
  |   .    |    .      |
  |   .    |    .      |
  |   .    |    .      |
  </code></pre>
  
  <p>It goes up to 62 values, I'm getting the scores from an sql table, and I'm calculating the Normal Distribution for each value on my asp.net page like this:</p>
  
  <pre><code>Dim dtScores as Datatable = new Datatable
  dtScores = EvaRH.GetScores(strLocation, "04/30/2015", "03/30/2016")
  
  dtScores.DefaultView.Sort = "Score ASC"
  Dim dvScore As DataView = dtScores.DefaultView
  
  Dim intTotal as integer = dtScores.Rows.Count
  Dim dbScore as Double
  
  For i As Integer = 0 To intTotal - 1
     dbScore += Convert.ToDouble(dtScores.Rows(i).Item(0).ToString)
  Next
  
  'Gets the Average of the data (Mean)
  dbScore = dbScore / intTotal
  
  Dim dbStdDev as Double
  
  'This calculate the Standard Deviation
  For i As Integer = 0 To intTotal - 1
      dbStdDev += Math.Pow((Convert.ToDouble(dtScores.Rows(i).Item(0).ToString) - dbScore), 2)
  Next
  dbDesvStd = dbDesvStd / (intTotal)
  dbDesvStd = Math.Sqrt(dbDesvStd)
  
  Dim dtNormal as Datatable = New Datatable
  dtNormal.Columns.Add(New DataColumn("Score", GetType(Double)))
  dtNormal.Columns.Add(New DataColumn("Normal Dist", GetType(Double)))
  
  Dim dr as DataRow   
  
  'Here I calculate the Normal Distribution of each point
  For Each Row As DataRowView In dvScore
      dr = dtNormal.NewRow()
      dr("Score") = Convert.ToDouble(Row.Item(0).ToString)
  Math.Pow(((Convert.ToDouble(Row.Item(0).ToString)) - dbScore), 2)
  
  
          dbNormal = (1 / (dbDesvStd * (Math.Sqrt(2 * Math.PI)))) * (Math.Exp(-(Math.Pow(((Convert.ToDouble(Row.Item(0).ToString)) - dbPromedio), 2) / (2 * Math.Pow(dbDesvStd, 2)))))
          dr("Normal Dist") = dbNormal
          dtNormal.Rows.Add(dr)
      Next
  
  
      Dim XPointMember As String() = New String(dtNormal.Rows.Count - 1) {}
      Dim YPointMember As Double() = New Double(dtNormal.Rows.Count - 1) {}
      For int As Integer = 0 To dtNormal.Rows.Count - 1
  
          XPointMember(int) = dtNormal.Rows(int).Item(0).ToString
          YPointMember(int) = Convert.ToDouble(dtNormal.Rows(int).Item(1))
  
      Next
      'binding chart control  
  
      chBell.Series(0).Points.DataBindXY(XPointMember, YPointMember)
  
      chBell.Series(0).ChartType = SeriesChartType.Spline
  </code></pre>
  
  <p>With this I get a chart like this one:
  <a href="https://i.stack.imgur.com/TA3Sx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TA3Sx.png" alt="enter image description here"></a></p>
  
  <p>As you can see its not the bell curve.
  I have made this same process in excel and I did got the right bell curve, I have the same Mean, StdDev, and NormDist values, but I dont know why I cant get the same chart on vb.net, Any help would be appreciated.</p>
  
  <p>This is the chart that I get from Excel
  <a href="https://i.stack.imgur.com/M29oZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M29oZ.png" alt="enter image description here"></a></p>
  
  <p>This <a href="https://stackoverflow.com/questions/20961511/how-to-make-a-bell-curve-in-vb-net">Question</a> gave me an idea to do the previous code.</p>
  
  <p><a href="https://www.dropbox.com/s/bs07prev0212kwr/Bell%20chart.xlsx?dl=0" rel="nofollow noreferrer">Here</a> is the excel sheet with the complete data and charts.</p>