Randomize Integer
Goal
Write randomize
rule logic to
- Takes the original values of the type integer, and adds random noise
- Specify the random noise by using the
offset
,flat-noise
, andpercentage-noise
parameters
Ano Structure and Example
- Structure
- Update Example
...
randomize <column> <rule-name?>
type integer
format %d
convert String2Integer
offset? <offset?>
flat-noise? <flat-noise?>
percentage-noise? <percentage-noise?>
...
table ROOMCATEGORY
...
column integer MAXDISCOUNT size 10
...
...
task ... {
update ROOMCATEGORY
randomize MAXDISCOUNT
type integer
format %d
convert String2Integer
offset 5.0 // add 5 to all original values
flat-noise 0.0 // no flat noise
percentage-noise 20.0 // adds 20% of the original value as size to the random noise
...
}
- type:
integer
- format:
%d
- integer format - convert: String2Integer - a built-in conversion function.
- offset: A fixed (double) value that is added to the original value.
- flat-noise: A fixed (double) noise value that is multiplied with the random number r
- large flat-noise - larger spread of generated values
- percentage-noise: A percentage (0.0% - 100.0%) of the original value that is multplied with the random number r
- large percentage-noise - larger spread of generated values
Noise Formula
- A random number r is drawn (at runtime) from the Standard Normal (Gaussian) Distribution Function
- We use r, together with given noise parameters to add noise to the original value
Noise formula for integer
original_value + offset + (flat-noise * r) + (original_value * percentage-noise/ 100) * r
The resulting value is cast from double to integer.