I want to use the Statistics package that enables to do symbolic calculations with random variables to define a sequence of random variables.
This code does not work:
restart;
with(Statistics):
X:=RandomVariable(DiscreteUniform(1,26));
seq(X(i),i=0..1000);
because it displays:
> Mean(X(5));
>
_R(5)
Instead of 27/2. Does somebody know how to fix this?
Make X a Vector, like this:
X:= Vector(1000, ()-> Statistics:-RandomVariable(DiscreteUniform(1,26))):
Then you can give commands like
Statistics:-Mean(X(5));
and you'll get your expected output.
If you insist on indexing starting at 0, it's a tiny bit more complicated. Change the defining command to
X:= Array(0..1000, ()-> Statistics:-RandomVariable(DiscreteUniform(1,26))):
And you'll need to do the indexing with square brackets: X[0], X[5], etc,