24小时热门版块排行榜    

查看: 3531  |  回复: 3

zyj8119

木虫 (著名写手)

[交流] 【转帖】(分形)布朗运动的Matlab生成代码 已有3人参与

本人是研究分形理论的,看到论坛上有人求助如何生成布朗运动,特贡献出一段代码。

生成(分形)布朗运动的近似方法主要有随机中点位移法(RMD),快速付立叶换(FFT),后者精度很高且性能好。我所写代码是paxson论文中的S语言代码翻译过来的,希望对大家有所帮助。

***********************刚才传txt文件说附件内容非法,只好贴在下面***************************
CODE:
function similar_sequence = generator_FFT(n,H)   
%--------------------------------------------------------------------------  
% GENERATOR_FFT Use fast fourier transform to generate normalized FGN   
%     and FBM. Then use Norrs method to generate normalized  
%     similar_sequence. Finally, the average of similar_sequence was set to   
%     1 through normaliztion. 
%     
%     Note:   
%     1. The input argument n is the number of point of sequence. It must |   
%     be even. H is the objective similarity you want. 
%     2. The output argument similar_sequence is a similar_sequence with 
%     average equal to 1. The FGN and FBM are normalized FGN and FBM   
%     respectively.   
%     3. This routine is a matlab version of paxson's R routine. For more   
%     details, see "Fast, approximate synthesis of fractional Gaussian   
%     noise for generating self-similar network traffic
%--------------------------------------------------------------------------  

%--------------------------------------------------------------------------   
%  
%    generator_FFT   
%    Edit by Chu Chen, 07/07/2007
%    Should you have any suggestion for improving the code, please contact:  
%    [email]chuch@scut.edu.cn[/email].
%--------------------------------------------------------------------------

if mod(n,2) ~= 0 
    error('The input argument "n" must be even');
else   
    % Returns a Fourier-generated sample path of a "self similar" process   
    % Consisting of n points(n should be even) and Hurst paramenter H   
    n = n/2;   
    lambda = [1:n]*pi/n;  

    % Approxiamte ideal power spectrum.  
    f = FGNspectrum(lambda,H);
  
    % Adjust for estimating power spectrum via periodogram   
    f = f.*exprnd(1,1,n); 
  
    % Construct corresponding complex numbers with randm phase  
    alpha = 2*pi.*unifrnd(0,1,1,n);
    a = sqrt(f).*cos(alpha);   
    b = sqrt(f).*sin(alpha);
    z = complex(a,b); 
  
    % Last element should have zero phase
    z(n) = abs(z(n));
  
    % Expand z to correspond to a Fourier transform of a real-valued signal.   
    zprime = [0,z,conj(fliplr(z(1:n-1)))]; 
  
    % Inverse FFT gives sample path.
    FGN = real(ifft(zprime));   
      
    % Standardize FGN and create FBM.   
    FGN = (FGN-mean(FGN))/std(FGN);
    FBM = cumsum(FGN);   

    % Use Norrs method to generate normalized similar_sequence
    similar_sequence = FGN;   
      
    % M = 30;   
    % a = 5;   
    % similar_sequence = M + sqrt(a*M)*similar_sequence;   
    % similar_sequence = max(0,similar_sequence);  
    % similar_sequence = similar_sequence*2*n/sum(similar_sequence);   
end;   
%----------------------------subfunction1----------------------------------  
function f = FGNspectrum(lambda,H) 
% Returns an approximation of the power spectrum of FGN at the given   
% frequencies lambda and the given Hurst parameter H.   
f = 2*sin(pi*H)*gamma(2*H+1).*(1-cos(lambda)).*(lambda.^(-2*H-1) + FGNest(lambda,H));  
  
%----------------------------subfunction2----------------------------------  
function est = FGNest(lambda,H)  
% Returns the estimate for B(lambda,H).  
d = -2*H-1;   
dprime = -2*H;   
a1 = 2*1*pi+lambda;   
b1 = 2*1*pi-lambda;   
a2 = 2*2*pi+lambda; `  
b2 = 2*2*pi-lambda;   
a3 = 2*3*pi+lambda;   
b3 = 2*3*pi-lambda;  
a4 = 2*4*pi+lambda;   
b4 = 2*4*pi-lambda;  
est = a1.^d + b1.^d + a2.^d + b2.^d + a3.^d + b3.^d + (a3.^dprime+b3.^dprime+a4.^dprime+b4.^dprime)/(8*pi*H)

[ Last edited by zyj8119 on 2010-10-17 at 16:02 ]
回复此楼

» 猜你喜欢

好好学习,天天向上。
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

peichengyan

新虫 (初入文坛)


小木虫(金币+0.5):给个红包,谢谢回帖
这个可不可以在matlab 中直接用啊
2楼2011-05-07 10:20:50
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

风之飘渺

木虫 (小有名气)

好用么
风之飘渺
3楼2011-05-07 10:50:27
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖

福尔摩静

新虫 (初入文坛)


小木虫: 金币+0.5, 给个红包,谢谢回帖
请问楼主 H是赫斯特指数吗?
4楼2017-12-19 10:11:26
已阅   回复此楼   关注TA 给TA发消息 送TA红花 TA的回帖
相关版块跳转 我要订阅楼主 zyj8119 的主题更新
普通表情 高级回复 (可上传附件)
最具人气热帖推荐 [查看全部] 作者 回/看 最后发表
[考研] 311求调剂 +5 26研0 2026-03-15 5/250 2026-03-16 16:21 by a不易
[考研] 材料与化工专硕调剂 +3 heming3743 2026-03-16 3/150 2026-03-16 15:05 by peike
[考博] 东华理工大学化材专业26届硕士博士申请 +6 zlingli 2026-03-13 6/300 2026-03-15 20:00 by ryzcf
[考研] 材料工程327求调剂 +3 xiaohe12w 2026-03-11 3/150 2026-03-14 20:20 by ms629
[考研] 本科南京大学一志愿川大药学327 +3 麦田耕者 2026-03-14 3/150 2026-03-14 20:04 by 外星文明
[考研] 材料080500调剂求收留 +3 一颗meteor 2026-03-13 3/150 2026-03-14 10:54 by peike
[考研] 337一志愿华南理工0805材料求调剂 +7 mysdl 2026-03-11 9/450 2026-03-13 22:43 by JourneyLucky
[考研] 求材料调剂 085600英一数二总分302 前三科235 精通机器学习 一志愿哈工大 +4 林yaxin 2026-03-12 4/200 2026-03-13 22:04 by 星空星月
[考研] 0856材料与化工301求调剂 +5 奕束光 2026-03-13 5/250 2026-03-13 22:00 by 星空星月
[考研] 285化工学硕求调剂(081700) +6 柴郡猫_ 2026-03-12 6/300 2026-03-13 20:46 by hmn_wj
[考研] 26调剂/材料科学与工程/总分295/求收留 +9 2026调剂侠 2026-03-12 9/450 2026-03-13 20:46 by 18595523086
[考研] 材料与化工085600调剂求老师收留 +9 jiaanl 2026-03-11 9/450 2026-03-13 20:22 by JourneyLucky
[考研] 293求调剂 +3 世界首富 2026-03-11 3/150 2026-03-13 16:27 by JourneyLucky
[考研] 295求调剂 +3 小匕仔汁 2026-03-12 3/150 2026-03-13 15:17 by vgtyfty
[考研] 290求调剂 +7 ADT 2026-03-12 7/350 2026-03-13 15:17 by JourneyLucky
[考研] 求调剂 +3 程雨杭 2026-03-12 3/150 2026-03-13 15:06 by JourneyLucky
[考研] 一志愿山大07化学 332分 四六级已过 本科山东双非 求调剂! +3 不想理你 2026-03-12 3/150 2026-03-13 14:18 by JourneyLucky
[考研] 296求调剂 +3 大口吃饭 身体健 2026-03-13 3/150 2026-03-13 10:31 by 学员8dgXkO
[考研] 08食品或轻工求调剂,本科发表3篇sci一区top论文,一志愿南师大食品科学与工程 +3 我是一个兵, 2026-03-10 3/150 2026-03-13 10:21 by Yuyi.
[考研] 一志愿河海大学085900土木水利专硕279求调剂不挑专业 +4 SunWwWwWw 2026-03-10 8/400 2026-03-13 02:23 by SunWwWwWw
信息提示
请填处理意见