← Back to home

The shuffle test

Week 2 · Models & null models · Marvel Wikipedia snapshot (2026-08-26)

Last week we wrote that the Marvel network has a clustering coefficient of 0.31, that 39% of its links are reciprocated, and that 17 heroes are completely invisible. We reported those numbers as if they meant something.

They don't — not on their own. A number about a network is only interesting relative to a world where the interesting thing didn't happen. So this week we built that world, one hundred times over, and put every number we had on trial: keep each hero's popularity exactly as it is, rewire everything else at random, and see which of our findings are still standing afterwards.

Seven of the ten died — two of them only barely. One survived. And two of them, it turns out, could never have died in the first place, which is its own kind of lesson.

What we found

  1. Triangles are the real structure. Marvel's clustering (0.32 on the giant component) sits 17 standard deviations above a degree-preserving shuffle. Nothing about who is famous explains it.
  2. Several of our week-1 "findings" were facts about the degree sequence. The diameter is exactly what you get by accident once everyone's degree is fixed, and the assortativity is within a whisker of it. The 17 isolates are not even a result — the shuffle cannot move them.
  3. The famous "13× more reciprocity than chance" style of claim is wrong twice. Against a random directed graph it is 20.6×. Against a null that keeps everyone's in- and out-degree, it is 6.0×. Same data, same effect, three different headline numbers.
  4. The friendship paradox has exactly two kings. 87% of Marvel heroes are less popular than the average of their friends, and only two characters in the entire network are never out-popularised by anyone they link to: Spider-Man — and an obscure hero named Radian, whose entire social world is eight other people. One king per island.
  5. We cannot tell you the Marvel degree distribution is a power law. We fit one (γ = 2.62). We also fit a log-normal. The likelihood-ratio test cannot separate them (p = 0.43), and we show below why 303 nodes were never going to be enough.

1. The lineup

Here is the whole idea in one picture. We took ten numbers you can compute about the Marvel network and asked each of them the same question twice.

The easy question (green): is this bigger than in a random graph with the same number of heroes and the same number of links? That null throws away everything — it does not know that Spider-Man exists.

The honest question (blue): is this bigger than in a network where every hero keeps their exact degree and nothing else is preserved? We build that by taking the real network and applying 14,340 degree-preserving double edge swaps — ten per link: pick two links, cross them over, keep the count at every node the same — one hundred separate times.

Horizontal bar chart of z-scores for ten Marvel network statistics against two null models
Ten statistics, two nulls, 100 shuffles each. The x-axis is a symlog scale, so the grey band (|z| < 2, i.e. "indistinguishable from chance") stays visible next to z-scores in the hundreds. Green bars are what you get when you let the null forget who the hubs are; blue bars are what is left when it remembers.
Statistic Real Marvel Degree-preserving shuffle z Verdict
Giant component size277285.96 ± 0.28−31.8dies
Average clustering C0.30750.1431 ± 0.0065+25.4dies
Transitivity0.18250.1148 ± 0.0042+16.2dies
Triangles1,8391,157 ± 42+16.2dies
Islands (components)1918.02 ± 0.14+7.0dies
Mean distance (giant comp.)2.6742.632 ± 0.012+3.5dies (barely)
Degree assortativity−0.098−0.120 ± 0.011+2.2dies (barely)
Diameter (giant comp.)65.47 ± 0.54+1.0survives
Isolated heroes1717 ± 00frozen by construction
Top hub's share of links0.07390.0739 ± 00frozen by construction

What the survivors mean

The diameter survives (z = +1.0). Six hops from one end of the Marvel universe to the other is not a fact about Marvel. It is a fact about having 277 nodes, 1,421 links, and one enormous hub — any wiring with that degree sequence gives you roughly six. If we had written "the Marvel universe is remarkably compact" last week, this is the sentence that would have been wrong.

The frozen two are worth more than they look. "17 isolated heroes" and "Spider-Man owns 7.4% of all links" are numbers a degree-preserving shuffle can never change, because they are functions of the degree sequence alone. Their z-score against the shuffle is exactly zero and always will be. That is not a null result — it is a statement that we asked the wrong null. Both are wildly extreme against G(n,m) (z = +70 and +52), and the interesting question about them is not "is this random?" but "what process produced a degree sequence like that?" We come back to that in section 5.

The giant component is a nice surprise in the other direction. The real giant component is smaller than a shuffle of itself, by 32 standard deviations. Marvel's 9-node Strikeforce: Morituri island — Radian, Vyking, Scaredycat, Blackthorn and friends — has enough internal links that a random rewiring would almost always splice it into the mainland. It stays separate because those nine characters link to each other and to no one else. That is real, interpretable structure: a corner of comics history that never got cross-referenced.

2. Run it yourself

Reading someone else's permutation test is not the same as watching a null distribution appear. So here is the machine. It holds the actual 277-hero giant component in your browser, and every time you press the button it runs 25 fresh shuffles — 14,210 degree-preserving edge swaps each — and drops the resulting statistic into the histogram.

Try Links among the top 20 hubs and Spider-Man's share of all links back to back. The first wanders a little every time you press the button and lands close to the real value — 87 real against about 80 ± 4 shuffled, so the hubs are not unusually wired to each other once you know how big they are. The second cannot move at all, ever. The difference between "not significant" and "not even possible" is the whole reason to think about your null.

(The machine works on the 277-node giant component; the battery in section 1 uses all 303 heroes, so their numbers differ a little. Everything else is the same procedure.)

The Shuffle Machine

277 heroes · 1,421 links · degree-preserving double edge swaps, computed live in this page

If the widget is blank

It needs JavaScript and the data file next to it; everything below stands on its own without it. The same numbers, computed in Python, are in analysis/week2_results_nulls.json.

3. Two roads to the same null, and they do not agree

There are two standard ways to build "the same degrees, everything else random". You can throw the network away and rebuild it from the degree sequence (the configuration model), or you can keep the network and shuffle its links in place (double edge swaps). They are supposed to sample the same thing. They do not.

Histograms of average clustering under three null models, with the real Marvel value marked
Average clustering on the giant component under three nulls, 100 draws each. Real Marvel is 0.320. G(n,m) says 0.037 (z = +82). The configuration model says 0.109 (z = +26). Edge swaps say 0.155 (z = +17). Right panel: the two degree-preserving nulls do not overlap at all.

The gap is 0.109 versus 0.155 — a 42% difference between two methods that are described in the same paragraph of every textbook. It comes from the cleanup step. The configuration model produces self-loops and duplicate links, and the standard fix is to delete them. On Marvel that costs 103 links, 7.3% of the network. The question is whose links.

Fraction of links lost in the configuration model, plotted against a hero's original degree
Share of each hero's links destroyed by the configuration model's cleanup, against their real degree. A degree-1 hero loses nothing. Spider-Man loses 27% of his.

There it is. A node with k stubs has roughly k² chances to collide with itself or double up, so the tax is quadratic in degree and lands almost entirely on the hubs. Spider-Man goes into the configuration model with 106 links and comes out with about 77. Hulk loses 20%, Wolverine 19%, Doctor Strange 18% — while every hero of degree 1 loses exactly nothing.

So the configuration model is not testing the degree sequence we handed it. It is testing a flattened version of it, with the hubs shaved down, and flatter degree sequences make fewer triangles. The edge-swap number, 0.155, is the one to quote. If you use the configuration model on a heavy-tailed network without reporting how many links you deleted and from whom, your null is quietly biased — in the direction that makes your result look better.

4. The reciprocity claim, and how to be wrong in two directions

39% of Marvel's 1,784 directed links are answered: if Spider-Man's page links to Venom's, there is a 39% chance Venom's page links back. Set against a random directed network of the same density, where reciprocity is 1.9%, that is a 20.6× enrichment. Impressive, and almost meaningless — the random network has no hubs, and a hub is a reciprocity machine simply because it has so many links that some are bound to be answered.

So we built the null that keeps every hero's in-degree and out-degree exactly and shuffles the rest (nx.directed_edge_swap, 100 replicates).

Histogram of reciprocity under two directed null models with the real value marked
Reciprocity under two directed nulls. Degree structure alone lifts the baseline from 1.9% to 6.5%, closing about 40% of the gap on a log scale and none of the rest.

Against the honest null the effect is 6.0×, and still enormous: the shuffled distribution sits at 6.5% ± 0.7 percentage points, and the real value is 39%, a z of +47. So the finding survives — but the headline number was inflated by a factor of three and a half, and anyone quoting "13×" or "20×" is reporting a property of their null model, not of Marvel.

What is left over after the hubs are accounted for is the actual claim: Wikipedia editors write mutual links. If Deadpool's page mentions Cable, somebody eventually adds Deadpool to Cable's page. That is a fact about how the encyclopedia is maintained, and no amount of degree structure produces it.

5. Two kings, one per island

Your friends have more friends than you. In Marvel: the average hero (counting only the 286 who have any links at all) has 10.0 connections, and the average connection of the average hero has 24.2. A factor of 2.4. And 87% of heroes — 250 out of 286 — are less popular than the mean of their own friends.

Left: mean own degree versus mean friend degree across five networks. Right: the heroes most likely to be your more-popular friend.
Left: the paradox across five networks, exact (no sampling error). The pink dashes are ⟨k⟩ + σ²/⟨k⟩ — see the note below on why they are not the same number as the blue bars. Right: the exact probability that each hero is the answer when a random hero is asked about a random friend. "Crowns" counts how many heroes have this character as their single most popular friend.

Who drives it? Spider-Man, mostly, and it is not close. Ask a random Marvel hero about a random friend and there is a 5.6% chance the answer is Spider-Man — more than Hulk and Wolverine combined. And all 106 of Spider-Man's neighbours have him as their most popular friend. Not most of them. All of them. There is no hero in the Marvel network who links to Spider-Man and also knows someone bigger.

Is there a character nobody out-populars?

We looked for local maxima: heroes whose every neighbour has a degree less than or equal to their own. Out of 286 connected characters there are exactly two.

The first is Spider-Man (106 links), which is not a surprise — he is the global maximum, so he was always going to qualify. The second is Radian, a character from Strikeforce: Morituri with six links, every one of them to another Morituri character with two or three links. Radian is the king of the 9-node island from section 1. His entire social world is eight people, and he is the most popular person in it.

The actual finding

There is one local king per island, and the Marvel network has two islands. The friendship paradox does not just say "hubs exist" — it says the degree landscape is so steep that almost nobody sits on a local peak. The closest near-miss on the mainland is Quasar, with 24 links, whose best friend has 25.

The shuffle cannot kill it — and that is the point

Run the same measurement on a degree-preserving shuffle of Marvel and the paradox is untouched: 23.7 versus 24.2, 76% versus 75%. Of course it is. The paradox is a theorem about the degree distribution, not about wiring: any network whose degrees have variance at all will show it, because a random friend is sampled with probability tilted toward high degree. Even the Marvel-sized random graph shows it (×1.1) — weak, but never absent, because even Poisson degrees have σ² > 0.

This makes the friendship paradox the exact mirror image of clustering. Clustering is destroyed by a shuffle, so it is a fact about wiring. The paradox is immune to a shuffle, so it is a fact about the degree sequence. Same test, opposite answers, and the answers tell you which layer of the network the phenomenon lives on.

A subtlety we nearly got wrong

The textbook formula ⟨k⟩ + σ²/⟨k⟩ gives 22.1 for Marvel, but the actual survey answer is 24.2. They are not the same quantity. The formula is the mean degree at a random edge endpoint — hub-weighted. "Pick a random hero, then a random friend of theirs" weights every hero equally and lands on 24.2. The two agree in the Marvel-sized random graph (10.40 vs 10.39) and diverge in Marvel and in BA — because both are disassortative, so low-degree heroes are attached to hubs at a higher rate than an edge-endpoint sample would suggest. Assortativity is the third thing the paradox depends on, and none of the textbook statements mention it.

6. Grow your own Marvel

The other way to ask "what is really going on here" is to build a fake Marvel from a mechanism and see how far you get. Preferential attachment, n = 303, m = 5 links per newcomer, tuned to land on the real link count (1,490 versus 1,434).

Left: CCDF of the real Marvel network against a Barabási–Albert network of the same size. Right: percentage error of the model on six statistics.
A 303-node Barabási–Albert network against the real thing. Left: the degree CCDFs. Right: how far off the model is on six numbers, as a percentage of the real value.

What it gets right, and it is genuinely impressive:

The most glaring thing it gets wrong is not the clustering, though the clustering is wrong (0.08 against 0.31 — preferential attachment has no reason to close a triangle). It is that the model has no bottom.

Every node in a BA network arrives with exactly m = 5 links. The minimum degree is 5, by construction, forever. So the model produces 0 isolates and 1 component, where Marvel has 17 isolates and 19 islands. Almost 6% of the real Marvel roster is characters that no hero page mentions and whose own page mentions no hero, and preferential attachment cannot represent them at all — not "gets the number wrong", but has no mechanism that could ever create one.

And at the top: the model's biggest hub has 49 links; Spider-Man has 106. Even with a mechanism purpose-built for making hubs, on 303 nodes, we could not grow a Spider-Man. Whatever made Spider-Man is not just "he arrived first."

7. What we cannot conclude

The obvious next move is to declare the Marvel in-degree scale-free and go home. Here is why we are not doing that.

Left: Marvel in-degree CCDF with a maximum-likelihood power law fit. Right: Marvel, BA and random CCDFs rescaled by their mean degree.
Left: the 245 heroes with at least one incoming link, as a binned P(k) and as a CCDF (58 have in-degree zero and cannot go on a log axis). The CCDF needs no bins, no bin widths, and no decisions — every data point is a data point. Right: shape comparison, with every degree divided by its own network's mean so the three densities do not confound the tails.

What we can say. The in-degree is heavy-tailed by any reasonable definition. Its maximum is 18× its own mean, and the same tail survives the undirected collapse, where 100 random networks with Marvel's exact n and m topped out at 19.0 ± 1.7 against Marvel's 106 — some 53 standard deviations out. The distribution is not Poisson, and no amount of arguing about fits changes that.

What we cannot say. That it is a power law. We ran the Clauset-style fit properly — scan kmin, maximum-likelihood γ at each, keep the kmin that minimises the KS distance. It picks kmin = 11, γ = 2.62, KS = 0.086, on a tail of 46 heroes. Then we fitted a truncated log-normal to the same 46 points and ran a likelihood-ratio test: normalised R = −0.78, p = 0.43. The data cannot tell the two apart. If anything, the log-normal is very slightly ahead.

And read the slope off by eye across the whole range, as everyone does, and you get γ ≈ 2.31 — different from the fitted 2.62 by more than the difference between most competing theories.

The demonstration that convinced us

We grew a 5,000-node Barabási–Albert network — a network we know has γ = 3, because we wrote the loop that generates it — and ran the same maximum-likelihood estimator on it at different kmin:

kmin235102040
estimated γ2.362.502.702.873.024.95
nodes in the tail1,62982035399267

The true answer is 3. The estimator wanders from 2.36 to 4.95 depending on where you cut, and it passes through the right value at a cut that leaves 26 nodes. On a network sixteen times bigger than Marvel, with a known exponent and no measurement noise whatsoever, the answer you get is mostly a function of a choice you made.

Our γ = 2.62 is therefore not really a measurement of Marvel. It is a measurement of what an estimator does when you hand it 46 numbers.

What it would take. More nodes — the whole of Wikipedia's comics coverage rather than one category, which is roughly the "crawl your own category" option the course offers for weeks 2–4. Or a goodness-of-fit p-value from synthetic resampling rather than a bare KS number. Or, better, stop asking. "Power law versus log-normal" is a question about functional forms; "does this network have hubs that a random graph could never produce" is a question about the world, and we can answer that one with confidence.

8. What we would tell last week's us

Every descriptive number needs the sentence "compared to what" attached to it, and the choice of comparison is not a technicality — it moved our reciprocity headline by a factor of 3.5 and our clustering baseline by 42%. The rule we are taking forward: state the null, state how many replicates, state what the null preserves, and state what it cannot move.

And there is a nice symmetry in the results. Clustering, triangles and the separate island are facts about wiring — the shuffle destroys them. The friendship paradox, the isolates, the hub's share of links are facts about the degree sequence — the shuffle cannot touch them. The diameter is a fact about neither; it falls out of n, m and the degree sequence together. Three different kinds of finding, and one test tells them apart.

Reproduce it

Two scripts, no notebooks, seeded throughout:

pip install -r requirements.txt
python analysis/week2_models.py   # 2.2, 2.4, 2.5b, 2.6
python analysis/week2_nulls.py    # 2.8, 2.9, the shuffle battery, grow-your-Marvel

Figures go to docs/assets/week2/, every number in this post to analysis/week2_results_models.json and analysis/week2_results_nulls.json. The Shuffle Machine above is 350 lines of dependency-free JavaScript in docs/assets/week2/shuffle-machine.js — view source, it is all there.

→ Our full week-2 solutions (2.1 – 2.10) ← Week 1: Fame, curation, and the islands All posts