如何計算西格瑪的值? |
答題得分者是:fusung
|
jean2004
初階會員 發表:69 回覆:80 積分:39 註冊:2004-12-18 發送簡訊給我 |
|
fusung
中階會員 發表:26 回覆:169 積分:99 註冊:2003-11-25 發送簡訊給我 |
|
jean2004
初階會員 發表:69 回覆:80 積分:39 註冊:2004-12-18 發送簡訊給我 |
感謝fusung大俠的幫助,我現在已經寫出代碼,可是代碼好像有錯誤,比如下面這個:
7.5
5.5
7
7.1
7.5
7
7.6
6.8
7.2
7.6
7.1
7.2
6.8
6.6
7
10.5
7
計算上述值的標準差,計算值為0.943049609661102實際值應為0.972073182646411,不知道我的代碼哪里錯了,我的代碼如下:
#include "math.h"
float iAverage = 0;//平均值μ
float iStandard = 0;//標準差σ
void __fastcall TForm1::Button1Click(TObject *Sender)
{
for(int i = 0; i <= ListBox1->Count-1; i )
{
iAverage = iAverage StrToFloat(ListBox1->Items->Strings[i]);
}
iAverage = iAverage / ListBox1->Count;//算出平均值 for(int i = 0; i <= ListBox1->Count-1; i )
{
iStandard =iStandard pow((StrToFloat(ListBox1->Items->Strings[i]) - iAverage), 2);
}
iStandard = sqrt(iStandard / ListBox1->Count);//算出標準差 Edit1->Text=iStandard;//顯示標準差
}
|
fusung
中階會員 發表:26 回覆:169 積分:99 註冊:2003-11-25 發送簡訊給我 |
哈囉, jean2004 你的程式中我修改下列這一行(紅色字)
iStandard = sqrt(iStandard / ListBox1->Count-1);//算出標準差至於理由你可以參考下列 http://mathworld.wolfram.com/StandardDeviation.html /* The first step toward proving things for yourself is to understand how others have done it before! */
------
The first step toward proving things for yourself is to understand how others have done it before! |
jean2004
初階會員 發表:69 回覆:80 積分:39 註冊:2004-12-18 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |