2. If an equal likelihood of each of several discrete eventsexists, in a simulation we can generate

Need your ASSIGNMENT done? Use our paper writing service to score better and meet your deadline.


Order a Similar Paper HERE Order a Different Paper HERE

2. If an equal likelihood of each of several discrete eventsexists, in a simulation we can generate a random integer toindicate the choice. For example, in a simulation of a pollen grainmoving in a fluid, suppose at the next time step the grain is justas likely to move in any direction—north, east, south, west, up, ordown—in a three-dimensional (3D) grid. A probability of 1/6 existsfor the grain to move in any of the six directions. With theseequal probabilities, we can generate a uniformly distributedinteger between 1 and 6 to indicate the direction of movement. Suppose in a simulation involving animal behavior, a lab ratpresses a food lever (FOOD = 1) 15% of the time, presses a waterlever (WATER = 2) 20% of the time, and does neither (NEI- THER = 3)the remainder of the time. For the simulation, we consider therange split into three parts, and again generate a uniformlydistributed ran- dom floating-point number from 0.0 to 1.0. If thenumber is less than 0.15, which occurs 15% of the time, we assignFOOD = 1 to the rat’s action. For 20% of the time, the uniformlydistributed random number is greater than or equal to 0.15 and lessthan 0.35. With a random number in this range, we make the rat’saction be WATER = 2. A random number is greater than or equal to0.35 with a probability of 65%. In such a case, we assign NEITHER =3 to the rat’s action. Thus, with rand being a uniformlydistributed random floating-point number from 0.0 to 1.0, we em-ploy the following logic for determination of the rat’s action: if a random number, rand, is Attached