Focal Point
[CLOSED] calculate the mode arithmetic

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/5237048826

February 18, 2013, 11:04 AM
expertomad
[CLOSED] calculate the mode arithmetic
Good afternon.
Someone can help , i need calculate the mode arithmetic
of a serie of number,for example :
I have diferents number 16 ,18 ,19 ,20 , 20 ,21 the mode aritmetic is 20 , there is some way for make this.

Thanks for everything.

This message has been edited. Last edited by: Kerry,
February 18, 2013, 02:16 PM
FrankDutch
Do you know how to calculate this in excel? Or in any other program without using an per designed formula?
In other words do you know the mathematic formula.
If you do, you can create this.
You can create an external formula and use that.




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

February 18, 2013, 03:41 PM
Waz
I haven't looked, but would this be in RSTAT ?

I think you need a licence for it.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

February 18, 2013, 06:11 PM
FrankDutch
Modulo calculation is not statistic as far as i know




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

February 18, 2013, 06:17 PM
Doug
Maybe MEDIAN?
February 18, 2013, 06:24 PM
Waz
I think we need clarification.

Mode According to wikipedia


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

February 18, 2013, 08:03 PM
jimster06
To calculate mode, the entire population has to be examined in order find the prevalent value(s).
Here is an example using the CAR file and two TABLE commands:
DEFINE FILE CAR
INSTANCE/I9 = 1;
END
TABLE FILE CAR
SUM INSTANCE BY SEATS
ON TABLE HOLD
END
TABLE FILE HOLD
PRINT SEATS INSTANCE
BY HIGHEST INSTANCE NOPRINT
END
The first pass will identify the mode and the second will print the instances out in high to low order. Be wary of multi-modal distributions.
In this example, SEATS = 5 is the mode.
HTH (from Maui)

This message has been edited. Last edited by: jimster06,


jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K
February 19, 2013, 12:16 AM
FrankDutch
There seems to be some confusion about what is ment.
Mode: the frequency of the amount in a certain series.
Mod arithmetic : http://en.wikipedia.org/wiki/Modular_arithmetic

So...what wil it be?




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

February 19, 2013, 12:32 AM
jimster06
Ah......Requirements Definition - the real challenge of our profession!


jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K
February 19, 2013, 01:13 AM
Ram Prasad E
If you are looking for most frequent occurance, then here is the sample code.
TABLE FILE CAR
SUM
COMPUTE CNT_SEATS/I2=CNT.SEATS; 
BY SEATS
ON TABLE HOLD
END
TABLE FILE HOLD
BY HIGHEST 1 CNT_SEATS
ON TABLE HOLD AS HOLD_2 FORMAT ALPHA
END
-RUN
-READ HOLD_2 &MAX_CNT.I2.
-? &MAX_CNT

TABLE FILE HOLD
PRINT
SEATS
CNT_SEATS AS 'No of Occurance'
WHERE CNT_SEATS EQ &MAX_CNT;
END

Note: Final result will give you mode values. Works for both Uni-Model and Multi-Model.

Thanks,
Ram


WebFOCUS 8.1.05
Windows
http://ibiwebfocus.wordpress.com
https://www.facebook.com/groups/ibi.webfocus/
February 19, 2013, 03:33 AM
expertomad
I don understand this solutions,
I try make this:
TABLE FILE INFORME

COUNT ENTRIES AS 'FRECUENCIA'
BY AGE
PRINT *

-*ON TABLE HOLD AS INFORME2 FORMAT FOCUS
END
-RUN
thi give 2 cols , after i want get age whit more frecuency .
Thanks for all, but somebody can help me.
February 19, 2013, 07:02 AM
FrankDutch
So you get two columns, one with the age and one with the number of ppl of that age, ?
Is this nit what you want?




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

February 19, 2013, 07:08 AM
expertomad
I want other columns the mode in this column had a value ,this value age whit more frecuency
February 19, 2013, 10:24 AM
FrankDutch
Sorry...I have now idea what you mean and what you want.
Can't you post an example based on one of the sample databases so we might better understand the problem




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

February 19, 2013, 01:56 PM
M. Meagher
Ram has the right solution. I think we need to look at what his data set would look like:
2,2,2,2,2,4,4,4,4,4,5,5,5,5,5,5,5,5
Five twos, five fours and eight fives. The most prevalent value is 5 - which is the mode. You can have multiple modes if there is a tie.


Developer Studio 7.7.05
Application Studio 8.0.09
Windows 7
All Formats
February 19, 2013, 04:46 PM
expertomad
I try get mode serie of numbers
example i have ages 19.20 ,21,23,21, the mode is 21.
i have by titulation example
TABLE FILE EXPEDIENTS
SUM
COUNT ENTRIES BY AGE
END
whit this i have 2 columns frecuency and age ,but i dont know how get the mode, also need group by titulation:
AGE FRECUENCY MODE
19 1
18 3
18
18
17 1
I need mode.
This proble this solutioned whit sql whit sql ora.
I want give one thousand thanks, this focal is gratefull i hel me all days in my job.
Thanks.
February 19, 2013, 06:36 PM
FrankDutch
Last try....

-SET &ECHO=ALL;
SET HOLDLIST=PRINTONLY
SET ASNAMES=ON

TABLE FILE EXPEDIENTS
SUM COUNT ENTRIES AS NUMBER
BY AGE
ON TABLE HOLD
END
TABLE FILE HOLD
BY HIGHEST 1 NUMBER
ON TABLE HOLD AS XXX FORMAT ALPHA
END
-READ XXX &MOD.I5
DEFINE FILE EXPEDIENTS
MODX/A1=IF AGE EQ &MOD THEN '*' ELSE '';
END
TABLE FILE EXPEDIENTS
PRINT EMPLOYEE
AGE
MODX
FOOTING
"These are all employees, the mod is &MOD"
END




I have no idea if EMPLOYEE is a field in your database, but this could also be CLIENTNAME.
If you copy this code exact as posted, I want you to tell us what you get and if this is what you need.
If there is an error you should see that too.

I hope this works..




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

February 20, 2013, 01:02 AM
Danny-SRL
According to Wiki: "The mode is the value that appears most often in a set of data"

So using the CAR file and the field MPG:
  
TABLE FILE CAR
SUM CNT.MPG AS MPGCNT
BY MPG
ON TABLE SET ASNAMES ON
ON TABLE HOLD
END
TABLE FILE HOLD
SUM MAX.MPG AS MPG_MODE
BY HIGHEST 1 MPGCNT NOPRINT
END



Daniel
In Focus since 1982
wf 8.202M/Win10/IIS/SSA - WrapApp Front End for WF

February 21, 2013, 06:51 AM
expertomad
Hello Danny.
I like you solution , i wold need some more ,i need this field mode and all field of table ,is possible i don t explain very good .
After i have work whit others field understand?

Thank for all.
February 21, 2013, 07:35 AM
FrankDutch
Did you try my solution?
Copy and run!




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

February 25, 2013, 05:19 AM
expertomad
Hello FrankDutch,

Forgive , i could not answer all person ,i have little time a lot of work, you solution is good , you get a column mode for all hold , i want diferents mode for diferents titulations ,my problem is dificult explain in english,a lot of thanks i get this whit sql ,
i like you idea is good.

DEFINE FILE EXPEDIENTS
MODX/A1=IF AGE EQ &MOD THEN '*' ELSE '';
END

Good day.