ComplexityMeasures.jl Dev Docs
Good practices in developing a code base apply in every Pull Request. The Good Scientific Code Workshop is worth checking out for this.
Adding a new ProbabilitiesEstimator
Mandatory steps
- Decide on the outcome space and how the estimator will map probabilities to outcomes.
- Define your type and make it subtype
ProbabilitiesEstimator
. - Add a docstring to your type following the style of the docstrings of other estimators.
- If suitable, the estimator may be able to operate based on
Encoding
s. If so, it is preferred to implement anEncoding
subtype and extend the methodsencode
anddecode
. This will allow your probabilities estimator to be used with a larger span of entropy and complexity methods without additional effort. Have a look at the file definingSymbolicPermutation
for an idea of how this works. - Implement dispatch for
probabilities_and_outcomes
and your probabilities estimator type. - Implement dispatch for
outcome_space
and your probabilities estimator type. - Add your probabilities estimator type to the table list in the documentation page of probabilities. If you made an encoding, also add it to corresponding table in the encodings section.
Optional steps
You may extend any of the following functions if there are potential performance benefits in doing so:
probabilities
. By default it callsprobabilities_and_outcomes
and returns the first value.outcomes
. By default callsprobabilities_and_outcomes
and returns the second value.total_outcomes
. By default it returns thelength
ofoutcome_space
. This is the function that most typically has performance benefits if implemented explicitly, so most existing estimators extend it by default.
Tests
You also need to add tests for all functions that you explicitly extended. Non-extended functions do not need to be tested.
Adding a new DifferentialEntropyEstimator
Mandatory steps
- Define your type and make it subtype
DifferentialEntropyEstimator
. - Add a docstring to your type following the style of the docstrings of other estimators. This docstring should contain the formula(s)/integral(s) which it estimates, and a reference to relevant
EntropyDefinition
(s). - Implement dispatch for
entropy
with the relevantEntropyDefinition
. If your estimator works for multiple entropies, implement one method forentropy
for each of them.
Tests
You need to add tests verifying that your estimator actually convergences, within some reasonable tolerance (that you define), to the true entropy of data from some known distribution. Have a look in the tests for existing estimators for inspiration (you can just copy-paste one of the existing tests, or make them more elaborate if you want to).
Adding a new EntropyDefinition
Mandatory steps
- Define your entropy definition type and make it subtype
EntropyDefinition
. - Implement dispatch for
entropy
(def::YourType, p::Probabilities)
- Add a docstring to your type following the style of the docstrings of other entropy definitions, and should include the mathematical definition of the entropy.
- Add your entropy definition type to the list of definitions in the
docs/src/entropies.md
documentation page. - Add a reference to your entropy definition in the docstring for
EntropyDefinition
.
Optional steps
- If the maximum value of your entropy type is analytically computable for a probability distribution with a known number of elements, implementing dispatch for
entropy_maximum
automatically enablesentropy_normalized
for your type.
Tests
You also need to add tests for all functions that you explicitly extended. Non-extended functions do not need to be tested.