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
Our writing company offers a unique service that provides guidance in different types of assignments. Please rest assured that the service is absolutely legal and doesn’t violate any regulations. It can be used for generating new ideas and thoughts for your own project, additional insight into the subject, or encouragement for further researches.