matlab boxcox变换,使用MATLAB自带boxcox函数将非正态分布转换成正态分布的一个注意事项...

boxcoxtransforms

nonnormally distributed data to a set of data that has

approximately normal distribution. The Box-Cox transformation is a

family of power transformations.

If λ is not

=0,

then

data(λ)=dataλ−1λ

If λ is

=0,

then

data(λ)=log(data)

The logarithm is the natural

logarithm (log base e). The algorithm calls for finding the λ

value that maximizes the Log-Likelihood Function (LLF). The search

is conducted usingfminsearch.

[transdat,

lambda] =

boxcox(data)transforms the

data vectordatausing the Box-Cox

transformation method

intotransdat. It also estimates the transformation parameter

λ.

[transfts,

lambda] =

boxcox(tsojb)transforms the

financial time series

objecttsobjusing the Box-Cox

transformation method

intotransfts. It also estimates the transformation parameter

λ.

If the input data is a

vector,lambdais a scalar. If the

input is a financial time series

object,lambdais a structure with

fields similar to the components of the object; for example, if the

object contains series

namesOpenandClose,lambdahas

fieldslambda.Openandlambda.Close.

transdat = boxcox(lambda,

data) and transfts = boxcox(lambda,

tsobj) transform the data using a certain

specified λ for the Box-Cox transformation. This syntax does not

find the optimum λ that maximizes the LLF.

请仔细阅读加黑部分

[transdat, lambda] = boxcox(data)

[transfts, lambda] = boxcox(tsobj)

假设我们有两组数据A和B,这两组数据分别经过shapiro方法检测,都是非正态分布的。

这时,我们要将这两组数据分别用boxcox方法各自转换成正态分布。

那么,我们使用boxcox函数分别对这两组数据进行操作,即

[ As, lambdaA ] = boxcox(A)

[ Bs, lambdaB ] = boxcox(B)

如果输入参数里没有lambda,则boxcox函数会对输出参数lambda的值进行自动寻优,也就导致输出参数transdat的值会有很大的偏差,因为转换公式里的参数lambda值不一样。因为算法是对这两组数据分别寻优的。

改为

As = boxcox(0.2,A)

Bs = boxcox(0.2,B)

即可。

你可能感兴趣的:(matlab,boxcox变换)