Penambahan standar deviasi
Rumus
standar deviasi (sd)
Sigma=
sigma+sqr(data[i]-rata);
Sd=sqrt(sigma/n);
source code :
#include
<iostream>
#include
<cmath>
using namespace
std;
int main()
{
int data[5];
int byknyadata;
float rata, sd=0;
int jumlah=0;
int sigma=0;
cout << "Silahkan Masukkan
Banyaknya Data :) ";
cin >> byknyadata;
for (int i=0; i<=byknyadata; i++)
{
cout << "Masukkan Data Ke-
["<<i+1<<"] = ";
cin >> data[i];
jumlah = jumlah + data[i];
}
rata=jumlah/byknyadata;
for (int i=0; i<=byknyadata; i++)
{
sigma=sigma + (sqrt(data[i]-rata), 2);
sd=sqrt(sigma/byknyadata);
}
cout << "Jumlah =" <<
jumlah << endl;
cout << "Rata-ratanya ="
<< rata << endl;
cout << "Sigmanya" <<
sigma << endl;
cout << "SDnya" << sd
<< endl;
return 0;
}
Hasil Outputnya :
0 comments:
Post a Comment