I'm coding for an Coherence project and I'm now stuck at the problem to mean my array of values in splitted parts.
So ym task would be: 1. Take my array of values (R) split it in a certain number of array parts (split by epoch) 2. enter a loop to run it automatically. 3. in the loop every value of each split part of the original array should be avaraged
Maybe the solution is damn simple, but I got stuck and I miss the wood for the forest.
Here is my approach (Rxx, epochs are defined above):
epoch_Rxx = np.array_split(Rxx,epochs)
for i in range(0,epochs):
Rxx_mean = np.zeros(epochs)
Rxx_mean[i] = np.mean(Rxx[i])
In the end I want from the e.g. Rxx = 100 values and epochs = 10
--> Rxx_mean = 10 values each to be the avaraged value of each epoch.
Greetings,
Daniel
-
5Can you give a Minimal, Complete, and Verifiable example? or show your expected output?Kasravnd– Kasravnd2015年05月27日 11:48:04 +00:00Commented May 27, 2015 at 11:48
-
1Whats the error that you're getting?chown– chown2015年05月27日 11:48:08 +00:00Commented May 27, 2015 at 11:48
-
there is no error, but the for loop serves the results of || array[0 ,0 ,0 ,0, 0.1521] for e.g. epoch is 5Daniel Velden– Daniel Velden2015年05月27日 12:03:50 +00:00Commented May 27, 2015 at 12:03
1 Answer 1
Is this what you are after?
import numpy as np
Rxx = np.arange(100)
epochs = 10
Rxx_mean = []
epoch_Rxx = np.array_split(Rxx,epochs)
for i in range(0,epochs):
Rxx_mean.append(np.mean(epoch_Rxx[i]))
print Rxx_mean