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))

Recommended Answers

All 2 Replies

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'.

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.