Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the bandwidth #90

Open
sekrul opened this issue May 3, 2022 · 1 comment
Open

Get the bandwidth #90

sekrul opened this issue May 3, 2022 · 1 comment

Comments

@sekrul
Copy link

sekrul commented May 3, 2022

Hello,
I like this package so much,but I don't know how can I get the bandwidth calculated by kde! .

@Affie
Copy link
Member

Affie commented May 3, 2022

Hi, I think it's getBW

"""
$(SIGNATURES)
Return the bandwidths used for each kernel in the density estimate.
"""
function getBW(bd::BallTreeDensity, ind::Array{Int,1}=zeros(Int,0))
if length(ind)==0
ind=1:bd.bt.num_points
end
s = zeros(bd.bt.dims,bd.bt.num_points)
perm = bd.bt.permutation[(bd.bt.num_points + 1):end]
res = reshape(bd.bandwidth[(bd.bt.dims*bd.bt.num_points + 1):end],bd.bt.dims,bd.bt.num_points)
s[:, perm ] = res[:,:]
s = s[:,ind]
s = sqrt.(s) # stddev gaussian covariance
return s
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants