#sampling #plot #graphing

curve-sampling

Adaptive sampling of parametric

4 releases (breaking)

0.4.0 Jan 3, 2024
0.3.0 Jun 2, 2023
0.2.0 Jan 29, 2023
0.1.0 Aug 27, 2022

#217 in Math

Download history 7/week @ 2024-01-01 20/week @ 2024-02-19 585/week @ 2024-02-26 45/week @ 2024-03-04 18/week @ 2024-03-11 56/week @ 2024-04-01

76 downloads per month

GPL-3.0-or-later

120KB
2.5K SLoC

Curve Sampling

This module provide a collection of routines to perform adaptive sampling of curves as well as manipulating those samplings.

Usage

Add this to your Cargo.toml:

[dependencies]
curve-sampling = "0.4"

See the documentation.

Example

To sample the function x ↦ x sin(1/x) on the interval [-0.4, 0.4] with 227 function evaluations, simply do

use curve_sampling::Sampling;
let s = Sampling::fun(|x| x * (1. / x).sin(), -0.4, 0.4).n(227).build();

You can save the resulting sampling to TikZ with

s.latex().write(&mut File::create("graph.tex")?)?;

or to a data file (whose format is compatible with Gnuplot) with

s.write(&mut File::create("graph.dat")?)?;

Asking Gnuplot to draw the resulting curve (with plot 'graph.dat') yields:

x sin(1/x)

P.S. The number of evaluations (227) was chosen to match a depth 5 recursion for Mathematica.

Dependencies