Simulate responses with random noise for linear regression model
Create a quadratic model of car mileage as a function of weight from the
carsmall data set.
load carsmall X = Weight; y = MPG; mdl = fitlm(X,y,'quadratic');
Create simulated responses to the data with random noise.
ysim = random(mdl,X);
Plot the original responses and the simulated responses to see how they differ.
predict accepts a single input argument containing
all predictor variables, and gives confidence intervals on its
feval accepts multiple input arguments with one input
for each predictor variable.
Usage notes and limitations:
codegen (MATLAB Coder) to generate code for the
random function. Save
a trained model by using
saveLearnerForCoder. Define an entry-point function
that loads the saved model by using
loadLearnerForCoder and calls the
random function. Then use
to generate code for the entry-point function.
random can return a different sequence of numbers than MATLAB® if either of the following is true:
The output is nonscalar.
An input parameter is invalid for the distribution.
This table contains
notes about the arguments of
random. Arguments not included in this
table are fully supported.
|Argument||Notes and Limitations|
For more information, see Introduction to Code Generation.
This function fully supports GPU arrays. For more information, see Run MATLAB Functions on a GPU (Parallel Computing Toolbox).
This function supports model objects fitted with GPU array input arguments.