5 ms·
27?
by relaia 13y ago
27?
- lsconjugate 13y ago39
- solve 13y agofrom random import random sum([(random()*4+1)**3 for x in xrange(1000000)])/1000000 => ~39 Weird.
- bluetech 13y agosum(random.uniform(1, 5)**3 for i in range(10000)) / 10000 Many people don't know that the random module allows to sample from many distributions directly without having to construct your own.
- hollerith 13y agoI like the first version better because everyone knows what infix * and + do.
- saucetenuto 13y agoI like the second version better because it taught me something I didn't know.
- zeckalpha 13y agoI'd say 45, assuming the side length is an integer.
- tzs 13y agoNope. To see where the subtlety lies in this problem, simplify it. Change it to a discrete problem: the side can be 1, 3, or 5, each with probability 1/3. The expected value of the side length is still 3. 1/3 of the cubes have volume 1, 1/3 have volume 27, and 1/3 have volume 125. The expected value of the volume is 51. Think about why it is 51, not 27, and you'll see why it is not 27 for the continuous case. In general, if you have a random variable X, and some function of that random variable, f(X), then it is NOT true that expected value of f(X) = f(expected value of X).
- dropdownmenu 13y ago27 would be correct if each side were independent random variables rather than the cube of a random variable. The way the problem is set up you are suppose to solve for E[a^3] (the third moment of the random variable) rather than (E[a])^3.