Esempio n. 1
0
#!/usr/bin/env python

import numpy as np
import cPickle
import multi_stats
import sys


if __name__ == "__main__":
    if len(sys.argv) < 2:
        print("Usage: show_comp_count.py <comp_count_file> [Nhyp]")
        sys.exit(1)

    print("Loading file %s ..." % sys.argv[1])
    with open(sys.argv[1], "r") as f:
        data = cPickle.load(f)

    Nhyp = int(sys.argv[2]) if len(sys.argv) >= 3 else None

    # load data and surrogate eigenvalues
    dlam = data["dlam"]
    slam = data["slam_ar"]

    p_vals = multi_stats.compute_eigvals_pvalues(dlam, slam)
    Nsurr = slam.shape[0]
    print("Bonferroni (single-level): %d components." % np.sum(multi_stats.bonferroni_test(p_vals, 0.05, Nsurr, Nhyp)))
    print("Sidak (single-level): %d components." % np.sum(multi_stats.sidak_test(p_vals, 0.05, Nsurr, Nhyp)))
    print("Bonferroni-Holm (stepdown): %d components." % np.sum(multi_stats.holm_test(p_vals, 0.05, Nsurr, Nhyp)))
    print("False Discovery Rate: %d components." % np.sum(multi_stats.fdr_test(p_vals, 0.05, Nsurr, Nhyp)))
figure(figsize=(10, 6))
FROM_EIG = 1
TO_EIG = 10
FR = 0
x = np.arange(TO_EIG - FROM_EIG) + FROM_EIG
plot(x, dlam[x - 1, FR], 'ro-')
errorbar(x,
         np.mean(slam_ar[:, x - 1, FR], axis=0),
         np.std(slam_ar[:, x - 1, FR] * 3, axis=0),
         fmt='bo-')
errorbar(x,
         np.mean(slam_w1[:, x - 1, FR], axis=0),
         np.std(slam_w1[:, x - 1, FR] * 3, axis=0),
         fmt='go-')
errorbar(x,
         np.mean(slam_f[:, x - 1, FR], axis=0),
         np.std(slam_f[:, x - 1, FR] * 3, axis=0),
         fmt='ko-')
legend(('Data', 'AR', 'WN', 'F1'))
title('Eigenvalues for frequency range %d' % FR)

# <codecell>

print slam_ar.shape[0]
pvals = compute_eigvals_pvalues(dlam, slam_ar)
print("Bonferroni correction: %d significant components." %
      np.sum(bonferroni_test(pvals, 0.05, slam_ar.shape[0])))
print("FDR correction: %d significant components." %
      np.sum(fdr_test(pvals, 0.05, slam_ar.shape[0])))
                      'orders' : sgf.model_orders()}, f)
elif USE_MUVAR:
    with open('results/hgt500_all_var_muvar_freq_comp_count_cosweights_pilot.bin', 'w') as f:
        cPickle.dump({ 'dlam' : dlam, 'slam_ar' : slam_ar, 'slam_w1' : slam_w1, 'slam_f' : slam_f,
                      'orders' : sgf.model_orders()}, f)
else:
    with open('results/hgt500_all_var_data_freq_comp_count_cosweights_pilot.bin', 'w') as f:
        cPickle.dump({ 'dlam' : dlam, 'slam_ar' : slam_ar, 'slam_w1' : slam_w1, 'slam_f' : slam_f,
                       'orders' : sgf.model_orders()}, f)

# <codecell>

figure(figsize = (10,6))
FROM_EIG = 1
TO_EIG = 10
FR = 0
x = np.arange(TO_EIG - FROM_EIG) + FROM_EIG
plot(x, dlam[x-1,FR], 'ro-')
errorbar(x, np.mean(slam_ar[:, x-1,FR], axis = 0), np.std(slam_ar[:, x-1,FR] * 3, axis = 0), fmt = 'bo-')
errorbar(x, np.mean(slam_w1[:, x-1,FR], axis = 0), np.std(slam_w1[:, x-1,FR] * 3, axis = 0), fmt = 'go-')
errorbar(x, np.mean(slam_f[:, x-1,FR], axis = 0), np.std(slam_f[:, x-1,FR] * 3, axis = 0), fmt = 'ko-')
legend(('Data', 'AR', 'WN', 'F1'))
title('Eigenvalues for frequency range %d' % FR)

# <codecell>

print slam_ar.shape[0]
pvals = compute_eigvals_pvalues(dlam, slam_ar)
print("Bonferroni correction: %d significant components." % np.sum(bonferroni_test(pvals, 0.05, slam_ar.shape[0])))
print("FDR correction: %d significant components." % np.sum(fdr_test(pvals, 0.05, slam_ar.shape[0])))
Esempio n. 4
0
import numpy as np
import cPickle
import multi_stats
import sys

if __name__ == '__main__':
    if len(sys.argv) < 2:
        print("Usage: show_comp_count.py <comp_count_file> [Nhyp]")
        sys.exit(1)

    print("Loading file %s ..." % sys.argv[1])
    with open(sys.argv[1], 'r') as f:
        data = cPickle.load(f)

    Nhyp = int(sys.argv[2]) if len(sys.argv) >= 3 else None

    # load data and surrogate eigenvalues
    dlam = data['dlam']
    slam = data['slam_ar']

    p_vals = multi_stats.compute_eigvals_pvalues(dlam, slam)
    Nsurr = slam.shape[0]
    print("Bonferroni (single-level): %d components." %
          np.sum(multi_stats.bonferroni_test(p_vals, 0.05, Nsurr, Nhyp)))
    print("Sidak (single-level): %d components." %
          np.sum(multi_stats.sidak_test(p_vals, 0.05, Nsurr, Nhyp)))
    print("Bonferroni-Holm (stepdown): %d components." %
          np.sum(multi_stats.holm_test(p_vals, 0.05, Nsurr, Nhyp)))
    print("False Discovery Rate: %d components." %
          np.sum(multi_stats.fdr_test(p_vals, 0.05, Nsurr, Nhyp)))