ysim = random(mdl)
ysim = random(mdl,Xnew)
ysim = random(mdl,Xnew,'Weights',W)
Nonlinear regression model, constructed by fitnlm.
Points at which mdl predicts responses.
Vector of real, positive value weights or a function handle.
Given weights, W, random estimates the error variance at observation i by MSE*(1/W(i)), where MSE is the mean squared error.
Default: No weights
Vector of predicted mean values at Xnew, perturbed by random noise. The noise is independent, normally distributed, with mean zero, and variance equal to the estimated error variance of the model.
Create a nonlinear model of car mileage as a function of weight, and simulate the response.
Create an exponential model of car mileage as a function of weight from the carsmall data. Scale the weight by a factor of 1000 so all the variables are roughly equal in size.
load carsmall X = Weight; y = MPG; modelfun = 'y ~ b1 + b2*exp(-b3*x/1000)'; beta0 = [1 1 1]; mdl = fitnlm(X,y,modelfun,beta0);
Create simulated responses to the data.
Xnew = X; ysim = random(mdl,Xnew);
Plot the original responses and the simulated responses to see how they differ.
For predictions without added noise, use predict.