Skip to content

Instantly share code, notes, and snippets.

@antiface
Last active February 14, 2021 14:36
Generate array of n random real numbers between 0 and 1 and print the mean value (average) of the values of the array.
n = 1000
a = Array.new(n) { |_| rand }
puts a.sum(0.0) / a.size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment