Frequency density distribution of 1D array - 2 different attempts

I have a large array of elements that I call RelDist(in which dimensionally, it is a unit of distance) in a simulated volume. I am trying to determine the distribution for "the number of values ​​per unit volume", which is also the density of the number. It should look like this diagram:

I know that the axis scales in database 10, the dialing chart should definitely fall. enter image description here

Mathematically, I set it as two equivalent equations:

enter image description here

where N is the number of elements in the array that differentiate with respect to the natural logarithm of distances. It can also be equivalently rewritten as a regular derivative by introducing another factor r.

Equivalently

enter image description here

, r N r.

.


1

dN/dlnr/volume

def n(dist, numbins):

    logdist= np.log(dist)
    hist, r_array = np.histogram(logdist, numbins)
    dlogR = r_array[1]-r_array[0]

    x_array = r_array[1:] - dlogR/2

    ## I am condifent the above part of this code is correct.
    ## The succeeding portion does not work.

    dR = r_array[1:] - r_array[0:numbins] 
    dN_dlogR = hist * x_array/dR

    volume = 4*np.pi*dist*dist*dist

    ## The included volume is incorrect

    return [x_array, dN_dlogR/volume]

, , , , , . , ?


2

dN/dr/volume.

numbins = np.linspace(min(RelDist),max(RelDist), 100)
hist, r_array = np.histogram(RelDist, numbins)

volume = 4*np.float(1000**2)

dR = r_array[1]-r_array[0]
x_array = r_array[1:] - dR/2


y = hist/dR

, , , , .

, ?

R 10, R, R 20, , 30, .. ..


txt , .

https://www.dropbox.com/s/g40gp88k2p6pp6y/RelDist.txt?dl=0

+6
1

, , - :

def n_ln(dist, numbins):
    log_dist = np.log10(dist)
    bins = np.linspace(min(log_dist),max(log_dist), numbins)
    hist, r_array = np.histogram(log_dist, bins)

    dR = r_array[1]-r_array[0]    
    x_array = r_array[1:] - dR/2
    volume =  [4.*np.pi*i**3. for i in 10**x_array[:] ]

    return [10**x_array, hist/dR/volume]
0

All Articles