我刚开始使用在http://pythonhosted.org/uncertainties/index.html#uncertainties找到的模块
假设我们有一个带有经过校准的温度传感器的实验装置。现在考虑校准产生了可变的测量误差,例如从±1 K @ 0 °C 线性增加到± 4 K @ 100 °C。使用模块定义变量时是否可以定义要使用的自定义函数uncertainties?
例子:
>>> from uncertainties import ufloat
>>> def err_fun(temp_in_C):
..: return 1 + 3 / 100 * temp_in_C
>>> temp_meas = ufloat(10, err_fun, 'tag')
>>> print temp_meas
10+/-1.3
如果是这样,当它的标称值改变时,变量的不确定性是否会改变?
例子:
>>> print temp_meas
10+/-1.3
>>> temp_meas.nominal_value = 50
>>> print temp_meas
50+/-2.5