Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
chowdhrykapildev

New User

Joined: 05 Aug 2009
Posts: 44

Posted: Wed Jul 27, 2011 6:33 pm    Post subject: Reg: Exponential statement in Cobol

Hi,

I have a requirement where I need to code the below statement in Cobol.

 Code: Adjusted_score = 1 / ( 1 + exp( -log( (unadj_riskscore) / (1 - (unadj_riskscore) ) ) - AF_new ) );

Can someone help me how can I do this in a Compute Statement?

Thanks,
KC

Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7315

 Posted: Wed Jul 27, 2011 6:43 pm    Post subject: Reply to: Reg: Exponential statement in Cobol Look at what mathematical intrinsic functions are available. Split it into more than one compute, into "logical" smaller parts. Make sure you know about how the compute treats intermediate values, and take account of that in data definitions. Come back if you get stuck.
Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8154
Location: East Dubuque, Illinois, USA

 Posted: Wed Jul 27, 2011 7:18 pm    Post subject: Which version of COBOL ar eyou using? Assuming you're using Enterprise COBOL, the LOG function is available. You will have to use exponentiation with whatever value of e you deem acceptable as a substitute for the EXP function.
chowdhrykapildev

New User

Joined: 05 Aug 2009
Posts: 44

Posted: Wed Jul 27, 2011 8:24 pm    Post subject: Reply to: Reg: Exponential statement in Cobol

Hi,

I had coded in the below way but unable to confirm whether it is correct or not.

 Code: COMPUTE Adjusted_score ROUNDED                                  = 1 / ( 1 + ( WS-E ** ( -                                         FUNCTION LOG ( ( unadj_riskscore)                  / (1 - ( unadj_riskscore) ) ) -                          AF_new ) ) )                            ON SIZE ERROR                                              MOVE 'PROBQUE ' TO WS-ON-SIZE-ERROR-NAME            END-COMPUTE

where WS-E is defined as below:
 Code: 05  WS-E                        COMP-2                                         VALUE      +2.71828182845904E+00.

The compilation and even the execution of the pgm went fine.
But I'm still having a doubt whether what has been mentioned in the requirement and the above Compute statement does the same calculation or is that I had missed something here in Cobol ?

Thanks,
KC.
Robert Sample

Global Moderator

Joined: 06 Jun 2008
Posts: 8154
Location: East Dubuque, Illinois, USA

 Posted: Wed Jul 27, 2011 8:44 pm    Post subject: What causes you to doubt the COBOL results? Unless you have something causing you to doubt the computer results (be they from COBOL, SAS, PL/I, ASSEMBLER, or whatever), you should accept that the computer knows how to do arithmetic. The results may or may not be accurate enough, depending upon such things as intermediate resutls (in COBOL), but the computer will do the calculation however you coded it. If you're asking whether or not you used the right formula, or coded it correctly in COBOL -- how could we possibly know that? That would require you to go back to the program specifications and compare your results and code to them.
dick scherrer

Site Director

Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

 Posted: Wed Jul 27, 2011 8:59 pm    Post subject: Hello, Suggest you do a few of these calculations "by hand" (using a calculator) and compare the results to the output from your code. . . If they are the same - you're probably good to go. If not, resolve. . .
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7315

 Posted: Wed Jul 27, 2011 10:36 pm    Post subject: Reply to: Reg: Exponential statement in Cobol I agree with Robert and Dick. There's not much we can do with what we have. You presumably have an actuary or loss-adjustor behind this calculation, so make friends with them and ask them to help you work through some examples to check out the code. You'll learn a lot at the same time. I would say in your original you specify -log, which is different from what you have coded in the compute (which is subtract the log) but I don't know which, if either, is a typo.
Akatsukami

Global Moderator

Joined: 03 Oct 2009
Posts: 1775
Location: Bloomington, IL

 Posted: Wed Jul 27, 2011 11:05 pm    Post subject: I don't know COBOL instrinct functions, but does LOG use base 10 or base e?
Bill Woodger

DFSORT Moderator

Joined: 09 Mar 2011
Posts: 7315

 Posted: Wed Jul 27, 2011 11:10 pm    Post subject: Reply to: Reg: Exponential statement in Cobol Excellent question. It has LOG10 and LOG. So LOG is base e. Useless guess following deleted.
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Extract all "IF" Statements... Adarsh Damodaran CLIST & REXX 1 Wed Sep 06, 2017 9:28 am WER268A OUTREC STATEMENT : SYNTAX E... frozenblood87 SYNCSORT 12 Sat Aug 26, 2017 9:45 pm ALPHABETIC check in COBOL vidyaa COBOL Programming 8 Thu Aug 17, 2017 7:13 pm Suppress value reported by BREAK in D... Learncoholic DFSORT/ICETOOL 3 Wed Aug 16, 2017 6:03 pm ON 2 AND EVERY 1 - Statement ??? UmeySan COBOL Programming 2 Tue Jul 25, 2017 1:20 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us