好的,所以我有一个1000x100的数组,其中包含随机数。我想用多个数字来限制这个列表。这些数字从[3到9]。如果它们高于阈值,我希望将行的总和追加到列表中。
我尝试了许多方法,其中3次是有条件的。现在,我找到了一种将数组与数字列表进行比较的方法,但是每次发生时,我都会从该列表中再次获得随机数字。
xpatient=5
sd_healthy=2
xhealthy=7
sd_patient=2
thresholdvalue1=(xpatient-sd_healthy)*10
thresholdvalue2=(((xhealthy+sd_patient))*10)
thresholdlist=[]
x1=[]
Ahealthy=np.random.randint(10,size=(1000,100))
Apatient=np.random.randint(10,100))
TParray=np.random.randint(10,size=(1,61))
def thresholding(A,B):
for i in range(A,B):
thresholdlist.append(i)
i+=1
thresholding(thresholdvalue1,thresholdvalue2+1)
thresholdarray=np.asarray(thresholdlist)
thedivisor=10
newthreshold=(thresholdarray/thedivisor)
for x in range(61):
Apatient=np.random.randint(10,100))
Apatient=[Apatient>=newthreshold[x]]*Apatient
x1.append([sum(x) for x in zip(*Apatient)])
因此,我的for循环中包含一个随机整数,但是如果我不这样做,那么我不会在每转弯时看到阈值。我希望整个数组的阈值为3、3.1、3.2等,等等。 我希望我能表达我的意思。预先感谢