× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.




On 16/02/2010, at 7:49 AM, James Newman, CDP wrote:

Anyone know a simple way to do this inside RPG?

STDDEV is a fairly simple calculation--although I think you're actually after a Sample Standard Deviation. Really just a sequence of addition, division, subtraction, squaring, addition, division, and square root--all of which can be done in RPG (even OPM RPG). Hardest part is keeping track of the stages but since you already know the limits (i.e., 60 values) arrays with that number of elements will suffice. Two arrays should do the trick: One array will hold the 60 original values, the other array will hold the calculated deviations from the mean, square them in place (i.e., same array), sum that array (XFOOT) and divide by one less than the number of elements, then calculate the square root of the final sum.

Load the array with the first 60 records and run the STDDEV calculation. As you process each new record (after the first 60) just shift up the elements in the first array, thus dropping the first element, and add the new element at the end. Then run through the STDDEV function again.

Is there a way to call a function in another language?

Yes, Use RPG IV, prototype the foreign function, and link to it at bind time. However, I'm not sure I see the relevance unless you hope to find a STDDEV function already written in another language.

Regards,
Simon Coulter.
--------------------------------------------------------------------
FlyByNight Software OS/400, i5/OS Technical Specialists

http://www.flybynight.com.au/
Phone: +61 2 6657 8251 Mobile: +61 0411 091 400 /"\
Fax: +61 2 6657 8251 \ /
X
ASCII Ribbon campaign against HTML E-Mail / \
--------------------------------------------------------------------




As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.