From: Francois Fleuret Date: Wed, 15 Jan 2014 07:34:09 +0000 (+0100) Subject: --cumul now computes P(X <= x) instead of P(X < x). X-Git-Url: https://fleuret.org/cgi-bin/gitweb/gitweb.cgi?a=commitdiff_plain;h=a4f7fd0c1bea70844bb60c0951195589bf00f2da;p=data-tool.git --cumul now computes P(X <= x) instead of P(X < x). --- diff --git a/data-tool.cc b/data-tool.cc index dc868a0..9ab7a8c 100644 --- a/data-tool.cc +++ b/data-tool.cc @@ -240,7 +240,7 @@ int main(int argc, char **argv) { } } - Couple tmp[nb_samples]; + Couple *tmp = new Couple[nb_samples]; for(int n = 0; n < nb_samples; n++) { tmp[n].index = n; tmp[n].value = x[n]; @@ -249,8 +249,9 @@ int main(int argc, char **argv) { qsort(tmp, nb_samples, sizeof(Couple), compare_couple); for(int n = 0; n < nb_samples; n++) - cout << tmp[n].value << " " << double(n)/double(nb_samples) << endl; + cout << tmp[n].value << " " << double(n+1)/double(nb_samples) << endl; + delete[] tmp; delete[] x; } @@ -284,7 +285,7 @@ int main(int argc, char **argv) { } } - Couple tmp[nb_samples]; + Couple *tmp = new Couple[nb_samples]; int nb_rn = 0, nb_rp = 0, nb_fp = 0, nb_fn = 0; bool binary = true; @@ -342,7 +343,9 @@ int main(int argc, char **argv) { } } - delete[] x; delete[] y; + delete[] tmp; + delete[] x; + delete[] y; } @@ -374,7 +377,7 @@ int main(int argc, char **argv) { } } - int nb[nb_bins]; + int *nb = new int[nb_bins]; for(int n = 0; n < nb_bins; n++) nb[n] = 0; int nb_total = 0; @@ -396,6 +399,8 @@ int main(int argc, char **argv) { cout << xmin + ((xmax - xmin) * n) / double(nb_bins) << " " << nb[n] / double(nb_total) << endl; } + + delete[] nb; } break; @@ -430,7 +435,7 @@ int main(int argc, char **argv) { } } - Couple tmp[nb_samples]; + Couple *tmp = new Couple[nb_samples]; for(int n = 0; n < nb_samples; n++) { tmp[n].index = n; tmp[n].value = x[n]; @@ -455,6 +460,7 @@ int main(int argc, char **argv) { << " QUANTILE0.9 " << tmp[int(nb_samples * 0.9)].value << endl; + delete[] tmp; } break;