exp_root_log 0.1.0

Fast and interpretable function approximation with exp-root-log basis
Documentation
  • Coverage
  • 33.33%
    1 out of 3 items documented0 out of 1 items with examples
  • Size
  • Source code size: 12.83 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 220.76 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 1m 14s Average build duration of successful builds.
  • all releases: 1m 22s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • andysay1

ExpRoot+Log: A Linear and Universal Basis for Function Approximation

ExpRoot+Log is a fast and interpretable function approximation method based on a hybrid linear basis. It combines exponential square-root, polynomial, and logarithmic terms to efficiently approximate a wide range of functions, including smooth, discontinuous, and decaying ones.

Features

  • Fast and accurate: Uses a minimal set of basis functions for efficient function approximation.
  • Interpretable: Each term in the basis has a clear mathematical interpretation.
  • Flexible: Can handle smooth, discontinuous, and asymptotically decaying functions.
  • Linear regression: Uses standard least-squares fitting for optimal performance.

Usage

Add the dependency to Cargo.toml:

[dependencies]
exp_root_log = "0.1.0"

📂 examples/demo.rs:

use exp_root_log::approx_exp_root_log;

fn main() {
    // Generate test data
    let x: Vec<f64> = (0..100).map(|i| i as f64 / 100.0).collect();
    let y: Vec<f64> = x.iter().map(|&x| (2.0 * std::f64::consts::PI * x).sin()).collect();

    // Create the approximation function using ExpRoot+Log
    let approx_fn = approx_exp_root_log(
        &x,
        &y,
        &[0.5, 2.0, 5.0, 10.0, 20.0],    //  b_i
        5,                                  //  x^5
        &[1.0, 5.0, 10.0, 20.0],           // log params
    );


    // Evaluate the approximation
    let y_pred: Vec<f64> = x.iter().map(|&xi| approx_fn(xi)).collect();

    // Print the result
    println!("Approximated values: {:?}", y_pred);
}