Published
Edited
Dec 30, 2019
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
normalizedCred = (a, exp) => cred.get(a).map((x) => Math.pow(x, exp))
Insert cell
totalCred = aliasMap((a) => d3.sum(cred.get(a)))
Insert cell
totalCredPower = aliasMap((a) => totalCred.get(a) / sumTotalCred)
Insert cell
Insert cell
totalNormalizedCred = aliasMap((a) => Math.pow(totalCred.get(a), normalizationExponent))
Insert cell
sumTotalNormalizedCred = aliasMapSum(totalNormalizedCred)
Insert cell
normalizedCredPower = aliasMap((a) => totalNormalizedCred.get(a) / sumTotalNormalizedCred)
Insert cell
perPeriodNormalizedCred = aliasMap((a) => d3.sum(normalizedCred(a, normalizationExponent)))
Insert cell
Insert cell
gini(data.map((x) => x.normalizedCredPower))
Insert cell
gini = (xx) => {
// from https://github.com/DrPaulBrewer/gini-ss/blob/master/index.js
let sumdiff = 0;
let sum = 0;
if (!Array.isArray(xx)) return undefined;
let x = xx.sort()
const n = x.length;
if (n<2) return undefined;
for(let i=0,l=x.length;i<l;++i){
sum += x[i];
for(let j=0;j<i;++j)
sumdiff += Math.abs(x[i]-x[j]);
}
if ((sum===0) && (sumdiff===0)) return 0;
return sumdiff/((n-1)*sum);
}
Insert cell
[1,3,2].sort()
Insert cell
{
const columns = [
{name: "Raw Cred %", map: totalCred},
{name: "Normalized %", map: totalNormalizedCred},
{name: "Per-Period Normalized", map: perPeriodNormalizedCred},
]
return md`${tableFor("Power", columns, 10)}
This table shows the different forms of explicit power for various contributors.
`
}
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
cred = aliasMap((a) => intervalCred.has(a) ? intervalCred.get(a).slice(0, last_week_idx+1) : []);
Insert cell
sumTotalCred = aliasMapSum(totalCred)
Insert cell
aliasMapSum = (m) => d3.sum(Array.from(m.values()))
Insert cell
timeDecayedCred = aliasMap((a) => timeDecay(cred.get(a)))
Insert cell
totalTimeDecayed = aliasMap((a) => d3.sum(timeDecayedCred.get(a)))
Insert cell
aggregateRenormalized = aliasMap((a) => Math.pow(d3.sum(timeDecay(cred.get(a))), normalizationExponent))
Insert cell
timeDecay = (credArray) => credArray.map((x, i) => x * Math.pow(expDecay, credArray.length - i - 1))
Insert cell
decayArray = (credArray) => {
let total = 0;
return credArray.map((x) => {
total*=0.5
total+=x;
return total;
})
}
Insert cell
Insert cell
Math.pow(Math.pow(2, 3), 2)
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
percentFormat = d3.format(".1%")
Insert cell
import {slider} from "@jashkenas/inputs"
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more