Che
04-14-2008, 01:30 PM
I'm fairly new to Splus.
I have a probabilty distribution:
P(Xj=-1) = 0.35
P(Xj=0)= 0.4
and P(Xj=1) = 0.25
and am looking at finding a function that simulates the summing of Xj variables. S(n)
e.g S(2) has
P(S(2)=0) = 0.335
P(S(2)=-1)= 0.280
P(S(2)=1) = 0.200
P(S(2)=-2) = 0.1225
and P(S(2)=2) = 0.0625
But I was to simulate this random walk for higher n in s-plus.
I've been hinted at the commands "sample", "cusum" and "tsplot" being helpful.
But I'm completely stuck!
I have a probabilty distribution:
P(Xj=-1) = 0.35
P(Xj=0)= 0.4
and P(Xj=1) = 0.25
and am looking at finding a function that simulates the summing of Xj variables. S(n)
e.g S(2) has
P(S(2)=0) = 0.335
P(S(2)=-1)= 0.280
P(S(2)=1) = 0.200
P(S(2)=-2) = 0.1225
and P(S(2)=2) = 0.0625
But I was to simulate this random walk for higher n in s-plus.
I've been hinted at the commands "sample", "cusum" and "tsplot" being helpful.
But I'm completely stuck!