The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > High Level Programming
.
google unix.com



High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How To Calculate krishna_sicsr Shell Programming and Scripting 3 03-21-2009 01:49 PM
Unix Arithmatic operation issue , datatype issue thambi Shell Programming and Scripting 23 02-19-2008 07:19 AM
syntax issue in ksh file manav666 Shell Programming and Scripting 2 10-30-2007 07:52 AM
calculate output amon Shell Programming and Scripting 3 04-12-2006 09:02 AM
How to calculate with awk whatisthis Shell Programming and Scripting 4 11-09-2005 12:39 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 08-01-2006
madhunk madhunk is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 91
Calculate scores and probability -- Syntax issue

Hi,

I am totally new to C programming on Sun Solaris environment. I am an active member on the UNIX forum and a good shell programmer.

I am trying to achieve some calculations in C programming. I have the pseudo code written down but don't know the syntax. I am reading a couple of books on C programming but still need some help.

Code:
#include <stdlib.h>
#include <stdio.h>

int transRiskLock,
    transRiskAdj,
    empirica;

double transRiskProb,
       transRiskNorm,
       fico;

   //Restrict range of transRiskScore from daily Trans-Union file PRM.JUNIPER.CSREJ.D*

   if (transRiskScore > 900)
      transRiskLock = 900;

   else
   if(transRiskScore < 150)
      transRiskLock = 150;

   else
      transRiskLock = transRiskScore;

   //Force score range between 150 and 900

   if (transRiskScore is missing)
      transRiskLock is missing;  //Handle missing values - missing transRiskScore should result in missing empirica


   for each record in recordset  //Loop through each record

      //Transrisk normalization Phase 1: Map transRiskScore to estimated probability

      if (transRiskLock >= 150 and < 257.14286)

         transRiskAdj = transRiskLock – 150;
         transRiskProb = 0.84415864 - (1.0488722e-005 * (transRiskAdj)2) + (3.2397817e-008 * (transRiskAdj)3);

      else
      if (transRiskLock >= 257.14286 and < 364.28571)

         transRiskAdj = transRiskLock – 257.14286;
         transRiskProb = 0.7636003 – (0.001131842 * transRiskAdj) – (2.0788434e-005 * (transRiskAdj)2) + (9.3295162e-008 * (transRiskAdj)3);

      else
      if (transRiskLock >= 364.28571 and < 471.42857)

         transRiskAdj = transRiskLock – 364.28571;
         transRiskProb = 0.51843775 – (0.0023735353 * transRiskAdj) – (6.0623834e-006 * (transRiskAdj)2) + (4.8571025e-008 * (transRiskAdj)3);

      else
         ;

      //Transrisk normalization Phase 2: Map estimated probability to EMPIRICASCORE

      if (transRiskProb >= 0 and < 0.00015241579)

         transRiskNorm = 820.36625 – (69591.494 * transRiskProb) – (1.312436e+008 * (transRiskProb)2) + (9.7484131e+011 * (transRiskProb)3);

      else
      if (transRiskProb >= 0.00015241579 and < 0.0024386526)

         transRiskNorm = 810.16217 – (41660.32 * (transRiskProb - 0.00015241579)) + (7018993.8 * (transRiskProb - 0.00015241579)2) +
         (1.8073426e+008 * (transRiskProb - 0.00015241579)3);

      else
      if (transRiskProb >= 0.0024386526) and <  0.012345679)

         transRiskNorm = 753.764 – (6732.1274 * (transRiskProb - 0.0024386526)) + (638606.42 * (transRiskProb - 0.0024386526)2) -
         (28380051 * (transRiskProb - 0.0024386526)3);

       
      else
         ;

   fico = round(transRiskNorm);  //Round to zero decimals
   empirica = (int) fico;  //cast to integer

   score_aligned = compress('+0000' || input(left(EMPIRICA),$8.))  // convert to string by adding "+" and four leading zeros, remove spaces from result
The input value is the transRiskScore here...and translate transRiskScore to Empirica score.

Please advise..
Thank You,
Madhu
  #2 (permalink)  
Old 08-01-2006
madhunk madhunk is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 91
Any body who is an expert in C...Can you please help with the syntax here? If you can give me a heads up, then I can work the rest of the thing..
  #3 (permalink)  
Old 08-01-2006
blowtorch's Avatar
blowtorch blowtorch is offline Forum Advisor  
Supporter
  
 

Join Date: Dec 2004
Location: Singapore
Posts: 2,350
madhunk, please do not 'bump' up your posts. That goes against the rules of the forum.
  #4 (permalink)  
Old 08-01-2006
nathan nathan is offline VIP Member  
Supporter
  
 

Join Date: Jul 2006
Posts: 156
This is the 1st thing that stands out:

Quote:
for each record in recordset //Loop through each record
C does not have a 'foreach'. You'll have to use a 'for' loop for this. If 'recordset' is defined as an array, it would be something like:

Code:
int i;
for( i = 0; recordset[i] ; i++ ) {
 /* stuff goes here */
}
This:
Quote:
if (transRiskLock >= 150 and < 257.14286)
becomes:
Code:
if (transRiskLock >= 150 && transRiskLock < 257.14286)
and this
Quote:
if (transRiskScore is missing)
transRiskLock is missing;
becomes
Code:
   if (transRiskScore == 0)
      transRiskLock = 0;

Last edited by nathan; 08-01-2006 at 10:17 PM.. Reason: Add some more content
  #5 (permalink)  
Old 08-03-2006
madhunk madhunk is offline
Registered User
  
 

Join Date: Nov 2005
Posts: 91
Thank You Nathan....I appreciate your help. I got the idea and working on it...
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 05:47 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0