首页 >
> 详细

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
- 微信：codinghelp2

- Tsp课程作业代写、代做algorithms留学生作业、代做java，C/C 2020-06-23
- Kit107留学生作业代做、C++编程语言作业调试、Data课程作业代写、代 2020-06-23
- Sta302h1f作业代做、代写r课程设计作业、代写r编程语言作业、代做da 2020-06-22
- 代写seng 474作业、代做data Mining作业、Python，Ja 2020-06-22
- Cmpsci 187 Binary Search Trees 2020-06-21
- Comp226 Assignment 2: Strategy 2020-06-21
- Math 504 Homework 12 2020-06-21
- Math4007 Assessed Coursework 2 2020-06-21
- Optimization In Machine Learning Assig... 2020-06-21
- Homework 1 – Math 104B 2020-06-20
- Comp1000 Unix And C Programming 2020-06-20
- General Specifications Use Python In T... 2020-06-20
- Comp-206 Mini Assignment 6 2020-06-20
- Aps 105 Lab 9: Search And Link 2020-06-20
- Aps 105 Lab 9: Search And Link 2020-06-20
- Mech 203 – End-Of-Semester Project 2020-06-20
- Ms980 Business Analytics 2020-06-20
- Cs952 Database And Web Systems Develop... 2020-06-20
- Homework 4 Using Data From The China H... 2020-06-20
- Assignment 1 Build A Shopping Cart 2020-06-20