Commit 81ec4f49 authored by Carl Poelking's avatar Carl Poelking
Browse files

Seeded subsampling.

parent 5f8a2b3c
import numpy as np
def subsample_array(array, n_select, method='stride', stride_shift=0):
def subsample_array(array, n_select, method='stride', stride_shift=0, seed=None):
# Number of data items; selected, discarded items
if type(array) == list:
n_data = len(array)
......@@ -16,6 +16,8 @@ def subsample_array(array, n_select, method='stride', stride_shift=0):
n_discard = n_data - n_select
# Subsample
if method == 'random':
if seed != None:
np.random.seed(seed)
# Random access indices
idcs = np.arange(0, n_data)
np.random.shuffle(idcs)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment