Results 1 to 8 of 8

Thread: [RESOLVED] Standard Deviation Issues

Threaded View

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Oct 2009
    Posts
    27

    Resolved [RESOLVED] Standard Deviation Issues

    Alright so im making a program that reads a text file that lists a persons name then next line has the persons test score. I am trying to calculate the standard deviation for any given amount of people. I got the mean calculation to work, but I can't seem to see why my standard deviation calculation doesnt work. Please check it out for me!

    Code:
    Dim name As String, total, x, n as Double
    Dim sr As IO.StreamReader = IO.File.OpenText("scores.txt")
    Dim count As Double = 0
    Do While sr.peek <> -1
         name = sr.ReadLine
         total += CDbl(sr.ReadLine)
         count += 1
    Loop
    Do While sr.Peek <> -1
         name = sr.ReadLine
         x = CDbl(sr.ReadLine)
         n += ((x - total) ^ 2)
    Loop
    ListBoxdata.items.add("Mean = " & Math.Round(total/count, 1))
    ListBoxdata.items.add("Standard Deviation = " & Math.Sqrt(n / count))
    end sub
    Standard Deviation Formula = http://en.wikipedia.org/wiki/Standard_deviation
    Last edited by mxzx440; Nov 17th, 2009 at 11:31 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width