gaussianSmoothingSlopeBlock: gaussianSmoothingSlopeBlock

View source: R/gaussianSmoothingSlopeBlock.R

gaussianSmoothingSlopeBlockR Documentation

gaussianSmoothingSlopeBlock

Description

Slope of a curve smoothed by a gaussian filter, done blockwise to reduce calculation cost

Usage

gaussianSmoothingSlopeBlock(x,y,sd=1,xout=x,block_size=6,...)

Arguments

x

The x values formatted as a vector

y

The y values, formatted as a vector of length identical to the length of x

sd

Standard deviation for the smoothing, in terms of x-coordinates

xout

The x values where an output is desired. If no value is provided, x is used for xout

block_size

To speed up calculation, use only neighbouring values in the smoothing calculation. block_size indicates how many standard deviations away the x values are allowed to be from the xout value under consideration to be taken into account in the calculation

...

Additional arguments passed to gaussianSmoothing, used internally

Value

A numerical vector of the same length as xout, giving the estimated slope at each point given in xout

Author(s)

Thomas+Marina Braschler

Examples


x=seq(from=0,to=1500,by=0.25)
xout=x
y=runif(length(x))+x/100
sd=50
smoothed=gaussianSmoothing(x=x,y=y,sd=sd,xout=xout)
slope=gaussianSmoothingSlope(x=x,y=y,sd=sd,xout=xout)
slopeBlock=gaussianSmoothingSlopeBlock(x=x,y=y,sd=sd,xout=xout,block_size=5)
plot(x=x,y=y,type="p")
plot.xy(xy.coords(x=xout,y=smoothed),type="l",col="red")
plot.xy(xy.coords(x=xout,y=slope*1000),type="l",col="green")
plot.xy(xy.coords(x=xout,y=slopeBlock*1000),type="l",col="blue")

# In particular the slope in the above example nicely shows the edge problem. This can be first-order corrected with linear boundary extension:


x=seq(from=0,to=1500,by=0.25)
xout=x
y=runif(length(x))+x/100
sd=50
boundary_extension=500
smoothed=gaussianSmoothing(x=x,y=y,sd=sd,xout=xout,boundary_extension=boundary_extension)
slope=gaussianSmoothingSlope(x=x,y=y,sd=sd,xout=xout,boundary_extension=boundary_extension)
slopeBlock=gaussianSmoothingSlopeBlock(x=x,y=y,sd=sd,xout=xout,boundary_extension=boundary_extension,block_size=5)
plot(x=x,y=y,type="p")
plot.xy(xy.coords(x=xout,y=smoothed),type="l",col="red")
plot.xy(xy.coords(x=xout,y=slope*1000),type="l",col="green")
plot.xy(xy.coords(x=xout,y=slopeBlock*1000),type="l",col="blue")



tbgitoo/textureAnalyzerGels documentation built on March 30, 2022, 4:53 a.m.