normrand() doesn't make normally distributed numbers

NMODL and the Channel Builder.
Post Reply
Bill Connelly
Posts: 86
Joined: Thu May 22, 2008 11:54 pm
Location: Australian National University

normrand() doesn't make normally distributed numbers

Post by Bill Connelly »

Now I presume I'm doing something wrong here, but normrand() doesn't pull out numbers from a normal distribution. It looks more like a Lorentizian Distribution (see image)

Also, the arguements (that I assumed were mean, stddev or mean, coefvar) doesn't seem to do a thing. I always get the same distribution.

I'll spare you the whole mod file, but this is the "offending" piece

Code: Select all

VERBATIM
static float Quanta_With_Var(int num, float amp, float coefvar) {
  int i;
  float totalG=0;
  for(i=0; i<=num; ++i) {
    totalG+=normrand(amp, amp*coefvar);
    printf("%f\n", normrand(10, 100));
  }
  return (float) totalG;
}
ENDVERBATIM
What is going on here?

Image
Clearly not normal. On a logged Y axis, normal distributions appear parabolic. But a Lorentzian curve seems to fit it okay.
Bill Connelly
Posts: 86
Joined: Thu May 22, 2008 11:54 pm
Location: Australian National University

Re: normrand() doesn't make normally distributed numbers

Post by Bill Connelly »

...However normrand outside of a verbatim block does work, and the arguments do what I would expect.
ted
Site Admin
Posts: 5810
Joined: Wed May 18, 2005 4:50 pm
Location: Yale University School of Medicine
Contact:

Re: normrand() doesn't make normally distributed numbers

Post by ted »

One might expect that a given keyword would have the same meaning whether used in hoc, NMODL, or a VERBATIM block inside NMODL, but I guess it isn't always so. Take a look at the .c files generated by compiling your two different versions of NMODL code--maybe it will reveal the source of the difference.
Post Reply