Forum Groups
  All forums
    Help & Feedback
      Work in progress
      Finished Art
      Non-Max related

Featured Threads
  inspiration alert!!!
(37 replies)
  Indespensible MaxScripts, Plugins and 3rd Party Tools
(37 replies)
  The allmighty FREE Resources Thread !
(17 replies)
  spam alert!!!
(4886 replies)
  Maxforums member photo gallery index
(114 replies)
  Maxforums Member Tutorials
(89 replies)
  three cheers to maxforums...
(240 replies)
  101 Things you didnt know in Max...
(198 replies)
  A Face tutorial from MDB101 :D
(95 replies) Members Gallery
(516 replies)
(637 replies)
  Dub's Maxscript Tutorial Index
(119 replies)

Maxunderground news unavailable

Mode... as in Mean, Median and Mode
show user profile  ccampbell
I Did what i think was a very thorough search online and inside the maxscript help file to try to find the Mode of a set of array integers/floats.

I could be using the wrong termonologr but in anycase - does anybody know how to find the mode(the most commonly seen value in a set) of a set of integers in an array?

if i have an array - Array1 = #(1,2,3,4,5,5,5,6,7,8). The Mode for Array1 would be 5.

I could write something by hand but I'm curious if there is actually a command for finding these values.

$Entrepreneur = if((Designer + Engineer)*Programmer){Problem Solver};

read 376 times
2/10/2012 12:17:25 AM (last edit: 2/10/2012 12:17:25 AM)
show user profile  Garp
I'm afraid you'll have to write them.
Should be fairly simple though.

read 358 times
2/10/2012 1:04:25 AM (last edit: 2/10/2012 1:04:25 AM)
show user profile  ccampbell
Yeah i kinda figured as much.. thanks alot for stopping by... here's what i came up with just incase you care :p

fn FindMode YourArray =
local Mode = YourArray[1] -- default value
local Count = 0 -- default count Value
local PreviousValue = 0
for i = 1 to YourArray.count do
for i2= 1 to YourArray.count do
if YourArray[i2] == YourArray[i] do (Count = Count +1)
if Count > PreviousValue do
PreviousValue = Count
Mode = YourArray[i]
Count = 0
format "Mode of Array is % \n" mode

TestArray = #(1,2,2,2,3,4,4,5,5,5,5,5,6,7,8,9,10,10,10,10,10,10,10,10,10,11,12)
FindMode TestArray


$Entrepreneur = if((Designer + Engineer)*Programmer){Problem Solver};

read 322 times
2/10/2012 6:59:07 PM (last edit: 2/10/2012 6:59:07 PM)
show user profile  Garp
You're ignoring the frequent case where two or more values have the same maximum count.

read 315 times
2/10/2012 7:51:59 PM (last edit: 2/10/2012 7:51:59 PM)
#Maxforums IRC
Open chat window