Expand description
Samplers are containers for sampling data or convergence trajectories; or recording epochs/iterations for later tabulation, plotting or analysis.
Container | Description |
---|---|
SampleVec | a reservoir sampler for periodic sampling |
SampleDeque | a reservoir sampler with guaranteed front and back minimum samples. Ideal for plots where the initial and final points are important to capture |
ProgressBar | prints a progress bar |
Tabulate | displays a simple table using println style formatting |
§Example
use stepwise::{VectorExt as _, Driver, fixed_iters, Step, samplers::SampleDeque};
// create a container with 10 initial, and 10 final samples,
// and 500 samples evenly taken from the 1,000,000 iterations
// this allows minimal memory use, and fast plotting
let mut sampler = SampleDeque::with_sizes(10, 500, 10);
type Point = (usize, Vec<f64>); // (iteration number, X-vector)
let (_solved, _step) = fixed_iters(gradient_descent, 1_000_000)
.on_step(|algo, step| {
let point: Point = (step.iteration(), algo.x().to_vec());
sampler.sample(point);
})
.solve()
.unwrap();
// plot_data will have 500 evenly spaced samples, with the first and
// last 10 items guaranteed to be captured
let plot_data : Vec<Point> = sampler.into_unordered_iter().collect();
Structs§
- Progress
Bar - A progress bar which can display to Stderr or Stdout
- Sample
Deque - A segmented vector that divides elements into three regions: head, middle, and tail.
- Sample
Vec - Tabulate
- A Tabulator or table generator which can display to Stderr or Stdout
Enums§
- Sampling
Outcome - Indicates the action taken by sampling.
Traits§
- Sampler
- Sampler trait