Errors Trying to Fancy Ternary Statements with Arrays, Python -


the basic problem 1 of highly customized kernel density estimators not fit standard can't use existing code.

here code works gaussian:

for counter1 in range (0,int(samples)):     edf[counter1] = np.sum( np.reciprocal(len(values)*sigmas[:]*2)*np.exp(-0.5*((edf_diam[counter1]-values[:])/sigmas[:])*((edf_diam[counter1]-values[:])/sigmas[:])) ) 

what doing is, @ every diameter point (counter1), add every gaussian piece every values, , each values has own bandwidth (sigmas). might not efficient, i've gotten work, that's something.

where i'm running issues i'm attempting add in other kernel shapes. simple being "top hat" or uniform. gaussian unbound, other kernels want program can exist in diameter range. while iterate through each feature (values sigmas), less efficient if can use fancy indexing.

i have tried ternary operator:

for counter1 in range (0,int(samples)):     edf[counter1] = 0 if np.logical_or((edf_diam[counter1] < (values[:]-sigmas[:])),((values[:]+sigmas[:]) < edf_diam[counter1])) else np.sum( 1/(len(values)*sigmas[:]) ) 

what code supposed 0 if logical_or() true, , constant if logical_or() false. seems simple enough ... i'm getting usual error n00bs numpy's logical statements of "valueerror: truth value of array more 1 element ambiguous. use a.any() or a.all()".

the problem don't think can use or in context. want go through every value in values corresponding sigmas, evaluate statement each one, , add uniform kernel density estimator.

a brute-force method may be:

for counter1 in range (0,len(values)):     counter2 in range (0,len(edf)):         edf[counter2] += 0 if (edf_diam[counter2] < values[counter1]-sigmas[counter1] || edf_diam[counter2] > values[counter1]+sigmas[counter1]) else 1/(len(values)*sigmas[counter1] 

however, slower (it gaussian, anyway), , since need bootstrap , run few thousand times on few thousand features, need fastest , efficient way.

help?


Comments

Popular posts from this blog

javascript - Thinglink image not visible until browser resize -

firebird - Error "invalid transaction handle (expecting explicit transaction start)" executing script from Delphi -

mongodb - How to keep track of users making Stripe Payments -