Bipartite graphs#
Bipartite \(G(n_1, n_2, p)\) graphs.
- tinto.theory.bipartite.law(n1, n2, p)[source]#
Exact law of the number of peaks on the monochrome \(G(n_1, n_2, p)\).
Take the nodes in decreasing label order. Given the interleaving of the two sides in that order, a node is a peak iff it has no edge to the larger nodes of the other side, independently of the others: the conditional generating function is a product \(\prod_u (1 - q^{h_u} + q^{h_u} v)\), \(q = 1 - p\), \(h_u\) the number of larger nodes on the other side. The law averages it over the \(\binom{n_1 + n_2}{n_1}\) equally likely interleavings, here by dynamic programming over the prefixes.
- Parameters:
- Returns:
\(P(S = j)\) for
j = 0, ..., n1 + n2.- Return type:
Examples
One node on each side: one peak with an edge, two without.
>>> from fractions import Fraction >>> [str(x) for x in law(1, 1, Fraction(1, 3))] ['0', '1/3', '2/3']
- tinto.theory.bipartite.limit_mean(lam, p)[source]#
Limit of \(\mathbb E S\) on the monochrome \(G(\lambda n, (1-\lambda) n, p)\).
\[\lim_{n \to \infty} \mathbb E S = \frac{\lambda}{(1-\lambda) p} + \frac{1-\lambda}{\lambda p}.\]- Parameters:
- Return type:
Examples
>>> round(limit_mean(0.5, 0.25), 6) 8.0
- tinto.theory.bipartite.mean(n1, n2, p, k=1)[source]#
Mean stabilization time on \(G(n_1, n_2, p)\) under k colors.
A node of the first side is a peak iff none of the larger nodes of the other side is a same-colored neighbor; averaging over the interleaving of the two sides gives
\[\mathbb E S = \frac kp \left(\frac{n_1}{n_2+1}\left(1 - q^{n_2+1}\right) + \frac{n_2}{n_1+1}\left(1 - q^{n_1+1}\right)\right), \quad q = 1 - \frac pk.\]- Parameters:
- Return type:
Examples
>>> round(mean(100, 100, 0.1), 6) 180.198493
- tinto.theory.bipartite.variance(n1, n2, p, k=1)[source]#
Variance of the stabilization time on \(G(n_1, n_2, p)\) under k colors.
Pairs on the same side are never adjacent and see the other side only: they use
integrals()withmthe size of the other side. Pairs across the sides are adjacent with probability p (then only distinct colors can make two peaks); their private neighborhoods are independent binomials, which gives two more double integrals.- Parameters:
- Return type:
Examples
>>> round(variance(100, 100, 0.1), 4) 9.9943 >>> round(variance(100, 100, 0.1, 3), 6) 28.284911