ANSWER :
Please find R code for above
n=30
x=matrix(rnorm(n*1000),1000,n)
x[,1:3]=x[,1:3]*10
y=1+matrix(rnorm(n*1000),1000,n)
#Calculating total nmber of rejections
#rejection if p value is less than 0.05
rejections=0
for(i in 1:1000){
t1=x[i,]
t2=y[i,]
t=t.test(t1,t2)
p=t$p.value
if(p<0.05){
rejections=rejections+1
}
}
The number of rejections are coming out to be 439
In part (A), the function can never be zero, so code will give absurd results
#part 2 a
#let m be the starting point and n be the number of iterations
f1=function(m,n){
it=m
i=1
while(i<(n+1)){
it=it-(2*exp(it^2)-1)/(4*it*exp(it^2))
i=i+1
}
return(it)
}
#part 2 b
f2=function(m,n){
it=m
i=1
while(i<(n+1)){
it=it-(it^2 -(251/187)*(1/it) + 82/187)/(2*it +
(251/187)*(1/it^2))
i=i+1
}
return(it)
}
If you do not get anything in this solution, please put a
comment and I will help you out.
Do not give a downvote instantly. It is a humble request. If you
like my answer, please give an upvote.
Code in R Part 1. a) Run the following lines: n<-30 x<-matrix(rnorm(n * 1000), 1000,n) xL,1:3]<-xl,1:3]*10...
In R, Part 1. Learn to understand the significance level α in hypothesis testing. a) Generate a matrix “ss” with 1000 rows and 10 columns. The elements of “ss” are random samples from standard normal distribution. b) Run the following lines: mytest <- function(x) { return(t.test(x,mu=0)$p.value) } mytest(rnorm(100)) Note that, when you input a vector in the function mytest, you will get the p-value for the one sample t-test H0 : µ = 0 vs Ha : µ =/= 0....
1. [12 marks] In the following parts of this question, write a MATLAB code to solve a linear system A b (A is a square nonsingular matrix) using Jacobi and Gauss-Seidel algorithms. Do not use the built-in Matlab functions for solving linear systems (a) Write a Matlab function called Jacobi that consumes a square n x n matrix A, and an n x 1 vector b, and uses the Jacobi technique to solve the system Ax-b, starting with the zero...
# 3. The following code draws a sample of size $n=30$ from a chi-square distribution with 15 degrees of freedom, and then puts $B=200$ bootstrap samples into a matrix M. After that, the 'apply' function is used to calculate the median of each bootstrap sample, giving a bootstrap sample of 200 medians. "{r} set.seed (117888) data=rchisq(30,15) M=matrix(rep(0,30*200), byrow=T, ncol=30) for (i in 1:200 M[i,]=sample(data, 30, replace=T) bootstrapmedians=apply(M,1,median) (3a) Use the 'var' command to calculate the variance of the bootstrapped medians....
RSTUDIO MUST BE USED TO ANSWER THIS QUESTION Run the following three commands in order\n x <- rnorm(100) y <- 2*x + 3 + rnorm(100,sd=1) z <- 2*x + 3 + rnorm(100,sd=2) Calculate the correlation coefficients between x and y and between x and z. Identify the true statements below. (There may be more than one correct answer) A. Both coefficients are positive B. The correlation between x and z is stronger than that between x and. y...
Part I: Code writing: 1. 3pts (Display matrix of numbers) Write a function that displays an n-by-n matrix using the following header: void printMatrix(int n) Each element is between (3,9), which is generated randomly. Write a test program that prompts the user to enter n and displays an n-by-n matrix. Here is a sample run: Enter n: 2 47 96
For this project, each part will be in its oun matlab script. You will be uploading a total 3 m files. Be sure to make your variable names descriptive, and add comments regularly to describe what your code is doing and hou your code aligns with the assignment 1 Iterative Methods: Conjugate Gradient In most software applications, row reduction is rarely used to solve a linear system Ar-b instead, an iterative algorithm like the one presented below is used. 1.1...
Publish using a MatLab function for the following: If a matrix A has dimension n×n and has n linearly independent eigenvectors, it is diagonalizable.This means there exists a matrix P such that P^(−1)AP=D, where D is a diagonal matrix whose diagonal entries are made up of the eigenvalues of A. P is constructed by taking the eigenvectors of A and using them as the columns of P. Your task is to write a program (function) that does the following If...
Please follow following scripts: Script for part A:Script for Part B: Matlab Exercises 1. Find the determinant (command: det(A)) and the condition number (command: cond(A)) of the Hilbert matrix H of order k (command: hilb(k)), for k = 1,2, ..., 10. Plot the determinant and the condition number as a function of k using a logarithmic scale for the vertical axis. Hint: The template to help you with this homework assignment is homework/hw15.m. 2. Determine if y is in the...
1. Modify the following code as needed to run in your environment. As well as the values for M and N given in the code, test all combinations of values of M = 2, 3, 5, 10 and N = 103, 104, 105, 106. 2. Explain the “node” class and the “main” function through comments in the code file and a written summary that includes your displayed test results. 3. Create the following functions for processing nodes: remove(), insert(), next(),...
what is a good matlab code to out put this matrix from question 1 to 3 HITA 1)-The general form cf the quadratic equation is a +bx+c 0 Wrte a MATLAB function named quadratic that finds the two roots of this equation and x when given the coeficients a, b and c 2)-Create a random matrix A in MATLAB with 6 rows and 3 oolumns using the rand) function 3)-Now modify quadratic by so that il can take each row...