File size: 680 Bytes
4f08d2c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
import numpy as np

def compute_alpha_model(rnd_similarities):
    """
    Computes alpha_model as per the formula:
    
        α_model = 1 - (1 / (n * |D|)) * sum(sim(RND-Pairs))
    
    Args:
        rnd_similarities (array-like): A 2D array of shape (n, |D|) 
                                       where each entry [i][j] is the similarity 
                                       of the j-th random pair in the i-th sample.

    Returns:
        float: The computed alpha_model value.
    """
    rnd_similarities = np.array(rnd_similarities)
    n, D_size = rnd_similarities.shape
    alpha_model = 1 - (1 / (n * D_size)) * rnd_similarities.sum()
    return alpha_model