in reply to Kernel Density Estimation

Before you can get to coding some perl its going to be necessary to clarify the problem to be solved.

It seems that you have three kernel functions, lets pick one and call it: K(u), and some random data which I assume you are going to use to simulate an arbitrary function F(u).

Now you need to find out how you are going to convolute the two: are you going to integrate their product for all (u), or perhaps F*F*K or what?

Once this part of the problem is clearer it will be relatively easy to simulate the necessary integrals via a finite summation - Perl is excellent for these kinds of tasks.

So please clarify the computation required and we can go from there.

Replies are listed 'Best First'.
Re^2: Kernel Density Estimation
by cmr72 (Initiate) on Aug 29, 2012 at 22:29 UTC
    Thank you. I a trying to mimic the output from this website: http://www.wessa.net/rwasp_density.wasp. where you can dump a set o data and it will calculate the kernel estimate. So I guess to answer the question, all of the data 'u' should pass through f(u).
Re^2: Kernel Density Estimation
by cmr72 (Initiate) on Aug 30, 2012 at 10:08 UTC
    Hi. I looked at the CPAN module again and realized that the code was available for Epanechnikov:
    0.75*(1-((x-m)/s)**2)/s if abs( (x-m)/s ) < 1 0 otherwise
    However, I don't see what 'm' and 's' are if my only input is 'x'.
      I took a stab at it thinking that 's' was the sum and 'm' was the previous value for 'x'

      I am pretty certain that this is incorrect.

      #!/usr/bin/perl -w use strict ; my %epan ; my @data ; my $sum ; while ( <STDIN> ) { my @line= split ; push (@data,$line[0]) ; } #Epanechnikov: 0.75*(1-((x-m)/s)**2)/s if abs( (x-m)/s ) < 1, otherwis +e 0 for ( my $i = 0 ; $i <= $#data ; $i++ ) { $sum+=$data[$i] ; if ($sum !=0 && abs(($data[$i]-$data[$i-1])/$sum) < 1) { $epan{$i}=0.75*(1-(($data[$i]-$data[$i-1])/$sum)**2)/$sum ; } else { $epan{$i} = 0 ; } } for ( my $i = 0 ; $i <= $#data ; $i++ ) { print "$data[$i] $epan{$i}\n" ; }