0

I have two quantities x and y and their covariance matrix cov(x,y), and I want to calculate the error in a derived quantity z=1/(x-y). Is there is a package to calculate mean value of z and sigma(xz) and sigma(zy) ?

thank you very much in advance

1 Answers1

1

The derived quantity will generally not follow a normal distribution, given that y and x does. You can estimate the error distribution numerically:

import scipy.stats
import numpy as np
import matplotlib.pyplot as plt

# sample from multivariate normal
x = scipy.stats.multivariate_normal(mean=[0,1], cov=[[1,0.5],[0.5,2]]).rvs(10000)
z = 1 / (x[0] - x[1])
print(z.mean())
print(z.var())
# Create kde of the distribution
kde = scipy.stats.gaussian_kde(z)
grid = np.linspace(z.min(), z.max(), 1000)
plt.plot(grid, kde.evaluate(grid))
plt.show()
user2653663
  • 2,818
  • 1
  • 18
  • 22