sample and distributions

Messages in english

Modérateur : xcasadmin

belanger
Messages : 52
Inscription : jeu. juil. 27, 2017 3:26 pm

sample and distributions

Message par belanger » jeu. déc. 17, 2020 11:56 pm

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?

belanger
Messages : 52
Inscription : jeu. juil. 27, 2017 3:26 pm

Re: sample and distributions

Message par belanger » ven. déc. 18, 2020 4:04 am

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).

lukamar
Messages : 300
Inscription : ven. juin 30, 2017 9:55 am
Localisation : Zagreb, Croatia

Re: sample and distributions

Message par lukamar » mar. déc. 22, 2020 5:03 pm

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.

Répondre