模拟模型学习 几何布朗运动_Java的几何布朗运动
生活随笔
收集整理的這篇文章主要介紹了
模拟模型学习 几何布朗运动_Java的几何布朗运动
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
模擬模型學習 幾何布朗運動
維納過程是一個連續時間的隨機過程,以紀念諾伯特·維納。 通常用于用隨機成分表示噪音或財務狀況。
可以計算幾何布朗運動以可視化某些界限(以分位數表示)以暗示絕對范圍。 為了進行計算,需要以下參數:
- μ(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
模擬模型學習 幾何布朗運動
總結
以上是生活随笔為你收集整理的模拟模型学习 几何布朗运动_Java的几何布朗运动的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 淀粉的化学式 淀粉的化学式是什么
- 下一篇: java美元兑换,(Java实现) 美元