Header menu logo FSharp.Stats

Interval Module

Functions and values

Function or value Description

add a b

Full Usage: add a b

Parameters:
Returns: Interval<^a> The sum of the two intervals
Modifiers: inline
Type parameters: ^a

Adds two intervals

a : Interval<^a>

The first interval

b : Interval<^a>

The second interval

Returns: Interval<^a>

The sum of the two intervals

InvalidOperationException Thrown when trying to add (half) open intervals

createClosedOfSize min size

Full Usage: createClosedOfSize min size

Parameters:
    min : ^a - The start value of the interval
    size : ^b - The size of the interval

Returns: Interval<^a> A closed interval
Modifiers: inline
Type parameters: ^a, ^b

Creates a closed interval [min, min + size]

min : ^a

The start value of the interval

size : ^b

The size of the interval

Returns: Interval<^a>

A closed interval

Example

 // Create a closed interval of size 5.0 starting at 2.0: [2.0, 7.0]
 Interval.createClosedOfSize 2.0 5.0

createLeftOpenOfSize min size

Full Usage: createLeftOpenOfSize min size

Parameters:
    min : ^a - The start value of the interval
    size : ^b - The size of the interval

Returns: Interval<^a> A left-open interval if size is non-zero, otherwise an empty interval
Modifiers: inline
Type parameters: ^a, ^b

Creates a left-open interval (min, min + size]

min : ^a

The start value of the interval

size : ^b

The size of the interval

Returns: Interval<^a>

A left-open interval if size is non-zero, otherwise an empty interval

Example

 // Create a left-open interval of size 5.0 starting at 2.0: (2.0, 7.0]
 Interval.createLeftOpenOfSize 2.0 5.0

createOpenOfSize min size

Full Usage: createOpenOfSize min size

Parameters:
    min : ^a - The start value of the interval
    size : ^b - The size of the interval

Returns: Interval<^a> An open interval if size is non-zero, otherwise an empty interval
Modifiers: inline
Type parameters: ^a, ^b

Creates an open interval (min, min + size)

min : ^a

The start value of the interval

size : ^b

The size of the interval

Returns: Interval<^a>

An open interval if size is non-zero, otherwise an empty interval

Example

 // Create an open interval of size 5.0 starting at 2.0: (2.0, 7.0)
 Interval.createOpenOfSize 2.0 5.0

createRightOpenOfSize min size

Full Usage: createRightOpenOfSize min size

Parameters:
    min : ^a - The start value of the interval
    size : ^b - The size of the interval

Returns: Interval<^a> A right-open interval if size is non-zero, otherwise an empty interval
Modifiers: inline
Type parameters: ^a, ^b

Creates a right-open interval [min, min + size)

min : ^a

The start value of the interval

size : ^b

The size of the interval

Returns: Interval<^a>

A right-open interval if size is non-zero, otherwise an empty interval

Example

 // Create a right-open interval of size 5.0 starting at 2.0: [2.0, 7.0)
 Interval.createRightOpenOfSize 2.0 5.0

getEnd interval

Full Usage: getEnd interval

Parameters:
    interval : Interval<'a> - The input interval

Returns: 'a The end value of the interval
Modifiers: inline
Type parameters: 'a

Returns the end value of the interval

interval : Interval<'a>

The input interval

Returns: 'a

The end value of the interval

Example

 // Create a closed interval [2.0, 7.0]
 let interval = Interval.CreateClosed(2.0, 7.0)
 // Get the end value of the interval (7.0)
 Interval.getEnd interval
val interval: obj

getSize interval

Full Usage: getSize interval

Parameters:
    interval : Interval<^a> - The input interval

Returns: 'b The size of the interval
Modifiers: inline
Type parameters: ^a, 'b, ^c

Returns the size of the interval (max - min)

interval : Interval<^a>

The input interval

Returns: 'b

The size of the interval

DivideByZeroException Thrown when the interval is empty and a NaN value does not exist for the type
Example

 // Create an open interval (2.0, 10.0)
 let interval = Interval.CreateOpen(2.0, 10.0)
 // Get the size of the interval (8.0)
 Interval.getSize interval
val interval: obj

getSizeBy projection interval

Full Usage: getSizeBy projection interval

Parameters:
    projection : 'a -> ^b - A function to project the interval values to the desired type
    interval : Interval<'a> - The input interval

Returns: 'a0 The size of the projected interval
Modifiers: inline
Type parameters: 'a, ^b, 'a

Returns the size of the interval after applying a projection function (projection max - projection min)

projection : 'a -> ^b

A function to project the interval values to the desired type

interval : Interval<'a>

The input interval

Returns: 'a0

The size of the projected interval

DivideByZeroException Thrown when the interval is empty and a NaN value does not exist for the type
Example

 // Create a closed interval ['a', 'c']
 let interval = Interval.CreateClosed('a', 'c')
 // Get the size of the interval using the ASCII values of the characters (3)
 Interval.getSizeBy int interval
val interval: obj
Multiple items
val int: value: 'T -> int (requires member op_Explicit)

--------------------
type int = int32

--------------------
type int<'Measure> = int

getStart interval

Full Usage: getStart interval

Parameters:
    interval : Interval<'a> - The input interval

Returns: 'a The start value of the interval
Modifiers: inline
Type parameters: 'a

Returns the start value of the interval

interval : Interval<'a>

The input interval

Returns: 'a

The start value of the interval

Example

 // Create a closed interval [2.0, 7.0]
 let interval = Interval.CreateClosed(2.0, 7.0)
 // Get the start value of the interval (2.0)
 Interval.getStart interval
val interval: obj

getValueAt proportion interval

Full Usage: getValueAt proportion interval

Parameters:
    proportion : ^a - The proportion (0.0 - 1.0 inside, < 0.0 or > 1.0 outside)
    interval : Interval<^d> - The input interval

Returns: 'e The value at the given proportion, or NaN if the interval is empty
Modifiers: inline
Type parameters: ^a, ^b, ^c, ^d, 'e, ^f, ^g

Get the value at a given proportion within (0.0 - 1.0) or outside (< 0.0, > 1.0) of the interval. Rounding to nearest neighbour occurs when needed.

proportion : ^a

The proportion (0.0 - 1.0 inside, < 0.0 or > 1.0 outside)

interval : Interval<^d>

The input interval

Returns: 'e

The value at the given proportion, or NaN if the interval is empty

DivideByZeroException Thrown when the interval is empty and a NaN value does not exist for the type
Example

 // Create a closed interval [0.0, 10.0]
 let interval = Interval.CreateClosed(0.0, 10.0)
 // Get the value at 0.5 within the interval (5.0)
 Interval.getValueAt 0.5 interval
val interval: obj

intersect a b

Full Usage: intersect a b

Parameters:
Returns: Interval<'a> The intersection of the two intervals
Modifiers: inline
Type parameters: 'a

Returns the intersection of two intervals

a : Interval<'a>

The first interval

b : Interval<'a>

The second interval

Returns: Interval<'a>

The intersection of the two intervals

Example

 // Create an open interval (0.0, 10.0)
 let interval1 = Interval.CreateOpen(0.0, 10.0)
 // Create a closed interval [5.0, 15.0]
 let interval2 = Interval.CreateClosed(5.0, 15.0)
 // Get the intersection of the two intervals [5.0, 10.0)
 Interval.intersect interval1 interval2
val interval1: obj
val interval2: obj

isIntersection a b

Full Usage: isIntersection a b

Parameters:
Returns: bool True if the intervals intersect, false otherwise
Modifiers: inline
Type parameters: 'a

Checks if two intervals intersect

a : Interval<'a>

The first interval

b : Interval<'a>

The second interval

Returns: bool

True if the intervals intersect, false otherwise

Example

 // Create an open interval (0.0, 10.0)
 let interval1 = Interval.CreateOpen(0.0, 10.0)
 // Create a closed interval [5.0, 15.0]
 let interval2 = Interval.CreateClosed(5.0, 15.0)
 // Check if the two intervals intersect (true)
 Interval.isIntersection interval1 interval2
val interval1: obj
val interval2: obj

subtract a b

Full Usage: subtract a b

Parameters:
    a : Interval<^a> - The first interval
    b : Interval<^a> - The interval to subtract

Returns: Interval<^a> The difference of the two intervals
Modifiers: inline
Type parameters: ^a

Subtracts one interval from another

a : Interval<^a>

The first interval

b : Interval<^a>

The interval to subtract

Returns: Interval<^a>

The difference of the two intervals

InvalidOperationException Thrown when trying to subtract (half) open intervals

trySize interval

Full Usage: trySize interval

Parameters:
    interval : Interval<^a> - The input interval

Returns: 'b option An option containing the size of the interval, or None if the interval is empty
Modifiers: inline
Type parameters: ^a, 'b

Returns an option containing the size of the interval, if it exists

interval : Interval<^a>

The input interval

Returns: 'b option

An option containing the size of the interval, or None if the interval is empty

Example

 // Create an open interval (2.0, 10.0)
 let interval = Interval.CreateOpen(2.0, 10.0)
 // Get the size of the interval Some(8.0)
 Interval.trySize interval
val interval: obj

values interval

Full Usage: values interval

Parameters:
    interval : Interval<'a> - The input interval

Returns: 'a * 'a A tuple of the start and end values
Modifiers: inline
Type parameters: 'a

Returns a tuple of the start and end values of the interval

interval : Interval<'a>

The input interval

Returns: 'a * 'a

A tuple of the start and end values

Example

 // Create a closed interval [2.0, 7.0]
 let interval = Interval.CreateClosed(2.0, 7.0)
 // Get the start and end values of the interval (2.0, 7.0)
 Interval.values interval
val interval: obj

Type something to start searching.