Reputation: 1
this is my formula
Else : cmb1.Text = "Rata - Rata"
' hitung rata-rata
rerata = jumlah / lstData.Items.Count
' menampilkan hasil rerata ke text box
txtRerata.Text = rerata.ToString
cmb1.Text = "Variansi" Then
'inisialisasi variabel variansi
Xi = lstData.Items.Item(index:=counter)
' hitung variansi
For counter = 0 To lstData.Items.Count - 1
variansi = (Xi - rerata) * (Xi - rerata)
Next
'menampilkan hasil variansi ke text box
txtVariansi.Text = variansi.ToString
End If
What's the problem with this ? I can't get the result. thanks
What if like this ?
ElseIf cmb1.Text = "Variansi" Then 'inisialisasi variabel variansi Xi = 0
' iterasi sejumlah item dari listbox
For counter = 0 To lstData.Items.Count - 1
Xi = Xi + ((lstData.Items.Item(counter) - rerata) ^ 2)
Next
'kalkulasi variansi dan simpangan baku
variansi = Xi / (txtN.Text - 1)
SD = Math.Sqrt(variansi)
txtSD.Text = SD.ToString
'menampilkan hasil variansi ke text box
txtVariansi.Text = variansi.ToString
can you help me ?
Upvotes: 0
Views: 64
Reputation: 8141
The variance is defined as the sum of the squared distances of each term in the distribution from the mean, divided by the number of terms in the distribution.
You need to divide variansi
by lstData.Items.Count
Upvotes: 1