%BINOMIAL RANDOM VARIABLE
%this is a script for simulating 'm' outcomes of a
'inomial random variable, and comparing the outcome
%of tha experiment with the theoretical PDF.
m=1000; ample size
n=10;
imulate m random walks until time t
t=100;
p=0.5;
m=10000;
X=rand(t+1,m);%create a matrix of t rows and m columns
%of uniform(0,1) random outcomes
S=zeros(t+1,m); %create a matrix of t+1 rows and m co
imulate m random walks until time t
t=100;
p=0.5;
m=4;
X=rand(t+1,m);%create a matrix of t rows and m columns
%of uniform(0,1) random outcomes
S=zeros(t+1,m); %create a matrix of t+1 rows and m column
0efine a row vector
a=[2,3,-2,4,-2,0]
0efine a column vector
c=[5;2;-4;-1;0;4]
%calculate the inner (dot) product of a and c
b=dot(a,c)
%create a matrix 3x3 matrix
A=[1,2,5; 3,7,-1; 0,3,pi]
%create a
t=50; % number of periods to simulate
X=zeros(t,1); torage for simulated states
U1=rand(); imulate the first state
if U1<=0.3
X(1,1)=0;
else
X(1,1)=1;
end
for i=2:t
if X(i-1,1)=0 0eed to indicate s