Produce a vector of twenty increasing equally spaced points

Assignment Help Engineering Mathematics
Reference no: EM131207568

Q1. Give R code using the function rep() to create the following vectors?

(i) 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5

(ii) 1 2 2 2 2 2 3 3 4 4 5

Q2. Give R code using the function seq() to produce a vector of twenty increasing equally spaced points between -2 and 3.

Q3. Give R code to evaluate the following, without using loops

1852_figure.png

Q4. Provide R code which uses a loop to generate samples of size 100 from t-distributions with degrees of freedom equal to 1, 2, 4, 8, 16, 32 and stores them in the columns of a 100 x 6 matrix. Create a histogram of each sample, together with a normal probability plot complete with a line to assess how straight the Q-Q plot is. The plots should be arranged in a 2 x 6 array on a single graph sheet, with the histograms on the top row and the Q-Q plots in the bottom row. Each plot should have a title with an indication of the distribution (including degrees of freedom) used to generate the data.

Q5. Carefully describe what is accomplished by the following piece of R code, commenting on each line of the code:

x <- seq(-5, 5, by = 0.1)

y <- 3 + 1.2 * x + rnorm(length(x) , mean=0,sd=2)

par (pty=" s" )

plot(x, y, pch=1)

title(main="Plot of Response vs. Explanatory")

fit <- lm(y ~ x)

abline(fit)

summary(fit)

par(pty="m", mfrow=c(2, 2))

plot (fit)

Q6. Assume that Y is a numeric matrix with n rows and m columns. Describe in detail what is accomplished by the following R code:

Ym <- rep(0, m)

Ys <- rep(0, m)

for (j in (1:m)) {

Ym[j] <- mean (Y [, j] )

Ys[j] <- sd(Y[,j])

for (i in (1:n) ) {

Y[i,j]<- (Y[i,j] - Ym[j] ) /Ys[j]

}

}

How can you compute Ym and Ys and perform the same transformation on Y in a quicker and more transparent way?

Use the function scale () in conjunction with the function apply () to perform the same transformation on Y in a single line of code (without calculating the values of Ym and Ys).

Q7. Suppose that f(x) is a function defined for all x ∈  (0, 1) . Also, suppose that you do not know how to compute 01 f(x)dx. One way to estimate the integral by simulation is as follows:

(i) randomly draw n points x in (0, 1);

(ii) generate the vector y such that y[i]=f (x[i]);

(iii) estimate the integral using the sample mean of y

I^ = y-.

Write a R function sim.integ() which takes as arguments the function f and returns the above estimates I^ of 01f(x)dx.

(b) Use your function to evaluate

01x2sin(x) + tan(x) dx.

for n = 100, 1000, 10000, 100000.

(c) Calculate the integral using R's integrate() function. [The exact value of the integral is -2 + 2 * sin(1) + cos(1) - log(cos(1)) = 0.83887.]

Q8. Let yt be a sequence of random variables that follows the moving average model of order 1:

yt = εt + bεt-1       t = 2, ..., N

where εt are i.i.d. N(0, σ2) and b is a known constant in the interval [-1, 1]. To define y1, we set ε0 = 0. According to this model, yt is equal to a noise term εt plus (or minus, depending on the sign of b) some fraction of the noise term εt-1 at the previous time.

Write an R function MA1() that takes as arguments the final time N and the parameters b and σ and generates a sequence yt from the model above, and plot four generated sequences in a 2 x 2 display.

The function should return a list with three components: b, sigma and a vector y containing the generated sequence. The function should check that N and o are positive and that b lies in the interval [-1, 1] and return an error if not.

Q9. Suppose that f(x) is a monotone function (i.e. strictly increasing or strictly decreasing) defined on an open interval of the real line and with a unique root xr satisfying f(xr) = 0. The root xr can be found numerically using an iterative method known as the regula falsi or secant method. Given two values xi and xi-1, the method determines the secant line, i.e. the line that goes through the points (xi-1, f(xi-1)) and (xi, f (xi)). The next iterate xi+1 is the value where the secant line cuts the x-axis, which is easily shown to be given by the following equation

xi+1 = xi - f(xi)( xi - xi-1/f(xi)-f(xi-1)).

Write an R function regulafalsi 0 to implement the secant method. The arguments of regulafalsi () should include a function f() to providing the definition of f(x), and two values x0 and x1 to start the iterations.

Use the function regulafalsi() to solve the equation

x1/2 + 3 log x = 5 x > 0.

numerically, starting at x = 1. Compare with the result of using the function uniroot() to find a solution in the interval (1,5).

Reference no: EM131207568

Questions Cloud

Calculate vl using the voltage divider rule : Find the total impedance ZT. - Determine the current Is. - Calculate IC using the current divider rule. -  Calculate VL using the voltage divider rule.
Employments of distributed computing : Compose a paper clarifying the business employments of distributed computing and Web 2.0. Make certain to address the accompanying in your task:
What is the concept of nature-nurture : In cognition, one of the major areas of discussion is the influence of nature and nurture. What is the concept of nature-nurture? Why is it important in the study of cognition?
Handling of data about business activities : Which type of information system automates handling of data about business activities?
Produce a vector of twenty increasing equally spaced points : Give R code using the function seq() to produce a vector of twenty increasing equally spaced points between -2 and 3
Ports on the same network : 1) Suppose a bridge has two of its ports on the same network. How might the bridge detect and correct this? 2) Having ARP table entries time out after 10 to 15 minutes is an attempt at a reasonable compromise. Describe the problems that can occur i..
Tabulate and graph data and compute results : Compute time, distance, average speed, average acceleration, speed, and acceleration for motion with constant acceleration, Tabulate and graph data and compute results. Draw reasonable conclusions from quantitative data and communicate results to ot..
Develop theories of root causes : The purpose of the Measure Phase is to give a true and accurate picture of the current condition as it relates to the project. Another way to think of the measure phase of DMAIC is that it is dedicated to assembling a data collection plan, executi..
Purposes and uses of technology : What is the technology you identified and what are the purposes and uses of this technology? What are the problems of existing technologies and how will the new technologies solve the problems? How will the new technologies change, support, or extend..

Reviews

Write a Review

Engineering Mathematics Questions & Answers

  Single-phase queuing system and multiphase queuing system

Compare and contrast the differences between a single-phase queuing system and multiphase queuing system. Describe your answer in full.

  Portfolio of three different bonds

Suppose you own a portfolio of three different bonds with the following information:

  Problem regarding the integer programming problem

Solve the integer programming model for the below problem.  For this problem, solve the integer programming model by using QM for Windows.

  Compute the derivative function

Problem 1: Compute the derivative function f'(x) algebraically.

  Compute b1 and b0

Compute B1 and B0 (for this I am having trouble finding the covariance and Sx if you could please write that out in detail)

  What is the x-intercept of tangent line

What is the x-intercept of this tangent line? Use this fact to draw the tangent line and find the volume of the solid generated by rotating the top half

  Demand for trainers means

What is the weekly profit of the manufacturer, assuming that the demand for trainers means that all pairs will be sold? Write down all the constraints for the problem.

  Intermediate nodes and destination nodes

In, addition, assume that no travel is possible between source nodes, between intermediate nodes and between destination nodes and no direct travel from source nodes to destination nodes. Let the source nodes be labeled as 1, 2, and 3, the interme..

  Determining the waste and operating cost

Machine 1 is available for 150 hours, machine 2 for 240 hours, machine 3 for 200 hours, and machine 4 for 250 hours. The products also result in different profits, according to the machine they are produced on, because of time, waste and operating..

  Problems based on multiple regression analysis

explain why the typical hypothesis that analysts want to test is whether a particular regression coefficient (B) is equal to zero (H0: B = 0) versus whether that coefficient is not equal to zero (H1: B ≠ 0).

  Calculate the circumfrential and longitudinal stresses

Calculate the circumfrential and longitudinal stresses in the plates when the internal pressure is 800KN/m sq. If the ultimate tensile stress of the material used is 600 MN/m sq, and the efficiency of the longitudinal joint is 70 per cent, determi..

  What drawbacks are there to de?ning multiplication

For ordered pairs of real numbers ( a, b ) and ( c, d ), what drawbacks are there to de?ning multiplication of complex numbers by ( a, b )( c, d )= ( ac, bd )?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd