This assignment is to a analyze a random experiment. Assume that you have to toss a fair coin (50% probability for each head and tail) N times, where N→ o0, When head comes up, you will be rewarded (gain) RM1, while if tail comes up, you will be penalized (loss) RM1. Write a function function sum return = coin_toss (N) that returns a row vector sum_return of length N+1. Each column i represents gained sum from i-1 number of coin tosses, i.e. sum_return (1)=0. To solve this problem, you will need both a for statement and the rand function. Try out several (minimum of 2) tries a value of N of 1000, 10000, 100000, 1000000 and plot the results. The x-axis must show the values from 0 to N. The y-axis should be limited to the maximum gain and minimum loss during each experiment. Note that as N is large, plotting N points will take a long time. Find a way on how this can be made faster.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
This assignment is to a analyze a random experiment. Assume that you have to toss a fair coin (50%
probability for each head and tail) N times, where N→ 00,
When head comes up, you will be rewarded (gain) RM1, while if tail comes up, you will be penalized
(loss) RM1.
Write a function
function sum_return
coin_toss (N)
that returns a row vector sum_return of length N+1. Each column i represents gained sum from
i-1 number of coin tosses, i.e. sum_return (1) =0.
To solve this problem, you will need both a for statement and the rand function. Try out several
(minimum of 2) tries a value of N of 1000, 10000, 100000, 1000000 and plot the results. The x-axis
must show the values from 0 to N. The y-axis should be limited to the maximum gain and minimum
loss during each experiment.
Note that as N is large, plotting N points will take a long time. Find a way on how this can be made
faster.
Transcribed Image Text:This assignment is to a analyze a random experiment. Assume that you have to toss a fair coin (50% probability for each head and tail) N times, where N→ 00, When head comes up, you will be rewarded (gain) RM1, while if tail comes up, you will be penalized (loss) RM1. Write a function function sum_return coin_toss (N) that returns a row vector sum_return of length N+1. Each column i represents gained sum from i-1 number of coin tosses, i.e. sum_return (1) =0. To solve this problem, you will need both a for statement and the rand function. Try out several (minimum of 2) tries a value of N of 1000, 10000, 100000, 1000000 and plot the results. The x-axis must show the values from 0 to N. The y-axis should be limited to the maximum gain and minimum loss during each experiment. Note that as N is large, plotting N points will take a long time. Find a way on how this can be made faster.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY