1

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

3
  • 5
    Can you give a Minimal, Complete, and Verifiable example? or show your expected output? Commented May 27, 2015 at 11:48
  • 1
    Whats the error that you're getting? Commented 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 5 Commented May 27, 2015 at 12:03

1 Answer 1

2

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.