Brian Dunning's FileMaker Custom Functions

RandomWeightedRank ( total )

Returns a random integer between 1 and total such that the probability of each number is proportional to itself.

  Average rating: 3.9 (44 votes) Log in to vote

Jeremy Bante   Jeremy Bante

https://github.com/jbante/

Share on Facebook Share on Twitter

  Sample input:
List (
RandomWeightedRank ( 10 );
RandomWeightedRank ( 10 );
RandomWeightedRank ( 10 );
RandomWeightedRank ( 10 );
RandomWeightedRank ( 10 );
RandomWeightedRank ( 10 );
RandomWeightedRank ( 10 );
RandomWeightedRank ( 10 );
RandomWeightedRank ( 10 );
RandomWeightedRank ( 10 )
)
  Sample output:
6
9
7
10
10
9
3
6
7
5

  Function definition: (Copy & paste into FileMaker's Edit Custom Function window)

Returns a random integer between 1 and total such that the probability of each number is proportional to itself. For example, 2 is twice as likely as 1, and 3 is 3 times as likely as 1. This may be useful for ordinally weighted lotteries, where applicants have a number of lottery tickets determined by some ranking. For example, you might want to randomly award a scholarship, but you might also want individuals with greater financial need to be more likely to receive the scholarship.

 

Comments

Log in to post comments.

 

Note: these functions are not guaranteed or supported by BrianDunning.com. Please contact the individual developer with any questions or problems.

Under construction. Email me your wish list for improvements.