python - Does NumPy have a Uniformity function? -


is there numpy function this:

enter image description here

i can calculate it, i'm wondering if there's better way.

here how i'd calculate without given function -

the len(z_vals) substituting ai / a, because individual areas uniformly distributed.

ui_minus = 0 value in z_vals:     ui_minus += abs(value - np.average(z_vals))/(len(z_vals)*np.average(z_vals))  ui = 1 - 0.5*ui_minus 

the code bellow solution without loop

ui = 1 - 0.5*sum(abs(z_vals - np.average(z_vals)))/(len(z_vals)*np.average(z_vals)) 

if need use calculation in code, can define function using method lambda

uniformity = lambda x : 1 - 0.5*sum( abs(x - np.average(x)) )/(len(x)*np.average(x)) 

then can call uniformity shown bellow.

ui = uniformity(z_vals) 

hope helps.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -