@njam-data/diversity-index
Based on the USA Today diversity index.
Install
npm i @njam-data/diversity-index
Examples
creating an index from one factor
const race = [0.7, 0.3]
const result = diversityIndex([
race
])
console.log('result', result)
// result === 0.42
creating an index from two factors
const race = [0.3, 0.2, 0.1, 0.5]
const ethnicity = [0.1, 0.9]
const result = diversityIndex([
race,
ethnicity
])
console.log('result', result)
// result === 0.75