",u+=1":"Since ("+n+") < 1, American odds = -100 / ("+n+") = "+(s=-100/i)+".
",o="
",o+="Fractional odds | "+n+" |
",o+="Decimal odds | "+b+" |
",o+="American odds | "+xrd(s,0)+" |
",o+="
",GEBI("bets_table").innerHTML=o,GEBI("bets_message").innerHTML=u}function calculate_probs(){var e=get_var("a"),a=e,t=get_var("b"),r=t;if(""==e||""==t)return!1;var l=GEBI("a_label").value,o=GEBI("b_label").value,i=get_var("digits"),n=e+t,b=xrd(e/n,i),s=html_frac([["P"+l+" = ",l],["",l+" + "+o]]);s+=html_frac([["P"+l+" = ",e," = "+b],["",e+" + "+t,""]]);var u=xrd(t/n);s+=html_frac([["P"+o+" = ",o],["",l+" + "+o]]),s+=html_frac([["P"+o+" = ",t," = "+u],["",e+" + "+t,""]]),GEBI("pa").value=b,GEBI("pb").value=u,display_blocks("result_block","");var c=reduce(e,t),d="The odds are "+e+" to "+t+". ";c[0]!=e&&(d+="
Divide by the greatest common divisor(GCD)
",d+="The odds are "+c[0]+" to "+c[1]+". ",n=(e=c[0])+(t=c[1])),d+=" ("+xrd(e/t,i)+").
",d+="It means that on average, from "+n+" events, "+e+" will be "+l+", and "+t+" will be "+o+".
",d+="The odds of "+l+" are "+e+":"+t+".
",d+="The odds of "+o+" are "+t+":"+e+".
",d+="The probability of "+l+" is "+b+".
",d+="The probability of "+o+" is "+u+".
",d+=s,GEBI("h1").innerHTML="Calculate probability from odds",GEBI("calc_message").innerHTML=d,calculate_charts(a,r,l,o),calculate_bets(e,t,l,o,i),gtag("event","measurements",{event_category:"odds",event_label:"calculate probability",value:e+":"+t})}function calculate_odds(e){var a,t,r,l,o="",i="
Step by step calculation
",n="",b=get_var("digits"),s=GEBI("a_label").value,u=GEBI("b_label").value;if("pa"==e){if(!(""!=(a=get_var("pa"))&&0<=a&&a<=1))return!1;t=xrd(1-a,b),i+="P"+u+" = 1 - P"+s+" = 1 - "+a+" = "+(GEBI("pb").value=t)+".
"}else{if(!(""!=(t=get_var("pb"))&&0<=t&&t<=1))return!1;a=xrd(1-t,b),i+="P"+s+" = 1 - P"+u+" = 1 - "+t+" = "+(GEBI("pa").value=a)+".
"}if(""==a&&""==t)return!1;var c=1*xrd(a/t,b),d="P"+s+"";i+=html_frac([[s+" = ",d," = ",d],["","P"+u+"","","1 - "+d]]),i+=html_frac([[s+" = ",a," = "+c],["",t,""]]);var h=1*xrd(t/a,b);if(c",n="Multiply by "+r+".
");i+="The odds are "+c+" to 1.
",i+="Since "+s+" < 1, divide "+s+" and "+u+" by "+s+".
",i+=s+"' = "+s+" / "+s+" = 1
",i+=u+"' = "+u+" / "+s+" = 1 / "+c+" = "+h+".
"}else{var v;if(l=1,!is_integer(r=c,.001))is_integer(v=1/Math.abs(c-Math.round(c)),.001)&&(r=xrd(c*(l=Math.round(v)),3),n+=u+" = 1.
",n+="Multiply by "+l+".
")}reduce1=reduce(r,l),c=reduce1[0],h=reduce1[1],GEBI("a").value=c,GEBI("b").value=h,display_blocks("result_block",""),o+="The odds are "+r+" to "+l+".
",reduce1[0]!=c&&(o+="The reduced odds are "+reduce1[0]+" to "+reduce1[1]+"."),o+="The probability of "+s+" is "+a+".
",o+="The probability of "+u+" is "+t+".
",o+=i+n,GEBI("h1").innerHTML="Calculate odds from probabiliy",GEBI("calc_message").innerHTML=o,calculate_charts(c,h,s,u),calculate_bets(c,h,s,u,b),gtag("event","measurements",{event_category:"odds",event_label:"calculate odds",value:a+":"+t})}function reduce(e,a){var t=function e(a,t){return t?e(t,a%t):a};return[e/(t=t(e,a)),a/t]}function is_integer(e,a){return Math.abs(e-Math.round(e))'+e+""}function td_up2(e){return''+e+" | "}function td_do(e){return''+e+" | "}function html_frac(e){for(var a="",t="
",r=0;r"+(a+="")+(t+="")+""}function xrd(e,a){if(void 0===a&&(a=6),"string"==typeof a&&(a=Number(a)),"infinite"==e)return"∞";if("ninfinite"==e)return"-∞";var t=Math.log10(1*Math.abs(e));10<(t=t<0?a:Math.round(t+.5)+a)&&(t=10);var r=(1*e).toPrecision(t);return"NaN"==(r=(1*r).toString())&&(r=e),r}function display_blocks(e,a){for(var t=e.split(","),r=0;r',console.log(r.innerHTML)})})}