Pas-Kapli / mptp

mPTP - a tool for single-locus species delimitation
GNU Affero General Public License v3.0
24 stars 5 forks source link

Compute confidence interval for number of species #53

Closed xflouris closed 8 years ago

xflouris commented 8 years ago

Each element frequencies[i] states the number of sampled delimitations of i species. i ranges between 1 and tips. Compute a 95% confidence interval in the following way:

for (mean = 0, i = 1; i <= tips; ++i)
  mean += frequencies[i]*i;
mean /= samples_count

for (stdev = 0, i = 1; i <= tips; ++i)
  stdev += frequencies[i]*(i - mean)*(i - mean)

stdev = sqrt(stdev/samples)

error_margin = 1.96 * stdev / sqrt(samples)

Output: <mean - error_margin , mean + error_margin>

xflouris commented 8 years ago

finished.