1

I've ran a bayesian model using pymc and drew a sample of 1,000 values across six chains for 1774 observations. This resulted in an array with shape (6, 1000, 1774). I need the mean sampled value for each 1774 observations. So in essenace, the mean of each chain, and each 1000 samples for each 1774 observations.

if x = array (6,1000,1774).

I need to add the mean values to my dataframe with a length of 1774 as another column.

Using fake data,

import numpy as np

x = np.random.rand(6,1000,1774)

Running:

x.mean(axis = 0) gives shape(1000, 1774)

How do I do this correctly?

Marat
  • 15,215
  • 2
  • 39
  • 48
Jordan
  • 1,415
  • 3
  • 18
  • 44

1 Answers1

2

pass multiple axes as a tuple:

x.mean(axis=(0,1))
Marat
  • 15,215
  • 2
  • 39
  • 48