13 #region Private Fields
17 private readonly
int _minTrialSelection;
22 private readonly
int _maxTrialSelection;
25 private readonly
int _hashValue;
26 #endregion Private Fields
30 [GreaterThan(0,
true), LessThan(1,
false)]
35 [GreaterThan(0,
false), LessThan(1,
true)]
50 throw new ArgumentOutOfRangeException(nameof(min), min,
51 "The min probability must be greater than or equal to zero. The range is [0,1)");
53 throw new ArgumentOutOfRangeException(nameof(min), min,
54 "The min probability must be less than one. The range is [0,1)");
56 throw new ArgumentOutOfRangeException(nameof(max), max,
57 "The max probability must be greater than zero. The range is (0,1]");
59 throw new ArgumentOutOfRangeException(nameof(max), max,
60 "The max probability must be less than or equal to one. The range is (0,1]");
62 throw new ArgumentOutOfRangeException(nameof(max), max,
63 "The max probability must be greater or equal to than the min probability.");
65 _minTrialSelection = (int)(min * Int32.MaxValue);
66 _maxTrialSelection = (int)(max * Int32.MaxValue);
67 _hashValue =
new { _minTrialSelection, _maxTrialSelection }.GetHashCode();
70 #region Public Static Factory Methods
93 [Obsolete(
"Warning: This implicit conversion will be deprecated. You should explicitly create a probability " +
94 "window for a tail distribution using ProbabilityWindow.Tail if that is your intention.")]
96 #endregion Public Static Factory Methods
98 #region IEquatable Implementation
106 _minTrialSelection == other._minTrialSelection && _maxTrialSelection == other._maxTrialSelection;
113 #endregion IEquatable Implementation
118 public override string ToString() => $
"{min_probability:R}_{max_probability:R}";
Base class used by all types and resources.
A probability range used to dictate the set of ordered trial losses in a loss distribution that shoul...
bool Equals(ProbabilityWindow other)
Determines whether the specified probability windows have precisely the same minimum and maximum.
override bool Equals(object obj)
static ProbabilityWindow FromReturnPeriods(double starting_return_period, double ending_return_period)
Create a probability window from return period window.
double min_probability
The inclusive lower-bound of the probability window, which will correspond to the largest trial loss ...
double max_probability
The inclusive upper-bound of the probability window, which will correspond to the smallest trial loss...
override string ToString()
static ProbabilityWindow All
Returns a window representing the full probability range [0, 1], such that all trial losses will be i...
override int GetHashCode()
ProbabilityWindow(double min, double max)
Constructs a probability window from a min and max probability.
static ProbabilityWindow Tail(double tail_probability)
Returns a window representing the tail probability range [0, tail_probability], such that all losses ...