Sample from Poisson distribution
We have been provided with the average yearly number of assaults, robberies and batteries in a small city (150, 300 and 50, respectively). Given that the three types of crimes can be modeled as a multivariate Poisson distribution, you are told to create 10 different scenarios for the number of crimes in the next year.
Deze oefening maakt deel uit van de cursus
Mixture Models in R
Oefeninstructies
- Using the function
rpois, create 10 observations for each type of crimes using their corresponding lambda. - Combine the simulated number of crimes into a multivariate Poisson distribution.
- Check the values of your simulated scenarios.
Praktische interactieve oefening
Probeer deze oefening eens door deze voorbeeldcode in te vullen.
set.seed(1541)
# Create the vector of lambdas
lambda_1 <- c(150, 300, 50)
# Create the sample of each crime
assault_1 <- ___(n = ___, lambda = ___)
robbery_1 <- ___(n = ___, lambda = ___)
battery_1 <- ___(n = ___, lambda = ___)
# Combine the results
cities_1 <- cbind(assault_1, ___, battery_1)
# Check the sample
cities_1