# java standard deviation

**Question description**

/* * Write an application that creates an int array of * size 1000000, assigns a random integer between + and * -10000 to each and computes the mean and * standard deviation as decimal values. * Print those to the user. * * Mean: * (sum of all values) / (number of values) * * Standard Deviation: * The square root of * the average of * the squared differences of * each value from the mean. * */ public class StandardDeviation{ public static void main(String[] args){ int[] values = new int[1000000]; final int MIN_VALUE = -10000; final int MAX_VALUE = 10000; double valuesSum = 0.0, sqDiffSum = 0.0, mean, standardDev; // Set each element in values equal to a random // integer between MIN_VALUE and MAX_VALUE // Compute the sum of all elements in values, // such the sum gets stored in valuesSum // Compute the mean (average) of all values // and store in the variable mean // Compute the sum of the squared differences // of each value from the mean. Conceptually, // this looks like: // (first - mean)^2 + // (second - mean)^2 + // (third - mean)^2 + // ....... + // (last - mean)^2 + // Compute the standard deviation, which is the // square root of the result of dividing the sum of // squared differences by the total number of values System.out.println("Mean: " + mean); System.out.println("Standard Deviation: " + standardDev); } private static int randomIntInRange(int low, int high) { int multiplier = high - (low - 1); return (int)(Math.random() * multiplier) + low; } }output

Mean: -3.77569 Standard Deviation: 5779.955079273639

## Tutor Answer

**Quality**

**Communication**

**On Time**

**Value**

Brown University

1271 Tutors

California Institute of Technology

2131 Tutors

Carnegie Mellon University

982 Tutors

Columbia University

1256 Tutors

Dartmouth University

2113 Tutors

Emory University

2279 Tutors

Harvard University

599 Tutors

Massachusetts Institute of Technology

2319 Tutors

New York University

1645 Tutors

Notre Dam University

1911 Tutors

Oklahoma University

2122 Tutors

Pennsylvania State University

932 Tutors

Princeton University

1211 Tutors

Stanford University

983 Tutors

University of California

1282 Tutors

Oxford University

123 Tutors

Yale University

2325 Tutors