Thread: Adaptive Kernel Density Estimation?

  1. #1
    Registered User
    Join Date
    Aug 2011
    Posts
    4

    Adaptive Kernel Density Estimation?

    Variable kernel density estimation - Wikipedia, the free encyclopedia

    Hi everyone,

    I am currently writing an algorithm using C, to perform an adaptive/variable kernel density estimation. I have been trying to use the NAG library which I am sure a lot of you are familiar with. I went through the documentation (NAG C Library - Supporting Documentation | Numerical Algorithms Group) but I was unable to find anything suitable. Does anyone have any ideas to point me in the right direction? Cheers!!

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    What about the link at the bottom of the wiki page?
    libAGF - A library for multivariate, adaptive kernel density estimation.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  3. #3
    Registered User
    Join Date
    Aug 2011
    Posts
    4
    I did actually check that out. That library is for C++, which in my understanding was quite a bit slower than C? Am I wrong in that assumption? This algorithm needs to be able to run extremely fast. Cheers!

  4. #4
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Quote Originally Posted by statsrabbit View Post
    I did actually check that out. That library is for C++, which in my understanding was quite a bit slower than C? Am I wrong in that assumption? This algorithm needs to be able to run extremely fast. Cheers!
    Hardly, but even if it was, reading and adapting an existing open source library is often a good place to start

  5. #5
    Registered User
    Join Date
    Nov 2010
    Location
    Long Beach, CA
    Posts
    5,909
    Quote Originally Posted by statsrabbit View Post
    I did actually check that out. That library is for C++, which in my understanding was quite a bit slower than C? Am I wrong in that assumption? This algorithm needs to be able to run extremely fast. Cheers!
    Pre-optimization is the root of all evil. How do you know the C++ implementation wont be fast enough? Sure, an ideal C implementation would probably be faster than an ideal C++ implementation. But you have to make that C implementation, and you will have to make it fast. You will also have lots of debugging to do. You will probably save tons of development time by using the existing C++ implementation, and it may be more than fast enough for your needs.

  6. #6
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    > That library is for C++, which in my understanding was quite a bit slower than C?
    Well there's no shortage of the word "fast" if you follow the library links.

    You could be done coding by the end of the week if you use that library, then you can start analysing your data.

    Or you could spend weeks/months rolling your own code, debugging it, optimising it before you get to analyse any data at all. If the only difference between your very late C answer and early C++ answer is a few seconds of run-time, it's going to be a seriously long time before that pays off.

    Besides, that library is GPL'ed, so you can just grab the code and start tweaking it, if it isn't quite good enough.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  7. #7
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    FYI:

    I glanced at the source code of libagf; and, the only C++ use that jumps out is the use of pass by reference (&).
    I saw no classes in the three headers I checked.

    Tim S.

  8. #8
    Registered User
    Join Date
    Aug 2011
    Posts
    4
    Wow, thanks everybody for the help! So I am a bit of a noob at both C and C++, and basically right now I am storyboarding what needs to be done step by step and finding the appropriate libraries, etc to draw my functions from. I am open to using either language, I had just been told that C was faster on the whole, and the purpose that we need to use this algorithm for require the run time to be ridiculously low..

    Tim, by saying that there are no headers in that class, did you mean that I would be able to port it to C if I so wished?

    Is it possible to have parts in C and parts in C++? Cheers!!

  9. #9
    Registered User
    Join Date
    May 2009
    Posts
    4,183
    Quote Originally Posted by statsrabbit View Post
    Tim, by saying that there are no headers in that class, did you mean that I would be able to port it to C if I so wished?

    Is it possible to have parts in C and parts in C++? Cheers!!
    I could port it to C if the project does not use the C++ keyword "class"; no idea if you could.

    Yes, it is possible to mix C with C++ code.

    NOTE: I said there where NO classes in the three header files I checked; not what you stated.

    Tim S.
    Last edited by stahta01; 08-29-2011 at 06:54 PM. Reason: Grammer error

  10. #10
    Registered User
    Join Date
    Aug 2011
    Posts
    4
    Oh sorry about that, Tim. Ok fantastic, I think I will stick to just coding in C++ for now. Thanks for the help!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Adaptive Rejection Sampling
    By swarup in forum C Programming
    Replies: 7
    Last Post: 08-03-2011, 02:17 PM
  2. density of 0s & 1s in an array
    By millsy5 in forum C Programming
    Replies: 2
    Last Post: 10-20-2009, 04:12 PM
  3. SOS - Can a monolithic kernel be used in a micro-kernel style OS?
    By sean in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 11-20-2008, 09:30 AM
  4. Frequency density of spectrogra[ph/m]
    By doubleanti in forum A Brief History of Cprogramming.com
    Replies: 13
    Last Post: 12-29-2004, 03:48 AM
  5. Possible to write adaptive programs?
    By crag2804 in forum A Brief History of Cprogramming.com
    Replies: 4
    Last Post: 06-16-2003, 04:35 PM

Tags for this Thread