4.3. Measures in detail

4.3.1. Introduction to measures

Any number that comes up in anableps can be a measure. Measures have a dimension and uncertainty associated.

To explain how measures work in Anableps, It’s important to distinguish among the terms dimension, units, value and mainValue:

Dimensions:is what is being measured: temperature, length, mass…
Units:are the units in which a dimension is expressed: for lenght, for example, can be meters, kilometers, yards, etc.
Reference unit:each dimension has several possible units, but only one reference unit: an unit considered the standard one. All the other units will be converted to this in order to perform operations. In Anableps, reference units are units belonging to the metric (mks) system.
value:is the actual figure (45, 23.12). Value alone has no sense, unless it comes with an unit.
refValue:is the value of the measure in the reference unit.

For example, in the measure ‘45yards’, the dimension is length, units are yards, the value is 45 (which, alone, makes no sense). Its refValue is 41.148 , with the implicit reference unit meters (which can be safely mixed with other mks measures).

There are two special cases: percentages and numbers

PureNumbers have no units. Numbers are created if the user don’t specify any units. They can be combined with other numbers. Adding them with measures issues warnings on compiling.

Percentages: percentages will be always referred to another measure so, alone, they make no sense. They are initially assigned “percent” units but, as soon as they are combined with any other measure, they will adopt the later units.

Multiplying and dividing measures is always possible (it’s necessary), thus creating new measures:

> 45Kg / 24m2
1.2Kg/m2

Adding up different units for the same dimension is obviously correct:

> a = 45m + 27yards
234.4m
> 45m + 105m   # this is ok
150m
> 75s + 45min  # this is ok too
> 46m15s
>

While, obviously, you can not add up measures with different dimensions:

> 45m + 26deg    # wrong: you can't add up distances and angles
ERROR!: DIFFERENT DIMENSIONS <length> AND <angle>
>

Note that the result acquires the units of the first sumand, unless a “!” is added to one of the operands:

> 45m + 25yards!
> 85 yards
> 45m + 2mm + 5inches! + 25 yards
> 110inches

If you want a measure to be stored/displayed in a different unit, use:

> 45Kg + 30oz
45.1 oz  ## result adopts units from the rightmost operand

> 45Kg + 30oz!
45.1oz   ## result adopts units of the !-labeled operand

> (45kg + 30lb)[lb]
123lb    ## result adopts the units from the expression
         ## in brackets

To convert a number to different units, use the same trick:

> 45Kg [oz]
1234oz
> a = 100Kg
> a [lb]?
203lb

Or the operator in:

> 45kg in lbs
109 lbs

See also: printing and displaying in Anableps

4.3.2. Formatting numbers

Todo

seccion vacía

4.3.3. Uncertainty in measures

4.3.3.1. A primer on errors

Measures can come up with uncertainty. That is something fundamental to the act of modelling measures with numbers. Uncertainties are inherent to the act of measuring or quantizing any quantity. Normally we just ignore them, and that is ok in Anableps too, as you can use measures without any uncertainty, but Anableps allows too errors to be included, allowing return error on some [#f3] calculations and freeing the user from tedious work of propagating the errors.

Uncertainties arise from:
  • errors on the measure process

Todo

seccion vacía

Anableps deal with the first. Systematic errors are obviously not taken into account.

4.3.3.2. Working with errors

Uncertainties can be given as:

percentage:using the symbol % . Example 14Kg(0.3%) [1].
absolute:Example: 145E10~30kgs
as significative figures:
 surrounding the error digits with parenthesis: 10.342(43)

4.3.3.3. Error distributions

In some cases, Anableps can take into account the error distributions.

  • a leading g means that the distribution is gaussian
  • a leading h means that the distribution is hat

Examples:

a = 45m2(0.4%)
b = 27ly(~h30)
c = 45deg(~g2)

Technical notes:

1:Arbitrary uncertainty profiles is dealt much more slowly than the standard functions
2:Uncertainties are ok to make algebraic calculations. However, for the number-crunching part of anableps, i.e the finite element engine that performs simulations on heat transfer, electromagnetics and gravitation fields among others, currently it is not possible deal with arbitrary-shape error functions, so gaussian will be assumed always.

4.3.4. Dimensions: kinds of measures

What follows is a list of mostly fundamental dimensions currently used in Anableps.

4.3.4.1. Direction

Signals a direction. Can be given in degrees, hours , vector or refenrece to an object (“in that direction”)

4.3.4.2. Length

4.3.4.3. Weight

4.3.4.4. Time

4.3.4.5. Angle

4.3.4.6. Percentages

4.3.4.7. Scales

Scales is a way of representing ratios. Instead of writing “0.3” or “1/3” you can write “1:3”

4.3.5. Attributes and methods

Sometimes you are interested in some attributes of the measures themselves:

> a = 50Km
> b = 10yards
> a.dim == b.dim
true
> a.units == b.units
false
> 45Km.dim  # or .dimension
[dimension: length]
> b.refVal
> 23  # measure of b in the std units: kms

This is a list of the attributes available:

.refVal:returns a number in the reference unit
.dim:dimensions (same as .dimension)
.units:units of the measure
.error:error in absolute terms
.at(n%):returns the range to find the value with the given certainty
prob:returns the probability of getting a measure in the given range?
.sample:returns a sample in the error range given

Example of the sampling:

histogram h: .range 8 12
a = 50km@10%
for i in 1..10:
   h.add a.sample
end
h.display
.setError:sets the error to a magnitude. Same as the operator “(error)”

4.3.6. Use as a calculator

You can use anableps as a calculator (with units and errors):

bash> blepx 15m in yards
14.4 yards

bash> blepx 15m + 20yards + 40nmi
2300m

You can use bleps to get an idea of some quantity:

bash> blepx estimate 15E4 Tm
15E4Tm is the weight of a building 10stories high
Other references:
   * weight of a locomotive:

Volume:
  A cube 20x20x20m of water weights

You can add graphical estimation, adding the -g flag, if needed:

blepx: estimate 15degrees -g

Footnotes

[1]Don’t mistake errors given as percentage of the measure with the percentage measures,
[2]asdfasf
[3]asdfasfasdf