MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Fast calculation of pair correlation function

  • To: mathgroup at
  • Subject: [mg98626] Fast calculation of pair correlation function
  • From: markus <markusg.phys at>
  • Date: Tue, 14 Apr 2009 06:19:43 -0400 (EDT)


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 (+-
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

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?

  • Prev by Date: Re: UNDO and Mathematica - how useless
  • Next by Date: Re: Re: How to find current ViewAngle, ViewPoint during Rotating graphics?
  • Previous by thread: Re: Any way to make help browser remember the last position?
  • Next by thread: Re: Fast calculation of pair correlation function