Question: Why is the "save+read" of a random variable no longer a random variable?

Hi, 

I've define a list V of 2 random variables and saved the result in an .m file.
When I read this same file and try to sample V I get a message error which, after quick search, comes from the fact that the V I read is no longer a random variable.
How can I fix this?

TIA


 

restart:

interface(version)

`Standard Worksheet Interface, Maple 2015.2, Mac OS X, December 21 2015 Build ID 1097895`

(1)

with(Statistics):

V := [ RandomVariable(Normal(0, 1)), RandomVariable(Uniform(0, 1)) ]

[_R, _R0]

(2)

map(v -> [attributes(v)][3], V);
print~(map(Sample, V, 5)):

"[[Typesetting:-mi("_ProbabilityDistribution",italic = "true",mathvariant = "italic"), Typesetting:-mi("_ProbabilityDistribution0",italic = "true",mathvariant = "italic")]]"

 

Vector[row](5, {(1) = -1.07242412799827, (2) = -.329077870547065, (3) = -.617091936909790, (4) = .214466745245291, (5) = -0.254281280423846e-1})

 

Vector[row](%id = 18446744078251172318)

(3)

dir := currentdir():
f   := cat(dir, "/Desktop/rvs.m"):
save V, f

 

restart

with(Statistics):

dir := currentdir():
f   := cat(dir, "/Desktop/rvs.m"):
read f:

anames(user);
V;

dir, f, V

 

[_R, _R0]

(4)

print~(map(Sample, V, 5)):

Error, (in Statistics:-Sample) invalid input: expected distribution or algebraic expression with random variables, but received _R

 

attributes(V[1]); # The Vs are no longer random variables


 

Download Why.mw

Please Wait...