Python 3D array. Calculate R squared
Question: I have 2 ndarrays with 3 dimensions. I need to calculate the Rsquared over
these ndarrays. To clarify.

    
    
    Array1.shape = Array2.shape = (100, 100, 10) 
    

So...

    
    
    resultArray = np.ones(100*100).reshape(100,100)
    
    for i in range(Array1.shape[0]:
        for j in range(Array1.shape[1]: 
            slope, intercept, r_value, p_value, std_err = scipy.stats.stats.linregress(Array1[i:i+1,j:j+1,:],Array1[i:i+1,j:j+1,:])
            R2 = r_value**2
            result[ i , j ] = R2
    


Answer: If passed two arrays, `stats.linregress` expects the two arrays to be
1-dimensional.

`Array1[i:i+1,j:j+1,:]` has shape `(1, 1, 10)`, so it is 3-dimensional. So
instead use `Array1[i, j, :]`:

    
    
    import numpy as np
    import scipy.stats as stats
    
    Array1 = np.random.random((100, 100, 10))
    Array2 = np.random.random((100, 100, 10))
    resultArray = np.ones(100*100).reshape(100,100)
    for i in range(Array1.shape[0]):
            for j in range(Array1.shape[1]):
                slope, intercept, r_value, p_value, std_err = stats.linregress(
                    Array1[i, j, :],
                    Array1[i, j, :])
                R2 = r_value**2
                resultArray[ i , j ] = R2
    
    print(resultArray)
    

