用抛硬币的方式介绍Python中的遍历经济学

This post was inspired by Ergodicity Economics.

这篇文章的灵感来自遍历经济学。

Suppose your wealth was subject to a coin toss- if heads, your wealth increases by 50%, if tails, your wealth decreases by 40%. Would you play this game? How would you go about figuring out if this game was worth it?

假设您的财富受到抛硬币的影响-如果正面朝上,则您的财富增加了50%;如果背面朝上,则您的财富减少了40%。 你会玩这个游戏吗? 您将如何确定该游戏是否值得?

Image for post
Source: Ergodicity Economics, Pg. 5
资料来源:Ergodicity Economics,Pg。 5

Let’s further suppose that you played this game once a week for a year. What then? The above graph is one simulation of that scenario.

进一步假设您一年玩一次这个游戏,一年。 然后怎样呢? 上图是该场景的一种模拟。

Towards the end, it appears as if your wealth has increased, but the final 52nd week has a wealth equal to only 1% greater than your initial amount, so not exactly great. Lots of volatility, and not much reward. Peak of 5x initial wealth; you should’ve quit while you were ahead!

到最后,您的财富似乎增加了,但是最后的第52周的财富仅比您的初始金额多1%,因此并不十分理想。 波动很大,回报不多。 5倍于初始财富的峰值; 您应该在前进时就退出!

Here’s the code on GitHub. We define a coinTossFunction that recalculates your wealth, and iterate 52 times to see what your wealth is. We can use MatPlotLib and Numpy to graph the charts.

这是GitHub上的代码 。 我们定义一个coinTossFunction来重新计算您的财富,并重复52次以查看您的财富是多少。 我们可以使用MatPlotLib和Numpy绘制图表。

Image for post

One iteration doesn’t tell us anything about whether the game was worth it, so let’s try again.

一次迭代不会告诉我们有关游戏是否值得的任何信息,所以让我们再试一次。

Image for post

Your final wealth here is 6% of your initial wealth, so this game is starting to look unprofitable. But maybe not. Let’s try to think about this in more rigorous terms.

您在此处的最终财富是初始财富的6%,因此该游戏开始显得无利可图。 但也许不是。 让我们尝试更严格地考虑一下。

We can think about whether this game is profitable by either A. playing it many times in parallel, or B. playing it one time for a really long time. But the trick is these will result in diametrically opposed outcomes for this coin toss game. And that has implications for the foundations of economics.

我们可以考虑通过A.多次并行玩游戏或B.长时间玩一次游戏来获利。 但是诀窍在于,这些将导致这种掷硬币游戏的结果截然相反。 这就对经济学的基础产生了影响。

Image for post

In the above chart, we have run 1000 parallel games, each lasting 52 weeks. Then, we take the average wealth at each week to come up with this chart. Notice, here the final value is 18x the initial. That makes the game seem worth it!

在上图中,我们已经运行了1000场平行游戏,每场持续52周。 然后,我们以每周的平均财富来得出此图表。 注意,这里的最终值是初始值的18倍。 这使游戏看起来值得!

Here we have calculated the “finite ensemble average”:

这里我们计算了“有限总体平均数”:

Image for post
Source: Ergodicity Economics, Pg. 6
资料来源:Ergodicity Economics,Pg。 6

Here is the updated code.

这是更新的代码。

Image for post

It should be noted, however, that the average values are “dragged up” by extreme outliers. If one person gets extremely lucky and ends up with wealth 1000x the starting value, the entire average will be brought up. Perhaps we would be better off only looking at median values instead.

但是,应该注意,平均值被极端的异常值“拖累”了。 如果一个人非常幸运,最终获得的财富是起始价值的1000倍,那么整个平均值就会提高。 也许我们最好只看中间值。

But in general, this is the wrong way to think about it. You are being asked to play this game. There aren’t 1000 you’s that each get to play this game. Furthermore, even if there were, would you really want to play a game where 1 of you ends up insanely rich, while the rest lose money? Then again, that’s kind of capitalism, isn’t it?

但是总的来说,这是错误的思考方式。 被要求玩这个游戏。 每个人只有1000个玩这个游戏。 此外,即使有,您是否真的想玩一个游戏,其中你们一个人疯狂地富起来,而其余的人赔钱呢? 再说一次,这是一种资本主义,不是吗?

Instead, another way to think about this game is to simply play the game one time, but for a really long time. Below is a chart of playing this game 1000 weeks, once. That’s as opposed to the above chart, where we play 1000 times in parallel for 52 weeks at a time.

相反,考虑该游戏的另一种方法是简单地玩一次游戏,但是要玩很长时间。 以下是一次玩此游戏1000周的图表。 这与上面的图表相反,在该图表中,我们一次连续玩1000次,连续52周。

Image for post

As you can see, the longer you play, it is almost certain that your wealth approaches 0. So, from this perspective, it is definitely bad to play this game. Only a few people end up with a ton of wealth, while the rest of us end up penniless. And the longer you play, the more likely you are to lose all your money.

如您所见,玩的时间越长,几乎可以肯定您的财富接近0。因此,从这个角度看,玩这个游戏绝对不好。 只有少数人拥有大量财富,而我们其他人最终却一文不值。 而且玩的时间越长,损失所有钱的可能性就越大。

There are two immediate lessons to be learned here. First is the obvious important difference between averages and medians. Playing a game with a high average but low median is probably not a game worth playing. Aka, the lottery.

这里有两个直接的教训要学习。 首先是平均值和中位数之间明显的重要差异。 玩平均水平高但中位数低的游戏可能不值得玩。 又名彩票。

But more important for the foundations of economics is the time or dynamics involved. Typically, economists like to look at things from a static perspective. That’s the finite ensemble average way of thinking.

但是,对于经济学基础而言,更重要的是所涉及的时间或动力。 通常,经济学家喜欢从静态的角度看待事物。 这就是有限的整体平均思维方式。

When we consider the dynamics of the game over a very long time, we can see that this game is definitely not profitable. While there are much more important implications to draw from this (and I will be writing about them in the future), you have completed your first lesson in ergodicity.

当我们长时间考虑游戏的动态时,我们可以看到该游戏绝对没有盈利。 尽管有很多更重要的含义可以借鉴(我将在以后进行介绍),但是您已经完成了遍历性的第一课。

Nassim Taleb would be proud!

Nassim Taleb将感到骄傲!

翻译自: https://medium.com/datadriveninvestor/introduction-to-ergodic-economics-in-python-with-a-coin-toss-b73d9b339088

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值