[R] Dequantizing

David Winsemius dwinsemius at comcast.net
Thu Nov 20 17:29:40 CET 2008


Another approach:

? jitter

plot(jitter(q, factor=1),type="l")

factor = 1 by default but can get increased so the spaces get filled  
in to your satisfaction:

plot(q,type="l"); points( jitter(floor(q), factor=2) ,col="red")
plot(q,type="l"); points( jitter(floor(q), factor=3), col="red")

I suppose knowing that you "rounded down" might make the choice of  
adding a positive runif a better option. I could not tell from the  
documentation what sort of noise was added to the values by jitter,  
but checking the code I see that it is also uniform.

-- 
David Winsemius

On Nov 20, 2008, at 10:43 AM, Stavros Macrakis wrote:

> I have some data measured with a coarsely-quantized clock.  Let's say
> the real data are
>
>      q<- sort(rexp(100,.5))
>
> The quantized form is floor(q), so a simple quantile plot of one
> against the other can be calculated using:
>
>      plot(q,type="l"); points(floor(q),col="red")
>
> which of course shows the characteristic stair-step.  I would like to
> smooth the quantized form back into an approximation of the underlying
> data.
>
> The simplest approach I can think of adds a uniform random variable of
> the size of the quantization:
>
>      plot(q,type="l"); points(floor(q),col="red");
> points(floor(q)+runif(100,0,1),col="blue")
>
> This gives pretty good results for uniform distributions, but less
> good for others (like exponential).  Is there a better
> interpolation/smoothing function for cases like this, either Monte
> Carlo as above or deterministic?
>
> Thanks,
>
>           -s
>
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list