{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

16-page11 - • Since the number of seconds is an integer...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Java’s Random Number Generators • Java has a class called Math.Random , which provides a variety of pseudorandom generators. How might we use these in the cinema cashier simulation? • One method there generates real numbers (doubles) that are uniformly distributed between 0 and 1. Rather than have a customer arrive every 15 seconds like clockwork, we could have them arrive after 10 + 10*rand seconds, so they would be uniform between 10 and 20.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: • Since the number of seconds is an integer, we could “throw a ten-sided die” and add the result to 10 to get the number of seconds. • The more likely realistic choice is a Gaussian (Normal) Distribution. We could get a series of arrival times where they average 15, and 95% are between 10 and 20, by using 15 + 2.5*gaussian. Math.Random has a method for this....
View Full Document

{[ snackBarMessage ]}