I am new to MATLAB and I am trying to built a voice morphing system using MATLAB.
我是MATLAB的新手,我正在尝试用MATLAB构建一个语音变形系统。
So I would like to know how to normalize a signal to zero mean and unit variance using MATLAB?
所以我想知道如何用MATLAB将一个信号规范化为零均值和单位方差?
5 个解决方案
#1
65
if your signal is in the matrix X
, you make it zero-mean by removing the average:
如果你的信号是在矩阵X中,你把它的平均值去掉:
X=X-mean(X(:));
and unit variance by dividing by the standard deviation:
单位方差除以标准差:
X=X/std(X(:));
#2
11
If you have the stats toolbox, then you can compute
如果你有stats工具箱,那么你可以计算。
Z = zscore(S);
#3
6
You can determine the mean of the signal, and just subtract that value from all the entries. That will give you a zero mean result.
你可以确定信号的均值,然后从所有的项中减去那个值。这会给你一个零均值的结果。
To get unit variance, determine the standard deviation of the signal, and divide all entries by that value.
为了得到单位方差,确定信号的标准偏差,并按该值除以所有项。
#4
4
It seems like you are essentially looking into computing the z-score or standard score of your data, which is calculated through the formula: z = (x-mean(x))/std(x)
看起来你基本上是在计算你的数据的z分数或标准分数,这是通过公式计算出来的:z = (x-均值(x))/std(x)
This should work:
这应该工作:
%% Original data (Normal with mean 1 and standard deviation 2)
x = 1 + 2*randn(100,1);
mean(x)
var(x)
std(x)
%% Normalized data with mean 0 and variance 1
z = (x-mean(x))/std(x);
mean(z)
var(z)
std(z)
#5
0
To avoid division by zero!
为了避免除法零!
function x = normalize(x, eps)
% Normalize vector `x` (zero mean, unit variance)
% default values
if (~exist('eps', 'var'))
eps = 1e-6;
end
mu = mean(x(:));
sigma = std(x(:));
if sigma < eps
sigma = 1;
end
x = (x - mu) / sigma;
end
#1
65
if your signal is in the matrix X
, you make it zero-mean by removing the average:
如果你的信号是在矩阵X中,你把它的平均值去掉:
X=X-mean(X(:));
and unit variance by dividing by the standard deviation:
单位方差除以标准差:
X=X/std(X(:));
#2
11
If you have the stats toolbox, then you can compute
如果你有stats工具箱,那么你可以计算。
Z = zscore(S);
#3
6
You can determine the mean of the signal, and just subtract that value from all the entries. That will give you a zero mean result.
你可以确定信号的均值,然后从所有的项中减去那个值。这会给你一个零均值的结果。
To get unit variance, determine the standard deviation of the signal, and divide all entries by that value.
为了得到单位方差,确定信号的标准偏差,并按该值除以所有项。
#4
4
It seems like you are essentially looking into computing the z-score or standard score of your data, which is calculated through the formula: z = (x-mean(x))/std(x)
看起来你基本上是在计算你的数据的z分数或标准分数,这是通过公式计算出来的:z = (x-均值(x))/std(x)
This should work:
这应该工作:
%% Original data (Normal with mean 1 and standard deviation 2)
x = 1 + 2*randn(100,1);
mean(x)
var(x)
std(x)
%% Normalized data with mean 0 and variance 1
z = (x-mean(x))/std(x);
mean(z)
var(z)
std(z)
#5
0
To avoid division by zero!
为了避免除法零!
function x = normalize(x, eps)
% Normalize vector `x` (zero mean, unit variance)
% default values
if (~exist('eps', 'var'))
eps = 1e-6;
end
mu = mean(x(:));
sigma = std(x(:));
if sigma < eps
sigma = 1;
end
x = (x - mu) / sigma;
end