From: shweta upadhya on 16 May 2010 08:27 can anyone plz explain the code..(function) seed=9; rand(state,seed);
From: ImageAnalyst on 16 May 2010 09:27 The help facility can explain that. Basically it initializes your random number generator so that you can control whether or not you want to use the same sequence of random numbers. From the help: "Note In versions of MATLAB prior to 7.7, you controlled the internal state of the random number stream used by rand by calling rand directly with the 'seed', 'state', or 'twister' keywords. That syntax is still supported for backwards compatibility, but is deprecated. For version 7.7, use the default stream as described in the @RandStream reference documentation."
From: Walter Roberson on 16 May 2010 11:04 shweta upadhya wrote: > can anyone plz explain the code..(function) > seed=9; > rand(state,seed); That would probably tell you that the variable state was undefined. If you were to give state a positive integer value, then rand would produce an output that was an array of that many by 9 random values. rand=(state,seed); that you asked about in your later message is invalid syntax. What you probably meant to ask about was seed=9; rand('state',seed); which changes the state of the random number generator. The exact value of the state is seldom important, so what you need to know is that if you were to later again use rand('state',9) that the random number generator would then produce the same sequence of random numbers each time. This can be important for reproducing results.
From: Godzilla on 16 May 2010 21:03 Walter Roberson <roberson(a)hushmail.com> wrote in message <RPTHn.4922$yx.3269(a)newsfe13.iad>... > shweta upadhya wrote: > > can anyone plz explain the code..(function) > > seed=9; > > rand(state,seed); > > That would probably tell you that the variable state was undefined. If > you were to give state a positive integer value, then rand would produce > an output that was an array of that many by 9 random values. > > rand=(state,seed); > > that you asked about in your later message is invalid syntax. > > > What you probably meant to ask about was > > seed=9; > rand('state',seed); > > which changes the state of the random number generator. The exact value > of the state is seldom important, so what you need to know is that if > you were to later again use rand('state',9) that the random number > generator would then produce the same sequence of random numbers each > time. This can be important for reproducing results. 'This can be important for reproducing results.' Of course! Some sequences are more random than others!!!
From: Walter Roberson on 16 May 2010 23:17 Godzilla wrote: > Walter Roberson <roberson(a)hushmail.com> wrote in message > <RPTHn.4922$yx.3269(a)newsfe13.iad>... >> if you were to later again use rand('state',9) that the random >> number generator would then produce the same sequence of random >> numbers each time. This can be important for reproducing results. > 'This can be important for reproducing results.' > > Of course! Some sequences are more random than others!!! Different sequences are _different_ from each other, and if you find that your program crashes sometimes and not others, then for debugging purposes you want to be able to go back to something known to causes the crash and then trace through the operations until you figure out what was wrong. Likewise, if you are (for example) doing "duplicate bridge" using computer generated cards, then each table needs the same sequence, such as would most easily be conveyed by sending the same sequence initialization data to each.
|
Next
|
Last
Pages: 1 2 Prev: format a string in a listbox Next: simulink model parameters for building exe |