hum.gen.signal_generators¶
Generating Signals
-
hum.gen.signal_generators.
alphabet_to_bins
(alphabet=['a', 'b', 'c', 'd', 'e'])[source]¶ Returns a dictionary matching each word in alphabet to bins of size 10.0 ranging from 0 to 10 * len(alphabet) >>> alphabet_to_bins() {‘a’: (0.0, 10.0), ‘b’: (10.0, 20.0), ‘c’: (20.0, 30.0), ‘d’: (30.0, 40.0), ‘e’: (40.0, 50.0)}
-
hum.gen.signal_generators.
bernoulli
(p_out=0.1)[source]¶ Returns a random sample of a bernoulli distribution with probability p_out >>> assert bernoulli(0) == 0 >>> assert bernoulli(1) == 1
-
hum.gen.signal_generators.
bernoulli_gen
(p_out=0.5)[source]¶ Returns a generator that returns random samples of a bernoulli distribution with probability p_out
-
hum.gen.signal_generators.
call_repeatedly
(func, *args, **kwargs)[source]¶ Returns a generator that calls func repeatedly with the given args and kwargs >>> gen = call_repeatedly(alphabet_to_bins) >>> assert next(gen) == {‘a’: (0.0, 10.0), ‘b’: (10.0, 20.0), ‘c’: (20.0, 30.0), ‘d’: (30.0, 40.0), ‘e’: (40.0, 50.0)} >>> next(gen) {‘a’: (0.0, 10.0), ‘b’: (10.0, 20.0), ‘c’: (20.0, 30.0), ‘d’: (30.0, 40.0), ‘e’: (40.0, 50.0)}
-
hum.gen.signal_generators.
gen_words
(N=30, alphabet=['a', 'b', 'c', 'd', 'e'], spread_pct=0.01, proba_dist='normal')[source]¶ Returns a generator of lists, with each consisting of n repetitions of a random word for alphabet, with n being determined by a normal distribution with mean N and variance N * spread_pct >>> gen = gen_words(N=3, alphabet=[‘foo’], spread_pct=0) >>> assert next(gen) == [‘foo’, ‘foo’, ‘foo’]
-
hum.gen.signal_generators.
inlier_outlier
(segment, interval_size, outlier_status)[source]¶ >>> assert inlier_outlier([0,1], 10, 0) < 1 >>> low = np.random.randint(5, 10) >>> high = np.random.randint(low, 20) >>> assert inlier_outlier([low, high], low*high, 1) < low + low*high