How can I specify the distance between values in such row I have a question, about verifying the value which are near to each other in such row, Is there any algorithm which can determine that ? 

Suppose I have a vector $z_i =$ {$z_1 , z_2, z_3, . . . ., z_n$}, I want first to determine the maximum and minimum values of this vector, then check if the distance between each other value is smaller compare then maximum and to minimum values. In other words, it means  dividing the vector into two categories and then check if the value is nearer to first category or second.   

Is there any algorithm can do that? 

thank you
Just a little bit of python:

import numpy as np

def splitVector(v):
    thres = (np.max(v)-np.min(v))/2
    return v[v&lt;=thres], v[v&gt;thres]


This will yield two vectors with just the lower or higher elements. If you want to preserve overall size and position of arguments, just a little modification will do it:

import numpy as np

def splitVector(v):
    thres = (np.max(v)-np.min(v))/2
    return np.where(v&lt;=thres,v,0), np.where(v&gt;thres,v,0)


This will fill in zeros for all elements not fulfilling the condition.