[Python] How do I get all possible halves in Python?

Discussão em 'Python' iniciado por Stack, Maio 13, 2025.

  1. Stack

    Stack Membro Participativo

    I would like to split a test into all possible two halves in Python. For example, a test with 10 items can be split into two halves in C(10, 5)/2 = 126 different ways (e.g., odd vs. even items, or the first five vs. the last five items). I want to store each of these paired-halves in an object and then calculate the Flanagan-Rulon split-half reliability (4*cov / var) between the two halves. In this example, there will be 126 reliability values. The average of these values should be equal to Cronbach’s Alpha.

    The functions I wrote either didn't work or worked for a very long time. This is all I've come up with for now.

    # dataset
    np.random.seed(99999)
    dat = pd.DataFrame(np.random.randint(0, 2, size = (40, 20)))


    # calculating Cronbach's alpha with the help of pingouin
    pip install pingouin

    from pingouin import cronbach_alpha
    alpha, _ = cronbach_alpha(dat)
    alpha

    Continue reading...

Compartilhe esta Página