相关疑难解决方法(0)

沿numpy数组中的维度回归

我有一个四维的numpy数组(x,y,z,时间),并希望numpy.polyfit在每个x,y,z坐标的时间维度上做一个.例如:

import numpy as np
n = 10       # size of my x,y,z dimensions
degree = 2   # degree of my polyfit
time_len = 5 # number of time samples

# Make some data
A = np.random.rand(n*n*n*time_len).reshape(n,n,n,time_len)

# An x vector to regress through evenly spaced samples
X = np.arange( time_len )

# A placeholder for the regressions
regressions = np.zeros(n*n*n*(degree+1)).reshape(n,n,n,degree+1)

# Loop over each index in the array (slow!)
for row in range(A.shape[0] ) :
    for col …
Run Code Online (Sandbox Code Playgroud)

python numpy

7
推荐指数
1
解决办法
1690
查看次数

标签 统计

numpy ×1

python ×1