Show mean level and deviation in census window

Post suggestions or requests of WarcraftRealms UI Mods here
Post Reply
rogan
Posts: 2
Joined: Sat Jan 27, 2007 11:38 am

Show mean level and deviation in census window

Post by rogan »

Hi, I think it would be nice to see the mean level and the standard deviation in the census window.
I wrote a little patch, only problem seems to be the localization. Sorry i'm new to lua.

Code: Select all

--- CensusPlus.lua.org  2007-01-27 18:45:15.000000000 +0100
+++ CensusPlus.lua      2007-01-27 18:51:02.000000000 +0100
@@ -2454,6 +2454,7 @@ function CensusPlus_UpdateView()
                levelSearch = levelSearch..level..")";
        end
 
+       local maxChars = 0;
        local totalCharactersText = nil;
        if (levelSearch ~= nil) then
                totalCharactersText = format(CENSUSPlus_TOTALCHAR, g_TotalCount)..levelSearch;
@@ -2462,6 +2463,7 @@ function CensusPlus_UpdateView()
        end
        CensusPlusTotalCharacters:SetText(totalCharactersText);
        CensusPlusTotalCharacterXP:SetText(format(CENSUSPlus_TOTALCHARXP, g_TotalCharacterXP));
+       maxChars = g_TotalCount;
        CensusPlus_UpdateGuildButtons();
 
        if( CensusPlus_EnableProfiling ) then
@@ -2575,19 +2577,30 @@ function CensusPlus_UpdateView()
        -- Accumulate totals for each level
        --
        local maxCount = 0;
+       local levelSum = 0;
        for i = 1, MAX_CHARACTER_LEVEL, 1 do
-           if &#40;&#40;levelKey == nil&#41; or &#40;levelKey == i&#41; or &#40;levelKey < 0 and levelKey + i ~= 0&#41;&#41; then
+               if &#40;&#40;levelKey == nil&#41; or &#40;levelKey == i&#41; or &#40;levelKey <0> maxCount&#41; then
                                maxCount = g_AccumulatorCount;
                        end
                        g_LevelCount&#91;i&#93; = g_AccumulatorCount;
+                       levelSum = levelSum + g_AccumulatorCount * i;
                else
                        g_LevelCount&#91;i&#93; = 0;
                end
        end
 
+       -- Process level data and calculate deviation
+       local mean = floor&#40;levelSum / maxChars&#41;;
+       local deviation = 0;
+       for i = 1, MAX_CHARACTER_LEVEL, 1 do
+                       deviation = deviation + &#40;i-mean&#41;*&#40;i-mean&#41;*g_LevelCount&#91;i&#93;;
+       end
+       deviation = math.sqrt &#40;deviation / maxChars&#41;;
+       CensusPlusMeanCharacterLvl&#58;SetText&#40;format&#40;CENSUSPlus_MEANCHARLVL, mean, deviation &#41;&#41;;
+
        --
        -- Update level bars
        --
--- localization.de.lua.org     2007-01-27 18&#58;45&#58;15.000000000 +0100
+++ localization.de.lua 2007-01-27 18&#58;52&#58;05.000000000 +0100
@@ -64,6 +64,8 @@ if &#40; GetLocale&#40;&#41; == "deDE" &#41; then
        CENSUSPlus_TOTALCHAR_0          = "Charaktere Gesamte &#58; 0"; 
        CENSUSPlus_TOTALCHARXP          = "Charakter-XP Gesamte &#58; %d"; 
        CENSUSPlus_TOTALCHARXP_0        = "Charakter-XP Gesamte &#58; 0"; 
+       CENSUSPlus_MEANCHARLVL      = "Level Durschnitt &#58; %d &#40;s=%d&#41;";
+       CENSUSPlus_MEANCHARLVL_0    = "Level Durschnitt &#58; n/a";
        CENSUSPlus_AUTOCLOSEWHO         = "Who automatisch beenden"; 
        CENSUSPlus_SHOWMINI             = "Mini-Button beim Start";
        CENSUSPlus_UNGUILDED            = "&#40;ohne Gilde&#41;";
@@ -104,4 +106,4 @@ if &#40; GetLocale&#40;&#41; == "deDE" &#41; then
        CENSUSPLUS_EU_LOCALE            = "Bitte gib an, ob du auf einem EURO-Server spielst.";
        CENSUSPLUS_LOCALE_SELECT        = "Bitte gib an, ob du auf einem US- oder EURO-Server spielst.";
 
-end
\ No newline at end of file
+end
--- localization.lua.org        2007-01-27 18&#58;45&#58;15.000000000 +0100
+++ localization.lua    2007-01-27 18&#58;52&#58;15.000000000 +0100
@@ -63,6 +63,8 @@ CENSUSPlus_TOTALCHAR        = "Total Cha
 CENSUSPlus_TOTALCHAR_0      = "Total Characters&#58; 0";
 CENSUSPlus_TOTALCHARXP      = "Total Character XP&#58; %d";
 CENSUSPlus_TOTALCHARXP_0    = "Total Character XP&#58; 0";
+CENSUSPlus_MEANCHARLVL      = "Mean Level&#58; %d &#40;s=%d&#41;";
+CENSUSPlus_MEANCHARLVL_0    = "Mean Level&#58; n/a";
 CENSUSPlus_AUTOCLOSEWHO     = "Automatically Close Who";
 CENSUSPlus_SHOWMINI         = "Show Mini On Start";
 CENSUSPlus_UNGUILDED        = "&#40;Unguilded&#41;";
--- localization.fr.lua.org     2007-01-27 18&#58;45&#58;15.000000000 +0100
+++ localization.fr.lua 2007-01-27 18&#58;45&#58;31.000000000 +0100
@@ -64,6 +64,8 @@ if &#40; GetLocale&#40;&#41; == "frFR" &#41; then
     CENSUSPlus_TOTALCHAR_0      = "Nombre de personnages &#58; 0";
     CENSUSPlus_TOTALCHARXP      = "Nombre d'xp total &#58; %d";
     CENSUSPlus_TOTALCHARXP_0    = "Nombre d'xp total &#58; 0";
+    CENSUSPlus_MEANCHARLVL      = "Mean Level&#58; %d &#40;s=%d&#41;";
+    CENSUSPlus_MEANCHARLVL_0    = "Mean Level&#58; n/a";
     CENSUSPlus_AUTOCLOSEWHO     = "Fermeture auto du /Who";
     CENSUSPlus_SHOWMINI         = "Montrer Mini au d?marrage";
     CENSUSPlus_UNGUILDED        = "&#40;Sans Guilde&#41;";
@@ -104,4 +106,4 @@ if &#40; GetLocale&#40;&#41; == "frFR" &#41; then
        CENSUSPLUS_EU_LOCALE            = "Choisissez si vous jouez sur un serveur EURO";
     CENSUSPLUS_LOCALE_SELECT    = "Choisissez la localit? de votre serveur";
     
-end
\ No newline at end of file
+end
--- CensusPlus.xml.org  2007-01-27 18&#58;45&#58;15.000000000 +0100
+++ CensusPlus.xml      2007-01-27 18&#58;45&#58;31.000000000 +0100
@@ -329,6 +329,15 @@
                         </Anchor>
                     </Anchors>
                 </FontString>
+                <FontString>
+                    <Anchors>
+                        <Anchor>
+                            <Offset>
+                                <AbsDimension>
+                            </Offset>
+                        </Anchor>
+                    </Anchors>
+                </FontString>
                 <FontString>
                     <Anchors>
                         <Anchor>

User avatar
Rollie
Site Admin
Posts: 4783
Joined: Sun Nov 28, 2004 11:52 am
Location: Austin, TX
Contact:

Post by Rollie »

I'll have to check this out =)
phpbb:phpinfo()

Skyfire
Trolling Enforcement
Posts: 708
Joined: Thu Aug 18, 2005 2:29 am
Location: New Jersey

Post by Skyfire »

I like this idea, but it should probably be restricted to the website (imo).

Maybe the median should be represented also, or else we're gonna' get a very, very, big skew with the mean alone, since most people are going to have characters between 60 and 70.
Admin on WoWWiki
Moderator, Blogger on Wowhead

Post Reply