# Sample new unseen points using AlgebraOfGraphics.density()

**URL:** <https://discourse.julialang.org/t/sample-new-unseen-points-using-algebraofgraphics-density/116334>\
**Category:** General Usage\
**Tags:** question\
**Created:** [June 28, 2024, 6:28am UTC](https://discourse.julialang.org/t/sample-new-unseen-points-using-algebraofgraphics-density/116334 "2024-06-28T06:28:11Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bonjour-Lemonde](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bonjour-lemonde/32/24199_2.png) [@Bonjour-Lemonde](https://discourse.julialang.org/u/Bonjour-Lemonde)\
**Post date:** [June 28, 2024, 6:28am UTC](https://discourse.julialang.org/t/sample-new-unseen-points-using-algebraofgraphics-density/116334/1 "2024-06-28T06:28:11Z")

</div>

Hi all,  
I want to know how to generate new data points according to the density function using AlgebraOfGraphics.density(). As the following code shows, I used AlgebraOfGraphics.density() to fit datasets and visualized data distribution. Further I wanted to sampled more data from the fitted distribution, is there any way to do so? Thanks!

```julia
using AlgebraOfGraphics
using Distributions
using DataFrames
using CairoMakie

dx = Normal(20,1)
dy = Normal(25,1)
x = rand(dx, 50)
y = rand(dy, 50)

dn2 = DataFrame(x = x, y = y)

p1 = data(dn2) * mapping([:x, :y] .=> "variables") *
    AlgebraOfGraphics.density() * 
    mapping(color = dims(1) => renamer(["x", "y"]))
draw(p1,axis = (width = 200, height = 200))

```
