mirror of
https://gitlab.com/pamhyr/pamhyr2.git
synced 2026-10-30 03:20:41 +01:00
Ensemble: Add standard derivation computation.
This commit is contained in:
1 parent
fef2a2e979
commit
d8fd4488e2
2 files changed
+20
-37
No files matched your search
+19
-21
@@ -1621,26 +1621,33 @@ class Mage8(Mage):
|
|||||||
res["z_mean"] = z
|
res["z_mean"] = z
|
||||||
res["q_mean"] = q
|
res["q_mean"] = q
|
||||||
|
|
||||||
|
res["z_tmp_M2"] = np.zeros(z.shape)
|
||||||
|
res["q_tmp_M2"] = np.zeros(q.shape)
|
||||||
|
|
||||||
|
res["z_std_derivation"] = np.zeros(z.shape)
|
||||||
|
res["q_std_derivation"] = np.zeros(q.shape)
|
||||||
|
|
||||||
res["z_min"] = z
|
res["z_min"] = z
|
||||||
res["z_max"] = z
|
res["z_max"] = z
|
||||||
|
|
||||||
res["q_min"] = q
|
res["q_min"] = q
|
||||||
res["q_max"] = q
|
res["q_max"] = q
|
||||||
|
|
||||||
res["res_z_min"] = []
|
|
||||||
res["res_z_mean"] = []
|
|
||||||
res["res_z_max"] = []
|
|
||||||
|
|
||||||
res["res_q_min"] = []
|
|
||||||
res["res_q_mean"] = []
|
|
||||||
res["res_q_max"] = []
|
|
||||||
|
|
||||||
res["traces"] = []
|
|
||||||
else:
|
else:
|
||||||
# Get mean results for Z and Q
|
# Get mean results for Z and Q
|
||||||
n = run_number
|
n = run_number
|
||||||
res["z_mean"] = (res["z_mean"] * n + z) / (n + 1)
|
for x, txt in [(z, "z"), (q, "q")]:
|
||||||
res["q_mean"] = (res["q_mean"] * n + q) / (n + 1)
|
t_mean = f"{txt}_mean"
|
||||||
|
t_M2 = f"{txt}_tmp_M2"
|
||||||
|
t_std_deriv = f"{txt}_std_derivation"
|
||||||
|
|
||||||
|
delta = x - res[t_mean]
|
||||||
|
|
||||||
|
res[t_mean] += delta / n
|
||||||
|
|
||||||
|
delta_2 = x - res[t_mean]
|
||||||
|
|
||||||
|
res[t_M2] += delta * delta_2
|
||||||
|
res[t_std_deriv] = np.sqrt(res[t_M2] / n)
|
||||||
|
|
||||||
# Z and Q min max values
|
# Z and Q min max values
|
||||||
res["z_min"] = np.minimum(z, res["z_min"])
|
res["z_min"] = np.minimum(z, res["z_min"])
|
||||||
@@ -1648,15 +1655,6 @@ class Mage8(Mage):
|
|||||||
res["q_min"] = np.minimum(q, res["q_min"])
|
res["q_min"] = np.minimum(q, res["q_min"])
|
||||||
res["q_max"] = np.maximum(q, res["q_max"])
|
res["q_max"] = np.maximum(q, res["q_max"])
|
||||||
|
|
||||||
# Keep results min, mean and max
|
|
||||||
# res["res_z_min"].append((run_number, np.min(z, axis=0)))
|
|
||||||
# res["res_z_mean"].append((run_number, np.mean(z, axis=0)))
|
|
||||||
# res["res_z_max"].append((run_number, np.max(z, axis=0)))
|
|
||||||
|
|
||||||
# res["res_q_min"].append((run_number, np.min(q, axis=0)))
|
|
||||||
# res["res_q_mean"].append((run_number, np.mean(q, axis=0)))
|
|
||||||
# res["res_q_max"].append((run_number, np.max(q, axis=0)))
|
|
||||||
|
|
||||||
@timer
|
@timer
|
||||||
def results_ensemble(self, study, repertory,
|
def results_ensemble(self, study, repertory,
|
||||||
tables, run_number,
|
tables, run_number,
|
||||||
|
|||||||
@@ -576,25 +576,10 @@ class SolverLogEnsWindow(SolverLogWindow):
|
|||||||
table = {}
|
table = {}
|
||||||
|
|
||||||
for key in ["z", "q"]:
|
for key in ["z", "q"]:
|
||||||
for func in ["min", "mean", "max"]:
|
for func in ["min", "mean", "max", "std_derivation"]:
|
||||||
name = f"{key}_{func}"
|
name = f"{key}_{func}"
|
||||||
table[name] = results.new_table_data(name, tables[name])
|
table[name] = results.new_table_data(name, tables[name])
|
||||||
|
|
||||||
name = f"res_{name}"
|
|
||||||
table[name] = results.new_table_data(
|
|
||||||
name,
|
|
||||||
np.array(
|
|
||||||
list(map(lambda e: e[1], tables[name]))
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
# for nb, data in tables["traces"]:
|
|
||||||
# name = f"{nb}_"
|
|
||||||
# table[name + "z"] = results.new_table_data(name + "z",
|
|
||||||
# data["Z"])
|
|
||||||
# table[name + "q"] = results.new_table_data(name + "q",
|
|
||||||
# data["Q"])
|
|
||||||
|
|
||||||
table["samples"] = results.new_table_data(
|
table["samples"] = results.new_table_data(
|
||||||
"samples", np.array(self._run_samples)
|
"samples", np.array(self._run_samples)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in new issue
Block a user