Fast calculation of pair correlation function
- To: mathgroup at smc.vnet.net
- Subject: [mg98626] Fast calculation of pair correlation function
- From: markus <markusg.phys at googlemail.com>
- Date: Tue, 14 Apr 2009 06:19:43 -0400 (EDT)
Hi, I have a quite large list (length ~ 10,000) of coordinates (positions of particles from a simulation), e.g. data={{x1,y1,z1}, {x2,y2,z2},...}, and I am looking for fast way to calculate the "pair correlation" or "radial distribution function", which tells me, for each value of r, how many particles are separated by a distance r (+- epsilon). Usually, this can be calculated by something like: Do[Do[histogr[[ Ceiling[Norm[ data[[i]]-data[[j]] ] / delta] ]], {j, i +1, Length[data]}], {i, 1, Length[data]-1}] where histogr is just a list whose index corresponds to the distance r. Unfortunately I have found that for lists of length >1,000, this way of calculating is very slow (it can take ~minutes), compared to the equivalent C code, which proceeds in a few seconds. I have also tried to "Compile" the function, but the speed does not increase... Does anybody know some fast way of calculating the pair distribution function in Mathematica?
- Follow-Ups:
- Re: Fast calculation of pair correlation function
- From: Daniel Lichtblau <danl@wolfram.com>
- Re: Fast calculation of pair correlation function
- From: Leonid Shifrin <lshifr@gmail.com>
- Re: Fast calculation of pair correlation function
- From: Sseziwa Mukasa <mukasa@jeol.com>
- Re: Fast calculation of pair correlation function