pub struct Exponential { /* private fields */ }Expand description
The struct representing an exponential distribution.
Given a range, it generates a vector of input sizes using an exponential distribution.
Implementations§
Source§impl Exponential
impl Exponential
Sourcepub fn new(range: RangeInclusive<usize>) -> Self
pub fn new(range: RangeInclusive<usize>) -> Self
Creates a new exponential distribution. The mean of the distribution is set to match the mean of the reciprocal distribution.
§Arguments
range- The range of the distribution.
Examples found in repository?
examples/sorting/main.rs (line 20)
17fn main() {
18 // Create a distribution for the length of the vectors
19 // Here we use an exponential distribution with a minimum of 1000 and a maximum of 500_000
20 let length_distribution = Exponential::new(1000..=500_000);
21
22 // Create the builder for the vectors
23 let vector_builder = InputBuilder::new(length_distribution, ());
24
25 // Build the vectors
26 // Here we build 2000 vectors, 10 of each length
27 let mut vectors = vector_builder.build_with_repetitions(200, 10);
28
29 // Create a slice of the algorithms we want to measure
30 let algorithms: &[(fn(&mut input::InputVec), &str); 2] = &[
31 (merge_sort_input, "Merge sort"),
32 (quick_sort_input, "Quick sort"),
33 ];
34
35 // Measure the algorithms on the vectors, given a relative error of 0.001
36 let results = measure_mut(&mut vectors, algorithms, 0.001);
37
38 let result_clone = results.clone();
39 // Serialize the results to a json file
40 result_clone.serialize_json("results.json");
41
42 let file_name = "results/sorting.svg";
43
44 // Plot the results
45 let config = PlotConfig::default()
46 .with_title("Sorting algorithms")
47 .with_caption("The time plot of sorting algorithms");
48
49 time_plot(file_name, results, &config);
50}Sourcepub fn set_lambda(&mut self, lambda: f64)
pub fn set_lambda(&mut self, lambda: f64)
Sets the λ of the exponential distribution.
§Arguments
lambda- The new λ of the exponential distribution.
Sourcepub fn set_gen_type(&mut self, gen_type: GenerationType)
pub fn set_gen_type(&mut self, gen_type: GenerationType)
Sets the generation type of the exponential distribution. The generation type can be either fixed intervals or random.
§Arguments
gen_type- The new generation type of the exponential distribution.
Trait Implementations§
Source§impl Clone for Exponential
impl Clone for Exponential
Source§fn clone(&self) -> Exponential
fn clone(&self) -> Exponential
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Exponential
impl Debug for Exponential
Source§impl ProbabilityDistribution for Exponential
impl ProbabilityDistribution for Exponential
Source§fn inverse_cdf(&self, u: f64) -> f64
fn inverse_cdf(&self, u: f64) -> f64
This function takes a value x in [0,1] uniformly distributed and returns a value that is
distributed according to the probability distribution chosen. Read more
Source§fn get_gen_type(&self) -> &GenerationType
fn get_gen_type(&self) -> &GenerationType
Returns the generation type of the distribution. Read more
Auto Trait Implementations§
impl Freeze for Exponential
impl RefUnwindSafe for Exponential
impl Send for Exponential
impl Sync for Exponential
impl Unpin for Exponential
impl UnwindSafe for Exponential
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more