haskell 解说

暴风骤雨
• 阅读 638

Monte Carlo Simulations (MCSs)
Expected payoff
St. Petersburg Paradox

Just to remind you, the St. Petersburg Paradox involves a mind game.

Imagine that I offer you the following game.

First, you pay a sum of money to play the game.

I toss a coin. If it comes up heads, I pay you £2.
If it comes up tails, I toss again. If it comes up heads, I pay you double the previous prize which in this case is £2 * 2 = £4.

Essentially the entire game is a loop:

Set the prize to be £2
Repeat:
Toss the coin
If it comes up tails, double the prize
Until – it comes up heads
Pay out the prize.

The paradox arises because the overall expected payoff is the sum of the individual expected payoffs, all of which are £1 (see the lecture notes). The number of individual expected payoffs is infinite. So there should be no limit to the amount that you would be willing to pay in order to play. In practice you would be very foolish to do so.

One question we never discussed was “What is, in practice, a reasonable amount to pay to play?” If you offer to pay £1 to pay, you are clearly going to win every time. If you pay £2 to play you will break even 50% of the time and make a profit 50% of the time. So, at least £2 is a safe bet.

But what about larger amounts?

For example, suppose you decide to pay £5 to play. If you play 10 games do you, on average, win? If you play 20 games do you, on average, win? If you increase the number of games you are prepared to play, does that increase or decrease your chances of winning?

One way to try to answer this is with a MCS.

Let’s stick with £5 to play for a moment. If you play 10 games it will cost you £50 to play them all. If your winnings exceed £50 you have made a profit, if they are less than £50 you have made a loss.

But if you played another 10 games, your winnings/loses are likely to be different because each game has a random element. But that is OK because this is a MCS. So you can program it to play 10 games over and over again until you have enough results to average them and get a good, reliable, answer. This will tell you whether, on average, a bet of £5 and playing 10 games is going to be profitable (or not).

But, of course, you could do this again for 20 games and 30 and a whole host of other numbers of games whilst keeping the same pay to play (£5 per game).

And, of course, you can also investigate what happens if you vary the amount you are prepared to pay to play. In other words, you can create a two-dimensional matrix like this:
In the cells at the intersection of these two values, you can put the average gain or lose that you have calculated.

So the assignment is to write a MCS in R that provides the data to fill this matrix. We leave it up to you to decide which:
pay to play values you investigate
average number of games you try
the number times you run the MCS with a given number of games.

The deliverables are:
An Excel worksheet that that includes the matrix shown above (except that yours should also contain values).
A Word document that provide an overview of what you have done and why. This document should not exceed 500 words.
A text file called AssignMCS.R that contains your MCS as a block of R code that can be pasted into R studio and run. We do not expect you to use any specialised libraries so there should be no need to run install.packages().

Marks are assigned for the functionality of the code and also for its readability.
WX:codehelp

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
美凌格栋栋酱 美凌格栋栋酱
6个月前
Oracle 分组与拼接字符串同时使用
SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(
Easter79 Easter79
3年前
typeScript数据类型
//布尔类型letisDone:booleanfalse;//数字类型所有数字都是浮点数numberletdecLiteral:number6;lethexLiteral:number0xf00d;letbinaryLiteral:number0b101
Wesley13 Wesley13
3年前
VBox 启动虚拟机失败
在Vbox(5.0.8版本)启动Ubuntu的虚拟机时,遇到错误信息:NtCreateFile(\\Device\\VBoxDrvStub)failed:0xc000000034STATUS\_OBJECT\_NAME\_NOT\_FOUND(0retries) (rc101)Makesurethekern
Wesley13 Wesley13
3年前
FLV文件格式
1.        FLV文件对齐方式FLV文件以大端对齐方式存放多字节整型。如存放数字无符号16位的数字300(0x012C),那么在FLV文件中存放的顺序是:|0x01|0x2C|。如果是无符号32位数字300(0x0000012C),那么在FLV文件中的存放顺序是:|0x00|0x00|0x00|0x01|0x2C。2.  
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
3年前
PHP创建多级树型结构
<!lang:php<?php$areaarray(array('id'1,'pid'0,'name''中国'),array('id'5,'pid'0,'name''美国'),array('id'2,'pid'1,'name''吉林'),array('id'4,'pid'2,'n
Wesley13 Wesley13
3年前
Java日期时间API系列36
  十二时辰,古代劳动人民把一昼夜划分成十二个时段,每一个时段叫一个时辰。二十四小时和十二时辰对照表:时辰时间24时制子时深夜11:00凌晨01:0023:0001:00丑时上午01:00上午03:0001:0003:00寅时上午03:00上午0
Wesley13 Wesley13
3年前
MBR笔记
<bochs:100000000000e\WGUI\Simclientsize(0,0)!stretchedsize(640,480)!<bochs:2b0x7c00<bochs:3c00000003740i\BIOS\$Revision:1.166$$Date:2006/08/1117
Python进阶者 Python进阶者
1年前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这