## WeBWorK Problems

### random numbers in arrays

by Zak Zarychta -
Number of replies: 2

Hi there I want to set up an array that contains manipulates some number using some generated random number to simulate experimental data

For example, one row of a data table might look like the following. where xVal and yVal are respectively independent and dependent variables. yVal is perturbed by a random amount

@row0 = ($xVal,$yVal + (-1)**(random(1,20,1)*0.01*random(5,20,1)*$tVal); problem is WW does not seem to like the function random in an array. Also, WW itself traps the standard perl rand function. Does anyone have any ideas on how to get around this? Thanks,Zak In reply to Zak Zarychta ### Re: random numbers in arrays by Glenn Rice - WW has no problem with random used in an array. I have done so many times in problems. You have a syntax error in the line you gave. Are you sure that is not what is causing the problem? The syntax error is an unmatched parenthesis. @row0 = ($xVal, $yVal + (-1)**(random(1,20,1)*0.01*random(5,20,1)*$tVal);
^