The Program Model in Inspera Assessment is a powerful feature for Numerical Simulation and Symbolic Math questions. It enables simulations by using an expressive programming language (Maxima, which is based on Lisp) to set variables and define calculations.
This article explains the basics of declaring variables in the Program Model and details how to randomize variable values using various functions.
Understanding the Program Model variables
The Program Model is the core engine behind Numerical Simulation and Symbolic Math questions. It's where you define all the dynamic elements of your question, such as variables that will hold specific values or be randomized.
The fundamental format for declaring variables in the Program Model is: variable_name: expression;
Remember, each line of code must end with a semicolon to be correctly interpreted by Maxima.
-
Lets take the following question: James has 2 apples. Amy has twice as many as James. How many apples does Amy have?
There are two variables that need to be set.
- The number of apples James has (2).
- The number of apples Amy has (James' value multiplied by 2).
In the Program Model, this can be entered as:
james_apples: 2;amy_apples: james_apples * 2;In this example, the variable
james_appleswill always equal 2, and the variableamy_appleswill always equal 4 ( thejames_applesvalue multiplied by 2).
Randomize variables with functions
The power of the Program Model lies in its ability to randomly generate variable values for each candidate, rather than using fixed values. Maxima offers several functions to achieve random values:
-
random(n): Replace "n" with a positive integer. The generated value will be a random integer from 0 up to, but not including, that number.
eg.
james_apples: random(5);will result in the value being 0, 1, 2, 3 or 4. -
rand(n.0): Replace "n" with a positive integer. A floating point will be generated between 0.0 and n.0.
eg.
james_apples: rand(2.0);will result in the value being between 0.0000 and 2.0000. -
rand([n0, n1, n3, n7]): Provide a list of values inside square brackets. A random value from this list will be selected.
eg.
james_apples: rand([2,7,12,18]);will result in the value being either 2, 7, 12, or 18. -
rand_with_step(lower, upper, step): Generates a random value between the specified lower and upper limits, with values increasing by the set step interval.
eg.
james_apples: rand_with_step(1,13,3);will result in the value being either 1, 4, 7, 10, or 13. -
rand_with_prohib(lower, upper, [n0,n1..]): Generates a random value from a number range between the lower and upper limits, but explicitly excludes the values provided in the square brackets.
eg.
james_apples: rand_with_prohib(1,10,[2,3,7,8]);will result in the value being either 1, 4, 5, 6, 9, or 10.