This content has been marked as final.
Show 4 replies

1. Re: Random weighting
Newsgroup_User Jul 12, 2006 7:07 AM (in response to ManOfMac)I'm not sure what exactly you are trying to do, but you can use random
to figure out which list to use.
case random(10) of
1,2,3,4,5,6,7:
do something 70% of the time
8,9:
do something 20% of the time
10:
do something 10% of the time
end case 
2. Re: Random weighting
ManOfMac Jul 12, 2006 4:54 PM (in response to Newsgroup_User)YEah I sortta looked a that but random is totally random.
Cancel, that your genius is in the simplicity.
Just did a rough test and it produces results within a reasonable tolerance. ( 6580 out of 100, 2535 out of 100, 512 out of 100)
FYI: I have 3 sections (Top 10, Coming Soon & Specials) I want the user to set the importance of the 3 sections and the larger the importance the more regulary it's displayed !! 
3. Re: Random weighting
Newsgroup_User Jul 13, 2006 2:45 AM (in response to Newsgroup_User)> Just did a rough test and it produces results within a reasonable
> tolerance. (
> 6580 out of 100, 2535 out of 100, 512 out of 100)
Try something like this:
on testRandom(loops)
a=0
b=0
c=0
m=float(loops)
repeat with i = 1 to m
case random(10) of
1,2,3,4,5,6,7:
a=a+1
8,9:
b=b+1
10:
c=c+1
end case
end repeat
put a/m*100&"%,"&&b/m*100&"%,"&&c/m*100&"%"
end
message window
testRandom(1000000)
 "70.0128%, 19.9946%, 9.9925%"

4. Re: Random weighting
Applied CD Jul 13, 2006 4:06 PM (in response to ManOfMac)Hey, I just throwing this out there for fun, but one of the few things I remember from grad school is that the probability of a particular set of multiple events is the product of the probability of each event separately. So for example, if you have 3 groups 1, 2, 3, and the items in each group are as follows:
1 = A, B, C, D, E, F, G, H, I, J
2 = A, B, C, D, E, F, G, H, I, J
3 = A, B, C, D, E
You’ve told us that the probability for group selection is 1=0.7, 2=0.2, and 3=0.1, the probability for item selection in each group is 1/(number of items in group) or 0.1 for groups 1 and 2, 0.2 for group 3. So…
the probability of getting a particular item in group 1 is 0.7 * 0.1 = 0.07 or 7% (for each of 10 items)
the probability of getting a particular item in group 2 is 0.2 *0.1 = 0.02 or 2% (for each of 10 items)
the probability of getting a particular item in group 3 is 0.1*0.2=0.02 or 2% (for each of 5 items)
So, given your numbers, you’ve got the unintuitive situation of a specific item in group 3 appearing with the same frequency as a specific item in group 2, although group 2 items will appear twice as frequently as a whole than group 3 items.