13.3.12. Macro “dataserverComputeStatVector.py”
13.3.12.1. Objective
This part shows the complete code used to produce the console display in Specific case of vectors.
13.3.12.2. Macro Uranie
"""
Example of statistical estimation on vector attributes
"""
from URANIE import DataServer
tdsop = DataServer.TDataServer("foo", "poet")
tdsop.fileDataRead("tdstest.dat")
# Considering every element of a vector independent from the others
tdsop.computeStatistic("x")
px = tdsop.getAttribute("x")
print("min(x[0])= "+str(px.getMinimum(0))+"; max(x[0])= "+str(px.getMaximum(0))
+ "; mean(x[0])= "+str(px.getMean(0))+"; std(x[0])= "+str(px.getStd(0)))
print("min(x[1])= "+str(px.getMinimum(1))+"; max(x[1])= "+str(px.getMaximum(1))
+ "; mean(x[1])= "+str(px.getMean(1))+"; std(x[1])= "+str(px.getStd(1)))
print("min(x[2])= "+str(px.getMinimum(2))+"; max(x[2])= "+str(px.getMaximum(2))
+ "; mean(x[2])= "+str(px.getMean(2))+"; std(x[2])= "+str(px.getStd(2)))
print("min(xtot)= "+str(px.getMinimum(3))+"; max(xtot)= "+str(px.getMaximum(3))
+ "; mean(xtot)= "+str(px.getMean(3))+"; std(xtot)= "+str(px.getStd(3)))
# Statistic for a single realisation of a vector, not considering other events
tdsop.addAttribute("Min_x", "Min$(x)")
tdsop.addAttribute("Max_x", "Max$(x)")
tdsop.addAttribute("Mean_x", "Sum$(x)/Length$(x)")
tdsop.scan("x:Min_x:Max_x:Mean_x", "", "colsize=5 col=2:::6")
13.3.12.3. Console
This macro should result in this output in console, split in two parts, the first one being from Uranie’s method
min(x[0])= 1.0; max(x[0])= 7.0; mean(x[0])= 3.0; std(x[0])= 3.4641016151377544
min(x[1])= 2.0; max(x[1])= 8.0; mean(x[1])= 4.666666666666666; std(x[1])= 3.055050463303893
min(x[2])= 3.0; max(x[2])= 9.0; mean(x[2])= 6.666666666666666; std(x[2])= 3.2145502536643185
min(xtot)= 1.0; max(xtot)= 9.0; mean(xtot)= 4.777777777777778; std(xtot)= 3.2317865716108862
The second on the other hand results from ROOT’s methods (the second part of the code shown above):
*****************************************************
* Row * Instance * x * Min_x * Max_x * Mean_x *
*****************************************************
* 0 * 0 * 1 * 1 * 3 * 2 *
* 0 * 1 * 2 * 1 * 3 * 2 *
* 0 * 2 * 3 * 1 * 3 * 2 *
* 1 * 0 * 7 * 7 * 9 * 8 *
* 1 * 1 * 8 * 7 * 9 * 8 *
* 1 * 2 * 9 * 7 * 9 * 8 *
* 2 * 0 * 1 * 1 * 8 * 4.3333 *
* 2 * 1 * 4 * 1 * 8 * 4.3333 *
* 2 * 2 * 8 * 1 * 8 * 4.3333 *
*****************************************************