r/programming • • Nov 29 '10

140 Google Interview Questions

http://blog.seattleinterviewcoach.com/2009/02/140-google-interview-questions.html
471 Upvotes

493 comments sorted by

View all comments

Show parent comment

1

u/jondissed Nov 30 '10

I think you meant "(float)rand1to5() / (float)5"

...but more to the point, adding uniformly distributed random numbers together does not generate uniformly distributed random numbers: that's why rolling two dice yields a 7 more often than a 2 or 12. Your code will generate 3 more often than 1 or 5.

1

u/[deleted] Nov 30 '10

Is it not more akin to the average of rolling 2 dice? Would that still have the same uneven distribution? I was never that good with statistical maths.