Define a Dimension
A dimension is a characteristic of an object that can be given different values. For example, a geographic location could have dimensions called latitude, longitude, or country.
In this example you get quotes to refurbish your kitchen:
The final price will depend on how big the kitchen is:
You can now calculate quotes:
Using dimensions has two main advantages:
- You will be able to add and remove characteristics without breaking your notebook
- In the future, you will be able to re-use dimensions across your notebooks
Converting Units
Just like everywhere in Decipad you can convert units:
Supported units
Here is a list of all the units Decipad knows.
Degrees of freedom
Any quantity has a defined number of degrees of freedom.
The space of numbers has one degree of freedom. They can vary from -Infinity to +Infinity:
But once you define a numeric value, they have 0 dimensions, since they can no longer vary. For instance, if you create a value of 3 oranges
, that value of oranges has 0 degrees of freedom; it cannot change.
One degree of freedom
You can define a 1-dimensional value by creating a table with at least two columns. In the first column you place a name, and in the second column you place a value, like this:
In the previous example, the column named FuelConsumption
is indexed by Type
. You can access the fuel consumption values using the .
character like this:
This column (Cars.FuelConsumption
) is a one-dimensional value. Given an index value, it can have, in this case, one of three values (23, 45 or 28 miles per gallon).
Two degrees of freedom
We can also declare a time value that also has one degree of freedom that is a sequence of years:
Which we now can use to calculate an interest rate and the price of fuel per year:
We can now relate both Cars.FuelConsumption
and Fuel.Price
to know how many dollars you need to spend to travel one mile:
The over directive
If you find that your values have too many degrees of freedom, you might want to generalize a bit. For example, by using the total
function:
This should display the total on a per-year basis. This is because Consumption
's first degree of freedom is based on the Fuel table. But this doesn't make sense for us unless we're going to buy all 3 cars.
We want to know how much we would spend per car in this time period. To do so, we need to replace the last line with total(DollarsSpentPerYear over Cars)
, meaning it would calculate the total per car.
Another example of dimensions combined with unit conversions
We can have operations and unit conversions work accross dimensions, like in this example where we show how long each animal would take to run 1.75 marathons:
Challenge: Try tweaking the units above to see how many seconds or days it takes for each animal to complete all three races.