5

This is my R code:

x <- c(5.89,6.81,6.69,7.61,5.44,6.17)
y <- c(1,0.09392423,0.07090779,0.0687634,0.06819157,0.06261615)

plot(density(x, bw=0.050, adjust=1, kernel="gaussian",weights=(y),n=1000))

I'm trying to achieve the same result using D3.js or any other equivalent JavaScript library..

Can somebody please help?

VividD
  • 10,456
  • 6
  • 64
  • 111
giorgioca
  • 713
  • 1
  • 8
  • 21

1 Answers1

7

Have you seen the kernel density estimation example?

kernel density estimation

Admittedly it uses the Epanechnikov kernel rather than Gaussian, but that part could be modified.

mbostock
  • 51,423
  • 13
  • 175
  • 129
  • Thanks, that was useful... although the main problem I'm facing is the "weights=(y)" part of the R script. I can't find a decent solution! – giorgioca May 01 '13 at 15:00