Skip to content

Commit

Permalink
Add documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasGensollen committed Apr 26, 2019
1 parent 213f83b commit 81563d2
Show file tree
Hide file tree
Showing 3 changed files with 352 additions and 16 deletions.
45 changes: 44 additions & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,46 @@
# IntervalUnions

TODO
## Introduction

`IntervalUnions` is a Julia package to work with intervals of real numbers. Most packages enables operations between intervals as long as the result is still an interval. For example `[0,2] ∪ [1,3]` will give `[0,3]`, but `[0,1] ∪ [2,4]` will throw an error. `IntervalUnions` simply returns `[0,1] ∪ [2,4]` as one might expect. This package however goes beyond and implements all kinds of operations on simple intervals and unions of disjoint intervals.

## Basic library examples

### Simple intervals

```julia
julia> i = Interval(0,1)
[0,1]
julia> j = Interval(0.2,true,2)
]0.2,2]
julia> i j
[0,2]
julia> i j
]0.2,1]
julia> cardinal(j)
1.8
julia> 0.2 in j
false
```

### Unions of intervals

```julia
julia> i = IntervalUnion([Interval(-2,0,true), Interval(0,true,1.3), Interval(2,3.4,true)])
[-2,0[ ]0,1.3] [2,3.4[
julia> j = IntervalUnion([Interval(0,1.3,true), Interval(2,true,4)])
[0,1.3[ ]2,4]
julia> cardinal(i)
4.7
julia> i j
[-2,1.3] [2,4]
julia> i j
]0,1.3[ ]2,3.4[
julia> complement(i)
]-Inf,-2[ [0,0] ]1.3,2[ [4,Inf[
julia> i complement(i)
julia> i complement(i)
]-Inf,Inf[
```
26 changes: 12 additions & 14 deletions docs/src/intervals.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Intervals

The type `Interval` implements a basic interval of real numbers like `[0,1]` or `]2.1,3.14]`. The following section gives some basic examples of operations on `Interval`s. Note that unions of disjoint `Interval`s cannot be computed and will throw an error. To work with disjoint intervals, use `IntervalUnions` instead.
The type `Interval` implements a basic interval of real numbers like `[0,1]` or `]2.1,3.14]`. The following section gives some basic examples of operations on `Intervals`. Note that unions of disjoint `Intervals` cannot be computed and will throw an error. To work with disjoint intervals, use `IntervalUnions` instead.

## Example Usage

Expand All @@ -19,7 +19,7 @@ julia> l = Interval(1.6,true,2.3,true)
]1.6,2.3[
```
Since `Interval`s are most of the time closed on both side, a simplified constructor can be used as a shortcut:
Since `Intervals` are most of the time closed on both side, a simplified constructor can be used as a shortcut:
```julia
julia> i = Interval(0,1)
Expand All @@ -41,7 +41,7 @@ julia> k = Interval(2,false,3,true)
[2,3[
```
Finally, the empty interval can be constructed with no argument:
Finally, the empty `Interval` can be constructed with no argument:
```julia
julia> m = Interval()
Expand All @@ -50,7 +50,7 @@ julia> m = Interval()
### Basic queries
Once an `Interval` is built, one has access to very simple queries to inspect the interval:
Once an `Interval` is built, one has access to very simple queries:
```julia
julia> i = Interval(0,2)
Expand All @@ -73,7 +73,7 @@ julia> cardinal(Interval())
### Order
`Interval`s implement a lexicographical order:
`Intervals` implement a lexicographical order:
```julia
julia> Interval(0,2) < Interval(1,2,true)
Expand All @@ -86,7 +86,7 @@ true
### Inclusivity
It is possible to check if a given number belongs to an interval:
It is possible to check if a given number belongs to an `Interval`:
```julia
julia> i = Interval(0,1)
Expand All @@ -103,7 +103,7 @@ julia> 0.99999999 in j
true
```
It is also possible to check if an interval is included in another one:
It is also possible to check if an `Interval` is included in another one:
```julia
julia> i = Interval(0,1)
Expand All @@ -116,7 +116,7 @@ julia> i ⊆ j
false
```
Or if two intervals are disjoint:
Or if two `Intervals` are disjoint:
```julia
julia> i = Interval(0,1,true)
Expand All @@ -133,7 +133,7 @@ false
### Intersection
We can compute the intersection of two `Interval`s:
We can compute the intersection of two `Intervals`:
```julia
julia> i = Interval(0,1)
Expand All @@ -154,7 +154,7 @@ julia> intersect(i,Interval())
### Union
We can compute theunion of two `Interval`s:
We can compute the union of two `Intervals`:
```julia
julia> i = Interval(0,1)
Expand All @@ -169,7 +169,7 @@ julia> i ∪ Interval()
### Sampling
We can sample uniform random numbers from `Interval`s:
We can sample uniform random numbers from `Intervals`:
```julia
julia> i = Interval(2,4,true)
Expand All @@ -188,19 +188,17 @@ julia> sample(i,4)
### Similarity metrics
Finally, we can compare two `Interval`s with different metrics:
Finally, we can compare two `Intervals` with different metrics:
- Jaccard coefficient:
$$
J(X,Y)=\frac{\left| X \cap Y \right|}{\left| X \cup Y \right|}
$$
- Overlap coefficient:
$$
O\left(X,Y\right)=\frac{\left| X \cap Y \right|}{min\left( \left|X\right|,\left|Y\right| \right)}
$$
- Dice coefficient:
$$
Expand Down
Loading

0 comments on commit 81563d2

Please sign in to comment.