Is there a mechanism to perform STATISTICS on a MACRO GENERATED ARRAY in a PREMIER APPLICATION?
ALL --
I would like to GENERATE an ARRAY of STATISTICS (or MEAN(), STDDEV(), etc) from an ARRAY of VALUES within a PREMIER APPLICATION.
I don't see anything appropriate within the
** Math Group
**** Abs, Atn, Cos, Exp, Fix, Int, Log, Randomize, Rnd, Round, Sgn, Sin, Sqr, Tan.
I see some EXAMPLE CODE on the web that does this in a reasonably straight forward way but I'm wondering if there is something already built into PREMIER that I'm missing.
Thanks in advance.
-- Matt
I would like to GENERATE an ARRAY of STATISTICS (or MEAN(), STDDEV(), etc) from an ARRAY of VALUES within a PREMIER APPLICATION.
I don't see anything appropriate within the
** Math Group
**** Abs, Atn, Cos, Exp, Fix, Int, Log, Randomize, Rnd, Round, Sgn, Sin, Sqr, Tan.
I see some EXAMPLE CODE on the web that does this in a reasonably straight forward way but I'm wondering if there is something already built into PREMIER that I'm missing.
Thanks in advance.
-- Matt
0
Best Answer
-
The GlobalTools.McBasicStatistics reports the Population Variance, Sum of squared deviations from the mean / N, and the StdDev as the Sqrt of that. Excel can compute either the same population standard deviation, STDDEV.P, or it can compute the standard deviation based on the Sample Variance, Sum of squared deviations from the mean / (N-1), STDDEV.S. The default STDDEV in Excel 2010, at least, is STDDEV.S.
You can get the Sample Standard Deviation from the Population Standard Deviation by:
STDDEV.S = Sqrt( STDDEV.P * STDDEV.P * N / (N-1) )
0
Answers
Look for McBasicStatistics in the automation help. This is also exposed as McApplication.GlobalTools.McBasicStatistics. GlobalTools exposes many useful array processing utilities.
Pierre
Thank you for your suggestion.
I'll look into it and post a bit of EXAMPLE CODE this AM if I can get it working.
Thanks again.
-- Matt
I've tried to use your suggestion but I'm hitting some roadblocks.
Searching PREMIER APPLICATION HELP for MCBASICSTATISTICS only locates
McBasicStatistics Method (ArrayToTest)
when I add
MediaCy.IQL.ObjectManager.dll
to the REFERENCE LIST for my appliction, I still get an EXPECTING VARIABLE NAME ERROR when I try to load my APP with the following test code . . .
Sub Test () Dim MyDataArray (3) As Single MyDataArray (1) = 1 MyDataArray (2) = 2 MyDataArray (3) = 3 Dim MyStats (8) As Single MyStats = McBasicStatistics(MyDataArray) End Sub
that seems to indicate that McBasicStatistic is not a recognized FUNCTION.Can you please let me know what I'm doing wrong here?
Thanks.
-- Matt
You would have to use ThisApplication.GlobalTools.McBasicStatistics.
Pierre
Thank you for the response.
I've changed my TEST ROUTINE to
and now the
line generates a TYPE MISMATCH ERROR.
I tried making MYSTATS a VARIANT as shown in the HELP FILE
Dim varBasicStats As Variant 'will be 2-D array of BASIC_STATISTICS varBasicStats = McBasicStatistics(varProfiles)
but VARIANT is not a VARIABLE TYPE within my PREMIER.
Where have I goofed up?
Thanks.
-- Matt
Pierre
Sub Test () Dim MyDataArray (2) As Single MyDataArray (0) = 10 MyDataArray (1) = 20 MyDataArray (2) = 25 Dim MyStats As mediacy.IQL.ObjectManager.BASIC_STATISTICS MyStats = ThisApplication.GlobalTools.McBasicStatistics(MyDataArray) End Sub
Thanks for the additional information.
It is working now.
My code is now
Sub Test2 () Dim MyDataArray (2) As Single MyDataArray (0) = 10 MyDataArray (1) = 20 MyDataArray (2) = 25 Dim MyStats As mediacy.IQL.ObjectManager.BASIC_STATISTICS 'BASIC_STATISTICS ' AverageAbsDev ' Count ' CountOfMissing ' IndexOfMaximum ' IndexOfMinimum ' Maximum ' Mean ' Minimum ' NormalizedKurtosis ' NormalizedSkew ' Range ' RawKurtosis ' RawSkew ' StdDev ' Sum ' Variance MyStats = ThisApplication.GlobalTools.McBasicStatistics(MyDataArray) Debug.Print "MyStats.Count" Debug.Print MyStats.Count Debug.Print "MyStats.Mean" Debug.Print MyStats.Mean Debug.Print "MyStats.StdDev" Debug.Print MyStats.StdDev End Sub
and generatesMyStats.Count
3
MyStats.Mean
18.3333333333333
MyStats.StdDev
6.23609564462324
in the DEBUG PANE.
But . . .
The STDDEV generated by MCBASICSTATS is different than the STDEV generated by EXCEL. The three data points pushed through the EXCEL AVERAGE and STDEV functions yield
Your thoughts on this?
Thanks again for your assistance on this.
-- Matt
Thank you for providing the info that addresses my request for a STATISTICS MECHANISM for USER GENERATED ARRAYS within PREMIER MACROS.
I have confirmed the information provide by CRAIG with
I'll confirm with the customer which STDEV is appropriate for their application.
Thanks again.
-- Matt