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年
结果如下表:
- 该代码可从Github获得。 它带有Swing GUI来输入值并根据计算结果绘制图表。 https://gist.github.com/mp911de/464c1e0e2d19dfc904a7
相关信息
翻译自: https://www.javacodegeeks.com/2015/12/geometric-brownian-motion-java.html