function rank_bootstrap(i) {
const subset =
i >= 0
? bootstraps.params({ i }).derive({ Total: (d, $) => d.bootstraps[$.i] })
: true_subset;
const transitions = subset
.groupby("InstitutionName")
.derive({ p: (d) => d.Total / op.sum(d.Total) })
.ungroup()
.select(["InstitutionName", "DegreeInstitutionName", "p", "Total"]);
let state = transitions
.groupby("DegreeInstitutionName")
.rollup({ t: (d) => op.sum(d.Total) })
.ungroup()
.derive({ p: (d) => d.t / op.sum(d.t) })
.orderby(aq.desc("p"))
.params({ placement_weight })
.derive({
p: (d, $) =>
d.p * $.placement_weight + (1 - $.placement_weight) / op.count()
})
.rename({ DegreeInstitutionName: "InstitutionName" });
for (let i in d3.range(20)) {
state = state
.join(transitions, ["InstitutionName", "InstitutionName"])
.derive({ p: (d) => d.p_1 * d.p_2 })
.groupby("DegreeInstitutionName")
.rollup({
t: (d) => op.sum(d.Total),
p: op.sum("p")
})
.orderby(aq.desc("p"))
.derive({ p: (d) => d.p / op.sum(d.p) })
.derive({
p: (d, $) =>
d.p * $.placement_weight + (1 - $.placement_weight) / op.count()
})
.rename({ DegreeInstitutionName: "InstitutionName" });
}
return state;
}