Skip to content

Commit

Permalink
Update docs for resampling sequentially.
Browse files Browse the repository at this point in the history
  • Loading branch information
kahaaga committed Apr 21, 2021
1 parent bab9c75 commit 96b6a4f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@
# Resampling syntax

## Manually resampling

Because both the indices and the values of `UncertainIndexValueDataset`s are
datasets themselves, you could manually resample them by accessing the `indices` and
`values` fields. This gives you full control of the resampling.

There are some built-in sampling routines you could use instead if you use cases are simple.

## Built-in resampling methods

Sequential constraints are always interpreted as belonging to the indices of an
[uncertain index-value dataset](../../uncertain_datasets/uncertain_indexvalue_dataset.md).
Therefore, when using the built-in function to resample an index-value dataset, you can use
Expand All @@ -23,21 +25,20 @@ The following examples illustrates the syntax. Assume `udata` is an
- `resample(udata, StrictlyIncreasing())` enforces the sequential constraint only to the
indices, applying no constraint(s) on the furnishing distributions of either the
indices nor the values of the dataset.
- `resample(udata, TruncateQuantile(0.1, 0.9), StrictlyIncreasing())` applies the truncating
- `resample(udata, StrictlyIncreasing(), TruncateQuantile(0.1, 0.9))` applies the truncating
constraint both the indices and the values, then enforces the sequential constraint
on the indices.
- `resample(udata, TruncateStd(2), TruncateQuantile(0.1, 0.9), StrictlyIncreasing())`
- `resample(udata, StrictlyIncreasing(), TruncateStd(2), TruncateQuantile(0.1, 0.9))`
applies separate truncating constraints to the indices and to the values, then
enforces the sequential constraint on the indices.
- `resample(udata, NoConstraint(), TruncateQuantile(0.1, 0.9), StrictlyIncreasing())` does
- `resample(udata, StrictlyIncreasing(), NoConstraint(), TruncateQuantile(0.1, 0.9))` does
the same as above, but `NoConstraint()` indicates that no constraints are applied to
the indices prior to drawing the sequential realization of the indices.

Of course, like for uncertain value datasets, you can also apply individual constraints to
each index and each value in the dataset, by providing a vector of constraints instead
of a single constraint.


Currently implemented sequential constraints:

- [StrictlyIncreasing](strictly_increasing.md)
Expand Down
10 changes: 8 additions & 2 deletions src/resampling/ordered_resampling/resample_sequential.jl
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ const XD = Union{AbstractUncertainDataset, Vector{<:AbstractUncertainValue}}

"""
resample(x, ssc::SequentialSamplingConstraint)
resample(x, ssc::SequentialSamplingConstraint, c::Union{SamplingConstraint, Vector{SamplingConstraint}})
resample(x, ssc::SequentialSamplingConstraint, c)
resample(x::UncertainIndexValueDataset, ssc::SequentialSamplingConstraint, ic, vc)
Sample `x` element-wise such that the samples obey the sequential constraints given by `ssc`.
Alteratively, apply constrain(s) `c` to `x` *before* sequential sampling is performed.
Expand All @@ -21,7 +22,12 @@ Before the check is performed, the distributions in `x` are truncated element-wi
to the quantiles provided by `c` to ensure they have finite supports.
If `x` is an uncertain index-value dataset, then the sequential constraint is only applied to
the indices.
the indices. If one set of additional constraints are added to an uncertain index-value dataset,
then they are applied to both the indices and the values. It is also possible to give separate
index constraints `ic` and value constraints `vc`.
If constraints `c`, or `ic` and `vc`, are given, then `c`/`ic`/`vc` must be either a single constraint,
or a vector of constraints where constraints are applied element-wise to the distributions in `x`.
resample!(s, x, ssc::SequentialSamplingConstraint, lqs, uqs)
Expand Down

0 comments on commit 96b6a4f

Please sign in to comment.