Skip to Content
概率机器学习在金融与投资中的应用
book

概率机器学习在金融与投资中的应用

by Deepak K. Kanungo
May 2025
Beginner to intermediate
266 pages
3h 38m
Chinese
O'Reilly Media, Inc.
Content preview from 概率机器学习在金融与投资中的应用

第 3 章 用蒙特卡罗模拟量化输出的不确定性 用蒙特卡罗模拟量化输出的不确定性

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

我拥有骰子的科学知识和数字技能。

-摩诃婆罗多》(Mahabharata,约公元前 900 年)中的瑞图巴纳国王,关于从随机选取的树枝上估算树叶的方法

蒙特卡罗模拟 (MCS),又称蒙特卡罗法,其重要性怎么强调都不为过。在金融和投资领域,MCS 被用于评估各类资产、优化各种投资组合、估算风险以及评估复杂的交易策略。MCS 尤其用于解决那些没有分析解决方案的问题。1事实上,有许多类型的金融衍生品--如回溯期权和亚洲期权--无法使用任何其他技术进行估值。虽然 MCS 的数学基础并不简单,但应用这种方法其实很容易,尤其是在你理解了它所依据的关键统计概念之后。

MCS 还广泛应用于一般机器学习算法,尤其是概率机器学习。正如第 1 章所讨论的以及第 2 章蒙特霍尔问题模拟解决方案所展示的,MCS 使 ,您可以在一个称为前向传播的过程中量化模型输出的不确定性。它将金融分析师使用的传统情景和敏感性分析提升到了一个完全不同的层次。

你可能会想, 一种使用随机抽样的方法怎么会带来稳定的解呢?这不是自相矛盾吗?从某种意义上说是的。但是,当你理解了几个统计定理后,你就会发现,在某些情况下,重复试验可以驯服随机性,使其向稳定解收敛。这就是我们在蒙蒂-霍尔问题的模拟解中观察到的情况,大约 1000 次试验后,解就会向理论值靠拢。在本章中,我们将使用 MCS 来复习关键的统计概念,并向您展示如何应用这一强大工具来解决金融和投资中的实际问题。特别是,我们将 MCS 应用于一个资本预算项目,这里是一个软件开发项目,并估算其价值和持续时间的不确定性。

蒙特卡罗模拟概念验证

在我们开始走这条路之前,我们如何知道 MCS 确实如描述的那样有效呢?让我们通过计算已知常数 pi 的值来对 MCS 进行简单的概念验证。图 3-1展示了我们如何设置模拟来估算 pi。

The blue circle of unit length in a red square with sides of two unit lengths is simulated to estimate the value of pi using MCS.
图 3-1. 在边长为两个单位长度的红色正方形中模拟单位长度的蓝色圆,用 MCS 估算 pi 值

正如 Python 代码所示,您模拟随机喷洒 N 个点,将整个正方形填满。正方形的长度为 2R,因此其面积为 2R × 2R = 4 ×R2= N。这意味着圆形面积与正方形面积之比为 pi/4 = M/N。所以 pi = 4 × M/N:

# Import modules
import numpy as np
from ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

基于scikit-learn和PyTorch的实践机器学习

基于scikit-learn和PyTorch的实践机器学习

Aurélien Géron
Python算法交易实战

Python算法交易实战

Posts & Telecom Press, Sebastien Donadio
软件工程基础

软件工程基础

Nathaniel Schutta, Dan Vega
Python金融实战

Python金融实战

Posts & Telecom Press, Yuxing Yan

Publisher Resources

ISBN: 9798341658271