Skip to content

An rust port of the LOcally WEighted Scatterplot Smoothing

Notifications You must be signed in to change notification settings

u8array/lowess-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LOcally Weighted Scatterplot Smoothing

This is a Rust port of LOcally Weighted Scatterplot Smoothing

Usage

use rand::Rng;
use std::ops::Range;

use loess::Lowess;

pub fn generate_random_series(length: usize, trend_slope: f64, noise: Range<f64>) -> Vec<f64> {
    let mut rng = rand::thread_rng();
    (0..length)
        .map(|_| {
            let random_noise = rng.gen_range(noise.clone());
            let value = rng.gen_range(0.0..1.0);
            value + trend_slope + random_noise
        })
        .collect()
}

fn main() {
    // Generate data
    let y = generate_random_series(50, 0.02, -0.1..0.1);
    let x: Vec<f64> = (1..(y.len()+1)).map(|x| x as f64).collect();


    // Use the generated random data to feed the LOWESS algorithm:
    let res = Lowess::new(&x, &y, 0.33333, 0, 0.0);

    println!("{:?}", res);
}

Example

example

About

An rust port of the LOcally WEighted Scatterplot Smoothing

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages