楼主: cheetahfly
8202 8

[学习分享] 用R语言模拟“维纳过程”和“高斯过程” [推广有奖]

  • 2关注
  • 71粉丝

版主

院士

6%

还不是VIP/贵宾

-

威望
0
论坛币
58984 个
通用积分
1436.4914
学术水平
480 点
热心指数
587 点
信用等级
328 点
经验
126603 点
帖子
2072
精华
1
在线时间
3779 小时
注册时间
2010-10-27
最后登录
2024-5-20

相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
在网上看到的,和大家分享,共同学习:
#
#
#
#
#
#
模拟用的函数:
  1. # 需要已经安装了MASS包
  2. gaussprocess <- function(from = 0,
  3.                          to = 1,
  4.                          K = function(s, t) {min(s, t)},
  5.                          start = NULL,
  6.                          m = 1000) {
  7.   # Simulates a Gaussian process with a given kernel
  8.   #
  9.   # args:
  10.   #   from: numeric for the starting location of the sequence
  11.   #   to: numeric for the ending location of the sequence
  12.   #   K: a function that corresponds to the kernel (covariance function) of
  13.   #      the process; must give numeric outputs, and if this won't produce a
  14.   #      positive semi-definite matrix, it could fail; default is a Wiener
  15.   #      process
  16.   #   start: numeric for the starting position of the process; if NULL, could
  17.   #      be randomly generated with the rest
  18.   #   m: positive integer for the number of points in the process to simulate
  19.   #
  20.   # return:
  21.   #   A data.frame with variables "t" for the time index and "xt" for the value
  22.   #   of the process
  23.   
  24.   t <- seq(from = from, to = to, length.out = m)
  25.   Sigma <- sapply(t, function(s1) {
  26.     sapply(t, function(s2) {
  27.       K(s1, s2)
  28.     })
  29.   })
  30.   
  31.   path <- MASS::mvrnorm(mu = rep(0, times = m), Sigma = Sigma)
  32.   if (!is.null(start)) {
  33.     path <- path - path[1] + start  # Must always start at "start"
  34.   }
  35.   
  36.   return(data.frame("t" = t, "xt" = path))
  37. }
复制代码

模拟“维纳过程”:
  1. library(tidyverse)
  2. gaussprocess() %>%
  3.     ggplot(aes(t, xt)) +
  4.     geom+line() +
  5.     theme_bw()
复制代码

Wiener.png
模拟“高斯过程”:
  1. gaussprocess(K = function(s, t) {exp(-16 * (s - t) ^ 2)}) %>%
  2.     ggplot(aes(t, xt)) +
  3.     geom_line() +
  4.     theme_bw()
复制代码

Gaussian.png

有兴趣的同学可以看看相关书籍: Gaussian_Processes_for_Machine_Learning.pdf (2.7 MB)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:维纳过程 高斯过程 R语言 Process GAUSS

已有 2 人评分经验 论坛币 学术水平 热心指数 信用等级 收起 理由
Sunknownay + 3 + 3 + 3 精彩帖子
jiangbeilu + 40 + 20 + 5 + 5 + 5 精彩帖子

总评分: 经验 + 40  论坛币 + 20  学术水平 + 8  热心指数 + 8  信用等级 + 8   查看全部评分

本帖被以下文库推荐

沙发
Edwardu 发表于 2018-1-31 11:32:56 |只看作者 |坛友微信交流群
good

使用道具

藤椅
胡明敏 发表于 2019-4-20 22:05:56 |只看作者 |坛友微信交流群
谢谢分享

使用道具

板凳
caimiao0714 学生认证  发表于 2019-4-21 07:46:31 |只看作者 |坛友微信交流群
所以能简要介绍一下高斯过程和维纳过程是用来做什么的不?

使用道具

报纸
cheetahfly 在职认证  发表于 2019-4-21 21:55:40 |只看作者 |坛友微信交流群
caimiao0714 发表于 2019-4-21 07:46
所以能简要介绍一下高斯过程和维纳过程是用来做什么的不?
很遗憾,受水平和眼界所限,我无法准确回答你的提问。在我熟悉的领域,高斯过程对于模拟资产价格走势,对于衍生品的价值评估有一定作用。

使用道具

地板
caimiao0714 学生认证  发表于 2019-4-22 06:39:06 |只看作者 |坛友微信交流群
cheetahfly 发表于 2019-4-21 21:55
很遗憾,受水平和眼界所限,我无法准确回答你的提问。在我熟悉的领域,高斯过程对于模拟资产价格走势,对 ...
感谢分享!

使用道具

7
westerly 在职认证  学生认证  发表于 2019-4-22 08:24:46 |只看作者 |坛友微信交流群
不错,感谢分享!

使用道具

8
木冫亻 发表于 2019-11-18 17:13:48 |只看作者 |坛友微信交流群
感谢分享呀~~

使用道具

9
xxrdragonfly 发表于 2022-8-15 12:26:48 |只看作者 |坛友微信交流群
您好,请问二元维纳过程如何模拟?

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-5-21 09:49