2. If an equal likelihood of each of several discrete events exists, in a simulation we can generate a random integer to indicate the choice. For example, in a simulation of a pollen grain moving in a fluid, suppose at the next time step the grain is just as likely to move in any direction—north, east, south, west, up, or down—in a three-dimensional (3D) grid. A probability of 1/6 exists for the grain to move in any of the six directions. With these equal probabilities, we can generate a uniformly distributed integer between 1 and 6 to indicate the direction of movement.
Suppose in a simulation involving animal behavior, a lab rat presses a food lever (FOOD = 1) 15% of the time, presses a water lever (WATER = 2) 20% of the time, and does neither (NEI- THER = 3) the remainder of the time. For the simulation, we consider the range split into three parts, and again generate a uniformly distributed ran- dom floating-point number from 0.0 to 1.0. If the number is less than 0.15, which occurs 15% of the time, we assign FOOD = 1 to the rat’s action. For 20% of the time, the uniformly distributed random number is greater than or equal to 0.15 and less than 0.35. With a random number in this range, we make the rat’s action be WATER = 2. A random number is greater than or equal to 0.35 with a probability of 65%. In such a case, we assign NEITHER = 3 to the rat’s action. Thus, with rand being a uniformly distributed 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 < 0.15
the rat presses the food lever
else if rand < 0.35 (i.e., 0.15 ? rand < 0.35)
the rat presses the water lever
else (i.e., 0.35 ? rand)
the rat does neither
Using the above logic used in determining the action of a rat, write a segment to return FOOD, WATER, or NEITHER, depending on the value of the random number. ?
// C code to solve given Problem
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int fun(float random_number)
{
if(random_number < 0.15) //
food
return 1 ;
if(random_number >= 0.15
&& random_number < 0.35) //water
return 2 ;
if(random_number >= 0.35)
// neither
return 3 ;
}
int main()
{
srand ( time(NULL) );
// To avoid same number generation when using
rand()
int tmp = rand() % 101
; // generate an integer b/w [0,100]
float
random_number=tmp/100.0 ; // divide by 100 such that number lies in
range [0,1]
int r=fun(random_number)
; // calling function
printf("Random Number =
%.2f\n",random_number) ;
if(r==1)
printf("FOOD") ;
else if(r==2)
printf("WATER") ;
else
printf("NEITHER")
;
return 0;
}
2. If an equal likelihood of each of several discrete events exists, in a simulation we...
A project has three activities A, B, and C that must be carried out sequentially; that is, A -> -> C. The probability distributions of the times required to complete each of the activities A, B, and C are uniformly distributed in intervals (1,6], [2,3] and (3,6) respectively. Find the total project completion time and run 1000 simulation trials in Excel. The project completion time" is a(n)... Select one: O a. Input of the simulation b. Decision variable in the...
Create a NOTEPAD or PDF file that restates the problem in your own words, specifies what input is needed, what output is expected, the step by step process (algorithm) to get the output from the input, and test data (input for which you know the expected output) for each of the 3 problems given below. You should not write any actual C++ code. Make sure the problem statement is in your own words and is descriptive enough so someone not...
STA2221 examples on CI & Testing of Hypothesis Name MULTIPLE CHOICE. Choose the one alternative that best completes the statement or answer the question Provide an appropriate response. 1) Find the critical value,te for 0.99 and n-10. A) 3.250 B) 3.169 1.833 D) 2.262 2) Find the critical value to forc=0.95 and n=16. A) 2.947 B) 2.602 2120 D) 2.131 3) Find the value of E, the margin of error, for A) 1.69 B) 0.42 0.99, n=16 and s=2.6. C)...
Question 2 : Virus Wars A popular subgenre of strategy game is the so-called Virus War format, where the player is shown a field of cells, each with a virus count, and may attack other cells within a certain range. We are going to write some classes in Python to implement a simple Virus Wars game. 2a) The position class (9 points) Everything within this game is going to require a position, so it makes sense to define it up...
All of the following questions are in relation to the following journal article which is available on Moodle: Parr CL, Magnus MC, Karlstad O, Holvik K, Lund-Blix NA, Jaugen M, et al. Vitamin A and D intake in pregnancy, infant supplementation and asthma development: the Norwegian Mother and Child Cohort. Am J Clin Nutr 2018:107:789-798 QUESTIONS: 1. State one hypothesis the author's proposed in the manuscript. 2. There is previous research that shows that adequate Vitamin A intake is required...
1. According to the paper, what does lactate dehydrogenase
(LDH) do and what does it allow to happen within the myofiber? (5
points)
2. According to the paper, what is the major disadvantage of
relying on glycolysis during high-intensity exercise? (5
points)
3. Using Figure 1 in the paper, briefly describe the different
sources of ATP production at 50% versus 90% AND explain whether you
believe this depiction of ATP production applies to a Type IIX
myofiber in a human....