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

  Prime number theorem

Dirichlet series

  Proof of bolzano-weierstrass to prove the intermediate value

Every convergent sequence contains either an increasing, or a decreasing subsequence.

  Antisymmetric relations

How many relations on A are both symmetric and antisymmetric?

  Distributed random variables

Daily Airlines fies from Amsterdam to London every day. The price of a ticket for this extremely popular flight route is $75. The aircraft has a passenger capacity of 150.

  Prepare a system of equations

How much money will Dave and Jane raise for charity

  Managing ashland multicomm services

This question is asking you to compare the likelihood of your getting 4 or more subscribers in a sample of 50 when the probability of a subscription has risen from 0.02 to 0.06.]  Talk about the comparison of probabilities in your explanation.

  Skew-symmetric matrices

Skew-symmetric matrices

  Type of taxes and rates in spokane wa

Describe the different type of taxes and their rates in Spokane WA.

  Stratified random sample

Suppose that in the four player game, the person who rolls the smallest number pays $5.00 to the person who rolls the largest number. Calculate each player's expected gain after one round.

  Find the probability density function

Find the probability density function.

  Develop a new linear programming for an aggregate production

Linear programming applied to Aggregate Production Planning of Flat Screen Monitor

  Discrete-time model for an economy

Discrete-time model for an economy

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