Question

Write a piece of R code to compute the following series: em = 1 + 0.8...

Write a piece of R code to compute the following series:
em = 1 + 0.8 (1*80%) + 0.64 (0.8*80%) + 0.512 (0.64*80%) + …
em = function(n, r = 0.8){
Body of code
}

Homework Answers

Answer #1

if you have any problem let me know i will try to help you. Thank you.

em <- function(n, r = 0.8){
 sum <- 1
 temp <- r
 for (i in 1:n){
     sum <- sum +(temp*temp)
    
     temp <- temp*r
 }
 print(sum)
 
}

em(2)
em(5)

// Sample output for n=2 and n=5.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Prompt: Write a code in MARS MIPS that uses a stack to recursively compute the series...
Prompt: Write a code in MARS MIPS that uses a stack to recursively compute the series from 1 to 10.
Use R Studio (show the code and output) Please write an R function named “outlier_detect” to...
Use R Studio (show the code and output) Please write an R function named “outlier_detect” to return or print out the outliers from a given data vector. outlier_detect = function(x){ #x: a column of numeric vector Body of code }
APPLIED STATISTICS 2 USE R CODE ! SHOW R CODE! Write a function to calculate the...
APPLIED STATISTICS 2 USE R CODE ! SHOW R CODE! Write a function to calculate the sum of cubes from 1 to n, but skip the multiple of 5. Say, if n=10, the result is 1^3+2^3+3^3+4^3+6^3+7^3+8^3+9^3. The input is the value of n, the output is the summation. (you need if statement to check whether a number is a multiple of 5.In R, a%%b is the remainder for a divided by b. So, we have 10%%5=0) APPLIED STATISTICS 2 USE...
1- Write algorithm (in pseudo-code) for the following problem: sum of the series: 1 +2+3+…+N 2-...
1- Write algorithm (in pseudo-code) for the following problem: sum of the series: 1 +2+3+…+N 2- Convert an algorithm to a flowchart diagram. 3- Counting the primitive operations of the algorithm. 4- Determine algorithm complexity. 5- Write a complete C++ program for the previous algorithm where the program should contain the following:  Display messages.  Input any number;  Display the series.  Display the sum of the series.
C++ please! Write a recursive function to compute the sum of the Taylor series. use double...
C++ please! Write a recursive function to compute the sum of the Taylor series. use double taylor(int a, int n)
Write the R statements and associated output to compute the following quantities. Draw a graph of...
Write the R statements and associated output to compute the following quantities. Draw a graph of the probability mass function or probability density function illustrating the quantity being computed. (a) The 90th percentile of a U(0, 20) random variable. (b) The 20th percentile of a N(0,1) random variable. (c) The interquartile range of a N(5, 9) random variable. (d) The interquartile range of a binomial(10, 0.4) random variable.
(1) Write R code to install the package named "MASS" only if the package is not...
(1) Write R code to install the package named "MASS" only if the package is not already installed on the machine. Then attach that package to your current workspace to use it in your programming. Your code below (2) Write R code to find what datasets are available only for the MASS package by creating a file named "R data sets". Your code below (3) Write R code to bring up the documentation page for the "Boston" dataset. Your code...
Write ARMv8 Assembly code and C++ code for a function called int grade(int n) that returns...
Write ARMv8 Assembly code and C++ code for a function called int grade(int n) that returns the character 'A' if n >= 90, 'B' if 90 > n >= 80, etc. (Use the ASCII code.)
write a java code. Write a program using loops to compute the sum of the 30...
write a java code. Write a program using loops to compute the sum of the 30 terms of the series below. 91/(3 + 2 + 2) + 92/(4 - 4 + 5) + 93/(5 + 6 - 8) + 94/(6 - 8 + 11) + 95/(7 + 10 + 14) + 96/(8 - 12 - 17) + . . . . Output: Term Ratio Sum 1 13 13 2 18.4 31.4 etc etc
Write an R code that does the following: (a) Generate n samples x from a random...
Write an R code that does the following: (a) Generate n samples x from a random variable X that has a uniform density on [0,3]. Now generate samples of Y using the equation: y = α/(x + β). For starters, set α = 1, β = 1 The R code: x=runif(n=1000, min = 0, max = 3) x y=1/x+1 y Please answer the following: b) Use plot(x,y) to check if you got the right curve. c) How does the correlation...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT