Skip to content

Discretization

Rectangular partitions

# CausalityToolsBase.RectangularBinningType.

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

  1. 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.
  2. RectangularBinning(ϵ::Float64) divides each axis into intervals of fixed size ϵ.
  3. 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.
  4. 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.

  1. 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 and n_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 into 10 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 into 10 equal-length intervals and the range along the second coordinate axis into 5 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 size 0.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 size 0.3 and the range along the second axis into equal-length intervals of size 0.1.

Explitly specifying data ranges (not guaranteed to cover data points):

  • RectangularBinning(-5:5, 2:2, n_intervals = 5): split the ranges -5:5 and 2:2 into n_intervals equal-length intervals.

Generating grid points from rectangular binnings

# CausalityToolsBase.generate_gridpointsFunction.

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) if grid = OnGrid(), and
  • (axisminima, axisminima .+ ((n_intervals_eachaxis .+ 1) .* stepsizes) if grid = 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 a Dataset instance.
  • binning_scheme: A RectangularBinning instance. See docs for RectangularBinning for more details.
  • grid: A GridType instance. The grid follows the same convention as in Interpolations.jl. Valid choices are OnGrid() (uses the bin origins as the grid points), and OnCell(), 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_minmaxesFunction.

get_minmaxes(pts) -> Tuple{Vector{Float}, Vector{Float}}

Return a vector of tuples containing axis-wise (minimum, maximum) values.

# CausalityToolsBase.get_minimaFunction.

get_minima(pts) -> SVector

Return the minima along each axis of the dataset pts.

# CausalityToolsBase.get_maximaFunction.

get_maxima(pts) -> SVector

Return the maxima along each axis of the dataset pts.

Edge lengths

# CausalityToolsBase.get_edgelengthsFunction.

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_edgelengthsFunction.

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.TriangulationBinningType.

TriangulationBinning

A type indicating that a triangulation partition in which a set of points is divided into simplices should be used.