From 0d20da01f1e6f3718dcc7f048a5b38a703d8fd8b Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Wed, 11 Dec 2024 11:36:54 +0100 Subject: Measure also the probability of being in the same cluster. --- percolation.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/percolation.cpp b/percolation.cpp index f012b07..fac04ec 100644 --- a/percolation.cpp +++ b/percolation.cpp @@ -189,7 +189,8 @@ int main(int argc, char* argv[]) { std::vector clusters = G.markClusters(activeEdges); Matrix laplacian = G.laplacian(activeEdges); - std::vector conductivities(L * L * D / 4); + std::vector conductivities((L * L * D) / 4); + std::vector probabilities((L * L * D) / 4); for (const Cluster& c : clusters) { std::vector inds; @@ -212,6 +213,7 @@ int main(int argc, char* argv[]) { double ΔV = std::abs(output(i) - output(j)); conductivities[G.squaredDistance(inds[i], inds[j]) - 1] += 1 / ΔV; + probabilities[G.squaredDistance(inds[i], inds[j]) - 1]++; } } } @@ -224,6 +226,14 @@ int main(int argc, char* argv[]) { } } std::cout << std::endl; + for (unsigned i = 0; i < probabilities.size(); i++) { + if (G.multiplicities[i] != 0) { + std::cout << ((Real)probabilities[i]) / G.multiplicities[i] << " "; + } else { + std::cout << 0 << " "; + } + } + std::cout << std::endl; } return 0; -- cgit v1.2.3-70-g09d2