Skip to main content

Simulate and analyze trajectories of Block Markov Chains.

Project description

This Python package provides tools to simulate and analyze trajectories of Block Markov Chains (BMCs).

Contents

A compiled C++ library is distributed, together with stubs.

Usage

Here is an example on how to use the library:

import random
import numpy as np
import BMCToolkit as BMCToolkit

if __name__ == "__main__":

    num_states = 10*30
    num_clusters = 2
    path_length = 1500

    current_state = 0
    frequency_matrix = np.zeros((num_states,num_states))
    trajectory = []
    for t in range(path_length):
        past_state = current_state
        if t % 2 == 0:
            if current_state <= num_states / 3:
                current_state = random.randint(num_states/3,num_states-1)
            else:
                current_state = random.randint(0,num_states/3-1)
        else:
            current_state = random.randint(0,num_states-1)    
        trajectory.append(current_state)
        frequency_matrix[past_state,current_state] += 1
    
    print("Testing compute_clusters_from_trajectory...")
    clustering = BMCToolkit.compute_clusters_from_trajectory( trajectory, num_states, num_clusters )
    
    print(clustering)

Related projects

The compiled C++ library utilizes the following other C++ libraries unmodified:

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

BMCToolkit-0.6.6-cp39-cp39-win_amd64.whl (307.4 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page