help-gsl
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Help-gsl] Lognormal normal distribution within prescribed range limits


From: Ghani, Irfan
Subject: [Help-gsl] Lognormal normal distribution within prescribed range limits
Date: Wed, 4 Jul 2012 13:21:16 +0000

Hello,
I am wondering, how can I get Lognormal distribution within a certain 
prescribed range limit. Following two functions gives lognormal variant and 
density distribution respectively in a range of [0, infinity].

Function: double gsl_ran_lognormal (const gsl_rng * r, double zeta, double 
sigma);
and
Function: double gsl_ran_lognormal_pdf (double x, double zeta, double sigma)

However, I could not figure out how to use these functions particularly the 
gsl_ran_lognormal() , to get a variant in a predefined range limit say [10, 
200]. I will highly appreciate any sort of help and hint.
Thanks.

________________________________________
From: address@hidden address@hidden on behalf of address@hidden address@hidden
Sent: 30 June 2012 18:00
To: address@hidden
Subject: Help-gsl Digest, Vol 104, Issue 17

Send Help-gsl mailing list submissions to
        address@hidden

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.gnu.org/mailman/listinfo/help-gsl
or, via email, send a message with subject or body 'help' to
        address@hidden

You can reach the person managing the list at
        address@hidden

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Help-gsl digest..."


Today's Topics:

   1. Re: using histogram fuctions - not getting expected       result.
      (Sam Mason)


----------------------------------------------------------------------

Message: 1
Date: Fri, 29 Jun 2012 17:13:30 +0100
From: Sam Mason <address@hidden>
To: Calvin Morrison <address@hidden>
Cc: address@hidden
Subject: Re: [Help-gsl] using histogram fuctions - not getting
        expected        result.
Message-ID:
        <address@hidden>
Content-Type: text/plain; charset="UTF-8"

On 29 June 2012 16:16, Calvin Morrison <address@hidden> wrote:
> https://github.com/mutantturkey/FlyTracking/blob/master/fly-tools/derive-background/pixel.c

You really don't need the GSL histogram routines for that; just something like:

int
findmax (uint8_t *p, int n)
{
  int mx = 0, v = p[0];
  for (int i = 1; i < n; i++) {
    if (p[i] > v) {
      v = p[i];
      mx = i;
    }
  }
  return mx;
}

  uint8_t histr[256] = { 0 }, histg[256] = { 0 }, histb[256] = { 0 };

  for (int i = 0; i < nImages; i++) {
    histr[array[i][j][k][0]] += 1;
    histg[array[i][j][k][1]] += 1;
    histb[array[i][j][k][2]] += 1;
  }

  output[j][k][0] = findmax(histr, 256);
  output[j][k][1] = findmax(histg, 256);
  output[j][k][2] = findmax(histb, 256);

I'd also recommend against storing the "array" as you are.  Traversing
lots of pointers is particularly inefficient (probably important if
you're in CS; chasing down four pointers is going to kill performance
as this is in the inner loop).  It's much easier to allocate a big
block of memory; i.e:

  uint8_t * array = calloc(nImages * width * height * 3);

and use the following to access an arbitrary pixel:

  // return a pointer rgb pixel triplet
  static inline uint8_t *getpixel(int image, int x, int y) { return
&array[((image * width + x) * height + y) * 3]; }

But for cases like where you're running along going over the same
pixel for many images, you can do something like:

  uint8_t *px = (j * height + k) * 3;
  const size_t step = width * height * 3;
  for (int i = 0; i < nImages; i++) {
    histr[px[0]] += 1;
    histg[px[1]] += 1;
    histb[px[2]] += 1;
    px += step;
  }

Also, just thought that if you've got more than about 500 images
you're better off (i.e. your "working set" will be smaller) storing
all the histograms (i.e. width*height*3 histograms) in memory and
streaming through the images.  A

Hope that helps!

  Sam




------------------------------

_______________________________________________
Help-gsl mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-gsl


End of Help-gsl Digest, Vol 104, Issue 17
*****************************************



reply via email to

[Prev in Thread] Current Thread [Next in Thread]