Click here for important information about Computing.net.

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;

}

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.txtThe data are:

1 4 7 5 6 9 15 11 8 2The Standard Deviation is: 4

Y or y continues, any other character quits -> yEnter the name of the data file

census2.txtThe data are:

10 19 11 25 13 15 8 17 2 7The Standard Deviation is: 6.3

Y or y continues, any other character quits -> q

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.

The linked Wikipedia article has a friendlier definition, which is surprising for Wikipedia math articles.

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.

Ask Your Question

Weekly Poll

Do you think Intel's new hybrid chips will better compete with Apple/ARM?

Yes (14) | ||

No (14) | ||

I don't know (15) |

Discuss in The Lounge

Poll History