MathGroup Archive 2008

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

Search the Archive

FindClusters & BarCharts

  • To: mathgroup at smc.vnet.net
  • Subject: [mg88488] FindClusters & BarCharts
  • From: "Namrata Khemka" <namrata.khemka at gmail.com>
  • Date: Tue, 6 May 2008 06:43:40 -0400 (EDT)

Hi everyone,
I have the following list:
list = {{2, 4, 2, 2, 9}, {7, 2, 8, 5, 4}, {2, 1, 4, 5, 3}}


I would like to find clusters in the above list:

tmpVal = 3;

temp = FindClusters[Cases[Flatten[Sort[list]], Except[tmpVal]]]


This gives me: {{2, 1, 2, 2, 2, 2}, {4, 4, 4}, {5, 5}, {9, 7, 8}} which is
correct. However, I do want one of the clusters to include the value of 3
and get something as follows:

{{2, 1, 2, 2, 2, 2}, {4, 4, 4}, {5, 5}, {9, 7, 8}, {3}}


If I change tmpVal = 2 I get something that is not desired:

tmpVal=2

temp = FindClusters[Cases[Flatten[list], Except[value]]]

This gives me: {{4, 5, 4, 1, 4, 5, 3}, {9, 7, 8}}.

However, I would like the output to be somewhat as the following (In other
words

{{1}, {2,2,2,2,2}, {3,4,5}, {7,8,9}}


Similarly, if I change the variable value=8, I get:

{{2, 2, 2, 2, 2, 1, 3}, {4, 5, 4, 4, 5}, {9, 7}}

but would like the output to include:

{{2, 2, 2, 2, 2, 1, 3}, {4, 5, 4, 4, 5}, {7}, {8}, {9}}


In other words, split the list up at the value and then



I would like to plot the above in a BarChart:

Needs["BarCharts`"]

BarChart[Map[Length[#] &, temp]]

I would like the bars to have the labels as the minimum and maximum for each
of the lists. For instance:

{{4, 5, 4, 1, 4, 5, 3}, {9, 7, 8}, {2,2,2,2,2}}

The first bar would be labeled 1-5



  • Prev by Date: Thank you..
  • Next by Date: Re: 32 or 64 bit front-end on 64-bit Mac
  • Previous by thread: Re: orthonormal eigenvectors]
  • Next by thread: Re: FindClusters & BarCharts