1. 如何用matlab做蒙特卡羅模擬
所以你的問題就是生成隨機數嘛。 randi函數可以生成隨機正整數。,例如: A = randi(1000, [10, 1]); A是一個5*1的矩陣,裡面是[1,1000]內的隨機整數
2. 怎麼用Matlab做蒙特卡洛模擬呢,求大神
不局限於 matlab,所謂蒙特卡洛模擬其實就是隨機試驗10000次,然後統計下結果。
會用 random 函數就行。。。
3. 如何使用MATLAB進行蒙特卡洛模擬
蒙特卡洛方法於MATLAB中的使用
以我目前粗淺的理解
就是給定參數范圍
利用for等循環語句
來進行大量次數的模擬
得出最接近理想值的結果
4. 如何使用MATLAB進行蒙特卡洛模擬 小小知識站
貼一個蒙特卡洛方法的matlab程序,供大家使用。 {3 x& K/ i1 i( D8 C0 c$ O % Example Monte Carlo Simulation in Matlab 0 O5 \; P" t# t7 v8 c& @ % Function: y = x2^2/x1 5 Z0 W4 e9 q, d5 B+ c % % Generate n samples from a normal distribution 4 s! c6 y, I6 H" d) K+ v. Y; X: Q % r = ( randn(n,1) * sd ) + mu 4 U F* Q) t, T# q* w/ K' Q % mu : mean / E( P8 U" c* o! G8 s/ x % sd : standard deviation % % Generate n samples from a uniform distribution 2 u# ^& K. [0 z% F) @1 y % r = a + rand(n,1) * (b-a) - D+ }& U$ w- M9 @& Q9 W, Z % a : minimum % b : maximum n = 100000; % The number of function evaluations 7 x5 a" @- F& O- Z; w5 j % --- Generate vectors of random inputs ! K& x0 ^# X+ q( V6 { % x1 ~ Normal distribution N(mean=100,sd=5) % x2 ~ Uniform distribution U(a=5,b=15) x1 = ( randn(n,1) * 5 ) + 100; 2 B' l3 n) V) D$ ~ x2 = 5 + rand(n,1) * ( 15 - 5 ); \: O: Y( w3 [9 d: V4 r( k4 { % --- Run the simulation % Note the use of element-wise multiplication - ~% x$ `7 A6 v9 R* F y = x2.^2 ./ x1; ' g$ O7 U; R* F% ` % --- Create a histogram of the results (50 bins) hist(y,50); / M9 m+ s( [* w" J2 I% s/ X % --- Calculate summary statistics y_mean = mean(y) y_std = std(y) ; R7 A2 y M/ T" p, h* m y_median = median(y)
5. 如何在matlab中用蒙特卡洛模擬計算歐式期權價格
function [c,p]=ucoption(S,X,sigma,r,T,M)
sig2=sigma^2;
srT=sqrt(T);
srTa=sigma*srT;
c=0;
p=0;
for i=1:M
ST=S*exp((r-0.5*sig2)*T+srTa*randn);
c=c+max(ST-X,0);
p=p+max(X-ST,0);
end
c=c/M;
p=p/M;
[Call,Put] = blsprice(S, X, r, T, sigma);
error=[c,p]-[Call,Put]
%可以試試 [c,p]=ucoption(10,10,0.3,0.05,0.5,10^4*100);
6. matlab如何實現蒙特卡洛演算法
1、打開MATLAB軟體,如圖所示,輸入一下指令。
7. 怎麼用matlab模擬股票的走勢啊
哥們我想說股票不是數學,這條路走不通
8. matlab 蒙特卡洛模擬
蒙特卡洛是一個電影
9. 怎樣用matlab實現蒙特卡洛模擬
貼一個蒙特卡洛方法的matlab程序,供大家使用。
{3 x& K/ i1 i( D8 C0 c$ O
% Example Monte Carlo Simulation in Matlab 0 O5 \; P" t# t7 v8 c& @
% Function: y = x2^2/x1 5 Z0 W4 e9 q, d5 B+ c
%
% Generate n samples from a normal distribution 4 s! c6 y, I6 H" d) K+ v. Y; X: Q
% r = ( randn(n,1) * sd ) + mu 4 U F* Q) t, T# q* w/ K' Q
% mu : mean / E( P8 U" c* o! G8 s/ x
% sd : standard deviation
%
% Generate n samples from a uniform distribution 2 u# ^& K. [0 z% F) @1 y
% r = a + rand(n,1) * (b-a) - D+ }& U$ w- M9 @& Q9 W, Z
% a : minimum
% b : maximum
n = 100000; % The number of function evaluations 7 x5 a" @- F& O- Z; w5 j
% --- Generate vectors of random inputs ! K& x0 ^# X+ q( V6 {
% x1 ~ Normal distribution N(mean=100,sd=5)
% x2 ~ Uniform distribution U(a=5,b=15)
x1 = ( randn(n,1) * 5 ) + 100; 2 B' l3 n) V) D$ ~
x2 = 5 + rand(n,1) * ( 15 - 5 ); \: O: Y( w3 [9 d: V4 r( k4 {
% --- Run the simulation
% Note the use of element-wise multiplication - ~% x$ `7 A6 v9 R* F
y = x2.^2 ./ x1; ' g$ O7 U; R* F% `
% --- Create a histogram of the results (50 bins)
hist(y,50); / M9 m+ s( [* w" J2 I% s/ X
% --- Calculate summary statistics
y_mean = mean(y)
y_std = std(y) ; R7 A2 y M/ T" p, h* m
y_median = median(y)
10. 求助,如何用matlab做蒙特卡羅模擬
如果是離散的變數,就要一般用一些離散的分布來進行估計,估計完後會有相應的檢驗來檢驗你的的估計結果是不是合理。
不知道你的是什麼實驗數據,如果是環境數據的話,絕大多數都是lognormal distribution!