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 Arigthmetic Mean Interval characteristic calculator for masked arrays #59

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 Arithmetic Mean Interval characteristic for given intervals array using formula:
$$\Delta_{a j}=\displaystyle \frac{1}{n_j} * \sum_{i=1}^{n_j} \Delta_{ij}$$
Where $\Delta_{ij}$ is an interval and $n_j$ is a number of intervals in the given congeneric sequence.

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 = arithmetic_mean(x_intervals)
print(result)
> [3.333, 2.5]
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 = arithmetic_mean(x_intervals)
print(result)
> [1,2,3]
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 = arithmetic_mean(x_intervals)
print(result)
> [3,2,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', 'Lossy')
result = arithmetic_mean(x_intervals)
print(result)
> [2]
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 = arithmetic_mean(x_intervals)
print(result)
> [2.6667]
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 = arithmetic_mean(x_intervals)
print(result)
> [2.3333]
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 = arithmetic_mean(x_intervals)
print(result)
> [2.75]
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 = arithmetic_mean(x_intervals)
print(result)
> [3.3333]
X = ['A','A','A','B','A','B','B','A','A','A','A','B','A','A','A']
mask = [1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1]
masked_X = ma.masked_array(X, mask)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Lossy')
result = arithmetic_mean(x_intervals)
print(result)
> [2.6667]
X = ['A','A','A','B','A','B','B','A','A','A','A','B','A','A','A']
mask = [1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1]
masked_X = ma.masked_array(X, mask)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Normal')
result = arithmetic_mean(x_intervals)
print(result)
> [3]
X = ['A','A','A','B','A','B','B','A','A','A','A','B','A','A','A']
mask = [1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1]
masked_X = ma.masked_array(X, mask)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'End', 'Normal')
result = arithmetic_mean(x_intervals)
print(result)
> [3]
X = ['A','A','A','B','A','B','B','A','A','A','A','B','A','A','A']
mask = [1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1]
masked_X = ma.masked_array(X, mask)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Redundant')
result = arithmetic_mean(x_intervals)
print(result)
> [3.2]
X = ['A','A','A','B','A','B','B','A','A','A','A','B','A','A','A']
mask = [1, 1, 1, 0, 1, 0, 0, 1, 1, 1, 1, 0, 1, 1, 1]
masked_X = ma.masked_array(X, mask)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Cycle')
result = arithmetic_mean(x_intervals)
print(result)
> [3.75]
X = ['B']
masked_X = ma.masked_array(X,)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Lossy')
result = arithmetic_mean(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 = arithmetic_mean(x_intervals)
print(result)
> [1]
X = ['B']
masked_X = ma.masked_array(X,)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'End', 'Normal')
result = arithmetic_mean(x_intervals)
print(result)
> [1]
X = ['B']
masked_X = ma.masked_array(X,)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Redundant')
result = arithmetic_mean(x_intervals)
print(result)
> [1]
X = ['B']
masked_X = ma.masked_array(X,)
order, alphabet = ma.order(masked_X, True)
x_intervals = ma.intervals(order, 'Start', 'Cycle')
result = arithmetic_mean(x_intervals)
print(result)
> [1]
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 = arithmetic_mean(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 = arithmetic_mean(x_intervals)
print(result)
> [8]
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 = arithmetic_mean(x_intervals)
print(result)
> [1]
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 = arithmetic_mean(x_intervals)
print(result)
> [4.5]
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 = arithmetic_mean(x_intervals)
print(result)
> [8]
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 = arithmetic_mean(x_intervals)
print(result)
> [1]
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 = arithmetic_mean(x_intervals)
print(result)
> [1]
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 = arithmetic_mean(x_intervals)
print(result)
> [1]
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 = arithmetic_mean(x_intervals)
print(result)
> [1]
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 = arithmetic_mean(x_intervals)
print(result)
> [1]
@ChainsManipulator ChainsManipulator converted this from a draft issue Oct 17, 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