首页 >
> 详细

Assignment 3

Question 1

Write a function that takes two matrices (say, A and B) as arguments and return the

matrix multiplication of A and B. Recall that in matrix multiplication, let C = A × B, then

Cij =P

k AikBkj . Notice that in matrix multiplication, the number of columns in A must

be the same as the number of rows in B. So in your program, if the inputs do not satisfy

the condition, then provide an error message. Notice that, you are not allowed to use the

R internal matrix multiplication function for this question, although you can verify your

solution with it.

Question 2

Suppose we had forgotten the formula for computing the area of a circle. All is not

lost. We can easily use the computer to approximate a circles area by simulation. For

convenience, we want to determine the area of the unit circle with radius 1 and name this

unknown constant π. We know that the area covered by a square with the corner points

(−1, 1), (1, 1), (1, −1), and (−1, −1) equals 4, as the length of each side is 2. This square

completely contains the unit circle. If we had a random point somewhere in the square,

we could calculate the probability that the point is also inside the unit circle. A random

point Z is determined by two coordinates, say X and Y , which have independent uniform

distributions on the interval [−1, 1]. The probability of Z being inside the circle is given by

the ratio of the circles area and the squares area or, more mathematically:

P(Z is inside the circle) = (circle area)/(square area) = π/4.

Knowing this, we can estimate (the unknown) π by multiplying the estimated probability

for Z being inside the circle by 4. Whats left is to generate a large number of random points

Z, calculate the proportion of points inside the circle, and multiply this by 4. This is our

estimate of π. Write a R program for this problem and estimate pi with 100, 1000, and 10,

000 random points. Try to work with complete vectors only and avoid loops. How far away

is the approximation from the pi we (fortunately) happen to know?

Hint: You need to know how to check if a point (x, y) is inside the circle. As the circle is

defined by its origin and the radius, the distance from the circles origin to the point is given.

Question 3

In statistical hypothesis testing, you specify a hypothesis about a population parameter

(your null hypothesis, or H0). You then draw a sample from this population and calculate

a statistic that’s used to make inferences about the population parameter. Assuming that

the null hypothesis is true, you calculate the probability of obtaining the observed sample

statistic or more extreme results. If the probability is sufficiently small, you reject the null

hypothesis in favor of its opposite (referred to as the alternative or research hypothesis, H1).

If the null hypothesis is false and the statistical test leads us to reject it, you’ve made

a correct decision. The power of a test is defined by the probability of rejecting the null

hypothesis given that the alternative hypothesis is correct.

If the null hypothesis is true and you don’t reject it, again you’ve made a correct decision.

If the null hypothesis is true but you reject it, youve committed a Type I error. If the null

hypothesis is false and you fail to reject it, youve committed a Type II error.

In this problem, we will use simulation to examine a statistical hypothesis test. We want

to test the null hypothesis that the population of mean of a normally distributed sample is

µ0 = 0, with known variance 1. Let the alternative be that the mean is equal to µ1 = 1. We

know that if we set the significance level to α (usually 1% or 5%) , the test will reject the

null hypothesis α% of the time (for a large number of samples), although the data actually

come from a normal distribution with mean 0 and variance 1 (the chance of making a type I

error is α% ). Show this by generating 1000 samples of size 100, calculating for each sample

whether or not the null hypothesis is rejected and summarizing how often the null hypothesis

was rejected (even when it is true). Recall that the criterion for rejecting the null hypothesis

in this case is that you reject the null hypothesis if

x¯ − µ0σ/√n> z1−α.

Question 4

This question is a continuation of Q3, in which we examine the power of the test.

• Estimate the power of your test in Q3 by generating 1000 samples of size 10 of the

population corresponding to the alternative hypothesis.

• Estimate the power of your test in Q3 by generating 1000 samples of size 10000 of the

population corresponding to the alternative hypothesis.

联系我们

- QQ：99515681
- 邮箱：99515681@qq.com
- 工作时间：8:00-23:00
- 微信：codinghelp

- 代写cs3014 Google Analytics Customer Rev 2020-01-21
- 代写cmpsc121 Structs代写留学生c/C++实验... 2020-01-21
- 代写mis6326 Data Management调试存储过程作业、数据库编 2020-01-21
- 代写msci 581作业、代做marketing Analytics作业、P 2020-01-20
- Software课程作业代做、代写java，C/C++程序设计作业、Pyth 2020-01-20
- Tcss 372作业代做、代写python，Java编程语言作业、代做c/C 2020-01-20
- Emergency Facilities作业代写、代写r编程设计作业、R课程 2020-01-18
- Cis 413/513作业代做、代写data Structures作业、Ja 2020-01-18
- 代写ia626留学生作业、Python程序设计作业调试、代做data课程作业 2020-01-18
- Mat00027i作业代写、Java程序语言作业调试、Mathematica 2020-01-17
- 代做kt Model作业、代写java，Python编程设计作业、代做c/C 2020-01-17
- Data Set课程作业代做、代写r程序语言作业、Ltcret留学生作业代做 2020-01-17
- 代写rstudio留学生作业、代做r编程设计作业、代写r课程设计作业代做数据 2020-01-17
- 代写cs2250 Delimiter Matching代做数据结... 2020-01-16
- 代写cs12b Edit Distance帮写java实验作业... 2020-01-16
- 代写mins325 Filereader And Filewriter代... 2020-01-16
- 代写cosi131 Tunnels帮写java实验作业 2020-01-16
- 代写inm312 Balancebit Software代写留学... 2020-01-16
- 代写cs61b Maze Solver代写java课程设计 2020-01-16
- Program留学生作业代做、C/C++编程语言作业代写、代做java，Py 2020-01-14