⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ranwalk.m

📁 此工具包是对Matlab的随机工具包的扩展
💻 M
字号:
function [rwproc] = ranwalk(npoints, p)
% RANWALK generate and plot a trajectory of a random walk which
%    starts at 0, jumps up with probability p and down with
%    probability 1-p 
%
% [rwproc] = ranwalk(npoints, p)
%
% Inputs: npoints - length of the trajectory 
%         p - probability of the jump upwards
%
% Outputs: rwproc - trajectory of the process

% Authors: R.Gaigalas, I.Kaj
% v1.2 07-Oct-02

  % default parameter values
  if (nargin==0)
    npoints = 100;
    p = 0.5;
  end

  % generate jumps and sum up
  rwproc = [0 cumsum(2.*(rand(1, npoints-1)<p)-1)]; 

  stairs(rwproc);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -