Skip to content

Update MKD to resemble <: Sampleable#320

Merged
Affie merged 1 commit intodevelopfrom
maint/mkd_rand
Sep 12, 2025
Merged

Update MKD to resemble <: Sampleable#320
Affie merged 1 commit intodevelopfrom
maint/mkd_rand

Conversation

@Affie
Copy link
Copy Markdown
Member

@Affie Affie commented Sep 12, 2025

No description provided.

@Affie Affie self-assigned this Sep 12, 2025
Comment on lines +272 to +277
Distributions.variate_form(mkd::ManifoldKernelDensity) = Ndim(mkd) == 1 ? Univariate : Multivariate
function Random.rand(mkd::ManifoldKernelDensity)
return _rand(Distributions.variate_form(mkd), mkd)
end
_rand(::Type{Univariate}, mkd::ManifoldKernelDensity) = sample(mkd.belief, 1)[1][:][]
_rand(::Type{Multivariate}, mkd::ManifoldKernelDensity) = sample(mkd.belief, 1)[1][:]
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not type stable, but a step in the direction of standard rand following <: Sampleable

Copy link
Copy Markdown
Member

@dehann dehann left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you know where the unstable type code is at? I don't see any forced abstracts -- all the arguments etc should resolve?

The closest one I noticed was the missing <: but assumed you just copied that from Distributions.jl as is, e.g. ::Type{<:Univariate}.

@Affie Affie merged commit 777166d into develop Sep 12, 2025
3 checks passed
@Affie Affie deleted the maint/mkd_rand branch September 12, 2025 18:38
@Affie
Copy link
Copy Markdown
Member Author

Affie commented Sep 12, 2025

rand returns a vector or scalar. We can add Univariate/Multivariate to MKD.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants