|
-
Aug 26th, 2001, 02:56 PM
#1
Thread Starter
Lively Member
standard deviation program
please can anyone help me finish this program....going mad!!
im trying to write a program that will compute the MEAN and STANDARD DEVIATION of a sequence of numbers.
sorry :-( still learning vb6 ( and struggling) thanks Tink
private Sub cboData_KeyPress(KeyAscii As integer)
DimValue As Integer
Value = Val(cboData.Text)
If KeyAscii = 13 Then
If Value >=0 Then
cboData.AddItem Value
cboData.Text = ""
Else
msgBox "sorry no negative numbers"
End If
End If
End Sub
private sub cmdMean_click()
Dim Index, sum As integer
IF cboData.ListCount>0 Then
Sum = 0
For Index = 0 To cboDataCount.ListCount - 1
Sum = Sum + Val(cboData.List(Index))
Next Index
lblResult = Sum / (cboData.ListCount)
Else
MsgBox "No Data"
End If
End Sub
Private Sub cmdStdDev_click
????????????????????????????????????????
-
Aug 27th, 2001, 12:05 PM
#2
Frenzied Member
Standard deviation is simple:
Number of elements is n:
sqrt[SIGMA{x^2/n} - m^2]
x is each element in turn; m is the mean.
So your code would look like
' function to get s.d. (have mean stored in the Mean variable)
For I = 1 to cboData.ListCount
Sum = Sum + ((cboData.List(I) ^ 2) / cboData.ListCount)
Next I
Sum = Sum - (Mean^2)
SD = Sqrt(Sum)
-
Aug 28th, 2001, 01:23 PM
#3
Frenzied Member
Tried to email but your username wasn't found... anyway.
My bad. Replace it with this line:
sum=sum+((Val(cboData.List(I))^2)/cboData.ListCount)
That should help.
-
Aug 28th, 2001, 02:02 PM
#4
Hey Tink, I got some table lookups and Fishers_exact for getting p-values and other stuff.
You want it?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|