Re: Dropping Similar Numbers from List
- To: mathgroup at smc.vnet.net
- Subject: [mg60580] Re: [mg60564] Dropping Similar Numbers from List
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Wed, 21 Sep 2005 03:20:13 -0400 (EDT)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
x={1.,1.-10^-15,1.-10^-6};
Union[x]
{0.999999,1.,1.}
Looking in the Help browser or
Options[Union]
{SameTest -> Automatic}
Union[x,SameTest->(Abs[#1-#2]<10^-10&)]
{0.999999,1.}
Bob Hanlon
>
> From: "andre" <erasmus.the.giant at gmail.com>
To: mathgroup at smc.vnet.net
> Date: 2005/09/20 Tue AM 05:19:43 EDT
> Subject: [mg60580] [mg60564] Dropping Similar Numbers from List
>
> My data set has some numbers which differ by a small amount, say one
> part in 10^-15, that I don't want to appear more than once. If they
> were identical, I would just use Union[data] and be finished. Is there
> a way to set a tollerance for the Union function?
>
> I tried to use SetPrecision to get rid of the unwanted extra digits,
> but Union[SetPrecision[data,n]] gives the same result as Union[data].
> What exactly does SetPrecision do? It seems that it's not just
> dropping the digits beyond the limit I set.
>
> Andre
>
>