Simpson’s Diversity Index Calculator?

Simpson’s Diversity Index Calculator is a tool used to calculate the diversity of a species in a given area. It is computed by taking the probability of two randomly chosen individuals belonging to different species, also known as the probability of interspecific encounter, and subtracting it from one. This equation is then used to calculate the diversity index, which is a measure of the richness and evenness of a species in a given area. This index can be used to compare different areas and to assess the overall biodiversity of an area.

@import url(‘https://fonts.googleapis.com/css?family=Droid+Serif|Raleway’);

h1 {
text-align: center;
font-size: 50px;
margin-bottom: 0px;
font-family: ‘Raleway’, serif;
}

p {
color: black;
margin-bottom: 15px;
margin-top: 15px;
font-family: ‘Raleway’, sans-serif;
}

#words {
padding-left: 30px;
color: black;
font-family: Raleway;
max-width: 550px;
margin: 25px auto;
line-height: 1.75;
}

#words_summary {
padding-left: 70px;
color: black;
font-family: Raleway;
max-width: 550px;
margin: 25px auto;
line-height: 1.75;
}

#words_text {
color: black;
font-family: Raleway;
max-width: 550px;
margin: 25px auto;
line-height: 1.75;
}

#words_text_area {
display:inline-block;
color: black;
font-family: Raleway;
max-width: 550px;
margin: 25px auto;
line-height: 1.75;
padding-left: 100px;
}

#calcTitle {
text-align: center;
font-size: 20px;
margin-bottom: 0px;
font-family: ‘Raleway’, serif;
}

#hr_top {
width: 30%;
margin-bottom: 0px;
border: none;
height: 2px;
color: black;
background-color: black;
}

#hr_bottom {
width: 30%;
margin-top: 15px;
border: none;
height: 2px;
color: black;
background-color: black;
}

#words label, input {
display: inline-block;
vertical-align: baseline;
width: 350px;
}

#button {
border: 1px solid;
border-radius: 10px;
margin-top: 20px;

cursor: pointer;
outline: none;
background-color: white;
color: black;
font-family: ‘Work Sans’, sans-serif;
border: 1px solid grey;
/* Green */
}

#button:hover {
background-color: #f6f6f6;
border: 1px solid black;
}

#words_table {
color: black;
font-family: Raleway;
max-width: 350px;
margin: 25px auto;
line-height: 1.75;
}

#summary_table {
color: black;
font-family: Raleway;
max-width: 550px;
margin: 25px auto;
line-height: 1.75;
padding-left: 20px;
}

.label_radio {
text-align: center;
}

td, tr, th {
border: 1px solid black;
}
table {
border-collapse: collapse;
}
td, th {
min-width: 50px;
height: 21px;
}
.label_radio {
text-align: center;
}

#text_area_input {
padding-left: 35%;
float: left;
}

svg:not(:root) {
overflow: visible;
}

td input {
max-width:80px;
max-height:30px;
}

is a way to measure the diversity of species in a community.

To calculate this index for a given community, simply enter a list of observed frequencies for up to 10 species in the boxes below, then click the “Calculate” button:

Species Frequency
Species #1
Species #2
Species #3
Species #4
Species #5
Species #6
Species #7
Species #8
Species #9
Species #10

Simpson’s Diversity Index (D): 0.343

Dominance Index (1 – D): 0.657

Simpson’s Reciprocal Index (1 / D): 2.917

function calc() {

//get input data
var o1 = +document.getElementById(‘o1’).value;
var o2 = +document.getElementById(‘o2’).value;
var o3 = +document.getElementById(‘o3’).value;
var o4 = +document.getElementById(‘o4’).value;
var o5 = +document.getElementById(‘o5’).value;
var o6 = +document.getElementById(‘o6’).value;
var o7 = +document.getElementById(‘o7’).value;
var o8 = +document.getElementById(‘o8’).value;
var o9 = +document.getElementById(‘o9’).value;
var o10 = +document.getElementById(‘o10’).value;

var obs = [o1, o2, o3, o4, o5, o6, o7, o8, o9, o10];
var empties = obs.filter(x => x==0).length;

var n = obs.reduce((a, b) => a + b, 0);

//do calculations
var diff1 = 0;
if (o1) {
diff1 = o1*(o1-1);
}
var diff2 = 0;
if (o2) {
diff2 = o2*(o2-1);
}
var diff3 = 0;
if (o3) {
diff3 = o3*(o3-1);
}
var diff4 = 0;
if (o4) {
diff4 = o4*(o4-1);
}
var diff5 = 0;
if (o5) {
diff5 = o5*(o5-1);
}
var diff6 = 0;
if (o6) {
diff6 = o6*(o6-1);
}
var diff7 = 0;
if (o7) {
diff7 = o7*(o7-1);
}
var diff8 = 0;
if (o8) {
diff8 = o8*(o8-1);
}
var diff9 = 0;
if (o9) {
diff9 = o9*(o9-1);
}
var diff10 = 0;
if (o10) {
diff10 = o10*(o10-1);
}

var errors = [diff1, diff2, diff3, diff4, diff5, diff6, diff7, diff8, diff9, diff10];
var summer = math.sum(errors);

var D = summer / (n*(n-1));
var D1 = 1-D;
var R = 1/D;

//output results
document.getElementById(‘D’).innerHTML = D.toFixed(3);
document.getElementById(‘D1’).innerHTML = D1.toFixed(3);
document.getElementById(‘R’).innerHTML = R.toFixed(3);

} //end calc function

x