# it's math related!

• 10-12-2012, 01:00 AM
bleaze
it's math related!
:)hi everyone...i'm new here...

probability=1/(1+(EXP((1.059)-(A8*1.37)+(-2.578*B8)+(-0.568*C8)+(0.987*D8)+(0.987*E8)+(1.205*F8)+(-1.795*G8)+(-0.645*H8))))

?? in php

i need to know it very badly!!

i'm calculating the probability of a person to have hypertension. . .

letterrs A-H stands for kasarian,weight, heredity, exercise, softdrink, likor, smoke, pork... accordingly ... i need to submit my system the very next week...

hope can get answers from you ASAP guys!! thanks in advance... God bless..
• 10-12-2012, 09:05 AM
xelawho
I'm guessing that you would make user inputs, get their values, assign them to variables A8 to H8, place that line of code, then output probability to the page

what are you stuck on?
• 10-16-2012, 08:45 PM
bleaze
function calculate()
{
var ka = parseFloat(document.hyp_frm.kasarian.value);
var wt = parseFloat(document.hyp_frm.weight.value);
var he = parseFloat(document.hyp_frm.heredity.value);
var ex = parseFloat(document.hyp_frm.exercise.value);
var so = parseFloat(document.hyp_frm.softdrink.value);
var li = parseFloat(document.hyp_frm.likor.value);
var sm = parseFloat(document.hyp_frm.smoke.value);
var po = parseFloat(document.hyp_frm.pork.value);
if (document.hyp_frm.kasarian.value == "0") {ka = ka * (1.37);}
if (document.hyp_frm.weight.value == "0") {wt = wt * (-2.578);}
if (document.hyp_frm.heredity.value == "0") {he = he * (-0.568);}
if (document.hyp_frm.exercise.value == "0") {ex = ex * (0.987);}
if (document.hyp_frm.softdrink.value == "0") {so = so * (0.987);}
if (document.hyp_frm.likor.value == "0") {li = li * (1.205);}
if (document.hyp_frm.smoke.value == "0") {sm = sm * (-1.795);}
if (document.hyp_frm.pork.value == "0") {po = po * (-0.645);}
pro="1/1+(EXP((1.059)-(1.37 * ka)+(-2.578 * wt)+(-0.568*he)+(0.987*ex)+(0.987*so)+(1.205*li)+(-1.795*sm)+(-0.645*po)))";
document.getElementById(sub3).value=pro;
}

This is the code i'm using and it simply didnt work....

I guess the problem is in the exponent(EXP)...do you have any idea how to make it work?
• 10-17-2012, 12:46 PM
JMRKER
Modified in next post
• 10-17-2012, 01:05 PM
JMRKER
Assuming it is the natural logarithm you are trying to convert from Excel,
the equivalent javascript command would be log() and/or pow().
See: http://www.w3schools.com/jsref/jsref_log.asp
Code:

```<script type="text/javascript"> alert(Math.E+'\n'+Math.log(Math.E)+'\n'+Math.pow(Math.E,1)); </script>```

## X vBulletin 4.2.2 Debug Information

• Page Generation 0.08125 seconds
• Memory Usage 2,358KB
• Queries Executed 11 (?)
Template Usage (20):
• (1)bbcode_code_printable
• (1)footer
• (1)gobutton
• (1)navbar_moderation
• (1)navbar_noticebit
• (2)option
• (1)spacer_close
• (1)spacer_open

Phrase Groups Available (3):
• global
• postbit
Included Files (19):
• ./global.php
• ./includes/class_bootstrap.php
• ./includes/init.php
• ./includes/class_core.php
• ./includes/config.php
• ./includes/functions.php
• ./includes/class_friendly_url.php
• ./includes/class_hook.php
• ./includes/class_bootstrap_framework.php
• ./vb/vb.php
• ./vb/phrase.php
• ./includes/functions_calendar.php
• ./includes/class_bbcode_alt.php
• ./includes/class_bbcode.php
• ./includes/functions_bigthree.php
• ./includes/functions_notice.php

Hooks Called (41):
• init_startup
• init_startup_session_setup_start
• database_pre_fetch_array
• database_post_fetch_array
• init_startup_session_setup_complete
• global_bootstrap_init_start
• global_bootstrap_init_complete
• cache_permissions
• fetch_foruminfo
• global_state_check
• global_bootstrap_complete
• global_start
• style_fetch
• global_setup_complete
• bbcode_fetch_tags
• bbcode_create
• bbcode_parse_start
• bbcode_parse_complete_precache
• bbcode_parse_complete
• cache_templates
• cache_templates_process
• template_register_var
• template_render_output
• fetch_template_start
• fetch_template_complete
• parse_templates