A Test of Probability

Mar 26th, 2015
KateS
Category:
Computer Science
Price: $10 USD

Question description

Given a function called rand5() which returns a random number between 1 and 5 (inclusive), write a function called rand7() which returns a random number between 1 and 7.

Be careful, the knee-jerk reaction is to call rand5() twice and add up the results to extend the range of rand5(). Do not go down this path since the probabilities are not even for a given output of rand5() + rand5(). The key here is to maintain fair probability at each step of the solution.

Tutor Answer

(Top Tutor) Daniel C.
(997)
School: UCLA
PREMIUM TUTOR

Studypool has helped 1,244,100 students

8 Reviews


Summary
Quality
Communication
On Time
Value
Five Star Tutor
Dec 3rd, 2016
" Outstanding Job!!!! "
SjSurvivor143
Nov 17th, 2016
" Thanks for the help. "
Joemoe
Nov 3rd, 2016
" <3 it, thanks for saving me time. "
tinytim47
Oct 25th, 2016
" Wow this is really good.... didn't expect it. Sweet!!!! "
pmallory
Oct 21st, 2016
" Totally impressed with results!! :-) "
mixedballz
Oct 12th, 2016
" excellent work as always thanks for the help "
kiln82
Sep 28th, 2016
" awesome work thanks "
darnay
Sep 19th, 2016
" The best tutor out there!!!! "
Ask your homework questions. Receive quality answers!

Type your question here (or upload an image)

1828 tutors are online

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