Erdős-Rényi graphs#
\(G(n, p)\) Erdős-Rényi graphs.
- tinto.theory.erdos_renyi.factorial_moments(n, p, k=1)[source]#
Exact \(\mathbb E S\) and \(\mathbb E S(S-1)\) on \(G(n, p)\).
The closed form of the second factorial moment, with \(s = 1 - p/k\), \(t_1 = 1 - (2p - p^2)/k\), \(t_2 = 1 - 2p/k\) and \(F(g) = \frac kp \left(\frac{1 - g^n}{1 - g} - \frac{s^n - g^n}{s - g}\right)\), is
\[\mathbb E S(S-1) = 2\left(\frac{1-p}{k} F(t_1) + \frac{k-1}{k} F(t_2)\right).\]With a
Fractionp the result is exact.- Parameters:
- Returns:
(E S, E S(S-1)).- Return type:
Examples
>>> from fractions import Fraction >>> factorial_moments(3, Fraction(1, 2)) (Fraction(7, 4), Fraction(7, 4))
- tinto.theory.erdos_renyi.integrals(m, p, k=1)[source]#
The two double integrals of the \(G(n, p)\) second factorial moment.
For a pair of nodes, m other nodes can be neighbors of either; the integrals average the probability that both are peaks over their labels, for distinct colors (\(I_{dist}\)) and for the same color without an edge between them (\(I_{same}\)). They also serve the same-side pairs of
bipartite.
- tinto.theory.erdos_renyi.limit_law(p, k=1, smax=60)[source]#
Limit law of the number of peaks on \(G(n, p)\) at fixed p, as \(n \to \infty\).
Monochrome, \(S_\infty = \sum_{i \ge 0} B_i\) with independent \(B_i \sim \mathrm{Bernoulli}((1-p)^i)\) (the node of rank i from the top is a peak iff it has no edge to the i larger ones). With k colors, the color classes are independent \(G(n/k, p)\): the law is the k-fold convolution.
- Parameters:
- Returns:
\(P(S_\infty = s)\) for
s = 0, ..., smax.- Return type:
ndarray, shape (smax + 1,)
Examples
With
p = 1there is one peak per color class:>>> limit_law(1.0, 2, smax=3).tolist() [0.0, 0.0, 1.0, 0.0]
- tinto.theory.erdos_renyi.mean(n, p, k=1)[source]#
Mean stabilization time on \(G(n, p)\) under k colors.
The node of rank r from the top is a peak iff none of the
r - 1larger nodes is a same-colored neighbor, which has probability \((1 - p/k)^{r-1}\); summing over the ranks, \(\mathbb E S = (k/p)(1 - (1 - p/k)^n)\).- Parameters:
- Return type:
Examples
>>> round(mean(200, 0.1), 6) 190.0
- tinto.theory.erdos_renyi.variance(n, p, k=1)[source]#
Variance of the stabilization time on \(G(n, p)\) under k colors.
\(\mathbb E S(S-1) = n(n-1)(I_{dist} + (1-p) I_{same})\) with the integrals of
integrals()atm = n - 2(a same-colored pair can only be two peaks when it is not an edge), then \(\mathrm{Var}\, S = \mathbb E S(S-1) + \mathbb E S - (\mathbb E S)^2\).- Parameters:
- Return type:
Examples
>>> round(variance(200, 0.1), 4) 4.7368 >>> round(variance(200, 0.1, 3), 6) 14.176553