# d3.contourDensity()

**URL:** <https://talk.observablehq.com/t/d3-contourdensity/7680>\
**Category:** Help\
**Created:** [March 2, 2023, 9:33am UTC](https://talk.observablehq.com/t/d3-contourdensity/7680 "2023-03-02T09:33:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![neocarto](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/neocarto/32/6554_2.png) [@neocarto](https://talk.observablehq.com/u/neocarto)\
**Post date:** [March 2, 2023, 9:33am UTC](https://talk.observablehq.com/t/d3-contourdensity/7680/1 "2023-03-02T09:33:25Z")

</div>

Is there a paper somewhere explaining in detail the algorithm behind d3.contourDensity() ?

---

<div class="post-metadata">

**Author:** ![Fil](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/fil/32/207_2.png) [@Fil](https://talk.observablehq.com/u/Fil)\
**Post date:** [March 2, 2023, 9:57am UTC](https://talk.observablehq.com/t/d3-contourdensity/7680/2 "2023-03-02T09:57:13Z")

</div>

Not that I know of.

This notebook explains the linear interpolation part:

> **[Density contours with linear binning](https://observablehq.com/@d3/contourdensity-linear-binning)**
>
> This brownian motion system with particles is visualized with the contours from d3.contourDensity. The first chart uses the traditional nearest neighbor method; the second chart shows the improved method—linear binning—adopted by d3-contour@3 (and...

The KDE is approximated with d3.blur2 which is documented here:

> **[d3.blur](https://observablehq.com/@d3/d3-blur)**
>
> d3.blur smooths an array of numbers by distributing the value of each element onto its neighbors. The transformation is made via three applications of a fast moving-average window transform of radius r. For example, here is a blurred random walk:...

---

<div class="post-metadata">

**Author:** ![neocarto](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/neocarto/32/6554_2.png) [@neocarto](https://talk.observablehq.com/u/neocarto)\
**Post date:** [March 2, 2023, 10:08am UTC](https://talk.observablehq.com/t/d3-contourdensity/7680/3 "2023-03-02T10:08:00Z")

</div>

Thanks
