Discretization
Rectangular partitions
#
CausalityToolsBase.RectangularBinning
— Type.
RectangularBinning(ϵ)
Instructions for creating a rectangular box partition using the binning scheme ϵ
.
Fields
ϵ
: A valid binning scheme.
Valid binning schemes
The following ϵ
are valid.
Data ranges along each axis dictated by data ranges
RectangularBinning(ϵ::Int)
divides each axis intoϵ
equal-length intervals, extending the upper bound 1/100th of a bin size to ensure all points are covered.RectangularBinning(ϵ::Float64)
divides each axis into intervals of fixed sizeϵ
.RectangularBinning(ϵ::Vector{Int})
divides the i-th axis intoϵᵢ
equal-length intervals, extending the upper bound 1/100th of a bin size to ensure all points are covered.RectangularBinning(ϵ::Vector{Float64})
divides the i-th axis into intervals of sizeϵ[i]
.
In these cases, the rectangular partition is constructed by locating the minima along each coordinate axis, then constructing equal-length intervals until the data maxima are covered.
Custom ranges along each axis
Rectangular binnings may also be specified on arbitrary min-max ranges.
RectangularBinning(ϵ::Tuple{Vector{Tuple{Float64,Float64}},Int64})
creates intervals along each axis from ranges indicated by a vector of(min, max)
tuples, then divides each axis into the same integer number of equal-length intervals.
It's probably easier to use the following constructors
RectangularBinning(RectangularBinning(minmaxes::Vararg{<:AbstractRange{T}, N}; n_intervals::Int = 10))
takes a vector of tuples indiciating the (min, max) along each axis andn_intervals
that indicates how many equal-length intervals those ranges should be split into.RectangularBinning(minmaxes::Vector{<:AbstractRange{T}}, n_intervals::Int)
does the same, but the arguments are provided as ranges.
Examples
Minimal and maximal positions of the grid determined by the data points:
RectangularBinning(10)
: find the minima along each coordinate axis of the points, then split the (extended) range into10
equal-length intervals.RectangularBinning([10, 5])
: find the minima along each coordinate axis of the points, then split the (extended) range along the first coordinate axis into10
equal-length intervals and the range along the second coordinate axis into5
equal-length intervals.RectangularBinning(0.5)
: find the minima along each coordinate axis of the points, then split the axis ranges into equal-length intervals of size0.5
RectangularBinning([0.3, 0.1])
: find the minima along each coordinate axis of the points, then split the range along the first coordinate axis into equal-length intervals of size0.3
and the range along the second axis into equal-length intervals of size0.1
.
Explitly specifying data ranges (not guaranteed to cover data points):
RectangularBinning(-5:5, 2:2, n_intervals = 5)
: split the ranges-5:5
and2:2
inton_intervals
equal-length intervals.
Generating grid points from rectangular binnings
#
CausalityToolsBase.generate_gridpoints
— Function.
generate_gridpoints(axisminima, stepsizes, n_intervals_eachaxis,
grid::GridType = OnGrid())
Return a set of points forming a grid over the hyperrectangular box spanned by
(axisminima, axisminima .+ (n_intervals_eachaxis .* stepsizes)
ifgrid = OnGrid()
, and(axisminima, axisminima .+ ((n_intervals_eachaxis .+ 1) .* stepsizes)
ifgrid = OnCell()
,
where the minima along each coordinate axis (axisminima
), the stepsizes
along each axis, and the set of intervals (n_intervals_per_axis
) indicating how many equal-length intervals each axis should be divided into.
If grid = OnGrid()
, then the bin origins are taken as the grid points. If grid = OnCell()
, then one additional interval is added and the grid is shifted half a bin outside the extrema along each axis, so that the grid points lie at the center of the grid cells.
generate_gridpoints(points, binning_scheme::RectangularBinning,
grid::GridType = OnGrid())
Return a set of points forming a rectangular grid covering a hyperrectangular box specified by the binning_scheme
and grid
type. Provided a suitable binning scheme is given, this grid will provide a covering of points
. See the documentation for RectangularBinning
for more details.
Arguments
points
: A vector of points or aDataset
instance.binning_scheme
: ARectangularBinning
instance. See docs forRectangularBinning
for more details.grid
: AGridType
instance. The grid follows the same convention as in Interpolations.jl. Valid choices areOnGrid()
(uses the bin origins as the grid points), andOnCell()
, which adds an additional interval along each axis, shifts the grid half a bin outside the extrema along each axis and retursn the centers of the resulting grid cells.
Examples
For example,
using CausalityToolsBase, DelayEmbeddings
pts = Dataset([rand(3) for i = 1:100])
generate_gridpoints(pts, RectangularBinning(10), OnGrid()
generates a rectangular grid covering the range of pts
constructed by subdividing each coordinate axis into 10 equal-length intervals. Next,
using CausalityToolsBase, DelayEmbeddings
pts = Dataset([rand(3) for i = 1:100])
generate_gridpoints(pts, RectangularBinning(10), OnCell()
will do the same, but adds another interval (11 in total), shifts the entire hypercube so that the minima and maxima along each axis lie half a bin outside the original extrema, then returns the centers of the grid cells.
Properties of rectangular binnings
Minima/maxima
#
CausalityToolsBase.get_minmaxes
— Function.
get_minmaxes(pts) -> Tuple{Vector{Float}, Vector{Float}}
Return a vector of tuples containing axis-wise (minimum, maximum) values.
#
CausalityToolsBase.get_minima
— Function.
get_minima(pts) -> SVector
Return the minima along each axis of the dataset pts
.
#
CausalityToolsBase.get_maxima
— Function.
get_maxima(pts) -> SVector
Return the maxima along each axis of the dataset pts
.
Edge lengths
#
CausalityToolsBase.get_edgelengths
— Function.
get_edgelengths(pts, binning_scheme::RectangularBinning) -> Vector{Float}
Return the box edge length along each axis resulting from discretizing pts
on a rectangular grid specified by binning_scheme
.
Example
using DynamicalSystems, CausalityToolsBase
pts = Dataset([rand(5) for i = 1:1000])
get_edgelengths(pts, RectangularBinning(0.6))
get_edgelengths(pts, RectangularBinning([0.5, 0.3, 0.3, 0.4, 0.4]))
get_edgelengths(pts, RectangularBinning(8))
get_edgelengths(pts, RectangularBinning([10, 8, 5, 4, 22]))
#
CausalityToolsBase.get_minima_and_edgelengths
— Function.
get_minima_and_edgelengths(points,
binning_scheme::RectangularBinning) -> (Vector{Float}, Vector{Float})
Find the minima along each axis of the embedding, and computes appropriate edge lengths given a rectangular binning_scheme
, which provide instructions on how to grid the space. Assumes the input is a vector of points.
See documentation for RectangularBinning
for details on the binning scheme.
Example
using DynamicalSystems, CausalityToolsBase
pts = Dataset([rand(4) for i = 1:1000])
get_minima_and_edgelengths(pts, RectangularBinning(0.6))
get_minima_and_edgelengths(pts, RectangularBinning([0.5, 0.3, 0.4, 0.4]))
get_minima_and_edgelengths(pts, RectangularBinning(10))
get_minima_and_edgelengths(pts, RectangularBinning([10, 8, 5, 4]))
Triangulated partitions
#
CausalityToolsBase.TriangulationBinning
— Type.
TriangulationBinning
A type indicating that a triangulation partition in which a set of points is divided into simplices should be used.