Markov Chain Monte Carlo
- Free software: MIT license
- Documentation: https://mcmc.readthedocs.io.
In this version, seven py file are included.
The main program is mcmc.py which has the functionality:
1.Creating a list storing every graphs at each time points, which generated by a Markov Chain Monta Carlo Method (Metripolis-Hastings Algorithm);
2.Ploting out the first N graphs, where N is smaller or eqaul to the total time points;
3.Finding the most possible graph which has the largest appearance times in the graph list;
4.Giving the expected number of edges connected to vertex 0;
5.Giving the expected number of edges in the entire graph;
6.Giving the expected maximum distance of the shortest path ina graph that connects vertex 0 to another vertex.
Two classes are included:
1.edge_oper;
2.connec_graph.
And four independent functions are included:
3.posi_assign;
4.theta;
5.Metripolis_Hastings;
6.plot_graph;
1.edge_oper: including all the edge operation related functions
a.weight_calc: returning the matrix storing the distance between each vertex pairs given the position of each vertex
b.ran_edge: returning the random edge created unifromly
c.update_edges_list: Given the random created edge and edges list containing edges cannot be deleted which garantee the connected graph, return True if the edges list has been updated; return False if the edges list is unchanged. Meanwhile, adding the random edge if it is not exist; deleting it if it is already exist and not among the edges listcontaining edges connot be deleted;
d.edges_weighted: returning the edges with weight of the current graph given the weight matrix
2.connec_graph:
- init_graph: creating the initial graph only connecting vertex 0 to other vertexes.
- edges_keep: returning the edges list containing edges cannot be deleted which garantee the connected graph and its number of elements.
- posi_assign: creating a 2D grid and picking N random points uniformly.
- theta : calculating the theta function posted in the note.
- Metripolis_Hastings: Using the Metripolis Hastings Algorithm to judge if the poposal graph accepted or not, if the proposal graph had been refected, the graph at next time point would be the same as the current graph.
- plot_graph: ploting out the graph.The edges with weight bigger than 0.5 would be connected by solid line, other edges would be connected by dash lines.
This package was created with Cookiecutter and the audreyr/cookiecutter-pypackage project template.