R/MRatCalcpowered by RiXOpen calculator

RiX walkthrough · 3d

Interval generation and sampling

Produce exact point ranges, partitions, mediants, and repeatable random samples.

Intervals can produce points or subintervals

The ordinary value a:b retains two exact bounds. Generation operators use those bounds to produce either a lazy point sequence or an eager collection of touching subintervals.

Step through an interval lazily

:+ starts at the lower bound for a positive step and stops before crossing the upper bound. The result is lazy and cached.

Runnable RiX

A negative step starts at the upper bound and walks downward.

Runnable RiX

The endpoint is included only when the chosen step lands on it exactly.

Ask for exactly n points

:: n returns exactly n equally spaced points, including both endpoints. The sequence is lazy even though its length is known.

Runnable RiX

Exact rational arithmetic keeps values such as 1/4 and 3/4 exact.

Partition the whole interval

:/: n eagerly returns n touching equal-width intervals. No gaps or overlaps are introduced.

Runnable RiX

Use partitions for bins and regions; use :: when you need representative points.

Explore mediants

The mediant of a/b and c/d is (a+c)/(b+d). :~ levels returns a nested array: the original endpoints, followed by the points inserted at each level.

Runnable RiX

:~/ levels uses the same exact boundaries to return a flat sequence of touching intervals. Level n creates 2^n subintervals.

Runnable RiX

Continue forever from one point

::+ creates an unbounded lazy arithmetic sequence. Unlike :+, it has no upper interval bound.

Runnable RiX

Negative steps work the same way.

Runnable RiX

Sample a fixed rational grid

For :% (count, denominator), RiX chooses integer numerators uniformly from the requested denominator grid inside the interval. Returned rationals are reduced, so 500/1000 displays as 1/2.

Runnable RiX

Seeding is local to the current RiX session. Run the cell again with the same seed to reproduce the same sample; change the seed to obtain another stream.

Sample with a tolerance

Without a denominator, RiX first samples a real-like point uniformly and then returns the simplest rational within a small default tolerance.

Runnable RiX

Supply _ in the denominator position to override the tolerance explicitly.

Runnable RiX

A count of one returns one rational value; larger counts return a finite sequence.

Create random partitions

:/% chooses distinct interior points, sorts them, and returns touching subintervals containing the original endpoints. With a denominator, selection is without replacement on that rational grid.

Runnable RiX

The number is the number of resulting subintervals, so four partitions require three distinct interior points.

Keep interval and sequence types distinct

After :+ or ::, the result is a point sequence rather than another interval. Partition operators therefore apply to the original interval, not to an already generated sequence.

Runnable RiX

Keep going

Return to lazy generators to map and filter these point sequences without materializing more values than your calculation needs.