How diverse is your student body? A tour through some classrooms may give you some idea. But how diverse is your student body *in relation
to the school across town?* To answer that question, you need a more precise measure. Enter Ethnic Diversity Index (EDI),
a reflection of how evenly distributed your students are among the race/ethnicity categories reported to the California Department of Education.

The precise formula can be found on Ed-Data’s old website, but it is obviously of little value until put into a computational environment. Here’s one possible instantiation in R:

EDI is calculated on a 0-100 scale: indices closer to zero indicate less diversity, and indices approaching 100 indicate great diversity. As Ed-Data explains:

…a school that had exactly 1/8th of its students in each of the eight categories would have an Ethnic Diversity Index of 100, and a school where all of the students are the same ethnicity would have an index of 0. In reality, of course, no school has an index of 100 (although a few have diversity indices of 0). Currently the highest index for a school is 76.

Let’s test our function with some simulated data of a perfectly balanced student body:

Precisely what we wanted.