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

Add Identifying Information (Amount of Information / Entropy) characteristic calculator for masked arrays #62

Open
ChainsManipulator opened this issue Oct 17, 2024 · 0 comments
Assignees

Comments

@ChainsManipulator
Copy link
Member

ChainsManipulator commented Oct 17, 2024

Add calculator function for Identifying Information (Amount of Information / Entropy) characteristic for given intervals array using formula:
$$\displaystyle H_j=-\log_2 P_j= \log_2 \Delta_{a j}$$
Where $P_j$ is a frequency of the element and $\Delta_{a j}$ arithmetic mean of intervals of $j$-th element of the alphabet.

Examples

X = [2, 4, 2, 2, 4]
masked_X = ma.masked_array(X)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Normal')
result = identifying_information(x_intervals)
print(result)
> [0.415037499, 1.321928094887]
X = [1, 2, 3]
masked_X = ma.masked_array(X)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Normal')
result = identifying_information(x_intervals)
print(result)
> [0, 1, 1.5849625]
X = [1, 2, 3]
masked_X = ma.masked_array(X)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'End', 'Normal')
result = identifying_information(x_intervals)
print(result)
> [1.5849625, 1, 0]
X = ['B','B','B','A','A','B','B','A','B','B']
mask = [1, 1, 1, 0, 0, 1, 1, 0, 1, 1]
masked_X = ma.masked_array(X, mask)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Lossy')
result = identifying_information(x_intervals)
print(result)
> [1]
X = ['B','B','B','A','A','B','B','A','B','B']
mask = [1, 1, 1, 0, 0, 1, 1, 0, 1, 1]
masked_X = ma.masked_array(X, mask)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Normal')
result = identifying_information(x_intervals)
print(result)
> [1.415037499]
X = ['B','B','B','A','A','B','B','A','B','B']
mask = [1, 1, 1, 0, 0, 1, 1, 0, 1, 1]
masked_X = ma.masked_array(X, mask)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'End', 'Normal')
result = identifying_information(x_intervals)
print(result)
> [1.222392421336]
X = ['B','B','B','A','A','B','B','A','B','B']
mask = [1, 1, 1, 0, 0, 1, 1, 0, 1, 1]
masked_X = ma.masked_array(X, mask)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Redundant')
result = identifying_information(x_intervals)
print(result)
> [1.459431618637297]
X = ['B','B','B','A','A','B','B','A','B','B']
mask = [1, 1, 1, 0, 0, 1, 1, 0, 1, 1]
masked_X = ma.masked_array(X, mask)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Cycle')
result = identifying_information(x_intervals)
print(result)
> [1.736965594]
X = ['B']
masked_X = ma.masked_array(X,)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Lossy')
result = identifying_information(x_intervals)
print(result)
> [0]
X = ['B']
masked_X = ma.masked_array(X,)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Normal')
result = identifying_information(x_intervals)
print(result)
> [0]
X = ['B']
masked_X = ma.masked_array(X,)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'End', 'Normal')
result = identifying_information(x_intervals)
print(result)
> [0]
X = ['B']
masked_X = ma.masked_array(X,)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Redundant')
result = identifying_information(x_intervals)
print(result)
> [0]
X = ['B']
masked_X = ma.masked_array(X,)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Cycle')
result = identifying_information(x_intervals)
print(result)
> [0]
X = ['A','A','A','A','A','A','A','B']
mask = [1, 1, 1, 1, 1, 1, 1, 0]
masked_X = ma.masked_array(X, mask)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Lossy')
result = identifying_information(x_intervals)
print(result)
> [0]
X = ['A','A','A','A','A','A','A','B']
mask = [1, 1, 1, 1, 1, 1, 1, 0]
masked_X = ma.masked_array(X, mask)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Normal')
result = identifying_information(x_intervals)
print(result)
> [3]
X = ['A','A','A','A','A','A','A','B']
mask = [1, 1, 1, 1, 1, 1, 1, 0]
masked_X = ma.masked_array(X, mask)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'End', 'Normal')
result = identifying_information(x_intervals)
print(result)
> [0]
X = ['A','A','A','A','A','A','A','B']
mask = [1, 1, 1, 1, 1, 1, 1, 0]
masked_X = ma.masked_array(X, mask)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Redundant')
result = identifying_information(x_intervals)
print(result)
> [2.169925]
X = ['A','A','A','A','A','A','A','B']
mask = [1, 1, 1, 1, 1, 1, 1, 0]
masked_X = ma.masked_array(X, mask)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Cycle')
result = identifying_information(x_intervals)
print(result)
> [3]
X = ['A','A','A','A','A']
masked_X = ma.masked_array(X)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Lossy')
result = identifying_information(x_intervals)
print(result)
> [0]
X = ['A','A','A','A','A']
masked_X = ma.masked_array(X)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Normal')
result = identifying_information(x_intervals)
print(result)
> [0]
X = ['A','A','A','A','A']
masked_X = ma.masked_array(X)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'End', 'Normal')
result = identifying_information(x_intervals)
print(result)
> [0]
X = ['A','A','A','A','A']
masked_X = ma.masked_array(X)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Redundant')
result = identifying_information(x_intervals)
print(result)
> [0]
X = ['A','A','A','A','A']
masked_X = ma.masked_array(X)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Cycle')
result = identifying_information(x_intervals)
print(result)
> [0]
@ChainsManipulator ChainsManipulator converted this from a draft issue Oct 17, 2024
@ChainsManipulator ChainsManipulator changed the title Add Entropy (Amount of Information / Amount of identifying information) characteristic calculator for masked arrays Add Identifying Information (Amount of Information / Entropy) characteristic calculator for masked arrays Dec 8, 2024
@ChainsManipulator ChainsManipulator moved this from In Progress to Pending review in FOApy V1 - Batman begins Dec 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Pending review
Development

No branches or pull requests

2 participants