# Numeric Expression¶

## Creating a Numeric Expression Algorithm via API¶

1. Retrieve the frameworkId for the Numeric Expression Framework. This information can be retrieved using the following endpoint:

algorithm       GET /algorithm/frameworks

The framework information should look similar to the following:

{
"frameworkId": 26,
"frameworkName": "Numeric Expression",
"frameworkType": "BIG_DECIMAL",
"description": "Numeric Expression masks input by ... [truncated for brevity].",
"plugin": {
"pluginId": 7,
"pluginName": "dlpx-core",
"pluginAuthor": "Delphix Engineering",
"pluginType": "EXTENDED_ALGORITHM"
}
}

2. Create a Numeric Expression algorithm instance via the following endpoint:

algorithm   POST /algorithms

Configure a new algorithm using the JSON formatted input similar to the following:

{
"algorithmName": "NumericExpressionTest",
"algorithmType": "COMPONENT",
"frameworkId": 26,
"algorithmExtension": {
"expression": "Math.floor(((input * randomPercentage) * 100.0) + 0.5) / 100.0",
"inputType": "DOUBLE",
"constants": [
{
"name": "randomPercentage",
"value": "new java.util.Random(seed).doubles(0.1, 0.9).iterator().nextDouble()"
}
],
}
}

## Numeric Expression Algorithm Extension¶

• expression

String
One-line mathematical expression written in the Java programming language that references input (the current unmasked value), e.g. input * 0.5 or input + Math.random().

• inputType

String ENUM(DOUBLE, LONG, BIG_DECIMAL)
Data type that input conforms to within the expression. DOUBLE (default) is double-precision floating point, LONG is long integer, and BIG_DECIMAL is java.math.BigDecimal object.

• constants (optional)

array[Constant]
An array of Constant objects. Constants are variables that the expression can reference by name and whose values remain fixed for the life of a masking job. Constants can reference by name other constants defined before them.

String
Default masked value to be used if the unmasked input is not a numeric data type and can't automatically be converted to one.

### Constant¶

• name

String
Must be valid Java variable name. No two constants can have the same name, nor can "input" or "seed" be used as a constant name.

• value

String
One-line Java expression that must return a value, which is not required to be numeric.