So bootstrapping, but for modes.
The end goal is to create a probability distribution out of these modes. I need to create a test statistic that compares these distributions (and then perform a permutation test), so the initial bootstrapping needs to be as quick as possible so that creating the null distribution doesn't take too much time. Can I use numpy's random.choice for this?
CodePudding user response:
Adapting from Using bootstrapping random.choice
import scipy.stats as ss
array = ...
num_samples = 1000
sample_size = 100
Replications = np.array([np.random.choice(array, sample_size, replace = True) for _ in range(num_samples)])
mode_result = ss.mode(Replications)
mode = mode_result.mode