# EXOTIC STATS PROBLEM ; MODE, FUZZY CLUSTERS, ETC

Page 1 of 1

## 5 Replies - 237 Views - Last Post: 12 August 2018 - 02:09 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=411995&amp;s=a903d6667088a21ed02b8362c745e79c&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 amy.vaulhausen

Reputation: 0
• Posts: 30
• Joined: 01-April 16

# EXOTIC STATS PROBLEM ; MODE, FUZZY CLUSTERS, ETC

Posted 31 July 2018 - 12:47 PM

Hi I'm working on a math problem and not sure how to approach it.

Trying to enumerate, rank and extract most common numeric ranges
from a list, with a twist ;

Basic operation example is, I have ten numeric values representing
weights in variable unit measure types, i.e. grams, ounces, etc

Each value is unique and is a decimal value,
for example we have the following set of numbers
shown below. In this set, we are interested in the
most common magnitudinal range. Here the most
common range value is shown by three values ;

295.999, 312.015, 330.111

the complete set is shown ;
.........................
102.35
8000.32
330.111
295.999
77.01
16.999
1099.222
645
890.01
312.015
.........................

What I want to be able to do, is to input a list of ten values similar to the above,
and have some way, to simply, easily derive the most common value by range.

If I was using values that were more static, for example if all value in the range
in the list were all similar such as "310", then I could just use the mode function
and it would easily tell me this.

However since the values are variable decimal types, I am a bit stumped as to how
I would accomplish this. I came across Python Fuzzy Clustering and it looks like
this might work possibly in relation to mode but wondering if there is a simpler, easier, faster
way to do this?

The end goal is I want to be able to do pattern analysis on a list of numbers and return
the most common range of highest magnitude.

Outputs desired, as an example from the list above would be the thee values printed
to screen, text file, or variable

???? better way to do this than ;

1.) Fuzzy Clustering
2.) Mode (most common value) of discrete data.

Is This A Good Question/Topic? 0

## Replies To: EXOTIC STATS PROBLEM ; MODE, FUZZY CLUSTERS, ETC

### #2 jon.kiparsky

• Beginner

Reputation: 11392
• Posts: 19,432
• Joined: 19-March 11

## Re: EXOTIC STATS PROBLEM ; MODE, FUZZY CLUSTERS, ETC

Posted 31 July 2018 - 01:13 PM

Can you define "most common value by range"?

### #3 amy.vaulhausen

Reputation: 0
• Posts: 30
• Joined: 01-April 16

## Re: EXOTIC STATS PROBLEM ; MODE, FUZZY CLUSTERS, ETC

Posted 31 July 2018 - 11:02 PM

jon.kiparsky, on 31 July 2018 - 01:13 PM, said:

Can you define "most common value by range"?

Thanks for the reply Jon. Yes, what I mean is that in any set of ten values, there will be a few values
that reoccur, but with slight variance. So for the above the most common range value would be 300 but with minor
variance for each instance. What I need to do is to have a function that can tell what number magnitude
occurs the most even though each instance is not fixed. If I had a set of ten numbers and out of ten
I had three exact values occur I could just use a mode function, but since here - the magnitudes are comprable
but not exact, mode wont work in the standard case, but there must be a way to achieve this?

### #4 andrewsw

• Stealth IT

Reputation: 6700
• Posts: 27,534
• Joined: 12-December 12

## Re: EXOTIC STATS PROBLEM ; MODE, FUZZY CLUSTERS, ETC

Posted 01 August 2018 - 02:31 AM

Why you have chosen those three values, and why three, is not clear to me. However, I'll guess that an approach would be to decide on, or determine, a tolerance for ranges, then determine how many values overlap a given tolerance, then perhaps increase the tolerance until you reach the output that you are looking for. That is, until enough values overlap sufficiently to define a range/ranges. [How fuzzy is fuzzy?]

But, as I say, your statement of the challenge remains unclear to me.

### #5 amy.vaulhausen

Reputation: 0
• Posts: 30
• Joined: 01-April 16

## Re: EXOTIC STATS PROBLEM ; MODE, FUZZY CLUSTERS, ETC

Posted 01 August 2018 - 06:41 AM

andrewsw, on 01 August 2018 - 02:31 AM, said:

Why you have chosen those three values, and why three, is not clear to me. However, I'll guess that an approach would be to decide on, or determine, a tolerance for ranges, then determine how many values overlap a given tolerance, then perhaps increase the tolerance until you reach the output that you are looking for. That is, until enough values overlap sufficiently to define a range/ranges. [How fuzzy is fuzzy?]

But, as I say, your statement of the challenge remains unclear to me.

Hi Andrew, "three" is stated in the original post 'as an example'. Here, Im saying we have a fixed data set
of ten decimal numeric values. In the set, a certain quantity of the ten values will approach a similiar
threshold of magnitude, the other values with be random. The threshold 'cluster magnitude' could be any
range, in a spectral type set. So here I chose three values, only to illustrate the concept I am after.

This could change, so out of ten there could be four, five, six values with similiar magnitudes.

Another way to view this problem might be like a sensor array, where each of the ten values in the set are picking
up a pulse value represented by a decimal number and we want to interpret similiar values across the set as
something like pressure, a curve, etc.

The point is, while we can use a python mode type function to extract most common numeric values from a list
where the values are exactly alike and fixed, here we cannot use mode, because the values are not exactly
alike, only approximately alike, such as the examples I gave of ; 295.999, 312.015, 330.111

### #6 DK3250

• Pythonian

Reputation: 504
• Posts: 1,584
• Joined: 27-December 13

## Re: EXOTIC STATS PROBLEM ; MODE, FUZZY CLUSTERS, ETC

Posted 12 August 2018 - 02:09 AM

I don't know if this is still an open topic. However, here is a working solution (provided that I have understood the problem correctly).
I have moved the topic to the normal python forum - it is really a programming question.
```lst = [102.35,
8000.32,
330.111,
295.999,
77.01,
16.999,
1099.222,
645,
890.01,
312.015,
]

lst.sort()

N = 3

range_N = lst[-1]  # create a too large start value

# find the smallest range in group of size N
for i in range(len(lst) - N + 1):  # check all groups of size N
test = lst[i + N - 1] - lst[i]
if test < range_N:
range_N = test
grp_index = i

# print result
for j in range(grp_index, grp_index + N):
print(lst[j])

```

This post has been edited by DK3250: 12 August 2018 - 03:20 AM
Reason for edit:: Topic moved