Below are the solutions to these exercises on Building a Neural Network.

############### # # # Exercise 1 # # # ############### set.seed(123) normal_draws <- rnorm(1000, mean = 10, sd = 2) hist(normal_draws)

############### # # # Exercise 2 # # # ############### qqnorm(normal_draws) qqline(normal_draws)

############### # # # Exercise 3 # # # ############### y <- rt(1000, df = 10, ncp = 9) means_t_test <- t.test(normal_draws, y) means_t_test$p.value

## [1] 0.03064702

############### # # # Exercise 4 # # # ############### greater_test <- t.test(normal_draws, y, alternative = "greater") greater_test$p.value

## [1] 0.01532351

############### # # # Exercise 5 # # # ############### test_func <- function(x, y){ t_test <- t.test(x, y) return(t_test$p.value) } test_func(x = rnorm(100, mean = 1, sd = 0.5), y = rnorm(100, mean = 0.9, sd = 1))

## [1] 0.2236878

############### # # # Exercise 6 # # # ############### p_reps <- replicate(1000, test_func(x = rnorm(100, mean = 1, sd = 0.5), y = rnorm(100, mean = 0.9, sd = 1))) qqplot(p_reps, runif(1000)) abline(0,1)

############### # # # Exercise 7 # # # ############### dbinom(5, size = 10, prob = 0.75)

## [1] 0.0583992

############### # # # Exercise 8 # # # ############### pbinom(4, size = 10, prob = 0.75)

## [1] 0.01972771

############### # # # Exercise 9 # # # ############### ppois(59, lambda = 50, lower = FALSE)

## [1] 0.09226505

################ # # # Exercise 10 # # # ################ pexp(30, rate = 1/50)

## [1] 0.4511884

## Leave a Reply