# Is there a logspline density estimation toolbox in Julia?

**URL:** <https://discourse.julialang.org/t/is-there-a-logspline-density-estimation-toolbox-in-julia/55214>\
**Category:** Statistics\
**Created:** [February 13, 2021, 4:27pm UTC](https://discourse.julialang.org/t/is-there-a-logspline-density-estimation-toolbox-in-julia/55214 "2021-02-13T16:27:17Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![drbenvincent](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drbenvincent/32/3046_2.png) [@drbenvincent](https://discourse.julialang.org/u/drbenvincent)\
**Post date:** [February 13, 2021, 4:27pm UTC](https://discourse.julialang.org/t/is-there-a-logspline-density-estimation-toolbox-in-julia/55214/1 "2021-02-13T16:27:17Z")

</div>

For density estimation, I know that there are various kernel density estimation packages ([KernelDensity.jl](https://github.com/JuliaStats/KernelDensity.jl), [KernelDensityEstimate.jl](https://github.com/JuliaRobotics/KernelDensityEstimate.jl), [KernelEstimator.jl](https://github.com/panlanfeng/KernelEstimator.jl)), but I wonder if there are any spline-based packages? The goal here is to find a package that can:

- produce decent density estimates, which are well-behaved at the edges of bounds
- is fast for thousands / tens of thousands of samples.

For example, there is a nice [plospline](https://cran.r-project.org/web/packages/logspline/) package for R which has the `logspline` function, which is fast and well-behaved at boundaries.

 ![106935662-8ba7c680-6713-11eb-9202-3a32287ce29a](https://global.discourse-cdn.com/julialang/original/3X/6/5/65023a94064fda05ca551dd2ee0d6b575b5e3897.png)

Does anyone know of any such spline based density estimation packages? Or any other suggestions?

---

<div class="post-metadata">

**Author:** ![drbenvincent](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/drbenvincent/32/3046_2.png) [@drbenvincent](https://discourse.julialang.org/u/drbenvincent)\
**Post date:** [February 15, 2021, 4:25pm UTC](https://discourse.julialang.org/t/is-there-a-logspline-density-estimation-toolbox-in-julia/55214/2 "2021-02-15T16:25:48Z")

</div>

If anyone was interested in implementing it, then this is the place to start

> Kooperberg, C., & Stone, C. J. (1992). Logspline density estimation for censored data. _Journal of Computational and Graphical Statistics_ , _1_ (4), 301-328

but the current implementation seems to be based on a this later paper

> Stone, C. J., Hansen, M. H., Kooperberg, C., & Truong, Y. K. (1997). Polynomial splines and their tensor products in extended linear modeling: 1994 Wald memorial lecture. _Annals of statistics_ , _25_ (4), 1371-1470.

I had a look at the [logspline R package code](https://cran.r-project.org/web/packages/logspline/index.html) to see if it would be a difficult task. It looks like the R functions are just wrapper functions which call C code. So there’s zero chance for me to be able to port that to be honest. And the mathematical and algorithmic details in the papers are beyond me.

Maybe someone here would be up for the challenge or porting to Julia?
