TAILIEUCHUNG - A Guide to MATLAB for Beginners and Experienced Users phần 6

Mỗi 1 đại diện cho một trò chơi mà các casino đã thắng, và -1 từng đại diện cho một trò chơi mà nó bị mất. Đối với một số lượng lớn các trò chơi, nói rằng 100, chúng ta có thể cho MATLAB tổng hợp doanh thu từ các cược cá nhân như sau: | Monte Carlo Simulation 145 revenues sign - rand 1 10 revenues 1-1 1-1-1 1 1-1 1-1 Each 1 represents a game that the casino won and each 1 represents a game that it lost. For a larger number of games say 100 we can let MATLAB sum the revenue from the individual bets as follows profit sum sign - rand 1 100 profit -4 The output represents the net profit or loss if negative for the casino after 100 games. On average every 100 games the casino should win 51 times and the player s should win 49 times so the casino should make a profit of 2 units on average . Let s see what happens in a few trial runs. profits sum sign - rand 100 10 profits 14 -12 6 2 -4 0 -10 12 0 12 We see that the net profit can fluctuate significantly from one set of 100 games to the next and there is a sizable probability that the casino has lost money after 100 games. To get an idea of how the net profit is likely to be distributed in general we can repeat the experiment a large number of times and make a histogram of the results. The following function computes the net profits for k different trials of n games each. profits @ n k sum sign - rand n k profits @ n k sum sign - rand n k What this function does is to generate an n X k matrix of random numbers and then perform the same operations as above on each entry of the matrix to obtain a matrix with entries 1 for bets the casino won and 1 for bets it lost. Finally it sums the columns of the matrix to obtain a row vector of k elements each of which represents the total profit from a column of n bets. 146 Chapter 10. Applications Now we make a histogram of the output of profits using n 100 and k 100. Theoretically the casino could win or lose up to 100 units but in practice we find that the outcomes are almost always within 30 or so of 0. Thus we let the bins of the histogram range from 40 to 40 in increments of 2 since the net profit is always even after 100 bets . hist profits 100 100 -40 2 40 axis tight 10 8 6 4 2 0 -20 0

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.