CS代考计算机代写 —
—
title: “R Notebook”
output: html_notebook
—
“`{r include=FALSE}
if(!require(tidyverse)) install.packages(“tidyverse”)
if(!require(car)) install.packages(“car”)
library(tidyverse)
library(car)
“`
# Question [10 marks]
Suppose the average weight of cats (in grams) is approximated well by the normal distribution N(μ=478,σ=23). Also, suppose that the average weight of dogs (in grams) is approximated well by the normal distribution N(μ=1450,σ=153). Two animals are selected at random, a cat C weighing 432 grams, and a dog D weighing 1123 grams. State, showing your working out, which one of these two animals have more unusual weight.
# Solutions
“`{r}
calc_animal_z_score <- function(X,μ,σ) {
animal_nd <- (X-μ) / σ
return (animal_nd)
}
# comparison
C <- calc_animal_z_score(X=432, μ=478, σ=23)
D <- calc_animal_z_score(X=1123, μ=1450, σ=153)
print(C)
print(D)
```
Conclusion:
According to the calculate above,
because |D| = 2.137255 > |Z_1| = 2,we can found that *the dog D* is more unusual than *the cat C*