Random value generation over huge range error

So far my code for generating a single random number between the range 1 to nsquare is
g = feval(symengine,'random',1,nsquare);
I'm doing this in Matlab code but calling on mupad due to needing system objects, in this case nsquare is a large number in the order of "273093755969093307889". Currently the code give the following result.
g =
proc()\n name random;\nbegin\n SEED := _MULTIPLIER*SEED mod _MODULUS; \n (SEED mod _DIVISOR) + _OFFSET\nend_proc
If anyone knows how to implement getting a single random variable from a large range, or knows where I'm going wrong with that line, I would greatly appreciate it.

 Réponse acceptée

The MuPAD routine random() takes as input a value range, and returns as output a generating procedure that can be called to generate values in that range. So tell MuPAD to evaluate the routine, which I think would be:
feval(symengine, g)

1 commentaire

David
David le 13 Nov 2012
Thank you very much, it appears to be doing what it should now.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by