If X[0], X[1],...., X[N - 1] is a list of N numbers and the mean (average) of these numbers is M, then we define their standard deviation to be the square root of the number: ((X[0] - M)^2 + (X[1] - M)^2 + ... + (X[N] - M)^2) / (N - 1)

Use a loop to allow a user to input up to 10 numbers in an array. The user should indicate that he is done by entering 0. Find the mean (average) of these numbers. Then use the mean to find the standard deviation. Your output should diplay both the mean and the standard deviation.

Name your variables as follows:

* the array of numbers should be X[10]
* the first sum should be named Sum1
* the average (mean) should be Mean
* the second sum sould be named Sum2
* the standard deviation should be StandardDeviation
* the number to be input should by the user should be Num
* counters can be named as desired; I like Count, K, or J

If you name your variables as shown above, you will use the following formulas:

* to sum all the numbers to calculate the mean: Sum = Sum + X[K]
* to calculate the average: Mean = Sum / (Count - 1)
* to calculate the first part of the standard deviation, you need to find the difference between each number, X[K], and the mean and then square the results: (X[K] - Mean)^2
* then you need to sum all of these parts up so use this formula in a loop:
Sum2 = Sum2 + (X[K] - Mean)^2
* the standard deviation is calculated with the following formula:
StandardDeviation = Sqrt (Sum2 / (Count -1))

I have no idea what I am doing and after trying, this is what I have come up with:

To compute the expected value - mean - you need to compute
K(X) = ∫x/n dx from 0 to n
K(X) = (1/n)*x^2/2 from 0 to n
K(X) = (1/n)*n^2/2 - (1/n)*0^2
K(X) = (1/n)*n^2/2
K(X) = n/2

Standard deviation is the square root of the variance. To compute the variance, you know that
Var(X) = E(X^2) – E(X)^2
Var(X) = E(X^2) – (n/2)^2
Var(X) = ∫x^2/n dx from 0 to n – (n/2)^2
Var(X) = (1/n)*x^3/3 from 0 to n – (n/2)^2
Var(X) = (1/n)*n^3/3 - (1/n)*0^3/3 – (n/2)^2
Var(X) = (1/n)*n^3/3 – (n/2)^2
Var(X) = n^2/3 – (n/2)^2
Var(X) = n^2/3 – n^2/4
Var(X) = 4n^2/12 – 3n^2/12
Var(X) = (4n^2 – 3n^2)/12
Var(X) = n^2/12

Since the standard deviation is the square root of the variance, then

σ = √(n^2/12) = n/√12 = n/(2√3)

Recommended Answers

All 3 Replies

And? What have you done so far? Realize that Daniweb isn't a homework service, we expect you to put forth a certain measure of effort.

This is what I have come up with so far:

Declare Number as Integer
Declcare Count as Integer
Declare Sum as Integer
Set Count = 0
Set Sums = 0
While Count < 10
Write "Enter a number:"
Input Number
Set Sums [Count + 1] = Sums [Count] + Number
Set Count = Count + 1
End while
While Count >= 0
Write Sums [Count]
Set Count = Count - 1
End while

And from this, what was the result or did you get any error? let us know.

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.