Java的几何布朗运动

Wiener过程是连续时间随机过程,以纪念Norbert Wiener命名。 通常用于用随机成分表示噪音或财务状况。

可以计算几何布朗运动以可视化某些界限(以分位数表示)以暗示绝对范围。 为了进行计算,需要以下参数:

  • µ(mu):平均百分比
  • σ(sigma):方差
  • t:时间段
  • v:初始值

常规计算的扩展使用:m:每个时间段的增值(在我的情况下为月度值)中断:分位数中断以计算界限

计算值的代码:

import java.time.LocalDate;
import java.util.*;
import static java.lang.Math.sqrt;
import static java.lang.Math.exp;

public class WienerProcess {
    /**
     * Run the Wiener process for a given period and initial amount with a monthly value that is added every month. The
     * code calculates the projection of the value, a set of quantiles and the brownian geometric motion based on a
     * random walk.
     *
     * @param mu mean value (annualized)
     * @param sigma standard deviation (annualized)
     * @param years projection duration in years
     * @param initialValue the initial value
     * @param monthlyValue the value that is added per month
     * @param breaks quantile breaks
     * @return a List of double arrays containing the values per month for the given quantile breaks
     */
    public static List<double[]> getProjection(double mu, double sigma, int years, int initialValue,
        int monthlyValue, double[] breaks) {
        double periodizedMu = mu / 12;
        double periodizedSigma = sigma / Math.sqrt(12);
        int periods = years * 12;

        List<double[]> result = new ArrayList<double[]>();

        for (int i = 0; i < periods; i++) {
            double value = initialValue + (monthlyValue * i);
            NormalDistribution normalDistribution = new NormalDistribution(periodizedMu * (i + 1),
                    periodizedSigma * sqrt(i + 1));
            double bounds[] = new double[breaks.length];
            for (int j = 0; j < breaks.length; j++) {
                double normInv = normalDistribution.inverseCumulativeProbability(breaks[j]);
                bounds[j] = value * exp(normInv);
            }

            result.add(bounds);
        }
        return result;
    }
}

应用值:

  • 亩:0.05(或5%)
  • sigma:0.1(或10%)
  • 初始值:7000
  • 每月增加:100
  • 时间:6年

结果如下表:

图1_50593

相关信息

翻译自: https://www.javacodegeeks.com/2015/12/geometric-brownian-motion-java.html

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值