KernelDensityEstimate.jl icon indicating copy to clipboard operation
KernelDensityEstimate.jl copied to clipboard

Get conditional kernel densities

Open ClaudMor opened this issue 5 years ago • 0 comments

Hello,

This may be more of a discussion topic, but I post it here as perhaps discussions have not been activated yet in this repo, and it could be more appropriate to have this here rather than on the discourse.

I was wondering if there is a method to get a conditional distribution out of a ::BallTreeDensity.

So say for example that I have the following code:

using KernelDensityEstimate, Distributions

# define number of samples
const n_samples = 500

# define two correlated variables
const x = randn(n_samples)
const y = x.^2 .+ rand(Uniform(-0.0005, 0.0005), n_samples) 

# and an uncorrelated one
const z = rand(Gamma(), n_samples);

# fit the kde
kde = kde!(Array((hcat(x,y,z)')))

And I would like to get the distribution of x and y conditioned to, say, z = 10.

How would you do it?

Thank you very much

ClaudMor avatar Jan 30 '21 11:01 ClaudMor