Need help on standard deviation

Dell Inspiron 546 mini-tower desktop - c...
April 18, 2011 at 03:11:40
Specs: Windows 7, 1.5GB
To be honest its my homework. I am stuck at the calculation part.
I don't know how to write the standard deviation.


#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;

const int MAX = 100;
const char MaxFileName = 11;

int main()
{
char response='y';
int counter, recordcount;
float number, next;
float array [MAX];
ifstream fin;


char infile [MaxFileName +1];

while (response == 'y' || response == 'Y')
{
cout << "Enter the filename of the data: ";
cin >> infile;

fin.open (infile);
if (fin.fail())
{
cout << "Opening file failed.\n";
exit(1);
}
cout<<"Open successful.\n";

counter = 0;
while (fin >> number && counter < MAX)
{
array [counter] = number;
counter ++;
}

recordcount = counter;
cout << "The data are: \n";

for (counter = 0; counter < recordcount; counter ++)
{
cout << array [counter] << " ";
}

cout<<endl<<"Enter 'y' to continue: ";
cin>>response;
}
system("pause");

return 0;
}


See More: Need help on standard deviation

Report •


#1
April 18, 2011 at 04:19:12

Report •

#2
April 18, 2011 at 04:41:30
My task is:
Calculate the standard deviation from a given set of data in a text file. Read and store the data in an array. Create user-defined functions to implement the input and standard deviation calculation separately.

http://en.wikipedia.org/wiki/Standa... random variable:
using summation notation


Do not use any pre-defined functions n the standard function library to determine standard deviation or average. Use constant to identify fixed percentages and value used.

Example:

Enter the name of the data file
census1.txt

The data are:
1 4 7 5 6 9 15 11 8 2

The Standard Deviation is: 4
Y or y continues, any other character quits -> y

Enter the name of the data file
census2.txt

The data are:
10 19 11 25 13 15 8 17 2 7

The Standard Deviation is: 6.3
Y or y continues, any other character quits -> q


Report •

#3
April 18, 2011 at 21:53:59
I don't know how to put in the standard deviation calculation and my input file repetition doesn't work.

http://upload.wikimedia.org/math/e/...

That is my formula for the code.
The u thing is actually x(bar).
Note: N = Total count of x values. Assume typical sample size 30.


Report •

Related Solutions

#4
April 19, 2011 at 16:56:58
The linked Wikipedia article has a friendlier definition, which is surprising for Wikipedia math articles.

How To Ask Questions The Smart Way


Report •

#5
April 19, 2011 at 22:03:17
Can someone tell me how to put in the calculation in my code.
I am bad in math. Even if i know the formula I don't know how to put it into the code.

Report •

Ask Question