以文本方式查看主题
- Foxtable(狐表) (http://foxtable.com/bbs/index.asp)
-- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2)
---- [求助]标准差的计算 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=50013)
|
-- 作者:有点甜
-- 发布时间:2014/4/27 22:28:00
--
可以参考这里
http://www.foxtable.com/help/topics/0545.htm
|
-- 作者:有点甜
-- 发布时间:2014/4/27 22:29:00
--
特殊计算,看这里,希望没有记错 标准差公式
For Each r As Row In Tables("表A").Rows Dim datas(9) As Integer For i As Integer = 0 To datas.length - 1 datas(i) = 2 ^ (r("log" & i)) Next \'求平均值 Dim x As Double For i As Integer = 0 To datas.length - 1 x = x + datas(i) / datas.length Next \'求平方差 Dim s2 As Double For i As Integer = 0 To datas.length - 1 s2 = s2 + (datas(i) - x) ^ 2 Next s2 = s2 / datas.length Dim s As Double = math.Sqrt(s2) r("标准差") = s Next
[此贴子已经被作者于2014-4-27 22:30:02编辑过]
|
-- 作者:有点甜
-- 发布时间:2014/4/27 22:32:00
--
是这样?
For Each r As Row In Tables("表A").Rows Dim datas(9) As Integer For i As Integer = 0 To datas.length - 1 datas(i) = 2 ^ (r("log" & i)) Next \'求平均值 Dim x As Double For i As Integer = 0 To datas.length - 1 x = x + datas(i) Next x = x / datas.length \'求平方差 Dim s2 As Double For i As Integer = 0 To datas.length - 1 s2 = s2 + (datas(i) - x) ^ 2 Next s2 = s2 / datas.length Dim s As Double = math.Sqrt(s2) r("标准差") = s Next
|
-- 作者:有点甜
-- 发布时间:2014/4/28 9:31:00
--
以下是引用liuruihua在2014-4-27 23:25:00的发言:
版主的公式还在理解当中,用实际数据检验,发现结果不对。比例在log8和log9这两列中,log8有3个,表示有3个2的8次方,即256,256,256这三个数;log9列有1个,表示有1个2的9次方数,即512。这四个数的标准差为128,套用版主的公式,结果为6.8922。不知我举例说得够不够明晰,请再看看。
哦,理解错了,那就改一下这里。
For Each r As Row In Tables("表A").Rows Dim length As Integer For i As Integer = 0 To 9 length += r("log" & i) Next
Dim datas(length-1) As Integer
Dim idx As Integer = 0 For i As Integer = 0 To 9 For j As Integer = 1 To r("log" & i) datas(idx) = 2 ^ i
idx += 1 Next Next
\'求平均值 Dim x As Double For i As Integer = 0 To datas.length - 1 x = x + datas(i) Next x = x / length
\'求平方差 Dim s2 As Double = 0 For i As Integer = 0 To datas.length - 1 s2 = s2 + (datas(i) - x) ^ 2 Next s2 = s2 / length
Dim s As Double = math.Sqrt(s2) r("标准差") = s Next
[此贴子已经被作者于2014-4-28 9:57:04编辑过]
|
-- 作者:有点甜
-- 发布时间:2014/4/28 9:59:00
--
回复楼主,重新弄了一下。看6楼。发觉你给的数据不正确吧?
256,256,256,512的标准差,是128?怎么将计算的?难道我的公式记错了,伤不起啊不要欺负我小学毕业
[此贴子已经被作者于2014-4-28 10:00:35编辑过]
|
-- 作者:有点甜
-- 发布时间:2014/4/28 11:07:00
--
标准差应该是 =STDEVP(256,256,256,512) 吧?
http://zhidao.baidu.com/link?url=b1MRs4uKxrOBzQc9F0yiiyMhCu5yvIR-euVgVOTH7iMOuerDm2TygpHvCEIyVkJNWA1__ekNaOnr22DWBVbUtq
|
-- 作者:有点甜
-- 发布时间:2014/4/28 14:30:00
--
回复10楼,那就这样做
For Each r As Row In Tables("表A").Rows Dim length As Integer For i As Integer = 0 To 9 length += r("log" & i) Next
Dim datas(length-1) As Integer
Dim idx As Integer = 0 For i As Integer = 0 To 9 For j As Integer = 1 To r("log" & i) datas(idx) = 2 ^ i idx += 1 Next Next
\'求平均值 Dim x As Double For i As Integer = 0 To datas.length - 1 x = x + datas(i) Next x = x / datas.length
\'求平方差 Dim s2 As Double = 0 For i As Integer = 0 To datas.length - 1 s2 = s2 + (datas(i) - x) ^ 2 Next s2 = s2 / (datas.length -1)
Dim s As Double = math.Sqrt(s2) r("标准差") = s Next
|
-- 作者:有点甜
-- 发布时间:2014/4/28 22:33:00
--
没有问题吧?你改一下你窗口的代码
If e.DataCol.Name="刷新" Then If e.DataRow("刷新")=True Then Dim r As DataRow = e.DataRow Dim length As Integer For i As Integer = 0 To 9 length += r("log" & i) Next Dim datas(length-1) As Integer Dim idx As Integer = 0 For i As Integer = 0 To 9 For j As Integer = 1 To r("log" & i) datas(idx) = 2 ^ i idx += 1 Next Next \'求平均值 Dim x As Double For i As Integer = 0 To datas.length - 1 x = x + datas(i) Next x = x / datas.length \'求平方差 Dim s2 As Double = 0 For i As Integer = 0 To datas.length - 1 s2 = s2 + (datas(i) - x) ^ 2 Next s2 = s2 / (datas.length -1) Dim s As Double = math.Sqrt(s2) r("标准差") = s End If End If
|