Repository: JuliaDynamics/ComplexityMeasures.jl (julia)

Issue:
Identification entropy
**Describe the feature you'd like to have**

In [Alswhede (2021)](https://link.springer.com/content/pdf/10.1007/978-3-030-65072-8.pdf) book on page 375, the *identification entropy* is defined.

The formula can straight-forwardly be defined for a set of `Probabilities`, and should be easy to implement.

Pull request description:
Fixes #179.

Patch:
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fbd4189e2..62ff5a9c6 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -6,6 +6,7 @@ Changelog is kept with respect to version 0.11 of Entropies.jl. From version v2.
 
 - New function `allprobabilities` that is like `probabilities` but also includes 0 entries for possible outcomes that were not present in the data.
 - `StatisticalComplexity` is now compatible with any normalizable `EntropyDefinition`.
+- New entropy definition: identification entropy (`Identification`).
 - Minor documentation fixes.
 
 ## 2.7.1
diff --git a/docs/src/entropies.md b/docs/src/entropies.md
index b61d77f4f..dfd2b3b56 100644
--- a/docs/src/entropies.md
+++ b/docs/src/entropies.md
@@ -21,6 +21,7 @@ Tsallis
 Kaniadakis
 Curado
 StretchedExponential
+Identification
 ```
 
 ## Discrete entropy
diff --git a/src/entropies_definitions/entropies_definitions.jl b/src/entropies_definitions/entropies_definitions.jl
index f3c937fcc..1e1eb0352 100644
--- a/src/entropies_definitions/entropies_definitions.jl
+++ b/src/entropies_definitions/entropies_definitions.jl
@@ -4,3 +4,4 @@ include("tsallis.jl")
 include("curado.jl")
 include("streched_exponential.jl")
 include("kaniadakis.jl")
+include("identification.jl")
diff --git a/src/entropies_definitions/identification.jl b/src/entropies_definitions/identification.jl
new file mode 100644
index 000000000..30d46ba30
--- /dev/null
+++ b/src/entropies_definitions/identification.jl
@@ -0,0 +1,38 @@
+export Identification
+
+"""
+    Identification <: EntropyDefinition
+    Identification()
+
+Identification entropy (Ahlswede et al., 2006)[^Ahlswede2006].
+
+## Description
+
+The identification entropy is the functional
+
+```math
+H_I(p) = 2\\left( 1 - \\sum_{i=1}^N p_i^2 \\right).
+```
+
+Details about this entropy definition can be found in Ahlswede et al. (2021)[^Ahlswede2021].
+
+[^Ahlswede2006]:
+    Ahlswede, R., Bäumer, L., Cai, N., Aydinian, H., Blinovsky, V., Deppe, C., &
+    Mashurian, H. (Eds.). (2006). General theory of information transfer and
+    combinatorics (Vol. 68). Berlin/Heidelberg, Germany: Springer.
+
+[^Ahlswede2021]:
+    Ahlswede, R., Ahlswede, A., Althöfer, I., Deppe, C., & Tamm, U. (2021). Identification
+    and Other Probabilistic Models. Springer International Publishing.
+"""
+struct Identification <: EntropyDefinition end
+
+# Page 375 in Ahlswede et al. (2021)
+function entropy(e::Identification, probs::Probabilities)
+    return 2 * (1 - sum(probs .^ 2))
+end
+
+# Page 378 in Ahlswede et al. (2021)
+function entropy_maximum(e::Identification, L::Int)
+    return 2 * (1 - 1 / L)
+end


Test patch:
diff --git a/test/entropies/entropies.jl b/test/entropies/entropies.jl
index 4f3446875..91b0c8757 100644
--- a/test/entropies/entropies.jl
+++ b/test/entropies/entropies.jl
@@ -8,6 +8,7 @@ testfile("entropy_types/tsallis.jl")
 testfile("entropy_types/curado.jl")
 testfile("entropy_types/stretched_exponential.jl")
 testfile("entropy_types/kaniadakis.jl")
+testfile("entropy_types/identification.jl")
 
 # Estimators
 testfile("estimators/estimators.jl")
diff --git a/test/entropies/entropy_types/identification.jl b/test/entropies/entropy_types/identification.jl
new file mode 100644
index 000000000..0b3b55d76
--- /dev/null
+++ b/test/entropies/entropy_types/identification.jl
@@ -0,0 +1,16 @@
+
+# Analytical tests
+# -----------------------------------
+# Minimal and equal to zero when probability distribution has only one element...
+@test entropy(Identification(), Probabilities([1.0])) ≈ 0.0
+
+# or minimal when only one probability is nonzero and equal to 1.0
+@test entropy(Identification(), Probabilities([1.0, 0.0, 0.0, 0.0])) ≈ 0.0
+
+# Maximal for a uniform distribution
+x = [0.1, 0.1, 0.1, 0.1, 0.2, 0.2, 0.2, 0.2, 0.3, 0.3, 0.3, 0.3, 0.4, 0.4, 0.4, 0.4]
+@test entropy_normalized(Identification(), CountOccurrences(), x) ≈ 1.0
+
+# Submaximal for a non-uniform distribution
+y = [0.1, 0.2, 0.2, 0.25, 0.2, 0.351, 0.312, 0.3, 0.3, 0.4, 0.4]
+@test entropy_normalized(Identification(), CountOccurrences(), y) < 1.0