Simulating the Number of Females in a Random Sample using R, Study Guides, Projects, Research of Mathematics

Instructions for using r to simulate the number of females in a random sample of size 15 from a population with a 30% male and 70% female composition. Five problems that involve generating and analyzing the empirical distribution and theoretical distribution of the random variable x, which represents the number of females in the sample.

Typology: Study Guides, Projects, Research

Pre 2010

Uploaded on 08/19/2009

koofers-user-dmn
koofers-user-dmn 🇺🇸

0

(1)

9 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computer Project 4
Simulating a random variable in R
Problem 1: Use R to simulate one copy of the random variable X, described
below:
A population consists of 30% males and 70% females. A sample of size
15 is taken from this population (with replacement). Let X be the
number of females in the sample. Generate 300 copies of X.
Hint : You may create a population with the above characteristics as follows:
population =
c("M","M",”M”,"F","F","F",”F”,”F”,”F”,”F”)
and use the commands sample, length, and which.
Problem 2. Use the R code in Problem 1, to generate 10000 copies of X. Draw the
histogram of the relative frequencies (density histogram) for the 10000 values. This is
referred to as the “empirical distribution” of X. What is the shape of the empirical
distribution of X?
Problem 3: Using the empirical distribution of X, as obtained in problem 2, what is the
approximate probability that the number of females in a sample of size 15 from this
population is more than 10?
Problem 4: Again using the empirical distribution, what is the mean and standard
deviation of X?
Problem 5: Determine the theoretical distribution of X, and answer Problems 2-4, using
the theoretical distribution. Are the theoretical quantities close to their empirical quantity
counterparts? To compute exact probabilities for binomial the R commands pbinom and
dbinom are useful.

Partial preview of the text

Download Simulating the Number of Females in a Random Sample using R and more Study Guides, Projects, Research Mathematics in PDF only on Docsity!

Computer Project 4

Simulating a random variable in R

Problem 1: Use R to simulate one copy of the random variable X, described

below:

A population consists of 30% males and 70% females. A sample of size

15 is taken from this population (with replacement). Let X be the

number of females in the sample. Generate 300 copies of X.

Hint : You may create a population with the above characteristics as follows:

population =

c("M","M",”M”,"F","F","F",”F”,”F”,”F”,”F”)

and use the commands sample, length, and which.

Problem 2. Use the R code in Problem 1, to generate 10000 copies of X. Draw the histogram of the relative frequencies (density histogram) for the 10000 values. This is referred to as the “empirical distribution” of X. What is the shape of the empirical distribution of X?

Problem 3: Using the empirical distribution of X, as obtained in problem 2, what is the approximate probability that the number of females in a sample of size 15 from this population is more than 10?

Problem 4: Again using the empirical distribution, what is the mean and standard deviation of X?

Problem 5: Determine the theoretical distribution of X, and answer Problems 2-4, using the theoretical distribution. Are the theoretical quantities close to their empirical quantity

counterparts? To compute exact probabilities for binomial the R commands pbinom and

dbinom are useful.