https://github.com/axect/kde_from_scratch
Kernel Density Estimation from scratch in Rust
https://github.com/axect/kde_from_scratch
kernel-density-estimation peroxide rust
Last synced: 4 months ago
JSON representation
Kernel Density Estimation from scratch in Rust
- Host: GitHub
- URL: https://github.com/axect/kde_from_scratch
- Owner: Axect
- License: mit
- Created: 2024-04-07T06:23:45.000Z (almost 2 years ago)
- Default Branch: master
- Last Pushed: 2024-04-07T13:57:43.000Z (almost 2 years ago)
- Last Synced: 2025-09-06T22:42:17.604Z (5 months ago)
- Topics: kernel-density-estimation, peroxide, rust
- Language: Rust
- Homepage:
- Size: 562 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# KDE from Scratch
This is a simple project that demonstrates Kernel Density Estimation (KDE) from scratch using Rust. KDE is a non-parametric way to estimate the probability density function of a random variable.
## Description
The project generates a mixture of two normal distributions and uses different kernel functions (Epanechnikov, Gaussian, Tricube, and Quartic) to estimate the underlying density function.
It then compares the estimated density with the true density function and generates a histogram of the samples.
## Dependencies
This project uses the following dependencies:
- `peroxide`: For random number generation, cubic hermite spline, piecewise rejection sampling and plotting.
- `rayon`: For parallel computation.
## Usage
To run the project, simply compile and execute the `main.rs` file:
```
cargo run --release
```
This will generate the `kde.png` and `histogram.png` files in the project directory.
## Results
1. `kde.png`: A plot showing the true density function and the estimated density function using KDE.

2. `histogram.png`: A plot showing the true density function and a histogram generated using the samples obtained from the estimated density function.

## Contributing
Contributions are welcome! If you find any issues or have suggestions for improvements, please open an issue or submit a pull request.
## License
This project is licensed under the [MIT License](LICENSE).