Random Numbers

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ricardo

    Random Numbers

    Does anyone know how to make $rand(0,3) very common, $rand(4,6) rare, and
    $rand(7,9) extremely rare and link it to echo one number?

    eg:

    blah 3-3 blah would be very common or 2-2 or 2-1 etc.

    Also, if it helps, the 0-3 has a 75% "success rate", 4-6 has 40, and 7-9 has
    10.

    Thanks alot everyone

    Rich




  • DvDmanDT

    #2
    Re: Random Numbers

    $tmp=rand(0,100 )
    if($tmp<=75)
    {
    echo rand(0,3);
    }
    elseif($tmp<=95 )
    {
    echo rand(4,6);
    }
    else
    {
    echo rand(7,9);
    }

    is that what you want?
    --
    // DvDmanDT
    MSN: dvdmandt@hotmai l.com
    Mail: dvdmandt@telia. com
    "Ricardo" <bh004b6751@blu eyonder.co.uk> skrev i meddelandet
    news:3iHUa.793$ Kp6.292@news-binary.blueyond er.co.uk...[color=blue]
    > Does anyone know how to make $rand(0,3) very common, $rand(4,6) rare, and
    > $rand(7,9) extremely rare and link it to echo one number?
    >
    > eg:
    >
    > blah 3-3 blah would be very common or 2-2 or 2-1 etc.
    >
    > Also, if it helps, the 0-3 has a 75% "success rate", 4-6 has 40, and 7-9[/color]
    has[color=blue]
    > 10.
    >
    > Thanks alot everyone
    >
    > Rich
    >
    >
    >
    >[/color]


    Comment

    • Ricardo

      #3
      Re: Random Numbers

      Yep, got that, but how do I show it, eg: blah 3 - 6 blah...


      "DvDmanDT" <dvdmandt@telia .com> wrote in message
      news:VsHUa.1774 3$mU6.15976@new sb.telia.net...[color=blue]
      > $tmp=rand(0,100 )
      > if($tmp<=75)
      > {
      > echo rand(0,3);
      > }
      > elseif($tmp<=95 )
      > {
      > echo rand(4,6);
      > }
      > else
      > {
      > echo rand(7,9);
      > }
      >
      > is that what you want?
      > --
      > // DvDmanDT
      > MSN: dvdmandt@hotmai l.com
      > Mail: dvdmandt@telia. com
      > "Ricardo" <bh004b6751@blu eyonder.co.uk> skrev i meddelandet
      > news:3iHUa.793$ Kp6.292@news-binary.blueyond er.co.uk...[color=green]
      > > Does anyone know how to make $rand(0,3) very common, $rand(4,6) rare,[/color][/color]
      and[color=blue][color=green]
      > > $rand(7,9) extremely rare and link it to echo one number?
      > >
      > > eg:
      > >
      > > blah 3-3 blah would be very common or 2-2 or 2-1 etc.
      > >
      > > Also, if it helps, the 0-3 has a 75% "success rate", 4-6 has 40, and 7-9[/color]
      > has[color=green]
      > > 10.
      > >
      > > Thanks alot everyone
      > >
      > > Rich
      > >
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Joshua Ghiloni

        #4
        Re: Random Numbers

        Ricardo wrote:
        [color=blue]
        > Does anyone know how to make $rand(0,3) very common, $rand(4,6) rare, and
        > $rand(7,9) extremely rare and link it to echo one number?
        >
        > eg:
        >
        > blah 3-3 blah would be very common or 2-2 or 2-1 etc.
        >
        > Also, if it helps, the 0-3 has a 75% "success rate", 4-6 has 40, and 7-9 has
        > 10.
        >
        > Thanks alot everyone
        >
        > Rich
        >
        >
        >
        >[/color]
        How does that happen? that's 125%!

        Anyway, assuming that the 75 above was a 50, do this:

        Create an array. The first 50 elements between 0 - 3. The next 40 is 4 -
        6, and the last 10 are 7 - 9. Then pick a random number between 0 and
        99. Statistically, your percentages should work out.

        Comment

        Working...