Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linear Probability Generator #86

Merged
merged 12 commits into from
Apr 7, 2022
Merged

Linear Probability Generator #86

merged 12 commits into from
Apr 7, 2022

Conversation

DK96-OS
Copy link
Owner

@DK96-OS DK96-OS commented Apr 6, 2022

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.

* Create ShortElementInterface
* Create LinearShortElement
* Create LinearShortElementStaticTest - add test cases for the countLinearStates method
* Update LinearShortElement - set limit on rate parameter, enforce limits in constructor and setters
* Create LinearShortElementTest
@DK96-OS DK96-OS added the enhancement New feature or request label Apr 6, 2022
@DK96-OS DK96-OS self-assigned this Apr 6, 2022
@DK96-OS
Copy link
Owner Author

DK96-OS commented Apr 6, 2022

Remaining Tasks:

  • Implement Generate method
  • Generated Value Analysis Tests

@DK96-OS DK96-OS changed the base branch from master to release-0.4.4 April 6, 2022 13:37
@DK96-OS DK96-OS mentioned this pull request Apr 6, 2022
2 tasks
@DK96-OS
Copy link
Owner Author

DK96-OS commented Apr 6, 2022

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
Copy link
Owner Author

DK96-OS commented Apr 6, 2022

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.

@DK96-OS DK96-OS mentioned this pull request Apr 6, 2022
3 tasks
* Update LinearShortElement - add documentation, add Random member, add constructor with Random argument, implement generate method, store number of LinearStates as member variable
* Create LinearShortElementAnalysis - measure distributions of outcomes
* Create LinearShortElementPerformance - measure performance of different outcomes
* Update RandomProvider - update code style
* Update LinearShortElementTest - add test cases, improve code style and quality by using static values
* Update LinearShortElementTest - add test cases for max value
* Update LinearShortElementAnalysis - combine length test cases into parameterized test
* Update LinearShortElementPerformance - improve code style
* Update LinearShortElement - redesign countLinearStates method (use a loop instead of recursion)
* Update LinearShortElementPerformance
* Update LinearShortElement - remove Rate parameter
* Update LinearShortElement Tests - remove Rate parameter
@DK96-OS DK96-OS merged commit ea0b7fe into release-0.4.4 Apr 7, 2022
@DK96-OS DK96-OS deleted the generators-dev branch April 7, 2022 13:20
DK96-OS added a commit that referenced this pull request Apr 7, 2022
* Lists and Arrays - Operation Byte Support (#85)

Lists:
* Create ByteList.kt - include similar methods to those of other types
* Update ByteArrayExt - update code style, add findTargetValueN method

Tests:
* Create ByteArrayExtFindTargetValueNTest - add test cases for findTargetValueN
* Create ByteListFindGreaterThanTest
* Create ByteListFindLessThanTest
* Create ByteListFindOutOfRangeTest
* Create ByteListLargeSumTest
* Create ByteListRemoveByIndicesTest
* Update ByteArrayExtTest - improve newArray method, make available for test package, add test cases for sum method

* Linear Probability Generator (#86)

Generators:
* Create LinearShortElement - add constructor with Random argument, implement generate method, store number of LinearStates as member variable
* Create ShortElementInterface

Tests:
* Create LinearShortElementAnalysis - measure distributions of outcomes, combine length test cases into parameterized test
* Create LinearShortElementPerformance - measure performance of different outcomes
* Create LinearShortElementStaticTest - add test cases for the countLinearStates method
* Create LinearShortElementTest
* Update RandomProvider - update code style

Build Updates:
* Increase Artifact 0.4.3 -> 0.4.4
* Increase Generators Coverage Limits - Instruction 95, Branch 92
* Remove Lists Module dependency from Generators
* Remove Kotlin Standard Library from dependencies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant