Page 1 sur 1

sample and distributions

Publié : jeu. déc. 17, 2020 11:56 pm
par belanger
I guess the sample command can take a distribution as the first argument.
The manual does something like
In: X:=randvar(normal,stddev=9.5):; Y:=randvar(normal,stddev=1.5):;
then
In: sample(eval(X/Y,0),10):
and it works fine. But
In: sample(eval(X,0),10)
gives a bad argument error, while
In: sample(eval(1*X,0),10)
works just fine.
How is sample supposed to work with a distribution as the first argument?

Re: sample and distributions

Publié : ven. déc. 18, 2020 4:04 am
par belanger
Never mind, I guess, Everything works fine without the eval(...,0) there (and I'm a bit surprised it worked in that one case with the eval).

Re: sample and distributions

Publié : mar. déc. 22, 2020 5:03 pm
par lukamar
Hi,
you get different output for eval(X,0) and eval(1*X,0) because X is of type _IDNT (identifier) and 1*X is of type _SYMB (symbolic expression). The _IDNT is currently not handled by sample command and therefore it returns an error. I will modify the code so that cases like eval(X,0) are handled.
Edit: in fact, not accepting eval(X,0) is not a bug, and the code should be left as it is to avoid calling eval from sample.