Ejemplo n.º 1
0
def run_analysis_uzal_nichkawde(cname, cause, ename, effect, theiler_window):
    # Calculate maximum prediction horizon (used by Uzal cost function)
    prediction_horizon = min(MAX_PREDICTION_HORIZON, 2 * theiler_window)
    sys.stderr.write('  prediction_horizon = {0}\n'.format(prediction_horizon))
    assert prediction_horizon > theiler_window

    # Hard-code maximum delay vector window:, equal to delay * (embedding_dimension - 1)
    max_window = 60
    sys.stderr.write('  max_window = {0}\n'.format(max_window))

    # Run Uzal cost function (will implicitly compile Uzal's C code if necessary)
    if OVERRIDE_UZAL_UPPER_BOUND is not None:
        max_embedding_dimension = OVERRIDE_UZAL_UPPER_BOUND
    else:
        ms, Lks, params = uzalcost.run_uzal_costfunc(
            effect, theiler_window=theiler_window, max_prediction_horizon=prediction_horizon,
            max_window=max_window
        )
        best_m_index = numpy.argmin(Lks)
        sys.stderr.write('  Uzal full embedding dimension = {0} (Lk = {1})\n'.format(ms[best_m_index], Lks[best_m_index]))
        max_embedding_dimension = int(numpy.round(UZAL_FACTOR * ms[best_m_index]))
    sys.stderr.write('  Using max embedding dimension = {}\n'.format(max_embedding_dimension))

    # Run Nichkawde algorithm to identify sub-embedding
    embedding, derivs_tup, fnn_rates_tup = pyembedding.nichkawde_embedding(effect, theiler_window, max_embedding_dimension, return_metrics=True)
    delays = embedding.delays
    write_and_plot_nichkawde_metrics(cname, ename, delays, derivs_tup, fnn_rates_tup)

    sys.stderr.write('  Nichkawde sub-embedding: {0}\n'.format(delays))
    run_analysis_for_embedding(cname, cause, ename, effect, embedding, theiler_window)
Ejemplo n.º 2
0
def run_analysis_uzal_nichkawde(cname, cause, ename, effect, theiler_window, db, rng, ccm_settings):
    # Calculate maximum prediction horizon (used by Uzal cost function)
    prediction_horizon = min(ccm_settings['max_prediction_horizon'], 2 * theiler_window)
    sys.stderr.write('  prediction_horizon = {0}\n'.format(prediction_horizon))
    assert prediction_horizon > theiler_window

    # Hard-code maximum delay vector window:, equal to delay * (embedding_dimension - 1)
    max_window = 60
    sys.stderr.write('  max_window = {0}\n'.format(max_window))

    # Run Uzal cost function (will implicitly compile Uzal's C code if necessary)
    if 'override_uzal_upper_bound' in ccm_settings and ccm_settings['override_uzal_upper_bound'] is not None:
        max_embedding_dimension = ccm_settings['override_uzal_upper_bound']
    else:
        ms, Lks, params = uzalcost.run_uzal_costfunc(
            effect, theiler_window=theiler_window, max_prediction_horizon=prediction_horizon,
            max_window=max_window
        )
        best_m_index = numpy.argmin(Lks)
        sys.stderr.write('  Uzal full embedding dimension = {0} (Lk = {1})\n'.format(ms[best_m_index], Lks[best_m_index]))
        max_embedding_dimension = int(numpy.round(ccm_settings['uzal_factor'] * ms[best_m_index]))
    sys.stderr.write('  Using max embedding dimension = {}\n'.format(max_embedding_dimension))

    # Run Nichkawde algorithm to identify sub-embedding
    embedding, derivs_tup, fnn_rates_tup = pyembedding.nichkawde_embedding(effect, theiler_window, max_embedding_dimension, return_metrics=True)
    delays = embedding.delays
    write_and_plot_nichkawde_metrics(cname, ename, delays, derivs_tup, fnn_rates_tup, db)

    sys.stderr.write('  Nichkawde sub-embedding: {0}\n'.format(delays))
    run_analysis_for_embedding(cname, cause, ename, effect, embedding, theiler_window, ccm_settings['n_ccm_bootstraps'], db, rng)
Ejemplo n.º 3
0
def run_analysis_uzal_nichkawde(cname, cause, ename, effect, theiler_window):
    # Calculate maximum prediction horizon (used by Uzal cost function)
    prediction_horizon = min(MAX_PREDICTION_HORIZON, 2 * theiler_window)
    sys.stderr.write('  prediction_horizon = {0}\n'.format(prediction_horizon))
    assert prediction_horizon > theiler_window

    # Hard-code maximum delay vector window:, equal to delay * (embedding_dimension - 1)
    max_window = 60
    sys.stderr.write('  max_window = {0}\n'.format(max_window))

    # Run Uzal cost function (will implicitly compile Uzal's C code if necessary)
    if OVERRIDE_UZAL_UPPER_BOUND is not None:
        max_embedding_dimension = OVERRIDE_UZAL_UPPER_BOUND
    else:
        ms, Lks, params = uzalcost.run_uzal_costfunc(
            effect,
            theiler_window=theiler_window,
            max_prediction_horizon=prediction_horizon,
            max_window=max_window)
        best_m_index = numpy.argmin(Lks)
        sys.stderr.write(
            '  Uzal full embedding dimension = {0} (Lk = {1})\n'.format(
                ms[best_m_index], Lks[best_m_index]))
        max_embedding_dimension = int(
            numpy.round(UZAL_FACTOR * ms[best_m_index]))
    sys.stderr.write('  Using max embedding dimension = {}\n'.format(
        max_embedding_dimension))

    # Run Nichkawde algorithm to identify sub-embedding
    embedding, derivs_tup, fnn_rates_tup = pyembedding.nichkawde_embedding(
        effect, theiler_window, max_embedding_dimension, return_metrics=True)
    delays = embedding.delays
    write_and_plot_nichkawde_metrics(cname, ename, delays, derivs_tup,
                                     fnn_rates_tup)

    sys.stderr.write('  Nichkawde sub-embedding: {0}\n'.format(delays))
    run_analysis_for_embedding(cname, cause, ename, effect, embedding,
                               theiler_window)