Activity Stream
48,167 MEMBERS
6734 ONLINE
besthostingforums On YouTube Subscribe to our Newsletter besthostingforums On Twitter besthostingforums On Facebook besthostingforums On facebook groups

Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 32

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1.     
    #1
    Respected Developer
    Website's:
    wrzc.org
    Quote Originally Posted by Hyperz View Post
    Maybe you should explain again what you want it to do. I thought you wanted to generate a random numbers that with each generated number have a higher probability of generating a bigger value. Since your friend suggested a matrix with a curve etc.
    Sorry I probably should have explained this more at the start. It's to pick topics randomly from a database but I want it to concentrate on picking the newest topics. I'm ordering the topics by latest posts and want it to pick one at random and run a script. I don't want it running the script too often on topics that are a year or two old.

    It would be useful for eg. a link checker but I've other ideas I want to use it on first eg. a fake account which replies to recent topics and only rarely replies and bumps an old topic.

    That's why I want it to pick lower numbers more often and as the number grows the chance of it being picked decreases.

    As I said your earlier example is fine for the purpose of the script and this topic is just improving the selection method and my knowledge which isn't exactly necessary but is helpful and greatly appreciated.
    Mr Happy Reviewed by Mr Happy on . [PHP] Random Number Problem Basically I want to generate a Random number but increase the chances of lower numbers appearing more. if I just use mt_rand(1, 1000) the chances of getting the number 1 is the same as 468 which is the same as 1000. I want to increase the chances of lower numbers appearing. This poor way shows what I mean if (mt_rand(1, 2) == 1) // 50-50 chance { Rating: 5
    Tutorial How to SEO your Warez Site a guide to help you increase your organic traffic

    Huge list of Warez Sites and free Multiposter Templates

  2.   Sponsored Links

  3.     
    #2
    Respected Developer
    And do you want to generate multiple random numbers at roughly the same time in the script or do you need just 1 per run?

  4.     
    #3
    Respected Developer
    Website's:
    wrzc.org
    Quote Originally Posted by Hyperz View Post
    And do you want to generate multiple random numbers at roughly the same time in the script or do you just need 1 per run?
    One per run would be fine but ideally multiples of a small amount. say something like 10 topics at a time. I wouldn't mind having to run it 10 times though in the loop.
    Tutorial How to SEO your Warez Site a guide to help you increase your organic traffic

    Huge list of Warez Sites and free Multiposter Templates

  5.     
    #4
    Respected Developer
    This is actually quite a complex problem which causes my brain to get stuck in an infinite loop.

    rand(min, max) - if I understand it right the max value should be different every time you need a random number. And the max value(s) should give a smaller random number a higher probability than a large one. But at the same time you cant use something like x procent because you want each step in the max value to have its own probability (damn this is hard to explain ). For example you want a random number between 1 and 1000. You want a higher probability for lower values. but there are 1000 'steps' in the 1-1000 range and you want each of those steps to have its own probability?

    If so: that's is a problem. Or at least it is for me because this is a chicken-egg situation. The probability should be random too per step. But how do you randomize the probability of the probability (lol).

    *brain fried*

    These are times I wish I had paid more attention during math lessons in school. A matrix will do little good here because that's linear.

  6.     
    #5
    Respected Developer
    Website's:
    wrzc.org
    Quote Originally Posted by Hyperz View Post
    This is actually quite a complex problem which causes my brain to get stuck in an infinite loop.
    lol that's good.

    Quote Originally Posted by Hyperz View Post
    rand(min, max) - if I understand it right the max value should be different every time you need a random number. And the max value(s) should give a smaller random number a higher probability than a large one. But at the same time you cant use something like x procent because you want each step in the max value to have its own probability (damn this is hard to explain ). For example you want a random number between 1 and 1000. You want a higher probability for lower values. but there are 1000 'steps' in the 1-1000 range and you want each of those steps to have its own probability?

    If so: that is a problem. Or at least it is for me because this is a chicken-egg situation. The probability should be random too per step. But how do you randomize the probability of the probability (lol).

    *brain fried*

    These are times I wish I had paid more attention during math lessons in school. A matrix will do little good here because that's linear.
    Well what I'm doing is one forum at a time to make it easier so the max will be constant at lease for the loop it's doing. So the max will be something like count() FROM thread WHERE forumid=$whatever if that helps (although I don't think it does much).
    but ya everything else you have correct theory wise. That's why I asked in the original post if someone even knows the mathematical term for this so I could maybe research it. My problem is I haven't studied advanced Maths in a few years now so don't even know what you'd call this.


    @ immortalxx: I don't see how that is scalable. Remember a forum can contain 100k plus topics.
    Tutorial How to SEO your Warez Site a guide to help you increase your organic traffic

    Huge list of Warez Sites and free Multiposter Templates

  7.     
    #6
    Member
    Website's:
    CodeSociety.net
    this is certainly a very complex problem.

    I think a simple solution would be to create an array with multiple numbers. Something like below

    $x[] = 1;
    $x[] = 2;
    $x[] = 2;
    $x[] = 2;

    Simple example so basically you can increase the chances of certain numbers that appear.

    so if you want 2 to appear more then 1 then 3 out of 4 times. This is a small scale example. This would be using rand(0, 4-1)



  8.     
    #7
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    Here you go Happy, Ive created a function that you insert any number and it will try bring you back a random with the chances leaning towards the lower integer.

    so heres the functions

    PHP Code: 
    function Random($highest 100,$strength 2)
    {
       
    $r round($highest/$strength);
       return 
    abs((rand()%(($r*2)+($r)))-$r);

    Ok so here an example.

    PHP Code: 
    $high $low 0;

    for(
    $i=0;$i<5000;$i++)
    {
        if(
    Random(6478,1) > (6478/2)) //Check see if its higher or lower then the count
        
    {
            
    $high++;
        }else
        {
           
    $low++;
        }
    }

    echo 
    $low '/' $high
    This is a test to see how the chances are over 500 loops on 6478 rows/

    some results are

    Using strength 2:
    • Low(3385) / High(1615)
    • Low(3271) / High(1729)
    • Low(3326) / High(1674)

    Using strength 1:
    • Low(2524) / High(2476)
    • Low(2537) / High(2463)
    • Low(2473) / High(2527)


    For strength only use 1,2 or 3.

    So yes, usage just call the functions with the first param as the MAX Integer and the second as strength, usually 2 tho..
    Join Litewarez.net today and become apart of the community.
    Unique | Clean | Advanced (All with you in mind)
    Downloads | Webmasters


    Notifications,Forum,Chat,Community all at Litewarez Webmasters


  9.     
    #8
    Respected Developer
    This again isn't what he's looking for lite.

  10.     
    #9
    Member
    Website's:
    litewarez.net litewarez.com triniwarez.com
    Okee Dokey, thought it was but owell
    Join Litewarez.net today and become apart of the community.
    Unique | Clean | Advanced (All with you in mind)
    Downloads | Webmasters


    Notifications,Forum,Chat,Community all at Litewarez Webmasters


  11.     
    #10
    Respected Developer
    Website's:
    wrzc.org
    To be honest I've just used a version Hyperz originally posted. For the script it's not essential it's such a randomized pick as it works fine. I was just interested to know if it was possible as it would improve it slightly. Sense it's such a complicated request with such a minor improvement I've no problem admitting defeat.

    Again massive thanks for all your help and replies guys. It's such a pleasure to be able to get such fast help in this in coding area rather than having to go to a dedicated coding site.
    Tutorial How to SEO your Warez Site a guide to help you increase your organic traffic

    Huge list of Warez Sites and free Multiposter Templates

Page 3 of 4 FirstFirst 1234 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problem with number of posts at homepage
    By bdr111446 in forum Wordpress
    Replies: 0
    Last Post: 21st May 2012, 03:10 PM
  2. Problem on DLE 9.3 Error Number: 1267
    By Devils in forum Technical Help Desk Support
    Replies: 6
    Last Post: 26th Sep 2011, 04:17 PM
  3. From random to more random
    By dannym23 in forum General Discussion
    Replies: 4
    Last Post: 13th Aug 2011, 07:35 PM
  4. DLE random log out problem
    By seraphim in forum Webmaster Discussion
    Replies: 0
    Last Post: 12th May 2011, 01:36 PM
  5. How to get those random ads?
    By DXS in forum Webmasters, Money Making
    Replies: 3
    Last Post: 8th Mar 2009, 08:13 AM

Tags for this Thread

BE SOCIAL