Pure Programmer
Blue Matrix


Cluster Map

Project: Sample Mean

To calculate the [[Sample_mean_and_covariance|mean]] (or average)

is the sum of a number of random samples divided by the number in the sample. Write a program that computes the mean of 10 random floating point values in the interval [0,1). This closed/open [[Interval_(mathematics)|interval]] notation means 0 is in the range but 1 is not. Print the mean to four decimal places. Run the program multiple times to confirm that you get different results each time.

Output
$ javac -Xlint SampleMean.java $ java -ea SampleMean Sample mean: 0.5087 $ javac -Xlint SampleMean.java $ java -ea SampleMean Sample mean: 0.4538 $ javac -Xlint SampleMean.java $ java -ea SampleMean Sample mean: 0.5753

Solution