1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
//! # Histogram flatness criteria
//!
//! This module provides implementations of the [`Flatness`] trait for
//! determining when a histogram is sufficiently "flat" during Wang-Landau
//! sampling.
//!
//! Two common criteria are provided:
//!
//! - [`Fraction`]: Checks if the minimum visit count is at least some fraction
//! of the mean visit count
//! - [`RMS`]: Checks if the relative standard deviation is below a threshold
//!
//! Custom criteria can be implemented by implementing the [`Flatness`] trait.
use crateFlatness;
/// Considers a histogram flat when `min(H) ≥ flat × mean(H)`.
///
/// This popular criterion checks if the minimum visit count across all bins is
/// at least some fraction of the mean visit count. The `flat` parameter typically
/// ranges from 0.7 to 0.9, with higher values enforcing stricter flatness.
///
/// # Example
///
/// ```
/// use wanglandau::prelude::*;
///
/// let hist = vec![80, 95, 103, 88, 90];
/// let flatness = Fraction;
///
/// // Check if visits are at least 80% of the mean
/// let is_flat = flatness.is_flat(&hist, 0.8);
///
/// // Mean is 91.2, minimum is 80, ratio is 0.877
/// // So this would return true
/// ```
;
/// Considers a histogram flat when the relative standard deviation `σ/μ ≤ (1 - flat)`.
///
/// This criterion uses the coefficient of variation (relative standard deviation)
/// to measure flatness. When `flat` is close to 1.0, this requires the histogram
/// to have a very small spread relative to its mean.
///
/// # Example
///
/// ```
/// use wanglandau::prelude::*;
///
/// let hist = vec![95, 105, 98, 102, 100];
/// let flatness = RMS;
///
/// // Check if relative std dev is <= 0.1
/// let is_flat = flatness.is_flat(&hist, 0.9);
///
/// // Mean is 100, std dev is ~3.74, so ratio is ~0.0374
/// // This is less than 0.1, so would return true
/// ```
;