Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

Linearly Weighted Random Number Generator


  • Please log in to reply
No replies to this topic
Uberi
  • Moderators
  • 1119 posts
  • Last active: May 02 2015 06:05 PM
  • Joined: 23 Aug 2010
A random number generator linearly weighted towards the upper bound.

Test

Histogram of 500,000 iterations:

Posted Image
Graphed with Bar Grapher

Usage

Simple example:

MsgBox % LinearWeightRandomNumber(1,10)

The above displays a decimal number that is between 1 and 10, biased towards 10. The lower bound is inclusive, while the upper bound is not (i.e. the above example could potentially return 1.0, but never 10.0).

Download

AutoHotkey.net