Beispiel #1
0
    sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..', '..'))
    sys.path.insert(0, os.path.join(os.path.dirname(__file__), '..'))

    #----------------------------Example Simple--------------------------------------

    #import needed packages
    import numpy as np
    from teaspoon.SP.network import knn_graph
    from teaspoon.TDA.PHN import PH_network

    #generate a siple sinusoidal time series
    t = np.linspace(0, 30, 300)
    ts = np.sin(t) + np.sin(2 * t)

    #create adjacency matrix, this
    A = knn_graph(ts)

    #create distance matrix and calculate persistence diagram
    D, diagram = PH_network(A, method='unweighted', distance='shortest_path')

    print('1-D Persistent Homology (loops): ', diagram[1])

    stats = point_summaries(diagram, A)
    print('Persistent homology of network statistics: ', stats)

    #---------------------------Complex Example---------------------------------------

    #import needed packages
    import numpy as np
    from teaspoon.SP.network import ordinal_partition_graph
    from teaspoon.TDA.PHN import PH_network
    plt.plot(embedded_ts.T[0][NN], embedded_ts.T[1][NN], 'rs')  #plot NN
    plt.plot(embedded_ts.T[0][i], embedded_ts.T[1][i],
             'bd')  #plot point of interest
    plt.show()

    # In[ ]: make graph from time series

    #import needed packages
    import numpy as np
    from teaspoon.SP.network import knn_graph
    from teaspoon.SP.network import ordinal_partition_graph

    t = np.linspace(0, 30, 200)
    ts = np.sin(t) + np.sin(2 * t)  #generate a simple time series

    A_knn = knn_graph(ts)  #ordinal partition network from time series

    A_op = ordinal_partition_graph(ts)  #knn network from time series

    #ANOTHER EXAMPLE

    t = np.linspace(0, 30, 200)
    ts = np.sin(t) + np.sin(2 * t)  #generate a simple time series

    from teaspoon.SP.network import knn_graph
    A = knn_graph(ts)

    from teaspoon.SP.network_tools import make_network
    G, pos = make_network(A)

    import matplotlib.pyplot as plt