# Kernel density (w/ weights)

**URL:** <https://discourse.julialang.org/t/kernel-density-w-weights/64278>\
**Category:** General Usage\
**Created:** [July 8, 2021, 2:32pm UTC](https://discourse.julialang.org/t/kernel-density-w-weights/64278 "2021-07-08T14:32:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![juliauser](https://avatars.discourse-cdn.com/v4/letter/j/46a35a/32.png) [@juliauser](https://discourse.julialang.org/u/juliauser)\
**Post date:** [July 8, 2021, 2:32pm UTC](https://discourse.julialang.org/t/kernel-density-w-weights/64278/1 "2021-07-08T14:32:36Z")

</div>

Hello, I have a vector of variables x, and a vector of weights y (y sums to 1). How can plot the pdf of the vector x?  
Something like histogram(x,weights=y) but smoothed out.

---

<div class="post-metadata">

**Author:** ![sijo](https://avatars.discourse-cdn.com/v4/letter/s/da6949/32.png) [@sijo](https://discourse.julialang.org/u/sijo)\
**Post date:** [July 8, 2021, 3:00pm UTC](https://discourse.julialang.org/t/kernel-density-w-weights/64278/2 "2021-07-08T15:00:06Z")

</div>

Are you using StatsPlots.jl? Then you can simply do `density(x, weights=y)`. The `weights` keyword is not documented, it might be good to file an issue or PR about this.
