Home Image-Pro Automation (Macros, Apps, Reports)

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

Best Answer

  • Accepted 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) )

Answers

  • Matt,

    Look for McBasicStatistics in the automation help. This is also exposed as McApplication.GlobalTools.McBasicStatistics. GlobalTools exposes many useful array processing utilities.

    Pierre
  • 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
  • Pierre --

    I've tried to use your suggestion but I'm hitting some roadblocks.

    Searching PREMIER APPLICATION HELP for MCBASICSTATISTICS only locates

    Image-Pro Premier Automation Help
    McBasicStatistics Method (ArrayToTest)
    Automation ReferenceMediaCy.IQL.ObjectManagerIMcOMGlobal ► 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


  • Matt,

    You would have to use ThisApplication.GlobalTools.McBasicStatistics.

    Pierre
  • Pierre --

    Thank you for the response.

    I've changed my TEST ROUTINE to

    Sub 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 the
        MyStats = 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


  • Here is the code.

    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
  • Pierre --

    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 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 yield

    10
    20
    25
    18.33333
    7.637626

    Your thoughts on this?

    Thanks again for your assistance on this.

    -- Matt


  • 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 with


    10

    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



Sign In or Register to comment.