Probabilty Formula

Discussion in 'PHP' started by gigamike, Jun 6, 2008.

  1. #1
    Guys,

    Any suggestion for probability logic. Example

    Ads=weight
    Ads1=100%
    Ads2=200%
    Ads3=100%

    Then when i select random, there is a big chances for ads2 to be selected since it has 200%

    I got an idea but im thinking its not the best way

    I create an array based on the %

    $choices=array('Ads1', 'Ads2', 'Ads2', 'Ads3');
    $selected=array_rand($choices) ;

    Any other idea?

    Thanks,

    Mike
     
    gigamike, Jun 6, 2008 IP
  2. GLD

    GLD Well-Known Member

    Messages:
    307
    Likes Received:
    12
    Best Answers:
    0
    Trophy Points:
    140
    #2
    You could try this:

     
    GLD, Jun 6, 2008 IP