Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Reg: Exponential statement in Cobol

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
chowdhrykapildev

New User


Joined: 05 Aug 2009
Posts: 44
Location: Hyderabad

PostPosted: Wed Jul 27, 2011 6:33 pm    Post subject: Reg: Exponential statement in Cobol
Reply with quote

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
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Jul 27, 2011 6:43 pm    Post subject: Reply to: Reg: Exponential statement in Cobol
Reply with quote

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.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed Jul 27, 2011 7:18 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
chowdhrykapildev

New User


Joined: 05 Aug 2009
Posts: 44
Location: Hyderabad

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

Hi,

Thanks for your replies.

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.
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Wed Jul 27, 2011 8:44 pm    Post subject:
Reply with quote

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.
Back to top
View user's profile Send private message
dick scherrer

Site Director


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

PostPosted: Wed Jul 27, 2011 8:59 pm    Post subject:
Reply with quote

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. . .
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Jul 27, 2011 10:36 pm    Post subject: Reply to: Reg: Exponential statement in Cobol
Reply with quote

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.
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


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

PostPosted: Wed Jul 27, 2011 11:05 pm    Post subject:
Reply with quote

I don't know COBOL instrinct functions, but does LOG use base 10 or base e?
Back to top
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7315

PostPosted: Wed Jul 27, 2011 11:10 pm    Post subject: Reply to: Reg: Exponential statement in Cobol
Reply with quote

Excellent question. It has LOG10 and LOG.

So LOG is base e. Useless guess following deleted.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts XML Parse for COBOL 5.2 Bhanu Praveen COBOL Programming 1 Sat Jul 08, 2017 8:58 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts Search utility(3.14) using JCl and Cobol RKS3 COBOL Programming 12 Sat Jun 10, 2017 10:24 pm
No new posts COBOL DB2 program - zIIP eligible vasanthz COBOL Programming 7 Wed May 31, 2017 5:12 am
This topic is locked: you cannot edit posts or make replies. Cobol GUI (like Editor) Kala Mainframe COBOL Programming 14 Wed May 10, 2017 12:30 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us