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
-
Matt,
Look for McBasicStatistics in the automation help. This is also exposed as McApplication.GlobalTools.McBasicStatistics. GlobalTools exposes many useful array processing utilities.
Pierre0 -
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
0 -
Pierre --
I've tried to use your suggestion but I'm hitting some roadblocks.
Searching PREMIER APPLICATION HELP for MCBASICSTATISTICS only locatesImage-Pro Premier Automation Help
McBasicStatistics Method (ArrayToTest)Automation Reference ► MediaCy.IQL.ObjectManager ► IMcOMGlobal ► McBasicStatistics(Object) Visual Basic
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
0 -
Matt,
You would have to use ThisApplication.GlobalTools.McBasicStatistics.
Pierre0 -
Pierre --
Thank you for the response.
I've changed my TEST ROUTINE toSub Test () Dim MyDataArray (3) As Single MyDataArray (1) = 10 MyDataArray (2) = 20 MyDataArray (3) = 25 Dim MyStats (8) As Single MyStats = ThisApplication.GlobalTools.McBasicStatistics(MyDataArray) End Sub
and now theMyStats = ThisApplication.GlobalTools.McBasicStatistics(MyDataArray)
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
0 -
Here is the code.
PierreSub 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
0 -
Pierre --
Thanks for the additional information.
It is working now.
My code is nowSub 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 generates
MyStats.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 yield10 20 25 18.33333 7.637626
Your thoughts on this?
Thanks again for your assistance on this.
-- Matt
0 -
Pierre and Craig --
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 with10 20 25 '=STDEV($B$1:$B$3) 7.637626158 '=STDEV.S($B$1:$B$3) 7.637626158 '=STDEV.P($B$1:$B$3) 6.236095645 '=STDEVA($B$1:$B$3) 7.637626158 '=STDEVPA($B$1:$B$3) 6.236095645 '=STDEVP($B$1:$B$3) 6.236095645
I'll confirm with the customer which STDEV is appropriate for their application.
Thanks again.
-- Matt
0
Categories
- All Categories
- 961 Image-Pro v9 and higher
- 9 Image-Pro FAQs
- 18 Image-Pro Download & Install
- 448 Image-Pro General Discussions
- 486 Image-Pro Automation (Macros, Apps, Reports)
- 20 AutoQuant Deconvolution
- 2 AutoQuant Download & Install
- 18 AutoQuant General Discussions
- 195 Image-Pro Plus v7 and lower
- 3 Image-Pro Plus Download & Install
- 106 Image-Pro Plus General Discussions
- 86 Image-Pro Plus Automation with Macros
- 19 Legacy Products
- 16 Image-Pro Premier 3D General Discussions
- 26 Image-Pro Insight General Discussions