cancel
Showing results for 
Search instead for 
Did you mean: 

Function formula for standard dev. and correlation coefficient "r" in a inspection lot record result

0 Kudos
857

Hi gurus,

I need to define the formula for the average, standard deviation and correlation coefficient Peason between two multiple values from two characteristics in the record result in the inspection lot. The Average is not so complex formula, but the standard deviation and the correlation coeficient there is.

Standard deviation formula

Correlation coefficient formula

My question is, there is some function in Sap that could calculate this values more easy, like excel that have the function formula =CORREL(Correlation coefficient) and =STDEV(Standard deviation)? or any ideas to do this more easy in the record result process for an inspection lot?

Regards

View Entire Topic
AlbertMolnar
Product and Topic Expert
Product and Topic Expert
0 Kudos

Dear Juan Ramon Quintero Noguera,

thank you for the details provided.

I think complex formula calculations can be done by a custom function module.

Customizing:
IMG (transaction QCC0 or SPRO)
>Quality Management
>>Quality Inspection
>>>Results Recording
>>>>Define Parameters for Calculated Characteristics
-->Define Parameters for Calculated Characteristic

Related to standard deviation there are some posts already in Community:
'Standard deviation in abap'

'To calculate the standard deviation & mean with an internal table'

About the Pearson's correlation coefficient, I have found

Class/Interface CL_UPF_STATISTICS
Method CORREL
Correlation Coefficient (Bravais-Pearson)

...
* Calculation of the correlation coefficient r (Bravais-Pearson) for
* (the values of) two variables X und Y.
* (1) it_x_values and it_y_values must have the same number of values
* (2) i_x_mean resp. i_y_mean is optional. When given, the calculation
*     of the mean for X resp. Y is skipped.
*
* Formula:
*   r = cov_xy / (s_x * s_y)
*   where cov_xy is the covariance of X and Y and
*   s_x resp. s_y is the standard deviation of X resp. Y.
...

It has also a Method STDDEV
Standard Deviation

method STDDEV .

stddev = sqrt( var( it_values = it_values
i_mean = i_mean ) ).
endmethod.

Have a nice day,

Albert

***

Read and follow the 'SAP Community Rules of Engagement' at

https://www.sap.com/community/about/rules-of-engagement.html

0 Kudos

Hi,

Sorry for the late response. I'm doing exactly what you told, but i'm seeing different result values using the "Method CORREL" vs CORREL function from the excel.

For example, if you try the next values X=[1,2,3,4] and Y=[1,4,3,4] in SAP i get 0,957 but in excel 0,730. You know why is the difference between them?

Regards

AlbertMolnar
Product and Topic Expert
Product and Topic Expert

Dear juan_quintero_27,

thank you for the feedback. The class belongs to component BW-PLA-BPS. You might open a new thread with TAGs:

BW Analytic Engine (OLAP)

BW Business Explorer (SAP BEx)

SAP Business Planning and Consolidation, version for SAP BW/4HANA

In current QM-related thread I could collect this information.

Have a nice day,

Albert

***

Read and follow the 'SAP Community Rules of Engagement' at

https://www.sap.com/community/about/rules-of-engagement.html