Interval vectors (ivs) in R

“ivs (said, “eye-vees”) is a package dedicated to working with intervals in a generic way. It introduces a new type, the interval vector, which is generally referred to as an iv. An iv is generally created from two parallel vectors representing the starts and ends of the intervals…”

Over here

Examples:

> iv_set_union(iv(2, pi), iv(3, 5))
[1] [2, 5)

> iv_set_union(iv(2, pi), iv(4, 5))
[1] [2, 3.141593) [4, 5.000000)

> iv_set_intersect(iv(0, pi), iv(3, 1000))
[1] [3, 3.141593)

> iv_set_union(iv(0, pi), iv(3, 1000))
[1] [0, 1000)

> iv_between(exp(1), c(iv(0, pi)))
[1] TRUE

> iv_between(pi, c(iv(0, pi)))
[1] FALSE

Converting between miles and kilometres using Fibonacci

Fun video, in case you were running out of applications of the Fibonacci sequence,

0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, …

(each term is the sum of the previous two; start at 0, 1).

You could use it to convert between miles and kilometre thanks to the ratio of consecutive terms (1.618, as you go further long the sequence) being close to how many km there are in a mile (1.609).

The approach doesn’t work so well for 1 mile (it would say, 2km 🙃). It gets better for larger numbers. If you wanted to convert, say, 89 miles to km, you’d get 144 by going one step along the sequence. The correct answer is 143.232 km.