:

## List of Perturbed Parameters

Maple

I have a rather complicated expressions involving several parameters. The parameters are calibrated to some baseline. I'm interested in having a quick look at how changing each parameter changes the value of the expression. This is very standard. I wrote a procedure to create a list of values to the left and to the right of the base value for a given parameter. I then use that to look at my expression, to plot lists of expressions, and so on.

I thought I'd share this very simple procedure. Naturally comments are welcome, especially if something like this already exists.

`restart;Perturb :=    proc( p     , { span :: positive := 0.1 }     , { step :: positive := 0.01 } )     description"given a number, returns a list of perturbed values symmetrically perturbed away from both sides of the number,        where span is an optional parameter taking the maximum percentage deviation away from the value on one side,        and where step is an optional parameter taking the percentage change from one perturbed value to the next.      The default span is 10%.      The default step is 1%.";     local i,L1,L2;     L1 := op(ListTools:-Reverse([seq(p*(1-i), i=0..span,step)][2..-1])):     L2 := seq(p*(1+i), i=0..span,step):     if p>0 then return([L1,L2]); elif p=0 then WARNING("Perturbations are computed as percentages, so zero values are not admissible"); else return(ListTools:-Reverse([L1,L2])); fi;  end proc:# Perturb a positive numberPerturb(10, 'span' = 0.1, 'step' = 0.05); [9.00, 9.50, 10, 10.50, 11.00]# Perturb a negative numberPerturb(-10, 'span' = 0.1, 'step' = 0.02); [-11.00, -10.80, -10.60, -10.40, -10.20, -10, -9.80, -9.60,  -9.40, -9.20, -9.00]# Perturb does not work on zero. Edit: since the perturbations are defined as percentages. # Edit: added a WARNING to the procedurePerturb(0);Warning, Perturbations are computed as percentages, so zero values are not admissible` ﻿