Results 21 to 30 of 32
Hybrid View
-
3rd Jul 2010, 02:26 PM #1OPRespected DeveloperWebsite's:
wrzc.orgSorry 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: 5Tutorial How to SEO your Warez Site a guide to help you increase your organic traffic
Huge list of Warez Sites and free Multiposter Templates
-
3rd Jul 2010, 02:31 PM #2Respected 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?
-
3rd Jul 2010, 02:39 PM #3OPRespected DeveloperWebsite's:
wrzc.orgTutorial How to SEO your Warez Site a guide to help you increase your organic traffic
Huge list of Warez Sites and free Multiposter Templates
-
3rd Jul 2010, 03:25 PM #4Respected 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.
-
3rd Jul 2010, 04:05 PM #5OPRespected DeveloperWebsite's:
wrzc.orglol that's good.
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
-
3rd Jul 2010, 03:47 PM #6MemberWebsite's:
CodeSociety.netthis 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)
-
4th Jul 2010, 09:51 AM #7MemberWebsite's:
litewarez.net litewarez.com triniwarez.comHere 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);
}
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;
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
-
4th Jul 2010, 02:12 PM #8Respected Developer
This again isn't what he's looking for lite.
-
4th Jul 2010, 03:24 PM #9MemberWebsite's:
litewarez.net litewarez.com triniwarez.comOkee 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
-
4th Jul 2010, 03:45 PM #10OPRespected DeveloperWebsite's:
wrzc.orgTo 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
Sponsored Links
Thread Information
Users Browsing this Thread
There are currently 1 users browsing this thread. (0 members and 1 guests)
Similar Threads
-
Problem with number of posts at homepage
By bdr111446 in forum WordpressReplies: 0Last Post: 21st May 2012, 03:10 PM -
Problem on DLE 9.3 Error Number: 1267
By Devils in forum Technical Help Desk SupportReplies: 6Last Post: 26th Sep 2011, 04:17 PM -
From random to more random
By dannym23 in forum General DiscussionReplies: 4Last Post: 13th Aug 2011, 07:35 PM -
DLE random log out problem
By seraphim in forum Webmaster DiscussionReplies: 0Last Post: 12th May 2011, 01:36 PM -
How to get those random ads?
By DXS in forum Webmasters, Money MakingReplies: 3Last Post: 8th Mar 2009, 08:13 AM
themaLeecher - leech and manage...
Version 5.03 released. Open older version (or...