Re: [R] How to get correct integration in C for step function?

From: Thomas Lumley <tlumley_at_u.washington.edu>
Date: Mon 22 Jan 2007 - 19:37:01 GMT

On Mon, 22 Jan 2007, Lynette wrote:

> Dear all, especially to Thomas,
>
> I have figured out the problem. For the step function, something wrong with
> my C codes. I should use the expression ((x>=0.25)&&(x<=0.75)) ? 2:1 instead
> of ((x>=1/4)&&(x<=3/4)) ? 2:1 ). Have no idea why 0.25 makes difference from
> 1/4 in C. But now I can go ahead with the correct integration in C. Thank you
> all. And hope this helps to others.
>

1 and 4 are ints in C, so 1/4 is 0 (integer division).

         -thomas



R-help@stat.math.ethz.ch 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. Received on Tue Jan 23 06:41:50 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 22 Jan 2007 - 20:30:38 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.