Strictly decreasing
The default constructor for a strictly decreasing sequential sampling constraint is StrictlyDecreasing
. To specify how the sequence is sampled, provide an OrderedSamplingAlgorithm
as an argument to the constructor.
Documentation¶
#
UncertainData.Resampling.resample
— Method.
1 2 3 4 | resample(udata::AbstractUncertainValueDataset, constraint::Union{SamplingConstraint, Vector{SamplingConstraint}}, sequential_constraint::StrictlyDecreasing{OrderedSamplingAlgorithm}; quantiles = [0.0001, 0.9999]) |
Draw a sequence of values strictly decreasing in magnitude from the dataset, sampling each of the furnishing distributions once each, after first truncating the supports of the values in the dataset using the provided constraint
s.
Arguments:
udata
: An uncertain dataset.constraint
: Sampling constraint(s) to apply to each of the values in the dataset
before drawing the sequence of decreasing values.
sequential_constraint
: An instance of aStrictlyDecreasing
sequential
sampling constraint. For example, StrictlyDecreasing(StartToEnd())
indicates that a strictly decreasing sequence should be created in one go from start to finish (as opposed to chunking the data set first, then gluing partial sequences together afterwards).
quantiles
: A two-element vector representing a quantile range which is used
to truncate the supports values in the dataset before drawing the sequence of decreasing values. This deals with distributions with infinite support.
#
UncertainData.Resampling.resample
— Method.
1 2 | resample(udata::DT, sequential_constraint::StrictlyDecreasing{T}; quantiles = [0.0001, 0.9999]) where {DT <: AbstractUncertainValueDataset, T <: StartToEnd} |
Element-wise resample the uncertain values in the dataset such that each preceding value is strictly larger in magnitude than the next one.
Arguments:
udata
: An uncertain dataset.sequential_constraint
: An instance of aStrictlyDecreasing
sequential sampling constraint.ordered_sampling_alg
: An instance of aStartToEnd
ordered sampling constraint, indicating that the sequence of decreasing values should be created in one go from start to finish (as opposed to chunking the data set first, then gluing partial sequences together afterwards).quantiles
: A two-element vector representing a quantile range which is used to truncate the supports values in the dataset before drawing the sequence of decreasing values. This deals with distributions with infinite support.
Compatible ordering algorithms¶
StrictlyDecreasing(StartToEnd())
(the default)
Examples¶
Example: Strictly decreasing sequences + regular constraints¶
We'll start by creating some uncertain data with decreasing magnitude and just minor overlap between values, so we're reasonably sure we can create strictly decreasing sequences.
1 2 3 4 | using UncertainData, Plots N = 20 u_timeindices = [UncertainValue(Normal, i, rand(Uniform(0.1, ))) for i = N:-1:1] u = UncertainDataset(u_timeindices) |
Now, we'll create three different plots. In all plots, we plot the 0.00001th to 0.99999th (black) and 33rd to 67th (red) percentile range error bars. For the first plot, we'll resample the data without any constraints. For the second plot, we'll resample without imposing any constraints on the furnishing distirbution, but enforcing strictly decreasing sequences when drawing realizations. For the third plot, we'll first truncate all furnishing distributions to their 33rd to 67th percentile range, then draw realizations whose consecutively value are strictly decreasing in magnitude.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # Plot the data with 0.00001th to 0.99999th error bars in both directions qs = [0.0001, 0.9999] p_noconstraint = plot(u, qs, legend = false, xaxis = false, title = "NoConstraint()") p_decreasing = plot(u, qs, legend = false, xaxis = false, title = "StrictlyDecreasing()") p_decreasing_constraint = plot(u, qs, legend = false, xaxis = false, title = "TruncateQuantiles(0.33, 0.67) + StriclyDecreasing()") # Add 33rd to 67th percentile range error bars to all plots. plot!(p_noconstraint, u, [0.33, 0.67], msc = :red) plot!(p_decreasing, u, [0.33, 0.67], msc = :red) plot!(p_decreasing_constraint, u, [0.33, 0.67], msc = :red) for i = 1:300 plot!(p_noconstraint, resample(u, NoConstraint()), lw = 0.2, lc = :black, lα = 0.2) plot!(p_decreasing, resample(u, StrictlyDecreasing()), lw = 0.2, lc = :black, lα = 0.1) plot!(p_decreasing_constraint, resample(u, TruncateQuantiles(0.33, 0.67), StrictlyDecreasing()), lw = 0.2, lc = :black, lα = 0.1) end plot(p_noconstraint, p_decreasing, p_decreasing_constraint, link = :x, layout = (3, 1), size = (300, 600), titlefont = font(8)) |