Brian Dunning's FileMaker Custom Functions

Bin ( number ; binNames ; binSizes )

Returns the name of the bin containing the number.

  Average rating: 4.5 (32 votes) Log in to vote

Michael Horak   Michael Horak
*COMMENT Visual Realisation
http://comment.cjb.net

Share on Facebook Share on Twitter

  Sample input:
Bin (
150 ;
List ( "Introduction" ; "First Part" ; "Coffee Break" ; "Second Part" ; "Lunch" ; "Questions" ) ;
List ( 15 ; 45 ; 20 ; 60 ; 90 ; 45 )
)
  Sample output:
"Lunch"

indicating that the 150th minute of the event occurs during the lunch break.

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

The Bin() function takes a list of bins and their respective sizes and returns the name of the bin containing the given number. For example, given a list of chapters and their page counts, Bin() can calculate which chapter contains the given page number.


Bins are consecutive intervals presumed to start at zero. Each bin can have an arbitrary positive size assigned to it. A boundary value is considered to be contained by the next higher bin; for example:

Bin (
.5 ;
List ( "First Half" ; "Second Half" ) ;
List ( .5 ; .5 )
)

returns "Second Half".


The Bin() function can be used to generate a discrete random value, drawn from a set of possible outcomes with the probability of each outcome separately specified. For example, given a population with the following blood type distribution:
• O: 45%;
• A: 40%;
• B: 11%;
• AB: 4%

you can use =

Bin (
Random ;
List ( "O" ; "A" ; "B" ; "AB" ) ;
List ( .45 ; .4 ; .11 ; .04 )
)

repeatedly to generate a representative sample of the population.

 

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.