DK96-OS / MathTools

Mathematical Software Components. This library is actively maintained, and aims to stay updated. New feature proposals are welcome, but may not be included.
Apache License 2.0
2 stars 1 forks source link

Linear Probability Generator #86

Closed DK96-OS closed 2 years ago

DK96-OS commented 2 years ago

Create a Generator with a linearly changing probability.

The outcomes are arranged in consecutive order from 1 to Length. Length must be greater than zero.

The first outcome 1, has the highest probability. Each outcome reduces in probability at a constant Rate. Rate must be greater than zero.

DK96-OS commented 2 years ago

Remaining Tasks:

DK96-OS commented 2 years ago

A sequence of Linear and Uniform probability Elements that span consecutive ranges of integers:

  1. Linearly Increasing
  2. Uniform Probability
  3. Linearly Decreasing

This is a common requirement. There is a known method of mediating the interaction between the number of states of the two Linear Elements.

The Lowest Common Multiple is an important number that solves this problem. A potential for integer overflow is present when calculating the Lowest Common Multiple of numbers with large differences in prime number composition.

The LCM has to be multiplied again to obtain the relevant number, and so to limit this inflation, the Linear Element accepts Short type integers, limited to around 200, as input parameters.

The limit of 200 can be increased, but there should be a strategy to validate that the inputs can work together without causing an overflow.

DK96-OS commented 2 years ago

Another piece of the strategy is to look for changes in work required on large inputs. The CompareFactors.lcm method is the most impacted by changes in inputs. It appears that this method has no tests on inputs larger than 256.