ExponentiallyWeightedNormalizer
Description
An ExponentiallyWeightedNormalizer model object represents an
incremental normalizer that uses exponential weighting, where newer observations receive
higher weight than older ones. After creating the object, you can use the fit object function
to update the weighted Center (mean) and Scale
(standard deviation) property values of the object based on new data. You can return
normalized data by using the fit or transform
function.
Creation
Create an exponentially weighted normalizer object using incrementalNormalizer.
Properties
This property is read-only.
List of categorical predictors, represented as a vector of positive integers. Each entry in the vector is an index value corresponding to the column of the predictor data that contains a categorical variable.
For categorical predictors:
Data Types: single | double
This property is read-only.
Predictor variable names, represented as a string array. If you do not specify
PredictorNames when you create the object, then
PredictorNames is ["x1" "x2" ... "xN"],
where N is the value of NumPredictors.
Data Types: string
This property is read-only.
Number of predictor variables, represented as a nonnegative integer.
If
Centeris not empty,NumPredictorsequals the number of elements inCenter.If
PredictorNamesis not empty,NumPredictorsequals the number of elements inPredictorNames.If
NumPredictorsis0, when you call the incrementalfitfunction, the software setsNumPredictorsto the number of predictors in the training data.
Data Types: single | double
This property is read-only.
Warm-up period before the normalized predictor output, represented as a nonnegative
integer. The WarmupPeriod value is the number of observations to
which the incremental model must be fit before the incremental fit
function returns predictor data that is not NaN.
Data Types: single | double
This property is read-only.
Flag indicating whether the incremental fit
function updates Scale, represented as a numeric or logical
0 (false) or 1
(true).
When ScaleData is false,
Scale is [] and the normalized predictor data
returned by fit or transform is centered and
not scaled.
Data Types: logical
This property is read-only.
Predictor means, represented as a
1-by-NumPredictors numeric
array. The Center values that correspond to CategoricalPredictors are NaN.
Data Types: single | double
This property is read-only.
Predictor standard deviations, represented as a 1-by-NumPredictors numeric array. The Scale values that
correspond to CategoricalPredictors are
NaN. If ScaleData is false, the Scale
values that correspond to noncategorical predictors are 0.
Data Types: single | double
This property is read-only.
Sum of weights, represented as a 1-by-NumPredictors array of positive scalar
values. The SumOfWeights values
that correspond to CategoricalPredictors are
NaN. The incremental
fit function uses
SumOfWeights to update
Center (and
Scale, if
ScaleData is
true).
Data Types: single | double
This property is read-only.
Flag indicating whether the incremental fit function returns
normalized predictor values, represented as a numeric or logical 0
(false) or 1 (true).
IsWarm becomes true after
fit processes WarmupPeriod observations.
If IsWarm is false, the normalized output of
fit consists of NaN values.
Data Types: single | double | logical
This property is read-only.
Number of observations used for training, represented as a nonnegative integer. If
NumTrainingObservations exceeds TrainingPeriod, the incremental fit function does
not update Center and Scale.
Data Types: double
Forgetting factor for the Center and Scale
values calculated by fit, represented as a scalar value from
0 to 1. A high
ForgettingFactor value gives more weight to newer observations
than older ones. A value of 0 indicates infinite memory, where all
the previous observations have equal weight when the incremental
fit function updates the Center values (and
Scale values, if ScaleData is
true).
Data Types: double | single
Object Functions
Examples
Generate a data set X that contains 1000 observations of a simulated Gaussian noise signal with a standard deviation of 0.05. The signal has an initial mean of 1, which increases linearly after the 500th observation.
rng(0,"twister"); % For reproducibility n = 1000; m = 500; initialMu = 1; sigma = 0.05; driftRate = 1/1000; X = initialMu + sigma*randn(m,1); t = (1:n-m)'; X = [X; initialMu + t*driftRate + sigma*randn(n-m,1)];
Plot the data set.
plot(X) xlabel("Observation") ylabel("X",Rotation=0)

Create Incremental Normalization Model
Create an exponentially weighted incremental normalization model with an initial Center (mean) value of 1 and a Scale (standard deviation) value of 0.05, based on 10 prior observations. Display the properties of the model object.
Normalizer = incrementalNormalizer("exponentiallyweighted", ... Center=1,Scale=0.05,NumObservations=10); details(Normalizer)
incremental.preprocessing.ExponentiallyWeightedNormalizer with properties:
SumOfWeights: 10
ForgettingFactor: 0.0500
ScaleData: 1
Center: 1
Scale: 0.0500
PredictorNames: "x1"
IsWarm: 1
NumTrainingObservations: 0
NumPredictors: 1
WarmupPeriod: 0
TrainingPeriod: Inf
UpdateFrequency: 1
CategoricalPredictors: []
Methods, Superclasses
Normalizer is an ExponentiallyWeightedNormalizer model object. All its properties are read-only. The properties of Normalizer affect how the software processes chunks of data as follows:
The incremental
fitfunction returns normalized data (IsWarm=true).The
ScaleDatavalue istrue, meaning that the normalized data is centered (mean =0) and scaled (standard deviation =1).fitupdates theCenterandScalevalues of the model each time it processes an observation (UpdateFrequency=1).The value of
ForgettingFactor(0.05) is greater than zero, meaning thatfitassigns higher weight to newer observations.The
TrainingPeriodvalue isInf, meaning that theCenterandScalevalues of the model are never fixed.
Perform Incremental Fitting
To simulate a data stream, process the data in chunks of 50 observations at a time. At each iteration:
Process 50 observations.
If the mean of the data chunk is within one standard deviation of the signal's initial mean, transform the data chunk using the current model. Otherwise, overwrite the previous incremental model with a new one fitted to the incoming observations, and then transform the data chunk using the updated values of
CenterandScale.Store
center, the fittedCentervalue ofNormalizer, to see it evolves during incremental learning.Store
scale, the fittedScalevalue ofNormalizer, to see how it evolves during incremental learning.Store
XNormalized, the normalized data chunk, to see how it evolves during incremental learning.
numObsPerChunk = 50; nchunk = floor(n/numObsPerChunk); center = zeros(nchunk,1); scale = zeros(nchunk,1); XNormalized = []; % Incremental normalization for j = 1:nchunk ibegin = min(n,numObsPerChunk*(j-1) + 1); iend = min(n,numObsPerChunk*j); idx = ibegin:iend; chunkMu = mean(X(idx)); if abs(chunkMu - initialMu) < sigma normalized = transform(Normalizer,X(idx)); else [Normalizer,normalized] = fit(Normalizer,X(idx)); end center(j) = Normalizer.Center; scale(j) = Normalizer.Scale; XNormalized = [XNormalized;normalized]; end
Analyze Incremental Model During Training
To see how the Center and Scale values evolve during training, plot them on separate tiles.
figure tiledlayout(2,1); nexttile plot(center,"o-") xlabel("Iteration") ylabel("Center") nexttile plot(scale,"o-") xlabel("Iteration") ylabel("Scale")

The Center and Scale values closely track the signal's mean and standard deviation values during the first 11 iterations. After the signal's mean starts to drift, the Center value continues to track the signal's mean, and the Scale value fluctuates slightly around the signal's standard deviation value.
Plot the normalized signal data, and then display its mean and standard deviation.
figure plot(XNormalized) xlabel("Observation") ylabel("XNormalized")

display(mean(XNormalized))
-0.0180
display(std(XNormalized))
0.9880
The normalized signal has a mean close to zero and a standard deviation close to 1.
Version History
Introduced in R2026a
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
选择网站
选择网站以获取翻译的可用内容,以及查看当地活动和优惠。根据您的位置,我们建议您选择:。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 MathWorks 国家/地区网站并未针对您所在位置的访问进行优化。
美洲
- América Latina (Español)
- Canada (English)
- United States (English)
欧洲
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)