MathGroup Archive 2011

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Finding Clusters

  • To: mathgroup at smc.vnet.net
  • Subject: [mg117111] Re: Finding Clusters
  • From: Daniel Lichtblau <danl at wolfram.com>
  • Date: Thu, 10 Mar 2011 06:07:54 -0500 (EST)

Martin Vavpotic( wrote:
> Hello everyone.
> 
> I have a large array of numbers (1000 =D72). I wish to find clusters in
> that mesh of numbers but the FindClusters method is giving me a hard
> time. I think it's because of those non-numeric leftovers from NSolve
> (x -> and y ->).
> 
> {{x -> 9.95043, y -> 0.201587}, {x -> -0.0507389,
>   y -> 0.39451}, {x -> -0.0502288 + 0.192544 I,
>   y -> 0.199992 - 2.42154*10^-6 I}, {x -> -0.0502288 - 0.192544 I,
>   y -> 0.199992 + 2.42154*10^-6 I}, <<992>>, {x -> -0.0507405,
>   y -> 0.394519}, {x -> -0.0502287 + 0.192544 I,
>   y -> 0.2}, {x -> -0.0502287 - 0.192544 I,
>   y -> 0.2}, {x -> -0.0507405, y -> 0.00548135}}
> 
> I know that if you write something like %[[1,2,2]] you get only the
> numbers but I have a whole array here. How do I get the whole array to
> lose those y -> ?
> 
> Help anyone?
> 

Have a look at Documentation Center > Rule. This will strongly suggest 
the following approach:

{x, y} /. {{x -> 9.95043, y -> 0.201587}, {x -> -0.0507389,
    y -> 0.39451}, {x -> -0.0502288 + 0.192544 I,
    y -> 0.199992 - 2.42154*10^-6 I}, {x -> -0.0502288 - 0.192544 I,
    y -> 0.199992 + 2.42154*10^-6 I}, {x -> -0.0507405,
    y -> 0.394519}, {x -> -0.0502287 + 0.192544 I,
    y -> 0.2}, {x -> -0.0502287 - 0.192544 I,
    y -> 0.2}, {x -> -0.0507405, y -> 0.00548135}}

Out[21]= {{9.95043, 0.201587}, {-0.0507389,
   0.39451}, {-0.0502288 + 0.192544 I,
   0.199992- 2.42154*10^-6 I}, {-0.0502288 -
    0.192544 I,
   0.199992 + 2.42154*10^-6 I}, {-0.0507405,
   0.394519}, {-0.0502287 + 0.192544 I, 0.2}, {-0.0502287 - 0.192544 I,
    0.2}, {-0.0507405, 0.00548135}}

Depending on your specific needs, you might also want to lop (chop) off 
the imaginary parts. That can be done either by using Re[] or 
Chop[...,tol] where tol gives the tolerance, that is, magnitude, beneath 
which values will be replaced by zero.


Daniel Lichtblau
Wolfram Research



  • Prev by Date: Re: Contour line colors from z coord of a 3D plot
  • Next by Date: Re: How to kill slave kernel securely?
  • Previous by thread: Re: Finding Clusters
  • Next by thread: Re: Finding Clusters