Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Densities This is the (small) population of patients with a rare disease, along with where they live: Name City Nana Alpharetta Nia Alpharetta Anya Alpharetta

Densities

This is the (small) population of patients with a rare disease, along with where they live:

Name City
Nana Alpharetta
Nia Alpharetta
Anya Alpharetta
Yamiaya Atlanta
Youssef Atlanta
Ibrahim Alpharetta
Lizelle Buckhead
Chen Atlanta
Carlos Buckhead
Jin Buckhead
Rachael Alpharetta
Lukas Alpharetta
Olivia Atlanta
Ayesha Buckhead
Fatima Buckhead

A) Come up with the density R function for "city " in this population.

B. The function (equivalent to or) that draws samples from a "population" that has a variable X that has this density. You don't have to understand how this code works, but if you're curious, all it does is pick a number between 1 and 3 and depending on what it is it samples from one of three different normal distributions.

r_mydensity=function(n){ df = tibble(

S = sample(1:3, size=n, replace=T),

X = case_when(

S==1~rnorm(n,mean=-5,sd=1), S==2 ~ rnorm(n, mean = 0, sd = 2), S==3~rnorm(n,mean=5,sd=1.5)

)

) %>% pull(X)

}

sample = r_mydensity(1000)

hist(sample)

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Probability With Applications and R

Authors: Robert P. Dobrow

1st edition

1118241257, 1118241258, 978-1118241257

More Books

Students also viewed these Mathematics questions

Question

How can the explanatory variables be checked for collinearity?

Answered: 1 week ago