[Python] Python function for propagation of uncertainty (with covariance terms) [SOLVED]

Discussão em 'Python' iniciado por Stack, Abril 7, 2025.

  1. Stack

    Stack Membro Participativo

    -- Thank you all, i used the monte carlo method (as suggested in the comment), and it kinda worked (some uncertainties are overestimated, and i really don't know why). ---

    I was wondering if there is a way to write a function with python that, automatically, propagate the uncertainties from n variables x_1,...,x_n to a function of these variables f=f(x_1,...,x_n,a_1,.., a_m), where a_1,..., a_m are parameters of f. Like, this function should get in input f, the variables x_1,..,x_n (possibly, each of these x_i are arrays with P elements) and their uncertainties sigma_x1,...,sigma_xn; then, it should give us an array f_value (where f_value[j] = f(x_1[j],...,x_n[j],a_1,.., a_m)) and its uncertainties sigma_f (computed with the covariance terms). Is this possible? I study physics and the propagation of uncertainty is something that i do a lot, and having a python function that can do this automatically will be very helpful. Sorry for my bad english, it's not my native language.

    I tried using libraries like the uncertainties package, sympy or the monte carlo method, but none of that worked.

    Continue reading...

Compartilhe esta Página