我想我可以通过制作一个返回平均值抽样分布结果的小程序(带有标准误差)来使数据统计的生活变得更轻松。它成功地完成了这部分,但为了尝试使用我在此处找到的公式返回 z 分数,它返回-1#IND
. 我对该公式的解释是:
((1 / (sqrt(2 * pi) * stdev)) * pow(e, (normalpow))
在哪里
double normalpow = -0.5 * ((mean - popmean) * (mean-popmean) / stdev)
我做了更多调查,发现无论如何都(mean - popmean) * (mean - popmean)
在评估。0
我怎样才能解决这个normalpow
评估到的问题0
。
#include <iostream>
#include <string>
#include <sstream>
#include <math.h>
using namespace std;
double number ;
double mean ;
double popmean ;
double stdev ;
double square = 2;
double e = 2.71828182845904523536;
double pi = 3.14159265358979323846;
double normalpow = -0.5*((mean-popmean)*(mean-popmean)/stdev);
int main ()
{
string continuer ;
do
{
cout << "Enter Sample Mean: " << endl;
cin >> mean;
cout << "Enter Population Mean: " << endl;
cin >> popmean;
cout << "Enter Standard Deviation: " << endl;
cin >> stdev;
cout << "Enter Sample Size: " << endl;
cin >> number;
if (stdev == 0)
cout << ((mean-popmean)/(number))<< endl;
else
{
cout << ((mean-popmean)/((stdev)/(sqrt(number))))<< endl;
cout << ((1/(sqrt(2*pi)*stdev))*pow(e, (normalpow)))<< endl;
}
cout << "If you want to continue, Press Y" << endl ;
cin >> continuer;
} while (continuer == "Y" || continuer == "y") ;
return 0;
}