Jellevanderwerff / thebeat

thebeat: Rhythms in Python for science
https://thebeat.readthedocs.io
GNU General Public License v3.0
19 stars 1 forks source link

ugof calculation: correlation between number of onsets and ugof #50

Closed Jellevanderwerff closed 1 year ago

Jellevanderwerff commented 1 year ago

MWE

import thebeat
import numpy as np

seq_iois = np.random.default_rng(123).normal(500, 50, 100)
n_onsets = range(1, len(seq_iois) + 2)
ugofs = []

# get ugofs for increasing number of onsets
for n in n_onsets:
    seq = thebeat.Sequence(seq_iois[:n])
    ugofs.append(thebeat.stats.get_ugof_isochronous(seq, 500))

# calculate correlation between number of onsets and ugof
corr = np.corrcoef(n_onsets, ugofs)[0, 1]
print(corr)  # output: 0.9352718532998031
Jellevanderwerff commented 1 year ago

Now I'm not convinced it's a thebeat issue. Will look into it more, later.

Jellevanderwerff commented 1 year ago

Though, still (though it's not the issue here), if both the test onsets and ref onsets start with zero, that value should be discarded. But have to think about the best way to do that. I think making a new array of onsets based on the IOIs is the easiest. That way, we also take into account sequences that do not have the first onset at zero.

Jellevanderwerff commented 1 year ago

For the comment directly above, this was fixed in ff43c82. The correlation seems to be a property of the ugof (it's the same for the nPVI).