cardioception.PAT.scoring.monte_carlo_threshold#
- cardioception.PAT.scoring.monte_carlo_threshold(periods_ms, n_trials, n_sim=100000, q=0.95, fixed=False, seed=0, weights=None)[source]#
Chance threshold for the mean resultant length, by Monte Carlo.
Each simulated participant makes
n_trialschoices with delays drawn uniformly on [0, p), turned into angles with the same periodp, and the MRL is computed. The threshold is theqquantile ofn_simsuch MRLs.Since
2 pi U p / p = 2 pi UforUuniform on [0, 1), the angles are uniform on the circle whatever the periods, and the threshold depends only onn_trials,weights,n_sim,qandseed. The angles are drawn directly.periods_msandfixedare checked and accepted, so callers can say which participant and mapping a threshold is for, but they do not change it.- Parameters
- periods_msarray-like
The participant’s heart periods in ms (NaN ignored). They must hold at least one finite positive value; they do not change the threshold.
- n_trialsint
Number of trials in each simulated participant.
- n_simint
Number of simulated participants. 100,000 in the paper; fewer is fine for tests.
- qfloat
Quantile of the simulated MRLs, 0.95 in the paper.
- fixedbool
Fixed mapping (one period for all trials) rather than variable mapping. It does not change the threshold either.
- seedint, np.random.Generator or None
Seed of the random generator. The default is fixed, so thresholds are reproducible; None draws fresh entropy.
- weightsarray-like or None
Confidence weights, one per trial. When given, the null distribution is that of the weighted MRL with these weights and random angles.
- Returns
- thresholdfloat