Question: This Week's Questions involve the Fibonacci sequence, which is the series of numbers: 1, 1, 2, 3, 5, 8, 13, 21, 34, . .., where,



This Week's Questions involve the Fibonacci sequence, which is the series of numbers: 1, 1, 2, 3, 5, 8, 13, 21, 34, . .., where, if we denote by fx the kth number in this sequence, then fke = fk-1+ fk-2, for k > 3. Your tasks are: 1. Create a function called fibo. seq , which satisfies the following properties: . It has two arguments: one called n (with no default value), and one called full (with default value set to TRUE ). . What the function returns depends on whether the user sets argument full to TRUE or FALSE . . If full=TRUE , then the function returns on one line (as a vector) the first n numbers in the Fibonacci sequence (starting at 1, 1, . . .). If full=FALSE, then the function returns the nth number (only) of the Fibonacci sequence. (You can assume that the argument n entered by a user is bigger or equal to 3.) 2. Consider a discrete random variable X such that Pr[X = fx] = Pk for k = 1, 2, ..., n, where fx corresponds to the kth number in the Fibonacci sequence and {p1, p2, . . ., Pn} is a sequence of probabilities such that Ck_1 Pk = 1.Create a function called f-ibo .moments , which satises the following properties: - It has two arguments: one called n {with no default value]. one called probes [with no default value}. Again you can assume that n E 3. - It returns a vector of two values: the rst is the expected value EDI] and the second is the standard deviation of X {under the assumption that the argument probes is a vector containingpl, p2, . . . mm in that order]. - If the elements in probes do not sum to II the function returns the sentence \"Are you sure you have valid probas?". - |f probes is valid but the number of elements in probes is not equal to n, the function returns the sentence \"Are you sure you have the right length for probas?' Hint: You can call a function {e.g. f-ibo. seq 1 within another function. A precision to avoid any possible ambiguity {added zzmsoozi 1: Because f1 2 f2 = 1, we have that Pr[}t' = 1] =p1 + 312. 3. Run the command rat-io
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
