0

这是我的公式

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

这有什么问题?我无法得到结果。谢谢

如果是这样呢?

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

你能帮助我吗 ?

4

1 回答 1

1

方差定义为分布中每个项与均值的距离平方和除以分布中项的数量。

你需要variansi除以lstData.Items.Count

于 2013-04-04T04:54:21.057 回答