Skip to content

Commit

Permalink
zero total bug
Browse files Browse the repository at this point in the history
  • Loading branch information
tylersimko committed Jun 5, 2024
1 parent c62cef4 commit 1ec4dd8
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/segregation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,19 @@ NumericVector segregationcalc(NumericMatrix distmat,

}

// Get district proportions
double p = (double)gpop / tpop;
if (tpop == 0.0) {

// Add to dissimilarity index
dissim += (double)d * tpop * std::abs(p - P);
dissim += 0;

} else {

// Get district proportions
double p = (double)gpop / tpop;

// Add to dissimilarity index
dissim += (double)d * tpop * std::abs(p - P);

}
}

// Add to vector
Expand Down

0 comments on commit 1ec4dd8

Please sign in to comment.