//Define a function that takes a partially filled array of numbers
//as its argument and returns the standard deviation of the numbers in
//the partially filled array. Since the partially filled array requires
//two arguments, the function will have two formal parameters: an array
//parameter and a formal parameter of type int that gives the number of the
//array positions used. The numbers in the array will be double. The task is
//the standard deviation of a list of numbers is a measure of how much the number
//deviate from the average. If the standard deviation is small the numbers are
//clustered close to the average and if the standard deviation is large, the numbers
// are scattered far from the average. The standard deviation, S,of a list of N
//numbers x, is defined as follows: where x is the average of N.

S = think square root symbol, N, sum(x, -x)to second power, i = 1, over N

I have not started the code yet as I have no real idea of what this wants .... if it could be explained or shown to me of what is required then I can start building code for this .... does anyone understand this enough to help me...

Recommended Answers

All 5 Replies

// ... the function will have two formal parameters: an array
//parameter and a formal parameter of type int that gives the number of the
//array positions used. The numbers in the array will be double. ...

Is
double func ( double *array, int numElements );

The standard deviaion is the square root of the sum of the variations from the average squared divided by the number of elements in the population.
numbers is an array of type double
N = number of elements ine numbers
x = average = sum of all elements in numbers divided by N
variance = numbers - x
variance squared = variance * variance, or you can use some other technique to to get this
sum = sum of variances squared
S= standard deviation = square root of (sum/N)

in C/C++ the square root of a number can be calculated using the pow() using 0.5 as the second parameter.

in C/C++ the square root of a number can be calculated using the pow() using 0.5 as the second parameter.

Isn't sqrt() available?

I apologize about leaving that option out. When thinking about a number to the n power I just automatically think of pow(). Duh...

S= standard deviation = square root of (sum/N)

FWIW, and I don't think it affects it too much for OP's purposes, it should be N-1 instead of N since it's a sample from a population (unless you have enough data to justify a population). Not knowing the population gives you one less degree of freedom.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.