The term "random" is often not well-defined and the addition of a probability density function can complete the picture.

For example, it could be (I can't properly identify your model from the info. so far) that the constraints should be achieved by shifting and scaling a bell curve to make it intersect y=0 exactly at the constraint points, or it might be that a Poisson distribution is required.

Most people will by default interpret "random" as having a flat probability density function, but that can often be unsuitable for statistical models.

Update: If its is "flat" however, you could generate the data in two steps: pick a constraint set at random and then use the constraints just chosen to randomly generate a "point" e.g.

use integer; my @limits = ( [10,40], [20,70], ); my $pick1 = ( 1 + $#limits ) * rand() - 1; } my $pick2 = $limits[$pick1][0] + ( rand() * ( $limits[$pick1][1] - $limits[$pick +1][0] );

-M

Free your mind


In reply to Re: Need technique for generating constrained random data sets by Moron
in thread Need technique for generating constrained random data sets by GrandFather

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



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.