LSWsim(wavethresh)
LSWsim()所属R语言包:wavethresh
Simulate arbitrary locally stationary wavelet process.
模拟任意局部平稳小波过程。
译者:生物统计家园网 机器人LoveR
描述----------Description----------
Simulates an arbitrary LSW process given a spectrum.
模拟的任意LSW过程中给予的频谱。
用法----------Usage----------
LSWsim(spec)
参数----------Arguments----------
参数:spec
An object of class wd (the NDWT kind) which contains the spectral information for simulating your process. See examples below on how to create and manipulate this object.
类的一个对象wd(NDWT的一种),其中包含模拟过程的光谱信息。见下面的例子,对如何创建和操作对象。
Details
详细信息----------Details----------
This function uses a spectral definition in spec to simulate a locally stationary wavelet process (defined by the Nason, von Sachs and Kroisandt, 2000, JRSSB paper).
此功能使用的光谱在规范中的定义,,局部平稳小波过程模拟(利晨·冯·萨克斯和Kroisandt,2000年,JRSSB纸)。
The input object, spec, is a wd class object which contains a spectral description. In particular, all coefficients must be nonnegative and LSWsim() checks for this and returns an error if it is not so. Other than that the spectrum can contain pretty much anything. An object of this type can be easily created by the convenience routine cns. This creates an object of the correct structure but all elements are initially set to zero. The spectrum structure spec can then be filled by using the putD function.
输入对象,spec是wd类对象,它包含的光谱描述。特别是,所有系数必须是非负的LSWsim()检查,并返回一个错误,如果它是不那么。除此之外,频谱可以包含更多的东西。可以很容易地创建此类型的对象,方便日常cns。这创建了一个对象的正确的结构,但所有的元素都最初设置为零。的频谱结构spec然后可以填充使用putD功能。
The function works by first checking for non-negativity. Then it takes the square root of all coefficients. Then it multiplies all coefficients by a standard normal variate (from rnorm()) and multiples the finest level by 2, the next finest by 4, the next by 8 and so on. (This last scalar multiplication is intended to undo the effect of the average basis averaging which combines cofficients but divides by two at each combination). Finally, the modified spectral object is subjected to the convert function which converts the object from a wd time-ordered NWDT object to a wst packet-ordered object which can then be inverted using AvBasis.
该功能的工作原理是首先检查非负。然后,它需要的所有系数的平方根。然后所有的系数相乘的标准正态变量(rnorm())的倍数最好的2 4,未来最好的,在未来8等。 (最后这标量乘法是旨在撤消结合cofficients但除以2在每个组合)的平均单位面积平均的效果。最后,修改后的光谱对象进行convert函数,它把从一个wd的时间序NWDT对象的对象wst有序分组的对象,然后可以反转使用 AvBasis。
Note that the NDWT transforms in WaveThresh are periodic so that the process that one simulates with this function is also periodic.
需要注意的是NDWT转换WaveThresh是周期性的,这样的过程,一个模拟使用此功能还定期。
值----------Value----------
A vector simulated from the spectral description given in the spec description. The returned vector will exhibit the spectral characteristics defined by spec.
一个向量模拟的光谱描述在spec描述。返回的向量会表现出的光谱特性定义的spec。
RELEASE----------RELEASE----------
Version 3.9 Copyright Guy Nason 2004
版本3.9版权所有2004年盖利晨
(作者)----------Author(s)----------
G P Nason
参见----------See Also----------
wd.object, putD, cns, AvBasis, convert, ewspec, plot.wst,
wd.object,putD,cns,AvBasis,convert,ewspec,plot.wst,
实例----------Examples----------
#[]
# Suppose we want to create a LSW process of length 1024 and with a spectral[假设我们要创建一个LSW长度为1024的光谱]
# structure that has a squared sinusoidal character at level 4 and a burst of[结构,有一个4级一阵平方的正弦字符]
# activity from time 800 for 100 observations at scale 9 (remember for a[活动从规模9的100个观测时间800(记得很]
# process of length 1024 there will be 9 resolution levels (since 2^10=1024)[过程的长度为1024分辨率将有9级(2 ^ 10 = 1024)]
# where level 9 is the finest and level 0 is the coarsest).[9级是最好的,级别0是最粗的)。]
#[]
# First we will create an empty spectral structure for series of 1024 observations[首先,我们将创建一个空的光谱结构系列,共1024个观察]
#[]
#[]
myspec <- cns(1024)
#[]
# If you plot it you'll get a null spectrum (since every spectral entry is zero)[如果您绘制它,你会得到一个空的频谱(因为每一个光谱项是零)]
#[]
## Not run: plot(myspec, main="My Spectrum")[#不运行:的图(myspec,主要=“谱”)]
#[]
#[]
# Now let's add the desired spectral structure[现在,让我们来添加所需的光谱结构]
#[]
# First the squared sine (remember spectra are positive)[首先平方正弦(记谱是积极的)]
#[]
myspec <- putD(myspec, level=4, sin(seq(from=0, to=4*pi, length=1024))^2)
#[]
# Let's create a burst of spectral info of size 1 from 800 to 900. Remember[让创建了一阵的大小为1的光谱信息,从800到900。记得]
# the whole vector has to be of length 1024.[的整个矢量具有长度1024。]
#[]
burstat800 <- c(rep(0,800), rep(1,100), rep(0,124))
#[]
# Insert this (00000111000) type vector into the spectrum at fine level 9[将(00000111000)型矢量频谱细平9]
#[]
myspec <- putD(myspec, level=9, v=burstat800)
#[]
# Now it's worth plotting this spectrum[现在,这是值得策划这个频谱]
#[]
## Not run: plot(myspec, main="My Spectrum")[#不运行:的图(myspec,主要=“谱”)]
#[]
# The squared sinusoid at level 4 and the burst at level 9 can clearly[4级和突发9级的平方正弦曲线可以清楚]
# be seen[可以看出]
#[]
#[]
# Now simulate a random process with this spectral structure.[现在模拟一个随机过程,这个光谱结构。]
#[]
myLSWproc <- LSWsim(myspec)
#[]
# Let's see what it looks like[让我们来看看它是什么样子]
#[]
## Not run: ts.plot(myLSWproc)[#不运行:ts.plot(myLSWproc)]
#[]
#[]
# The burst is very clear but the sinusoidal structure is less apparent.[是很清楚,但突发的的正弦结构是不太明显的。]
# That's basically it.[这基本上就是它。]
#[]
# You could now play with the spectrum (ie alter it) or simulate another process[现在,您可以发挥的频谱(即改变)或模拟另一个进程]
# from it.[从它。]
#[]
# [The following is somewhat of an aside but useful to those more interested[[以下是有点顺便说一句,但那些更感兴趣的有用]
# in the LSW scene. We could now ask, so what? So you can simulate an[在LSW现场。现在我们可以问,还等什么?所以,你可以模拟]
# LSW process. How can I be sure that it is doing so correctly? Well, here is[LSW的过程。我怎么能确保它这样做正确吗?嗯,这里是]
# a partial, computational, answer. If you simulate many realisations from the[一个部分,计算答案。如果您许多实现从模拟]
# same spectral structure, estimate its spectrum, and then average those[相同的频谱结构,估计其频谱,然后平均]
# estimates then the average should tend to the spectrum you supplied. Here is a[估计平均应趋向于你所提供的频谱。这里是一个]
# little function to do this (just for Haar but this function could easily be[小功能,做到这一点(只是哈尔但这个功能可以很容易地]
# developed to be more general):[发展成为更普遍的):]
#[]
checkmyews <- function(spec, nsim=10){
ans <- cns(2^nlevels(spec))
for(i in 1:nsim) {
cat(".")
LSWproc <- LSWsim(spec)
ews <- ewspec(LSWproc, filter.number=1, family="DaubExPhase",
WPsmooth=F)
ans$D <- ans$D + ews$S$D
ans$C <- ans$C + ews$S$C
}
ans$D <- ans$D/nsim
ans$C <- ans$C/nsim
ans
}
# If you supply it with a spectral structure (like myspec)[如果您提供的光谱结构(如myspec)]
# from above and do enough simulations you'll get something looking like[,以上做足够的模拟,你会得到的东西看起来像]
# the original myspec structure. E.g. try[的原myspec结构。例如尝试]
#[]
## Not run: plot(checkmyews(myspec, nsim=100))[#未运行图(checkmyews(myspec,NSIM = 100))]
##[#]
# for fun. This type of check also gives you some idea of how much data[为了好玩。这种类型的检查,也给你一些想法多少数据]
# you really need for LSW estimation for given spectral structures.][你真正需要的为LSW估计给定的光谱结构。]]
#[]
转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。
注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
|