Displaying 5 results from an estimated 5 matches for "is_evenly_spac".
Did you mean:
is_evenly_spaced
2018 Aug 31
2
compairing doubles
El vie., 31 ago. 2018 a las 16:00, Mark van der Loo
(<mark.vanderloo at gmail.com>) escribi?:
>
> how about
>
> is_evenly_spaced <- function(x,...) all.equal(diff(sort(x)),...)
This doesn't work, because
1. all.equal does *not* return FALSE. Use of isTRUE or identical(.,
TRUE) is required if you want a boolean.
2. all.equal compares two objects, not elements in a vector.
I?aki
>
> (use ellipsis to set tole...
2018 Aug 31
3
compairing doubles
Agreed that's it's rounding error, and all.equal would be the way to go.
I wouldn't call it a bug, it's simply part of working with floating point numbers, any language has the same issue.
And while we're at it, I think the function can be a lot shorter:
.is_continous_evenly_spaced <- function(n){
length(n)>1 && isTRUE(all.equal(n[order(n)], seq(from=min(n),
2018 Aug 31
0
compairing doubles
how about
is_evenly_spaced <- function(x,...) all.equal(diff(sort(x)),...)
(use ellipsis to set tolerance if necessary)
Op vr 31 aug. 2018 om 15:46 schreef Emil Bode <emil.bode at dans.knaw.nl>:
> Agreed that's it's rounding error, and all.equal would be the way to go.
> I wouldn't call it a...
2018 Aug 31
0
compairing doubles
...s)
or
max(abs(diff(diff(sort(x))))) < eps
-Mark
Op vr 31 aug. 2018 om 16:14 schreef I?aki Ucar <iucar at fedoraproject.org>:
> El vie., 31 ago. 2018 a las 16:00, Mark van der Loo
> (<mark.vanderloo at gmail.com>) escribi?:
> >
> > how about
> >
> > is_evenly_spaced <- function(x,...) all.equal(diff(sort(x)),...)
>
> This doesn't work, because
>
> 1. all.equal does *not* return FALSE. Use of isTRUE or identical(.,
> TRUE) is required if you want a boolean.
> 2. all.equal compares two objects, not elements in a vector.
>
> I?aki...
2018 Aug 31
2
compairing doubles
...eps
Serguei.
>
>
> -Mark
>
> Op vr 31 aug. 2018 om 16:14 schreef I?aki Ucar <iucar at fedoraproject.org>:
>
>> El vie., 31 ago. 2018 a las 16:00, Mark van der Loo
>> (<mark.vanderloo at gmail.com>) escribi?:
>>> how about
>>>
>>> is_evenly_spaced <- function(x,...) all.equal(diff(sort(x)),...)
>> This doesn't work, because
>>
>> 1. all.equal does *not* return FALSE. Use of isTRUE or identical(.,
>> TRUE) is required if you want a boolean.
>> 2. all.equal compares two objects, not elements in a vector....