Thanks for pointing KernelDensity.jl, that looks quite useful.

Here however I’m not trying to fit a model, it’s really about generating random numbers from an arbitrary distribution and showing what the density looks like. It’s for an introductory lesson in probability, I’d like to keep things as basic as possible (the Julia code in particular should be as pedestrian as possible ).

Maybe I miss the point, but I would not teach students to artificially smoothen data of a distribution they should rather learn why it’s not smooth etc.
…but as said, I don’t know what you are up to.

It’s just not the subject of that particular lesson (ideally I would do without sampling, showing “perfect” curves). But I agree with the general point.

Thanks, StatsPlots.density is perfect for the job!

For the theoretical pdfs: yep that’s what I meant (except I’m looking at functions of several random variables, so the distribution is not available in Distributions.jl).