def ergodic_chain(args): (burnin, run_length, alpha_count_slow, alpha_count_fast, alpha_mu_slow, alpha_mu_fast, buckets_slow, buckets_fast) = args np.random.seed((os.getpid() << 16) | (int(time.time()) & 0xFFFF)) rh_slow = create_rolling_histogram_class( Bucket=create_bucket_class( alpha_mu=alpha_mu_slow, alpha_count=alpha_count_slow), target_buckets=buckets_slow)() rh_fast = create_rolling_histogram_class( Bucket=create_bucket_class( alpha_mu=alpha_mu_fast, alpha_count=alpha_count_fast), target_buckets=buckets_fast)() jagged = [stats.uniform(x, x + 1) for x in range(200)] #for val in gen_value(jagged, burnin): #for val in gen_value([stats.uniform(0, 1)], burnin): for val in gen_value([stats.norm(0, 1)], burnin): #for val in gen_value([stats.cauchy(0)], burnin): rh_slow.update(val) rh_fast.update(val) data = [[] for _ in range(len(FUNC_LIST))] #for val in gen_value(jagged, run_length): #for val in gen_value([stats.uniform(0, 1)], run_length): for val in gen_value([stats.norm(0, 1)], run_length): #for val in gen_value([stats.cauchy(0)], run_length): rh_slow.update(val) rh_fast.update(val) cdf_long = rh_slow.get_CDF() cdf_short = rh_fast.get_CDF() for i, func in enumerate(FUNC_LIST): data[i].append(func(cdf_short, cdf_long)) return data
def get_detection_windows(args): (burnin, run_length, alpha_count_slow, alpha_count_fast, alpha_mu_slow, alpha_mu_fast, buckets_slow, buckets_fast, threshold) = args np.random.seed((os.getpid() << 16) | (int(time.time()) & 0xFFFF)) rh_slow = create_rolling_histogram_class( Bucket=create_bucket_class( alpha_mu=alpha_mu_slow, alpha_count=alpha_count_slow), target_buckets=buckets_slow)() rh_fast = create_rolling_histogram_class( Bucket=create_bucket_class( alpha_mu=alpha_mu_fast, alpha_count=alpha_count_fast), target_buckets=buckets_fast)() #for val in gen_value([dist0], burnin): # rh_slow.update(val) # rh_fast.update(val) data = [] #for i, val in enumerate(gen_value([dist1], run_length)): for i, val in enumerate(datasets.dataset1()): rh_slow.update(val) rh_fast.update(val) cdf_slow = rh_slow.get_CDF() cdf_fast = rh_fast.get_CDF() KS = get_KS(cdf_slow, cdf_fast) if KS > threshold: data.append(i) return data