# Question:Creating single random values from a distribution

## Question:Creating single random values from a distribution

Maple

Dear Maple users

I wanted to create a list of random datapoints for the "simple linear regression model". Standard deviation sigma is given, slope a and fixed value b given for the line as well. Before the code below I had some random x-values created for the data points saved in the list X. To calculate the corresponding y-values randomly from a normal distribution with standard deviation sigma and mean equal to a*x+b I wrote the code below:

randomize():
for i from 1 by 1 to N do
mean:=a*X[i]+b:
Yvar:=RandomVariable(Normal(mean,sigma));
S:=Sample(Yvar,1);
Z[i]:=S[1];
end do:
Y:=convert(Z,list):

....

It actually works, but I just found it a bit strange having to repeatedly ask for a random sample with only a single member. Isn't it possible to do it more efficiently? I am aware of the special properties of the normal distribution, which would make it possible to take only one sample and add the mean afterwards, but I am not looking for ad hoc solutions, rather appropriate commands to create simgle random values from a distribution.

Erik

﻿