I need to make a java app that computes and prints mean and standard deviation for a list of integers x1 through xn. If anyone can help out, point me in the right direction even, that would be awesome, I get intimidated by these math problems when it comes to programming.

N will be inputed by the user
Ints should be randomly generated, stored in an array

Mean and std dev should be floating points

mean = (E(i = 1, n) x(i)) / n
E(i = 1, n) x(i) is read as the summation from i equals 1 to n of x subscript i

sd = sqrt((E(i = 1, n) (x(i) - mean) ^ 2) / (n - 1))

9 Years
Discussion Span
Last Post by Fuze

These are the pieces I can think of to use, can anyone point me in the right direction?

int[] array = new int[n];
int n = generator.nextInt(100) + 1;
cmd = scan.nextInt();
double mean = sum / NumAmount;
SUM((x[i] - mean(x)) ^2) / (n-1);
public static double sqrt(double a);

Sorry if my response doesn't help much, the equation above was somewhat hard for me to understand.

But to handle the summation part of the equation, the best option will be to use a 'for' loop to handle all values between 'i' through 'n'.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.