0

I want to generate noise in a DataFrame using multivariate_normal. For this i want to use the Covariance matrix of the original DataFrame

The original DataFrame have 4 columns and 6819 rows. So the Covariance matrix is 4x4.

For the moment I am generating the noise like that:

rng = np.random.default_rng()
noise = rng.multivariate_normal(mean = np.array([0,0,0,0], cov = df.cov(), size = df.shape)
#the noise have a dimens of (6819,4,4)
result = df + noise

where df is the original DataFrame.

But i don't know how to sum DataFrames of different dimensions

  • Does this help? https://stackoverflow.com/questions/46093073/adding-gaussian-noise-to-a-dataset-of-floating-points-and-save-it-python – Andreas Apr 26 '21 at 19:37
  • not at all, because is using normal instead of multivariate_normal – kdfjlasjdflaj Apr 26 '21 at 21:12
  • I suspect that you actually just want to generate the `noise` array of size `(6819, 4)`. So I would pass `df.shape[0]` to the `size=` parameter. That parameter specifies how many samples to generate from your 4-variate distribution. – AlexK Apr 27 '21 at 05:45

0 Answers0