Question

In: Advanced Math

A girl who has two siblings is chosen at random and the number X of her...

A girl who has two siblings is chosen at random and the number X of her sisters is counted. Describe how to simulate an observation on X based on U ∼ unif[0, 1] in Matlab.

Solutions

Expert Solution

consider simulate 20 observations on X.

Using Matlab.

The rand() function gives a random number in the range [0, 1] with a uniform distribution. Instead of directly using this function, we can use the randi() function which gives an integers in the range [1, n] with a uniform distribution where n is the first parameter to randi(). As we have 4 possiblilites (0, 1, 2, 3) for number of daughters, n = 4. We will also have to subtract one to get a number in [0, 3] range. So, the Matlab code will be:

>> randi(4,1,20)-1
ans =

   3   0   2   2   3   2   1   2   0   3   1   2   1   0   3   1   0   2   3   3

The first parameter to randi is the number of values we need. The second one is the number of rows. As we have passed one here, we will get a row vector. The third one is the number of columns. As we need 20 values, we pass 20 here.

Note: we can switch rows and columns to get a similar result as a column vector.

Note: We can get a similar result directly using rand(), but it will require some extra processing to get numbers in the right range:

>> fix(rand(1,20)*4)%4
ans =

   3   3   1   3   2   1   2   3   1   3   2   3   1   2   2   0   3   1   2   2

Here, rand() gives a number in [0,1] with uniform distribution. When we multiply by 4, we get a floating point number in [0. 4]. Using fix() we truncate the number to [0,4]. Note that we will be getting an integer with uniform distribution in [0,3] here. In a rare case when we get 4, we treat it as 0.

The first parameter to rand() is the number of rows. The second parameter to rand() is the number of columns.


Related Solutions

Melanie is a 16-year old who lived with her parents and two siblings in a suburban...
Melanie is a 16-year old who lived with her parents and two siblings in a suburban neighborhood until her parents separated 6 months ago. At that time her school performance began to decline and she was truant from school, frequently not returning home until after dark. when she arrived home,she was verbally abusive to her mother when asked where she had been. Three days ago, her relationship with her boyfriend of 1 year ended when he told her she had...
An 8-month-old girl who is brought in by her parents because of fever and fussiness. Her...
An 8-month-old girl who is brought in by her parents because of fever and fussiness. Her appetite is poor and she refuses to eat or take most fluids. On physical examination, she has a bright red right TM, dull without mobility or landmarks. Her left TM is pearly gray and mobile. She has yellow nasal discharge; cervical adenopathy and chest clear to auscultation. Her diagnosis is right otitis media. a. What will you prescribe, for how long, and what dosage?...
The 8-year-old girl who was naughty. 8-year-old girl brought to her pediatrician by her 26-year-old mother...
The 8-year-old girl who was naughty. 8-year-old girl brought to her pediatrician by her 26-year-old mother • Chief complaint: fever and sore throat Psychiatric History • While evaluating the patient for an upper respiratory infection, the pediatrician asks if school is going well • The patient responds “yes” but in the background the mother shakes her head “no” • The mother states that her daughter is negative and defi ant at home and she has similar reports, mostly of disobedience,...
82 Mary is an 8 year old girl who fell off her skateboard and has grazed...
82 Mary is an 8 year old girl who fell off her skateboard and has grazed her knee and hand. The epithelium of the skin is broken and bleeding. This case study will be used to contextualise and highlight the linkages between the early non-specific defences and later specific defences. Non-specific defence mechanisms that would be important at the time of Mary’s injury: Select one: A. Include barriers to invasion, phagocytosis, inflammation, fever, interferon and complement proteins. B. Include barriers...
A number between 1 and 10 is chosen at random . What is the probability of...
A number between 1 and 10 is chosen at random . What is the probability of getting a multiple of 5 or an even number?
In MAPLE or MATLAB A family with three children is chosen at random and the number...
In MAPLE or MATLAB A family with three children is chosen at random and the number X of daughters is counted. Describe how to simulate an observation on X based on U ~ unif[0,1]. Then, simulate 20 observations on X.
A 2-year-old girl has been brought to the ambulatory clinic by her mother who states, “She's...
A 2-year-old girl has been brought to the ambulatory clinic by her mother who states, “She's put a pea in her ear, and I think she did it 2 days ago because that was the last time we ate them.” The nurse's otoscopic examination confirms the presence of this foreign body in the girl's middle ear. How should the nurse best respond to this assessment finding?
A 12-year-old girl who has been losing weight comes to the doctor, her mother tells the...
A 12-year-old girl who has been losing weight comes to the doctor, her mother tells the physician that the daughter is always hungry. The mother is sure there is a kidney problem, because her daughter is getting up twice each night to go to the bathroom. Respiration : 15/min                                        ph:7.35                                             urine ph :5 Blood pressuere:125/80                                WBC: 8200/mm3                          urine glucose:1000mg/gl Pulse:75                                                               blood glucose:260mm/gl          urine ketones: large Temperature:37c                                             Albumin:4.0g/l                              urine specific gravity:1,006 Why is patient always hungry if she is eating well?...
A random number X is generated by reporting the sum of the digits on two randomly...
A random number X is generated by reporting the sum of the digits on two randomly chosen ping-pong balls, one from a bucket of two balls labeled “0” and “1” and one from a bucket of three balls labeled “0”, “1”, and “2”. Find the probability mass function of X by specifiying the values x that X can take and the probability p(x) = P (X = x) of each of those values. Please explain how you arrived at the...
A random sample of 1000 eligible voters is drawn. Let X = the number who actually...
A random sample of 1000 eligible voters is drawn. Let X = the number who actually voted in the last election. It is known that 60% of all eligible voters did vote. a) Find the approximate probability that 620 people in the sample voted, and b) Find the approximate probability that more than 620 people in the sample voted.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT