Skip to main content

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:

  1. You will be able to add and remove characteristics without breaking your notebook
  2. 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:

Degrees of freedom

Degrees of freedom refer to the number of independent variables or dimensions that can vary in a given quantity. It determines the flexibility and variability of the values that can be assigned to the quantity.

One degree of freedom

In a one-dimensional value, you have a single dimension that can vary. For example:

In this example, the FuelConsumption column is indexed by the Type column. Each type of car has a specific fuel consumption value. You can access the fuel consumption values using the . operator:

Here, the Cars.FuelConsumption is a one-dimensional value, where each index corresponds to a specific type of car, and the value represents the fuel consumption in miles per gallon.

Two degrees of freedom

In a two-dimensional value, you have two dimensions that can vary independently. For example:

In this example, the Year value represents a sequence of years from 2020 to 2025. It can be used as an independent variable to calculate other quantities over time.

Here, the Fuel value has two dimensions: Year and InterestRateFromYear. It calculates the fuel price for each year based on an interest rate that varies with the year.

The over directive

The over directive is used to generalize values by collapsing them along a specific dimension. It allows you to calculate totals or summaries over a particular dimension. For example:

In this example, total(DollarsSpentPerYear over Cars) calculates the total amount spent in dollars per year for each type of car. It collapses the values over the Cars dimension and provides the total values for each car type.

Units and conversions

Dimensions can also be combined with units and conversions. You can perform operations and conversions across different dimensions. For example:

In this example, sum(Race.Distance / Animals.Speed over Animals) in hours calculates the time it takes for each animal to complete different races. The units are converted appropriately to provide the time in hours.

You can further modify the units and tweak the example to calculate the time in seconds or days for each animal to complete the races.

Overall, degrees of freedom allow you to model and analyze the variability of quantities across different dimensions, providing insights into relationships, summaries, and conversions.