commit 39b4e392b048f2717e3414bbe72e2570ca1dc113
parent d33af008381a36eafc4933595ec98b792a28d42b
Author: Christophe Coustet <christophe.coustet@meso-star.com>
Date: Mon, 4 Sep 2017 11:30:19 +0200
BugFix: Variance could be reported to be <0 in MC results.
Now sets it to 0, as it was already the case for StdErr.
Diffstat:
2 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/ssol_estimator.c b/src/ssol_estimator.c
@@ -116,7 +116,8 @@ ssol_estimator_get_mc_global
const struct mc_data* data = &estimator->Name; \
global->Name.E = data->weight / N; \
global->Name.V = data->sqr_weight / N - global->Name.E*global->Name.E; \
- global->Name.SE = global->Name.V > 0 ? sqrt(global->Name.V / N) : 0; \
+ global->Name.V = global->Name.V > 0 ? global->Name.V : 0; \
+ global->Name.SE = sqrt(global->Name.V / N); \
} (void)0
SETUP_MC_RESULT(cos_factor);
SETUP_MC_RESULT(absorbed);
@@ -167,7 +168,8 @@ ssol_estimator_get_mc_sampled_x_receiver
const struct mc_data* data = &mc_rcv1->Name; \
rcv->Name.E = data->weight / N; \
rcv->Name.V = data->sqr_weight / N - rcv->Name.E*rcv->Name.E; \
- rcv->Name.SE = rcv->Name.V > 0 ? sqrt(rcv->Name.V / N) : 0; \
+ rcv->Name.V = rcv->Name.V > 0 ? rcv->Name.V : 0; \
+ rcv->Name.SE = sqrt(rcv->Name.V / N); \
} (void)0
SETUP_MC_RESULT(integrated_irradiance);
SETUP_MC_RESULT(integrated_absorbed_irradiance);
@@ -231,7 +233,8 @@ ssol_estimator_get_mc_sampled
const struct mc_data* data = &mc->Name; \
sampled->Name.E = data->weight / N; \
sampled->Name.V = data->sqr_weight/N - sampled->Name.E*sampled->Name.E; \
- sampled->Name.SE = sampled->Name.V > 0 ? sqrt(sampled->Name.V / N) : 0; \
+ sampled->Name.V = sampled->Name.V > 0 ? sampled->Name.V : 0; \
+ sampled->Name.SE = sqrt(sampled->Name.V / N); \
} (void)0
SETUP_MC_RESULT(cos_factor, sampled->nb_samples);
SETUP_MC_RESULT(shadowed, estimator->realisation_count);
diff --git a/src/ssol_mc_receiver.c b/src/ssol_mc_receiver.c
@@ -56,7 +56,8 @@ ssol_estimator_get_mc_receiver
const struct mc_data* data = &mc_rcv1->Name; \
rcv->Name.E = data->weight / N; \
rcv->Name.V = data->sqr_weight/N - rcv->Name.E*rcv->Name.E; \
- rcv->Name.SE = rcv->Name.V > 0 ? sqrt(rcv->Name.V / N) : 0; \
+ rcv->Name.V = rcv->Name.V > 0 ? rcv->Name.V : 0; \
+ rcv->Name.SE = sqrt(rcv->Name.V / N); \
} (void)0
SETUP_MC_RESULT(integrated_irradiance);
SETUP_MC_RESULT(integrated_absorbed_irradiance);
@@ -146,7 +147,8 @@ ssol_mc_shape_get_mc_primitive
const struct mc_data* data = &mc_prim1->Name; \
prim->Name.E = data->weight / N; \
prim->Name.V = data->sqr_weight/N - prim->Name.E*prim->Name.E; \
- prim->Name.SE = prim->Name.V > 0 ? sqrt(prim->Name.V / N) : 0; \
+ prim->Name.V = prim->Name.V > 0 ? prim->Name.V : 0; \
+ prim->Name.SE = sqrt(prim->Name.V / N); \
prim->Name.E /= area; \
prim->Name.V /= area*area; \
prim->Name.SE /= area; \