python大数

重点(Top highlight)

大数定律:(The Law of Large Numbers:)

Have you ever wondered how casinos make money? The law of large numbers is a concept well known right from the early stages of Statistics. But it is not just in Statistics that we find its use. Its significance is felt in various fields of life ranging from gambling to fixing the price for car insurance or even in guessing who might win the poll.

您是否想过赌场如何赚钱? 大数定律是从统计学的早期阶段就广为人知的概念。 但是,我们发现它的用途不仅仅在于统计。 从赌博到确定汽车保险价格,甚至猜测谁可能赢得民意测验,在生活的各个领域中都感受到了它的重要性。

The law of large numbers points out that as the number of trials or observations increases, the observed or the actual probability approaches the expected mean or the theoretical value. This means that as the sample size grows, the mean of the sample gets closer to the average of the total population.

大量定律指出,随着试验或观察次数的增加,观察到的或实际概率接近预期的均值或理论值。 这意味着随着样本数量的增加,样本的平均值越来越接近总人口的平均值。

The law of large numbers sees its application in various fields of analyses ranging from financial to business to statistics. In the business context, for example, growth rates tend to be a representation of The law of large numbers. This is seen in the form of growth rates more or less converging to the growth rates of the economy. Similar is seen in the financial context where the companies with huge market capitalization more or less become stagnant and don’t really see the growth observed previously.

大数定律将其应用于从金融到商业再到统计的各种分析领域。 例如,在商业环境中,增长率往往代表着“大数定律”。 这可以通过增长率或多或少地收敛于经济增长率的形式看出。 在财务背景下,市值巨大的公司或多或少停滞不前,并没有真正看到以前的增长。

A very powerful and widely quoted example for understanding the concept is by observing the flipping of a coin. The initial few tosses might not necessarily give a 50–50 chance for heads or tails. There might be a higher cumulative probability towards one outcome. So the relative frequency can be much farther from the expected 50% in let’s say 10, 20, 50, 100 flips. But on the other hand, let’s say we flip a coin like a 1000 times or 100000 times, then the cumulative probability of getting a heads is much closer to the expected value of 50%.

理解硬币概念的一个非常有力且被广泛引用的例子是观察硬币的翻转。 最初的几次抛掷不一定会给头部或尾部带来50–50的机会。 一个结果可能有更高的累积概率。 因此,相对频率可以比预期的50%远得多,例如10、20、50、100次翻转。 但是,另一方面,假设我们将硬币翻转了1000或100000次,那么获得正面的累积概率就非常接近50%的期望值。

I have tried to simulate this by writing a code in python.

我试图通过在python中编写代码来模拟这一点。

On observing the cumulative probabilities for different number of flips, we see the probability converging to an expected value of 50.0% when the overall flips start growing higher along with the distribution approaching a normal distribution.

在观察不同翻转次数的累积概率时,我们看到当整个翻转开始随着分布接近正态分布而开始变得更高时,概率收敛到50.0%的期望值。

For just 10 Flips we see the below:

仅10次翻转,我们就会看到以下内容:

Probability of heads on flipping the coin 10 times
掷硬币10次的正面概率

For 1000 Flips we see the below:

对于1000次翻转,我们看到以下内容:

Probability of heads converging to 50% on flipping the coin 1000 times
将硬币翻转1000次后,头部的概率收敛至50%

The law of large numbers thus helps us understand why a single outcome alone can’t be trusted. That is why we need to be skeptical of the observations that we get from sample populations, especially ones with low numbers.

因此,大数定律有助于我们理解为什么不能单靠一个结果。 这就是为什么我们需要怀疑我们从样本总体中获得的观察结果,尤其是那些数量较少的观察结果。

平均法则: (The Law of Averages:)

Sometimes people tend to interchange The law of large numbers with the law of averages. They are not the same. While the law of large numbers is a mathematical theorem with a theoretical certainty of the results converging to the expected mean with increasing number of trials (large trials), whereas law of averages is more or less a layman term with a belief that the outcomes of the trials will even out within a small sample. This is not a mathematical principle but rather wishful thinking. And this very bad statistics leads to the concept of ‘Gambler’s fallacy’.

有时人们倾向于将大数定律与平均数定律互换。 它们是不相同的。 大数定律是一个数学定理,随着试验次数(大型试验)的增加,结果的理论确定性会收敛到预期均值,而平均值定律或多或少是一个外行术语,并相信这些试验将在一个很小的样本中实现均衡。 这不是数学原理,而是一厢情愿的想法。 这种非常糟糕的统计数据导致了“赌徒谬论”的概念。

赌徒的谬误: (Gambler’s Fallacy:)

This fallacy is a belief that a certain outcome is likely to happen due to a wrongly perceived underlying principal of the law of averages. This leads the ‘gambler’ to believe that since a specific outcome has not happened recently, there will be a probability for it to happen now so as to average out. One will need to understand that there is no relation between the occurrences of the various outcomes and that they are independent of each other.

这种谬论是一种信念,即由于对均值定律的基本原理的错误理解而可能会产生某种结果。 这使“赌徒”相信,由于最近没有发生过特定的结果,因此有可能现在就发生,以求平均。 人们将需要理解,各种结果的发生之间没有关系,并且它们彼此独立。

While the law of large numbers will help the casino with the earnings over a large number of spins even if it loses on a single or few spins of roulette, the law of averages will not help the gambler by assuming that the wheel will now land on black as it previously landed a few times on red. Therefore it is purely random and there is no real concept of law of averages.

尽管大数定律即使在一次或几次旋转的轮盘赌中失败,也将使赌场获得大量旋转收益,即使平均数定律也不会通过假设轮子现在落在赌徒身上而对赌徒有所帮助黑色,因为它之前几次落在红色上。 因此,它纯粹是随机的,没有真正的平均值定律概念。

大数法在贸易和金融中的应用: (Law of large numbers’ applications in trading and finance:)

The law of large numbers sees its applications in the world of trading and finance too. It suggests that a large number of trades with a higher Sharpe ratio (the reward to risk ratio) will tend to be more effective than a smaller number of trades.

大数定律也在贸易和金融领域也看到了它的应用。 这表明,大量具有较高Sharpe比率(风险收益率)的交易将比少量交易更有效。

As George Soros would put it, what matters is not whether you are right or wrong, rather how much will you make when right and how much will you lose when one is wrong makes your strategy more relevant. This boils down to the reason for effective risk management. In this scenario, basis the law of large numbers, a trader can be wrong the majority of the time but still be profitable.

正如乔治·索罗斯(George Soros)所说,重要的不是你是对还是错,而是当正确时你会赚多少,而当一个错误时你会损失多少,这会使你的策略更有意义。 这归结为有效风险管理的原因。 在这种情况下,根据大数定律,交易者大多数时候可能会犯错,但仍然可以获利。

In a lot of these scenarios, the major challenge is to understand how long a period is actually large enough. Experience tells us that backtesting on the longest period possible gets us closer to the mean annualized returns. Let us take the examples of lower frequency trading strategies. Let us try to understand how long it takes to realize a truer Sharpe strategy and its variance.

在许多这样的情况下,主要的挑战是要了解一个周期实际上足够大的时间。 经验告诉我们,尽可能长的回溯测试使我们更接近平均年化收益。 让我们以较低频率交易策略为例。 让我们尝试了解实现更真实的Sharpe策略及其变化所需的时间。

Let’s assume that a backtested strategy has a true Sharpe ratio of 2 (assuming the case as an average for the lower frequency trades). And let us try and realize this over a 40 day trading period which is broadly around 2 months. Assuming a normal distribution with mean returns of 0.1%, let us simulate and see how the Sharpe Ratios tend to be with an increasing number of trades (or trials).

让我们假设一个经过重新测试的策略的真实Sharpe比率为2(假设该情况是低频交易的平均值)。 让我们尝试在40天的交易期内(大约2个月左右)实现这一目标。 假设平均收益率为0.1%的正态分布,让我们模拟并观察随着交易次数(或试验次数)的增加,夏普比率的趋势。

The python code of it is as below.

它的python代码如下。

With just 15 trades made, we see the below Sharpe Ratios:

仅进行了15笔交易,我们就会看到以下夏普比率:

15 trades placed
进行了15笔交易

The above histogram shows us with just a few trades, one would end up with a lesser Sharpe Ratio than what was seen through backtesting.

上面的直方图显示了只有几笔交易,而最终的夏普比率却比回测中看到的要少。

With 500 trades made, we observe the below:

进行了500笔交易,我们观察到以下几点:

500 trades placed
500笔交易

With 2500 trades, we seen the following:

通过2500笔交易,我们看到了以下内容:

2500 trades placed
进行了2500笔交易

From the above graphs, we can clearly see that with fewer trails, we might observe more losses than wins. But as eventually, the trials keep increasing, the Sharpe ratio is tending towards the backtested number (by tending towards a normal distribution). The trick here is again to involve in as many huge number of trials as one ideally can.

从上面的图表中,我们可以清楚地看到,随着步数的减少,我们可能会看到损失多于胜利。 但是随着试验的最终增加,夏普比率趋向于回测数(趋向于正态分布)。 理想的方法是再次进行尽可能多的试验。

行为心理学对LLN的入侵: (Behavioral psychology’s intrusion on the LLN:)

The key to the working of the law of large numbers is to firstly go in trade after trade and secondly not to interrupt it by changing the underlying assumptions time and again. Traders do tend to change the strategies with a hope to beat the markets and hence finding to maintain the self-control very hard. And to place as many trades as possible without really getting discouraged is too difficult a task. Hence the very concept of ‘Patience and Finance’ becomes more important than ever. This information overloaded era acts as a double edged sword. It on one hand helps the long term investor in making informed choices but at the same perturbs another impatient investor into a regular evaluation of the strategies. This tends the investor with proper stock choices but wrong timing to exit the trade strategy or even the trading game altogether, quite early on.

实施大数定律的关键是,首先是先进行贸易,其次是不通过反复改变基本假设来打断贸易。 交易者确实倾向于改变策略,希望能打败市场,从而发现很难保持自我控制。 在不真正灰心的情况下进行尽可能多的交易是一项艰巨的任务。 因此,“耐心和财务”这一概念比以往任何时候都更加重要。 这个信息超载的时代就像一把双刃剑。 一方面,它有助于长期投资者做出明智的选择,但同时又会扰乱另一位耐心的投资者对策略进行定期评估。 这倾向于使投资者选择适当的股票,但是在很早的时候退出交易策略甚至完全退出交易游戏的时机错误。

离别的想法: (Parting thoughts:)

However sound the trading strategies derived from backtesting might feel, it is only as good as your execution and practice of it numerous times. Trading is a job which requires the right technique and skill set, experience and a more important constant attempts at it.

无论从回测中得出的交易策略听起来多么合理,它都与您多次执行和实践一样好。 交易是一项需要正确的技术和技能,经验以及更重要的不断尝试的工作。

Note from Towards Data Science’s editors: While we allow independent authors to publish articles in accordance with our rules and guidelines, we do not endorse each author’s contribution. You should not rely on an author’s works without seeking professional advice. See our Reader Terms for details.

Towards Data Science编辑的注意事项:虽然我们允许独立作者按照我们的规则和指南发表文章,但我们不认可每位作者的贡献。 您不应在未征求专业意见的情况下依赖作者的作品。 有关详细信息,请参见我们的阅读器条款

翻译自: https://towardsdatascience.com/law-of-large-numbers-in-finance-using-python-86945eaee444

python大数


http://www.taodudu.cc/news/show-3123625.html

相关文章:

  • 【算法】大数乘法问题及其高效算法
  • 超大数相乘的java代码,java版大数相乘
  • 大数定理的MATLAB编程,用MATLAB模拟大数定律和中心极限定理.pdf
  • matlab 大数,在Matlab中考虑大数,然后得到结果中的数字
  • c语言编程 大数运算,求大数运算C语言代码?
  • 看图工具、测试移动端
  • 微信小程序制作看图工具
  • 知乎上的看图神器,你懂的
  • Camera 调试工具使用汇总
  • 免费实用的看图工具 Xee
  • MAC系统的绝佳看图工具iSmartPhoto_我是亲民_新浪博客
  • 三款Linux下最好的看图工具GPicView,sxiv,feh
  • Python3下用tkinter和PIL实现简单的看图工具
  • OS X 安装命令行看图工具 chafa 以及其依赖libtool
  • Synopsys Sentaurus TCAD系列教程之-- Svisual《一》看图工具
  • 由ACD Systems开发的看图工具-ACDSee提供下载
  • 看图工具IrfanView
  • MAC系统的绝佳看图工具iSmartPhoto
  • 看图工具 -- 蓝湖 Axure 墨刀
  • 【腾讯 macOS 优质看图工具】Kantu(看图) V2.4 Mac 正式版
  • python中self image_Python3用tkinter和PIL实现看图工具
  • 看图工具 -- 蓝湖/Axure/墨刀
  • 好工具推荐系列:看图软件irfanview/Honeyview/pineapple-pictures
  • 练习四
  • 超频
  • 在对象内部尽量直接訪问实例变量 --Effictive Objective-C 抄书
  • JAVA读取X.509格式的cer公钥文件信息
  • 北极特快
  • 10 Java基础 多线程2
  • “移”步到位:一站式移动应用研发体系

python大数_使用python的金融大数定律相关推荐

  1. 第一章 第一节:Python基础_认识Python

    Python基础入门(全套保姆级教程) 第一章 第一节:Python基础_认识Python 1. 什么是编程 通俗易懂,编程就是用代码编写程序,编写程序有很多种办法,像c语言,javaPython语言 ...

  2. java python算法_用Python,Java和C ++示例解释的排序算法

    java python算法 什么是排序算法? (What is a Sorting Algorithm?) Sorting algorithms are a set of instructions t ...

  3. excel python插件_利用 Python 插件 xlwings 读写 Excel

    Python 通过 xlwings 读取 Excel 数据 去年底公司让我做设备管理,多次委婉拒绝,最终还是做了.其实我比较喜欢技术.做管理后发现现场没有停机率统计,而原始数据有,每次要自己在Exce ...

  4. 网络安全用python吗_使用Python进行网络安全渗透——密码攻击测试器

    相关文章: 本篇将会涉及: HTTP 基本认证 对HTTP Basic认证进行密码暴力攻击测试 什么是HTTP 基本认证 HTTP基本认证(HTTP Basic Authentication)是HTT ...

  5. 动态照片墙 python 实现_利用python生成照片墙的示例代码

    这篇文章主要介绍了利用python生成照片墙的示例代码,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧 PIL(Python Im ...

  6. python字符串_(Python基础教程之七)Python字符串操作

    Python基础教程 在SublimeEditor中配置Python环境 Python代码中添加注释 Python中的变量的使用 Python中的数据类型 Python中的关键字 Python字符串操 ...

  7. python 字符识别_使用python进行光学字符识别入门

    python 字符识别 语言模型设计 (Language Model Designing) Optical Character Recognition is the conversion of 2-D ...

  8. 如何用python赚钱_利用python能怎么挣钱

    广告关闭 腾讯云11.11云上盛惠 ,精选热门产品助力上云,云服务器首年88元起,买的越多返的越多,最高返5000元! 6年python,期间写了各种奇葩爬虫,挣各种奇葩的钱,写这篇文章总结下几种爬虫 ...

  9. 类的继承python事例_【Python五篇慢慢弹(5)】类的继承案例解析,python相关知识延伸...

    作者:白宁超 2016年10月10日22:36:57 摘要:继一文之后,笔者又将python官方文档认真学习下.官方给出的pythondoc入门资料包含了基本要点.本文是对文档常用核心要点进行梳理,简 ...

最新文章

  1. Redis 分布式锁使用不当,酿成一个重大事故,超卖了100瓶飞天茅台!!!
  2. Adnroid提高效率之资源移动
  3. 1.4. Open Source and License
  4. linux vi 上下左右 ab,【Linux】Ubuntu vi 上下左右变ABCD及 apt-get install报错问题解决方法...
  5. windows下dump文件调试
  6. wps中打印图片去除黑边
  7. python 抓取行政区划
  8. Beanshell相关
  9. BitCoin p2p通信过程
  10. 万万没想到,“红孩儿” 竟然做了程序员,还是 CTO!
  11. Git配置详细教程及基础使用方法,教你轻松学会git代码管理
  12. matlab用方程的解赋值,Matlab隐式符号方程求解和赋值
  13. python 多元线性回归_多元统计分析之多元线性回归的R语言实现
  14. 【渝粤教育】广东开放大学 学前教育研究方法 形成性考核 (23)
  15. MYSQL数据库插入数据时出现Data truncation问题
  16. 次世代游戏美术资源开发全流程及常用的软件
  17. 习题6-2 使用函数求特殊a串数列和 (20分)
  18. QT写小游戏详细教程
  19. 单通道驱动LVDS驱动1080P液晶屏
  20. 记一次越狱砸壳iOSApp的艰辛过程

热门文章

  1. redis/ae总结
  2. BFF在SoundCloud中的实践(翻译)
  3. Unity丛林战争学习02_TCP_解决分包和黏包的问题
  4. 考研日语线上笔记(二):惯用句型250条
  5. Java实现Excel批量导入数据
  6. semantic-ui semantic.json配置
  7. 亚马逊云科技在中国区域新推多项服务;德州仪器携手台达打造高效能服务器电源供应器 | 全球TMT...
  8. 模块的included()
  9. 如何查询Lancome生产及保质期
  10. 【ps-course 网页设计】抠图