Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
The process starts with a random seed that I provide, so that I can reproduce interesting results later.

The code you provided will make it hard for you to reproduce the results later.

The only thing that is predictable about rand() is that given the exact same input to srand(), you will get the exact same outputs from rand() every time you do it.

srand(42) -> 78, 102, 4, 19, ...
srand(55) -> 8, 2, 66, 243, ...

There isn't anything wrong with calling srand() more than once, except that doing so will not make the output more random, it may even make it less random.

To reproduce the same outputs from rand(), you will have to call srand() with the same inputs in the same order every time, so this is a new part of state that you must save. On top of that, if the implementation of rand() changes in different versions of perl, you will not reproduce the same results on different versions.

In reply to Re: Can I seed srand() with results from rand()? by bunnyman
in thread Can I seed srand() with results from rand()? by blokhead

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (3)
As of 2022-12-02 06:30 GMT
Find Nodes?
    Voting Booth?