Kernel density estimation in Rust.

Overview

kernel-density-estimation

Crates.io Crates.io Crates.io

Kernel density estimation in Rust.

Kernel density estimation (KDE) is a non-parametric method to estimate the probability density function of a random variable by taking the summation of kernel functions centered on each data point. This crate serves three major purposes based on this idea:

  1. Evaluate the probability density function of a random variable.
  2. Evaluate the cumulative distribution function of a random variable.
  3. Sample data points from the probability density function.

An excellent technical description of the method is available here.

Note: Currently only univariate distributions are supported but multivariate is a goal in the future!

Examples

univariate - This example showcases the core pdf, cdf, and sample functionalities for a univariate distribution.

cargo run --example univariate

Univariate Distribution

kernel - This example showcases each of the available kernel functions.

cargo run --example kernel

Kernel Functions

Roadmap

Refer to the milestone issues to see the direction the project is headed in future releases or CHANGELOG.md to see the changes between each release.

License

Distributed under the MIT License. See LICENSE for more information.

Acknowledgements

  • Notes for Nonparametric Statistics1 - An excellent technical description of nonparametric methods referenced heavily in the development of this project.

Footnotes

  1. García-Portugués, E. (2022). Notes for Nonparametric Statistics. Version 6.5.9. ISBN 978-84-09-29537-1.

You might also like...
Rux - An x86_64 toy operating system kernel written in Rust
Rux - An x86_64 toy operating system kernel written in Rust

Rux - An x86_64 toy operating system kernel written in Rust. Rux is a port of the Hux kernel, my x86 32-bit single-CPU toy kernel written in C, following the OSTEP book structure and terminology.

An super minimal kernel written in rust

Grisha This project depends on this blog serie Philipp Oppermann's blog Required Knowlege I don't know what you really need to know to learn efficient

An x86-64 kernel with ~100% Rust (originally) in a week
An x86-64 kernel with ~100% Rust (originally) in a week

litchi-rs An x86-64 kernel with ~100% Rust (originally) in a week. The continuation of Litchi. Try it Make sure the Rust toolchains and qemu-system-x8

Linux ABI-compatible kernel written in Rust
Linux ABI-compatible kernel written in Rust

Linux ABI-compatible kernel written in Rust 🖼️ Screenshot (v0.1.0-alpha.1) 📦 Build dependencies To compile GalaxyOS kernel and create basic OS ISO i

A KISS Rust crate to parse Windows kernel crash-dumps created by Windows & its debugger.
A KISS Rust crate to parse Windows kernel crash-dumps created by Windows & its debugger.

kdmp-parser A KISS Rust crate to parse Windows kernel crash-dumps created by Windows & its debugger. This is a cross-platform crate that parses Window

💻 An x86_64 kernel in the works

BruhOS a basic x86_64 kernel in the works. cool stuff written in rust boots with any stivale2-compliant bootloader framebuffer bitmap font renderer pm

The official kernel for Popcorn OS, and operating system designed for handheld devices.

About Popkern is the kernel for Popcorn OS, an operating system designed for handheld devices. As such, the kernel is (to be) optimised at all levels

The kernel for LibertyOS.
The kernel for LibertyOS.

This is the official repository of the LibertyOS kernel. LibertyOS is an operating system, built with Rust, that is open-source, free-to-use, and open to new contributors.

A custom kernel for educational reasons

A custom kernel for educational reasons

Comments
  • f64 featuers makes incompatible changes to the API

    f64 featuers makes incompatible changes to the API

    Features in rust are not supposed to change the signatures of the API, because it means that turning on the feature is a breaking change. This is the problem because cargo's choice of features as additive across the dependency tree.

    For example suppose I have library A that doesn't use f64, and another library B that does. If I add both as a dependency, the KDE crate will be compiled with the f64 enabled. This will cause library A to not compile, because it was using f32.

    From the cargo book:

    features should be additive. That is, enabling a feature should not disable functionality, and it should usually be safe to enable any combination of features. A feature should not introduce a SemVer-incompatible change

    bug 
    opened by TheButlah 1
  • Add support for multivariate KDE

    Add support for multivariate KDE

    Currently only univariate distributions are supported. A complete implementation would include seamless support for multivariate distributions. The only type that should be changed is the KernelDensityEstimator struct. Currently, the data structure is as follows:

    pub struct KernelDensityEstimator<B, K> {
        observations: Vec<Float>,
        bandwidth: B,
        kernel: K,
    }
    

    The observations field will need to be converted to a nalgebra::DMatrix to support a multivariate distribution. The type should be hidden behind an alias so that end-users do not need to add nalgebra as a dependency in their own projects.

    pub type Matrix2D = nalgebra::DMatrix<Float>;
    
    pub struct KernelDensityEstimator<B, K> {
        observations: Matrix2D,
        bandwidth: B,
        kernel: K,
    }
    

    To prevent needless conversions for users working with univariate data, the data structure could instead add a generic parameter T representing the type of observations. For univariate data T could be concretely represented as Vec<Float> and for multivariate data T could be concretely represented as Matrix2D. However, this would require the introduction of two new traits UnivariateKDE and MultivariateKDE to mimic overloading of the method names pdf, cdf, and sample.

    pub struct KernelDensityEstimator<T, B, K> {
        observations: T,
        bandwidth: B,
        kernel: K,
    }
    
    pub trait UnivariateKDE {
        // Unimplemented.
    }
    
    pub trait MultivariateKDE {
        // Unimplemented.
    }
    
    // Univariate case.
    impl<B, K> UnivariateKDE for KernelDensityEstimator<Vec<Float>, B, K>
    where
        B: Bandwidth,
        K: Kernel,
    {
        // Unimplemented.
    }
    
    // Multivariate case.
    impl<B, K> MultivariateKDE for KernelDensityEstimator<Matrix2D, B, K>
    where
        B: Bandwidth,
        K: Kernel,
    {
        // Unimplemented.
    }
    

    Lastly, the traits UnivariateKDE and MultivariateKDE should be sealed to prevent end-user implementations.

    enhancement 
    opened by seatonullberg 0
  • Add more kernel functions

    Add more kernel functions

    All the kernel functions described here should be implemented.

    • [x] Uniform
    • [ ] Triangular
    • [x] Epanechnikov
    • [ ] Quartic
    • [ ] Triweight
    • [ ] Tricube
    • [x] Normal (Gaussian)
    • [ ] Cosine
    • [ ] Logistic
    • [ ] Sigmoid
    • [ ] Silverman
    enhancement good first issue 
    opened by seatonullberg 0
Releases(v0.1.0)
Owner
Seaton Ullberg
Materials Science and Engineering PhD candidate at the University of Florida
Seaton Ullberg
A tiny 32 bit kernel written in Rust

rustboot A tiny 32 bit kernel written in Rust. I was inspired to download Rust and try to do this after seeing zero.rs - a stub that lets Rust program

Charlie Somerville 1.5k Dec 30, 2022
Experimental kernel for embedded devices written in Rust

bkernel is an experimental kernel for embedded devices written in Rust. I'm mostly trying out Rust now to see how it applies to kernel development. Pr

Alexey Shmalko 84 Dec 13, 2022
Open Source Rust kernel; Runs WASM and WASI as lightweight containers.

?? etheryal Kernel etheryal kernel is an Open Source capability-based Kernel written in the Rust programming language. The kernel allows implementing

null 32 Dec 4, 2022
Basic Rust kernel using Limine

Rust Limine Barebones This is a small kernel that boots using Limine. Build First of all, download Rust ! (I guess you already did it if you are here

Quentincestino 16 Dec 23, 2022
A new operating system kernel with Linux binary compatibility written in Rust.

Kerla Kerla is a monolithic operating system kernel from scratch in Rust which aims to be compatible with the Linux ABI, that is, runs Linux binaries

Seiya Nuta 3.1k Jan 1, 2023
Minimal x86_64 OS kernel written in Rust

rkernel A minimal x86_64 Rust OS kernel. Multiboot2 VGA driver PIC PIT PS/2 Keyboard driver PS/2 Mouse driver TSC RTC Allocator ATA PIO (In progress..

Divy Srivastava 36 Apr 26, 2022
🍒 Small, simple, and fast kernel written in Rust. 🌸

?? Small, simple, and fast kernel written in Rust. ??

Cherry Developers 5 May 20, 2022
Examples on how to write Windows kernel drivers in Rust

windows-kernel-rs Note: this is still work in progress! This is a Windows kernel framework in Rust that consists of windows-kernel-sys, a crate that p

S.J.R. van Schaik 77 Dec 28, 2022
Xrs is a POSIX-subset operating system kernel written in Rust.

XRS-OS ( ?? WIP) Xrs is a POSIX-subset operating system kernel written in Rust. Current project team members 0x5459 core developer (he/him) 0x5457 cor

null 7 Nov 16, 2022
Linux kernel modules written in Rust

Linux kernel modules written in Rust A collection of in-progress experimental Linux kernel modules written for the Rust for Linux project To run the o

Milan 10 Nov 13, 2022