Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

std deviation and square root

Vijay
Active Contributor
0 Likes
915

hi all

i have a requirement where i need to calculate the standard deviation and squre root of some variables.

can anybody please tell how can i calculate that in abap.

regards

vijay

3 REPLIES 3
Read only

Former Member
0 Likes
595

You can use the function module

1. 'QRKT_STD_DEVIATION_SHEWHART'-Algorithms for Shewhart chart for s with internal dispersion and mean line

2.'QRKT_STD_DEVIATION_SHEWHART_2'- Algorithms for Shewhart chart for s with overall dispersion and mean line.

You could also calculate it yourself of course - standard deviation is the square root of the sum of the square of the differences between the mean and each value divided by the number of values you have less one.

Reward points..

Read only

Former Member
0 Likes
595

Hi,

try this code..


data : begin of it occurs 1,
num type p,
x_xbar type p, 
end of it.

data : num1 type p value 10.
data : tot type p,l(2),
total type p. " E(x - mean)^2
data : mean type p.
data : var type p,
sd type p.

do 5 times .
it-num = num1.
append it.
num1 = num1 + 10.
enddo.

loop at it .
tot = tot + it-num.
endloop.

describe table it lines l.

mean = tot / l.

loop at it .
it-x_xbar = ( it-num - mean ) * ( it-num - mean ).
total = total + it-x_xbar.
endloop.

var = ( total ) / ( l - 1 ).
sd = SQRT( var ).

write : sd.

for square root


DATA : in TYPE f VALUE 16 ,
out TYPE f .

CALL METHOD cl_foev_builtins=>square_root
EXPORTING
im_number = in
IMPORTING
ex_result = out.

WRITE out.

Regards,

Omkar.

Read only

Former Member
0 Likes
595

Hi,

You can use the SQRT to compute the square root.

Check the code.

data: var(3) type n,

sqt(3) type n.

var = 100.

sqt = sqrt( var ).

write: / sqt.

For Std deviation, you need to compute it manually or by using the function module

'QRKT_STD_DEVIATION_SHEWHART'

Reward if helpful.

Regards.