ÿþ<HTML> <HEAD> <TITLE>Power Mean Inequality Curve</TITLE> <!-- 99,03,05,15,23 ªQGW NI{_òfÚ} --> <META http-equiv=Content-Type content="text/html; charset=big5"> <style type="text/css"> v\:* { behavior: url(#default#VML); } </style> <!-- The Cauchy-Schwarz Master Class author --> <meta name="author" content="J. Michael Steele" /> <!-- XYGraph v2.3 code author --> <meta name="author" content="J. Gebelein" /> <!--powmean2.htm author --> <meta name="author" content="Liu, HsinHan ‰Rk”"o &#21129;&#37995;&#28450;" /> <script type="text/javascript"> <!-- //If can not load jsgraph2.js next definition is //effective, tell user where to get jsgraph2.js var msg01='document.getElementById("gotoFM2msg").innerHTML+=\''; var msg02=' goto online to get http://freeman2.com/jsgraph2.js<br>\';'; function stepf(t0,bgn0) //9712091955 {eval(msg01+'01'+msg02);} function loggamma(x) {eval(msg01+'02'+msg02);} function gamma(x) {eval(msg01+'03'+msg02);} function factorial(n) {eval(msg01+'04'+msg02);} function wipeCurve(d3) {eval(msg01+'05'+msg02);} function DrawGraf2(argd2) {eval(msg01+'06'+msg02);} function closeStr(klozID) {eval(msg01+'07'+msg02);} function toSyntax(inStr1) {eval(msg01+'08'+msg02);} function x2t(in0) {eval(msg01+'09'+msg02);} function deleteData(workID,probID) {eval(msg01+'10'+msg02);} function delAll(probID) {eval(msg01+'11'+msg02);} function openTable(drawID,table01) {eval(msg01+'12'+msg02);} function open0lxr(xx) {eval(msg01+'13'+msg02);} function closelxr(yy) {eval(msg01+'14'+msg02);} //9712092032 //if receive http://freeman2.com/jsgraph2.js // jsgraph2.js redefine above functions, //otherwise tell where to find jsgraph2.js function XYGraph(yy) {eval(msg01+'101'+msg02);} //9801260855 function XYLine(yy) {eval(msg01+'102'+msg02);} //9801260857 function Label(yy) {eval(msg01+'103'+msg02);} //9801260859 function tutelink() //9806231220 { document.getElementById("gotoFM2msg").innerHTML+= '50 goto online to get http://freeman2.com/tutelink.js<br>'; } function initial0(linkNum, plotNum) { tuteLink(0); //9806231221 //http://freeman2.com/tutelink.js //if use tutelink(0) when offline, get error 9711252125 QEspanAlertpPow2.innerHTML=AlertpPow2; //9903011049 } function alert0() //9806161720 { document.write('<font color=red>' +'This file is personal home work. No one<br>' +'proofread. Cannot promise correctness.<br>' +'If you suspect any view point wrong,<br>' +'please ask a math expert near by. <br>' +'Freeman 2009-06-19-10-46</font><br>' ); } //9806161724 var AlertpPow2='' //9903011048 +'length (GM) compare length (AM) OK, require "pk=1 exactly.' //--> </SCRIPT> <script src="http://freeman2.com/tutelink.js" language="javascript"></script><!--9806111210--> <script src="tutelink.js" language="javascript"></script><!--9806111211--> <script type="text/javascript" src=jsgraph2.js> </script><!--9801101328--> </HEAD> <body link="#FF0000" vlink="#0000FF" alink="#50A000" bgcolor="#ccfcfc" onload="javascript:initial0()" > <span id="gotoFM2msg"></span><!--9712091951--> <font size=+2><a href=#powMeanBgn> Power Mean Inequality Curve</a> </font> <br> <a href=#powMeanBgn> program </a> &nbsp; <a href=#powMeanClick> click </a> &nbsp; <a href=#docA033> explore </a> &nbsp; <a href=#docA001> help </a> &nbsp; <a href=#docA051> Update 2010-03-06 </a> <br> <a href=http://www.structura.info/XYGraph/XYGraphDemo.htm> XYGraph v2.3 - web page graph </a> &nbsp; <!--9506231219 add link--> <a href=http://www.structura.info/XYGraph/Links.htm> && <!--##9756;##9758;--> </a> &nbsp; <!--9506231216 add link--> <a href=http://www.structura.info/XYGraph/Purchase.htm> donate<!--9801031950 use donate ##9829;##9835; e&k&--> </a> &nbsp; <a href="http://www.structura.info/XYGraph/XYGraph.zip"> get code</a> <!-- 2006-06-12-18-21 download http://www.structura.info/XYGraph/XYGraph.zip C:\$fm\js\xygraph\XYGraph.zip 2006-06-19-08-21 record --> <br> <a href=http://www-stat.wharton.upenn.edu/~steele/Publications/Books/CSMC/CSMC_index.html> The Cauchy-Schwarz Master Class </a> &nbsp; <a href=http://www-stat.wharton.upenn.edu/~steele/index.html> J. Michael</a> <a href=http://www.wharton.upenn.edu/faculty/steele.html> Steele</a> &nbsp; <a href=http://www.amazon.com/review/product/052154677X/ref=cm_cr_dp_all_helpful?%5Fencoding=UTF8&coliid=&showViewpoints=1&colid=&sortBy=bySubmissionDateDescending> &&&&& </a><!--9806081839 add link--> <br> <font color=red> This file is personal home work. No one <br> proofread. Cannot promise correctness. <br> If you suspect any view point wrong, <br> please ask a math expert near by. <br> Freeman 2009-06-19-10-46</font> <br> Please use MSIE browser to read this file. <br> Did not test other browser. This file is <br> <!--9806081846--> written under MSIE 6.0 <br> <span id="tutelink1"></span> <br> <script src="http://freeman2.com/rocsitee.js" language="javascript"></script> <br> <a name="powMeanBgn">&lt;a name="powMeanBgn"&gt;</a> 2010-02-19-12-53 <br><font color=red><b> Output may contain error, Please verify first <br> Program environment is MSIE 6.0, please use MSIE <br> If you save this file powmean2.htm to your computer <br> and open local powmean2.htm, it can not draw figure. <br> You need also save http://freeman2.com/jsgraph2.js <br> to your computer stay in same folder as powmean2.htm </b></font> <br> <a name="contralCenter"></a><!--9903032107--> Graph area size, W: <INPUT id=QEboxWidth value="300" size=3 onchange="javascript:if(QEboxWidth.value<100)QEboxWidth.value=100; else if(QEboxWidth.value>800)QEboxWidth.value=800;" > H: <INPUT id=QEboxHeight value="300" size=3 onchange="javascript:if(QEboxHeight.value<100)QEboxHeight.value=100; else if(QEboxHeight.value>800)QEboxHeight.value=800;" > <INPUT onclick='QEboxWidth.value=QEboxHeight.value=""' type=button value="dW"> &nbsp; <INPUT onclick='QEboxXmin.value=QEboxXmax.value=QEboxYmin.value=QEboxYmax.value=""' type=button value="dx"> <INPUT id="QEchkbxComplex" type="checkbox" ><a href="#docA031">complex</a><!--9902240753 add for testing--> <br> x min: <INPUT id=QEboxXmin value="-5" size=3 > , x max: <INPUT id=QEboxXmax value="5" size=3 > ; y min: <INPUT id=QEboxYmin value="0" size=3 > , y max: <INPUT id=QEboxYmax value="10" size=3 > ; <br> x/y min/max : <INPUT id="QEchkbxcD1" type="checkbox" onclick="QEchkbxcD2.checked=!QEchkbxcD1.checked;if(QEchkbxcD1.checked)QEboxXmin.disabled=QEboxXmax.disabled=QEboxYmin.disabled=QEboxYmax.disabled=1;" checked >auto scale, <INPUT id="QEchkbxcD2" type="checkbox" onclick="QEchkbxcD1.checked=!QEchkbxcD2.checked;if(QEchkbxcD2.checked)QEboxXmin.disabled=QEboxXmax.disabled=QEboxYmin.disabled=QEboxYmax.disabled=0;" >user scale <a href="#powMeanClick">Click button</a> <br> <table border=1> <tr> <td> 10^ <INPUT value="1.2345" id=QEboxcA4 size=5 > ; <!-- 2009-10-12-20-00 paid attention that Exercise 2.13 limit to complex number real part be positive. Next check box control complex number real part. complex number imaginary part is +/0/- user can not control. 2009-10-12-20-12 --> <INPUT id="QEchkbxcA2" type="checkbox" onclick="QEchkbxcA3.checked=!QEchkbxcA2.checked;spanAlert1.innerHTML='Please click [random5#], then click [Plot3].'" checked >+/0 , <INPUT id="QEchkbxcA3" type="checkbox" onclick="QEchkbxcA2.checked=!QEchkbxcA3.checked;spanAlert1.innerHTML='Violate problem assumption complex real part > 0 !'" >+/0/- ; <INPUT value="5" id=QEboxcA3 size=5 > digits <a href="#docA001">Help1</a> </td> </tr> <tr> <td> <!-- next line OK <input type="button" value="random5#" onclick="javascript:QEboxb11.value=fillRand5(0,QEboxcA4.value,QEboxcA3.value,QEboxcA1.value,QEchkbxcA3.checked,QEchkbxcA1.checked)" /> fillRand5() parameters arg1 = 0/1, if 1 output complex, else real arg2 = 10^this, 10^2=random in [0,100] arg3 = precision, 5 output 12.345 arg4 = generate this many random numbers arg5 = 0/1 for +/0 [false] or +/0/- [true] arg6 = 0/1 for real [false] or integer [true] 2010-02-19-11-08 --> <input type="button" value="random5#" onclick="javascript: QEboxb11.value= fillRand5(QEchkbxComplex.checked, QEboxcA4.value, QEboxcA3.value, QEboxcA1.value, QEchkbxcA3.checked, QEchkbxcA1.checked); QEboxb12.value= probabOne(QEboxcA1.value,QEchkbxcA4.checked); " /> <!-- QEboxb12.value= probabOne(QEboxcA1.value); 9902231537 change from above to next QEboxb12.value= probabOne(QEboxcA1.value,QEchkbxcA4.checked); --> fill <INPUT value="20" id=QEboxcA1 size=5 > numbers; <input type="checkbox" name="QEchkbxcA1" id="QEchkbxcA1" /> integer; <input type="checkbox" name="QEchkbxcA4" id="QEchkbxcA4" /><a href="#docA028"> eq.p</a><!--9902231534 begin equal probability--> </td> </tr> </table> <a name="boxb11Here"></a> <table border=0> <tr> <td> Box 1, x<sub>j</sub> sequence <INPUT onclick='javascript:window.clipboardData.setData("Text",document.getElementById("QEboxb11").value.toString())' type=button value="copy1"> <INPUT onclick='document.getElementById("QEboxb11").value=""' type=button value="del1"> <br> <TEXTAREA id=QEboxb11 name=QEboxb11 rows=6 cols=30 > 0.27 5.92 6.89 3.47 9.41 nonnegative number sequence</TEXTAREA> </td> <td> Box 2, p<sub>j</sub> sequence <INPUT onclick='javascript:window.clipboardData.setData("Text",document.getElementById("QEboxb12").value.toString())' type=button value="copy2"> <INPUT onclick='document.getElementById("QEboxb12").value=""' type=button value="del2"> <br> <TEXTAREA id=QEboxb12 name=QEboxb12 rows=6 cols=30 > 0.181 0.103 0.226 0.237 0.253 weights must sum to one</TEXTAREA> </td> </tr> <tr> <td> Box 3, output <INPUT onclick='javascript:window.clipboardData.setData("Text",document.getElementById("QEboxb13").value.toString())' type=button value="copy3"> <INPUT onclick='document.getElementById("QEboxb13").value=""' type=button value="del3"> <br> <TEXTAREA id=QEboxb13 name=QEboxb13 rows=6 cols=30 > </TEXTAREA> </td> <td> Box 4, drawDot <INPUT onclick='javascript:window.clipboardData.setData("Text",document.getElementById("QEboxb14").value.toString())' type=button value="copy4"> <INPUT onclick='document.getElementById("QEboxb14").value=""' type=button value="del4"> <br> <TEXTAREA id=QEboxb14 name=QEboxb14 rows=6 cols=30 > xj sequence elements all >=0 pj sequence elements all >=0 SUM[j]{pj}=1 is required. If fill t value at box 5 curve draw dot, dot Mt value save to box 4 (here)</TEXTAREA> </td> </tr> </table> <a name="pPowBox"></a> <INPUT value="1" id=QEboxpPow size=5 > p<sub>k</sub> <a href=#docA033>power</a>. <font color=red> <span id=QEspanAlertpPow1><!--2010-02-25-11-22--> If not one, use steps=300+ 2010-02-25-11-22 </span><!--9902251237 use spanAlert--> <br> <span id=QEspanAlertpPow2> </span> </font> <br> t bgn <INPUT value="-5" id=QEboxtBgn size=5 > , t end <INPUT value="5" id=QEboxtEnd size=5 > steps <INPUT value="30" id=QEboxStep size=5 > &nbsp; <input type="button" value="dt" onclick="QEboxtBgn.value=QEboxtEnd.value=''" /> &nbsp; <input type="button" value="ds" onclick="QEboxStep.value=''" /> <br> <a name="powMeanClick"></a> <!--9902181818--> <font color=red><b> Click to RUN </b></font> <input type="button" value="PowerMeanA" onclick="javascript: QEboxtBgn.value=-5; QEboxtEnd.value=5; QEboxStep.value=30; QEchkbxcD2.checked=0 QEchkbxcD1.checked=1 var answer0=powMeanf( QEboxb11.value, QEboxb12.value, QEboxtBgn.value, QEboxtEnd.value, QEboxStep.value, QEboxb15.value, QEboxpPow.value); QEboxb13.value= answer0[0]; if(answer0[1]) QEboxb14.value=answer0[1]; " /><!-- 9903011945 PowerMeanA modify input PowerMeanB not modify input box --> <input type="button" value="PowerMeanB" onclick="javascript: var answer0=powMeanf( QEboxb11.value, QEboxb12.value, QEboxtBgn.value, QEboxtEnd.value, QEboxStep.value, QEboxb15.value, QEboxpPow.value); QEboxb13.value= answer0[0]; if(answer0[1]) QEboxb14.value=answer0[1]; " /><!-- 9902251123 add QEboxpPow.value --> <a href="#contralCenter"> control center </a> <br> <!--9903021040--> <a href="#docA042"> <font color=red><b> Why 'A', 'B' </b></font> </a> ? <input type="button" value="JensenA" onclick="javascript: QEboxtBgn.value=0; QEboxtEnd.value=1.5; QEboxStep.value=300; QEboxXmin.value=0 QEboxXmax.value=1.5 QEboxYmin.value=-2 QEboxYmax.value=10 QEchkbxcD2.checked=1 QEchkbxcD1.checked=0 var answer0=powMeanf( QEboxb11.value, QEboxb12.value, QEboxtBgn.value, QEboxtEnd.value, QEboxStep.value, QEboxb15.value, QEboxpPow.value, 'Jensen'); QEboxb13.value= answer0[0]; if(answer0[1]) QEboxb14.value=answer0[1]; " /><!-- 9903011728 add 'Jensen' 9903011728 start Jensen 9903011923 done Jensen --> <input type="button" value="JensenB" onclick="javascript: var answer0=powMeanf( QEboxb11.value, QEboxb12.value, QEboxtBgn.value, QEboxtEnd.value, QEboxStep.value, QEboxb15.value, QEboxpPow.value, 'Jensen'); QEboxb13.value= answer0[0]; if(answer0[1]) QEboxb14.value=answer0[1]; " /> <INPUT name=DelGraph type="button" value="Wipe" onclick="QEdivGraphA.innerHTML=QEspanEqnDocA.innerHTML=''";> <!--9902191016--> <input type="button" value="random5#" onclick="javascript: QEboxb11.value= fillRand5(QEchkbxComplex.checked, QEboxcA4.value, QEboxcA3.value, QEboxcA1.value, QEchkbxcA3.checked, QEchkbxcA1.checked); QEboxb12.value= probabOne(QEboxcA1.value,QEchkbxcA4.checked); " /> <!-- QEboxb12.value= probabOne(QEboxcA1.value); 9902231537 change from above to next QEboxb12.value= probabOne(QEboxcA1.value,QEchkbxcA4.checked); --> <TABLE WIDTH="520" border=0 id=T120L18a > <td> <TABLE WIDTH="180" border=0 id=T120L18b > <TR><!--9902181743--> <TD> <FONT SIZE=+3>{</FONT> </TD> <TD> <CENTER><FONT SIZE=-2>k=n</FONT></CENTER> <CENTER><FONT SIZE=+3>"</FONT></CENTER> <CENTER><FONT SIZE=-2>k=1</FONT></CENTER> </TD> <TD> p<sub>k</sub>x<sub>k</sub><sup>t</sup> </TD> <TD> <FONT SIZE=+3>}</FONT> </TD> <TD> <CENTER><FONT SIZE=-1>1/t</FONT></CENTER> <CENTER>0</CENTER> </TD> </TR> </TABLE> </td> <td> Box 5, dots t values <INPUT onclick='javascript:window.clipboardData.setData("Text",document.getElementById("QEboxb15").value.toString())' type=button value="copy5"> <INPUT onclick='document.getElementById("QEboxb15").value=""' type=button value="del5"> <INPUT onclick='QEboxb15.value="-1 0 1 2 "' type=button value="reset"><!-- 9903041118 add reset to erase Jensen debug.--> <br> <TEXTAREA id=QEboxb15 name=QEboxb15 rows=3 cols=36 > -1 0 1 2 Output to box four PowerMeanA, JensenA two button both reset control box, two B not to. </TEXTAREA> </td> </TABLE> <div id=QEdivGraphA></div> <br> <span id=QEspanEqnDocA> </span> <SCRIPT language=JavaScript> <!-- /** 2010-02-19-15-50 start document function powMeanf(arg1,arg2,arg3,arg4,arg5,arg6) draw power mean inequality curve for a x-sequence and p-sequence pair. Both sequences must have no negative element. Both sequences must have same number of elements. p-sequence must sum to one. Next is one calling method [[ <input type="button" value="PowerMean" onclick="javascript: var answer0=powMeanf( QEboxb11.value, QEboxb12.value, QEboxtBgn.value, QEboxtEnd.value, QEboxStep.value, QEboxb15.value); QEboxb13.value= answer0[0]; if(answer0[1]) QEboxb14.value=answer0[1]; " /> ]] Equation for Mt is Mt={SUM[k=1,n]pk*xk^t}^(-t) t range (-infinity, +infinity) function powMeanf(arg1,arg2,arg3,arg4,arg5,arg6) arg1=x sequence arg2=p sequence arg3=t begin value arg4=t end value arg5=total number of steps arg6=draw dots at t=these values arg7=0.75 reset all probability 9902251126 start coefficients pk to pk=pk^0.75 if arg7=1, SUM{pk}=1, normal if arg7!=1, SUM{pk}!=1, explore 9902251127 stop function powMeanf() output to variable answer0 (can be any variable name) answer0 has two strings. string one goto output box QEboxb13.value=answer0[0]; string two goto output box QEboxb14.value=answer0[1]; HTML elements ID QEboxb13 and QEboxb14 can be changed to other name. function powMeanf() itself use one HTML element ID, which is QEdivGraphA User must set up next line [[ <div id=QEdivGraphA></div> ]] in web page. Otherwise function powMeanf() can not work. 2010-02-19-16-08 stop document 2010-02-25-23-17 start function powMeanf() use second HTML element ID, it is QEspanAlertpPow1 Define it as next [[ <span id=QEspanAlertpPow1> </span> ]] 2010-02-25-23-18 stop /**/ function powMeanf(arg1,arg2,arg3, arg4,arg5,arg6,arg7,arg8) { //9902181822 //9903011809arg8 var xArray=readdata(arg1); //x sequence var pArray=readdata(arg2); //p sequence var tBgn=parseFloat(arg3); //t begin var tEnd=parseFloat(arg4); //t end var step5=parseFloat(arg5);//total number of steps var dArray=readdata(arg6); //draw dot sequence var pPow=parseFloat(arg7); //pk reset power var JensenDraw=0; //9903011810 if(arg8=='Jensen')JensenDraw=1; var drawDot=0; //9902182047 if(dArray.length>0)drawDot=1; var d; var autoScale=1; //9902182341 if(QEchkbxcD2.checked==1)autoScale=0; var b0,b1,b2,b3; if(xArray.length!=pArray.length) return ['xj sequence and pj sequence must have same number of elements.',''] for(u0=0;u0<xArray.length;u0++) if(xArray[u0]<0) return ['xj sequence can not have negative element.',''] for(u0=0;u0<pArray.length;u0++) if(pArray[u0]<0) return ['Weight pj sequence can not have negative element.',''] var sum0=0; var sum1=0; //9903040354 var tolerance=1.e-8 for(u0=0;u0<pArray.length;u0++) sum0+=pArray[u0]; if(Math.abs(sum0-1)>tolerance) return ['Weight pj sum must be one. Now sum to '+sum0,''] QEspanAlertpPow1.innerHTML="If not one, use steps=300+ 2010-02-25-11-22"; QEspanAlertpPow2.innerHTML=AlertpPow2; //9903011051 if(!isNaN(pPow)) //9902251130 if(Math.abs(pPow-1)>tolerance) { for(u0=0;u0<pArray.length;u0++) pArray[u0]=Math.pow(pArray[u0],pPow); //9902251132 //alert('Probability coefficients in Box 2,\n' //+'all changed to rise power of '+pPow+'\n' //+'Expect unusual curve output.\n'); //9902251138 use alert, 9902251142 del alert sum0=0; for(u0=0;u0<pArray.length;u0++) sum0+=pArray[u0]; //9902251239 QEspanAlertpPow1.innerHTML="Attention! New "p<sub>k</sub>="+sum0; //9902251240 QEspanAlertpPow2.innerHTML= //9903011052 'length^'+(sum0+"").substring(0,5)+' compare length^1.0?0NO ! See broken curve below.' } if(isNaN(tBgn)) return ['t begin must be a number. Now ['+arg3+']',''] if(isNaN(tEnd)) return ['t end must be a number. Now ['+arg4+']',''] if(isNaN(step5)) return ['steps must be a number. Now ['+arg5+']',''] if(step5<10) return ['steps must be greater than 9. Now ['+arg5+']',''] var MyGraph = new XYGraph(); var MyLine1 = new XYLine(); var MyLine2 = new XYLine(); MyLine1.VMLpointshapetype="none"; MyLine2.VMLpointshapetype="none"; //9903011822 MyLine3,4,5 for JensenDraw var MyLine3 = new XYLine(); var MyLine4 = new XYLine(); var MyLine5 = new XYLine(); MyLine3.VMLpointshapetype="none"; MyLine4.VMLpointshapetype="none"; MyLine5.VMLpointshapetype="none"; var delta=(tEnd-tBgn)/step5; var t,o; var out0=''; //curve (t,Mt) coord. var out1=''; //t=0 datail. 9902181910 var out2=''; //drawDot (t,Mt) coord. 9902182101 var xSeqMax=xSeqMin=xArray[0]; //9902191226 for(b0=1;b0<xArray.length;b0++) { if(xArray[b0]>xSeqMax)xSeqMax=xArray[b0]; if(xArray[b0]<xSeqMin)xSeqMin=xArray[b0]; } if(drawDot) //dArray { for(b0=0;b0<dArray.length;b0++) { t=dArray[b0]; sum0=0; if(Math.abs(t)>tolerance) { for(b1=0;b1<xArray.length;b1++) //9902181852 sum0+=pArray[b1]*Math.pow(xArray[b1],t); o=Math.pow(sum0,1/t); //9902181858 } else { sum0=1; for(b1=0;b1<xArray.length;b1++) //9902181903 { sum0*=Math.pow(xArray[b1],pArray[b1]); } o=sum0; //9902182059 } dArray[b0]=[t,o]; //9902182100 out2+=t+', '+o+'\n'; //9902182104 } //for(b0=0;b0<dArray.length;b0++) out2+='\n' +'t and Mt value. If t not=0\n' +'Mt equation is on top of\n' +'figure. If t=0 Mt= next line\n' +'"xk^pk=x1^p1*x2^p2*x3^p3 ...\n' } // if(drawDot) var dbg0=''; //9903040410 if(!JensenDraw) { for(b0=0;b0<=step5;b0++) { //9902181849 t=tBgn+delta*b0; sum0=0; if(Math.abs(t)>tolerance) { for(b1=0;b1<xArray.length;b1++) //9902181852 sum0+=pArray[b1]*Math.pow(xArray[b1],t); o=Math.pow(sum0,1/t); //9902181858 } else { sum0=1; for(b1=0;b1<xArray.length;b1++) //9902181903 { sum0*=Math.pow(xArray[b1],pArray[b1]); out1+='' +'b1='+b1+', xArray[b1]='+xArray[b1] +', pArray[b1]='+pArray[b1] +'\npow(x,p)='+Math.pow(xArray[b1],pArray[b1]) +', sum0='+sum0 +'\n\n' ; } //for(b1=0;b1<xArray.length;b1++) o=sum0; //9902181917 } //if(Math.abs(t)>tolerance) else out0+=t+', '+o+'\n' MyLine1.x[b0] =t; MyLine1.y[b0] =o; } //for(b0=0;b0<=step5;b0++) } //if(!JensenDraw) else//if(JensenDraw) { //eqn.AZ064 (eqn.8.35) sum0=0; //eqn.AZ064 "pk*xk sum1=0; //eqn.AZ064 "pk*xk*log(xk) for(b0=0;b0<xArray.length;b0++) { //9903040351 b1=pArray[b0]*xArray[b0]; sum0+=b1; sum1+=b1*Math.log(xArray[b0]); dbg0+='b0='+b0+', b1='+b1+'\n' +'sum0='+sum0+', sum1='+sum1+'\n' ; } var dfdtat1= //eqn.AZ064 , 9903040358 sum1-sum0*Math.log(sum0); var o3,o4,o5; //9903011824 for(b0=0;b0<=step5;b0++) { //9903011825 t=tBgn+delta*b0; sum0=0; if(Math.abs(t)>tolerance) { for(b1=0;b1<xArray.length;b1++) sum0+=pArray[b1]*Math.pow(xArray[b1],t); o3=sum0; //9903011826 sum0=0; //9903011921 correction for(b1=0;b1<xArray.length;b1++) sum0+=pArray[b1]*xArray[b1]; o4=Math.pow(sum0,t); //9903011918 correction o5=o3-o4; //9903011829 /** 9903011728 start Jensen 9903011923 done Jensen /**/ } else { sum0=1; for(b1=0;b1<xArray.length;b1++) //9902181903 { sum0*=Math.pow(xArray[b1],pArray[b1]); out1+='' +'b1='+b1+', xArray[b1]='+xArray[b1] +', pArray[b1]='+pArray[b1] +'\npow(x,p)='+Math.pow(xArray[b1],pArray[b1]) +', sum0='+sum0 +'\n\n' ; } //for(b1=0;b1<xArray.length;b1++) o3=o4=o5=sum0; } //if(Math.abs(t)>tolerance) else out0+=t+'; '+o3+'; '+o4+'; '+o5+'\n' MyLine3.x[b0] = MyLine4.x[b0] = MyLine5.x[b0] =t; MyLine3.y[b0] =o3; MyLine4.y[b0] =o4; MyLine5.y[b0] =o5; //9903011832 } //for(b0=0;b0<=step5;b0++) } //if(!JensenDraw) var MtMax, MtMin; //9902181921 MtMax=MyLine1.y[b0-1]; MtMin=MyLine1.y[0]; if(autoScale) { MyGraph.ymax=Math.floor(xSeqMax+1); MyGraph.ymin=Math.floor(xSeqMin-1); MyGraph.xmax=Math.floor(tEnd+1); MyGraph.xmin=Math.floor(tBgn-1); MyGraph.gheight=300; MyGraph.gwidth=300; } else { MyGraph.ymax=QEboxYmax.value; MyGraph.ymin=QEboxYmin.value; MyGraph.xmax=QEboxXmax.value; MyGraph.xmin=QEboxXmin.value; MyGraph.gheight=QEboxHeight.value; MyGraph.gwidth=QEboxWidth.value; } if(!JensenDraw) //power mean graph doc. { MyGraph.title= "Power Mean Inequality Curve"; QEspanEqnDocA.innerHTML="" +"2010-03-02-19-01 start<br>" +"This is real Power Mean Inequality Curve. Build from<br>" +"user x-sequence (data) and p-sequence (probability).<br>" +"Equation is M<sub>t</sub>={"[k=1,n](p<sub>k</sub>*x<sub>k</sub><sup>t</sup>)}<sup>1/t</sup> If x<sub>k</sub> is length,<br>" +"then for t=2, x<sub>k</sub><sup>2</sup> is area; for t=3, x<sub>k</sub><sup>3</sup> is volume.<br>" +"(Inner power<sup>t</sup> cancel outer power<sup>1/t</sup> back to length)<br>" +"If t=0, M<sub>0</sub> is special. M<sub>0</sub>="[k=1,n](x<sub>k</sub><sup><sup>p<sub>k</sub></sup></sup>)=G.M.<br>" +"Mathematician know how to play magic. We can go<br>" +"from 0 dimensional space to any_number_dim_space<br>" +"continuously. Drawing horizontal axis represent this<br>" +"practice. Power mean follow t and change continuously.<br>" +"Result is above curve. If you let [p<sub>k</sub> power] box fill<br>" +"with 1. geometric mean has same dimension as other<br>" +"means. If you let [p<sub>k</sub> power] box fill with non_one.<br>" +"then geometric mean has different physics dimension<br>" +"from other means. Can we say 'Two acre is greater <br>" +"then one mile'? NO we can not compare area with<br>" +"distance. When different physics dimension presented,<br>" +"Power Mean Inequality Curve blow up at singular point<br>" +"t=0 where we call as Geometric Mean. If we force<br>" +"[p<sub>k</sub> power] box to be one. Power Mean Inequality<br>" +"Curve is a smooth monotone increase curve. M<sub>t</sub> value<br>" +"increase with t increase. 2010-03-02-19-20 stop<br>" ; } //above power mean graph doc. else //if(!JensenDraw) { //below Jensen graph doc. MyGraph.title= "Jensen Inequality, red/blue are parts. Black sum"; QEboxb15.value=dbg0; //9903040412 QEspanEqnDocA.innerHTML='' +'2010-03-02-00-13 start<br>' +'Independent variable (horizontal axis) is<br>' +'power t in pk*(xk^t), pk is k-th probability<br>' +'if xk is k-th observed length, then increase t<br>' +'is goto higher dimension space continuously.<br>' +'Black curve is <a href="tute0032.htm#textbook">textbook</a> <a href="tute0032.htm#ch08c097">eqn.AZ044</a><br>' +'Red curve is eqn.AZ044 first (positive) term.<br>' +'Blue curve is eqn.AZ044 second (negative) term.<br>' +'Blue dropped negative sign. Red ÿBlue=Black<br>' +'First key point to observe is<br>' +'<font color=red><b>Black curve has f(t)=f(1)=0</b></font> see textbook<br>' +'eqn.AZ044 and <a href="tute0032.htm#ch08c098">eqn.AZ045</a><br>' +'Second key point to observe is<br>' +'Black curve increase function value at t=1<br>' +'see textbook question <a href="tute0032.htm#ch08c093">part (a)</a> and eqn.AZ044<br>' +'eqn.AZ045. <font color=red><b>We have d[f(t)]/dtÿ0 at t=1</b></font><br>' +'[Here f(t) mean black curve eqn.AZ044]<br>' +'<br>' +'Black curve slope at t=1 is '+dfdtat1+'<br>' //9903040405 add dfdtat1 +'Above slope must be ÿ0 see textbook <a href=tute0032.htm#ch08c095>eqn.8.35</a><br>' +'Above slope is from <a href=tute0032.htm#ch08c128>eqn.AZ064</a> If drawing <br>' +'board x-axis, y-axis ratio is not 1:1, then slope<br>' //9903040425 add 1:1 +'look wrong. Adjust x min, x max; y min, y max<br>' +'let x max ÿ x min = y max ÿ y min to get 1:1 <br>' +'Added tangent at t=1. See code at "9903041110"<br>' +'<br>' +'In control panel, do not set y min at zero<br>' +'If you do, black curve negative part can not<br>' +'show up on drawing board, xygraph auto move<br>' +'curve upward. "Black curve has f(t)=f(1)=0"<br>' +'is void, surprise user.<br>' +'Set y min at -1 or -2 for correct drawing.<br>' +'(This is for Jensen buttons. If click PowerMean<br>' +' button, set y min at 0, no negative curve.)<br>' +'2010-03-02-00-32 stop<br>' } //if(!JensenDraw) else; graph doc if(!JensenDraw) { MyLine1.VMLstroke="weight='1pt'; color='red'; dashstyle='solid';"; MyGraph.Plot(MyLine1); MyLine2.x[0]=MyGraph.xmin MyLine2.y[0]=xSeqMax MyLine2.x[1]=MyGraph.xmax MyLine2.y[1]=xSeqMax MyLine2.VMLstroke="weight='1pt'; color='red'; dashstyle='dash';"; MyGraph.Plot(MyLine2); MyLine2.x[0]=MyGraph.xmin MyLine2.y[0]=xSeqMin MyLine2.x[1]=MyGraph.xmax MyLine2.y[1]=xSeqMin MyGraph.Plot(MyLine2); if(drawDot) { // draw intercept points var MyLabel = new Label(); MyLabel.labelsize = "10"; MyLabel.VMLpointshapetype="circle"; MyLabel.labelcolor="black"; MyLabel.rotation = +0; for(b1=0;b1<dArray.length;b1++) //9902182116 { MyLabel.x =dArray[b1][0]; MyLabel.y =dArray[b1][1]; MyLabel.label = ""; MyGraph.Drawlabel(MyLabel); } } //if(drawDot) } //if(!JensenDraw) else { //9903011837 MyLine3.VMLstroke="weight='1pt'; color='red'; dashstyle='solid';"; MyGraph.Plot(MyLine3); MyLine4.VMLstroke="weight='1pt'; color='blue'; dashstyle='solid';"; MyGraph.Plot(MyLine4); MyLine5.VMLstroke="weight='1pt'; color='black'; dashstyle='solid';"; MyGraph.Plot(MyLine5); /** (y2-y1)/(x2-x1)=slope (y -y0)/(x -x0)=slope y = slope*(x -x0)+y0 yEnd = x0slope*(xEnd-x0)+y0 yBgn = x0slope*(xBgn-x0)+y0 9902262027 /**/ //9903041105 add one more redundunt //variable slope0 on purpose. //dfdtat1=d[f(x)]/dt at t=1 is descriptive //slope0 is also descriptive. Future //search code, know only slope0. var slope0=dfdtat1; var x0=1.0,y0=0.; //9903041108 MyLine2.x[0]=x0+0.5; MyLine2.y[0]=slope0*((x0+0.5)-x0)+y0 MyLine2.x[1]=x0-0.5 MyLine2.y[1]=slope0*((x0-0.5)-x0)+y0 MyLine2.VMLstroke="weight='1pt'; color='silver'; dashstyle='dash';"; MyGraph.Plot(MyLine2); //9903041110 } //if(!JensenDraw) QEdivGraphA.innerHTML = MyGraph; var oStr0= out0 +'\n\nNext is special case t=0\n\n' +out1 +'\nx sequence max/min\n' +'xSeqMax='+xSeqMax+'\n' +'xSeqMin='+xSeqMin+'\n' +'\nMt two end values\n' +'MtMax='+MtMax+'\n' +'MtMin='+MtMin+'\n' ; //9902181857 return [oStr0, out2]; //9902182106 } // function powMeanf() 9902181832 done //2009-09-23-15-01 from tute0009.htm //find function readdata(inStr0) // function readdata(inStr0) //9806101151 { //9807270955 read other's no-comment code //very headache, now back to my code, add //more comments. // //if input inStr0 is Not a Number (isNaN=true) //then inStr0 is an array or string of char. if(isNaN(inStr0) //9807161944 //and if inStr0[0] is a Number //(isNaN=false) (!isNaN=true) //inStr0 is a number array, return oroginal form &&!isNaN(inStr0[0])) return inStr0; //if input inStr0 is empty, return oroginal form if(inStr0.length==0)return inStr0; //9806101153 //if input inStr0 is a number, return oroginal form if(!isNaN(inStr0[0]))return inStr0; //9807271000 //up to here input inStr0 is one string of character //below change string of char '1.23 4.56 7.89 ...' //to number array aa[0]=1.23, aa[1]=4.56, aa[2]=7.89 ... //9807271010 here //assume input string is '1.23 4.56 7.89 ...' //oArray[0] store '1.23' this is a string //oArray[1] store '4.56' not a number yet //oArray[2] store '7.89' convert to number later //9807271043 var oArray=''; //9806101158 var w0,w1,numb0; for(w0=0;w0<inStr0.length;w0++) { numb0=''; //skip those char are NOT [0123456789-+.] // [!(...)] means [is not ...] // [!=] means [not equal] 9807271051 // w1=w0; //9802172117 while(!(inStr0.charAt(w1)>='0' &&inStr0.charAt(w1)<='9') &&inStr0.charAt(w1)!='-' &&inStr0.charAt(w1)!='+' &&inStr0.charAt(w1)!='.' &&w1<inStr0.length ) { //index w1 increase only, //no record what read 9807271058 w1++; } //above while() loop stop at reading //either one in the list [0123456789-+.] //then start next while loop. 9807271055 // while((inStr0.charAt(w1)>='0' &&inStr0.charAt(w1)<='9') ||inStr0.charAt(w1)=='-' ||inStr0.charAt(w1)=='+' ||inStr0.charAt(w1)=='.' ||inStr0.charAt(w1)=='e' ||inStr0.charAt(w1)=='E' &&w1<inStr0.length ) //9802171608 { //If it is either one of [0123456789-+.eE] //continue store data into numb0 . 9807271102 numb0+=inStr0.charAt(w1); w1++; } //if all I get is just '.' for example // 'aa.txt' it is not a number, //no need to build output oArray //9807271106 if(numb0.length==1&&numb0.charAt(0)=='.') { w0=w1; //9802172218 //update index w0=w1 continue; //continue to next iteration. } //skip the following building code. //up to this point, numb0 is useful number //build output string oArray //9807271111 w0=w1; //9806101210 update index //string numb0 to output string oArray //add a newline byte '\n' to separate data // 9807271113 oArray+=numb0+'\n'; //9806101159 } // for(w0=0;w0<inStr0.length;w0++) //done for() loop, done output string oArray //use newline byte '\n' to separate numbers. // oArray.split('\n') in oArray cut data at //newline byte '\n' and change string // '1.23\n4.56\n7.89\n...' //to array oArray[0]='1.23', oArray[1]='4.56', //oArray[2]='7.89' ... //no matter input data use ',' or tab or //newline to separate data, here all done //9807271125 oArray=oArray.split('\n'); //9806101643 //string '1' + string '2' = '12' //number 1 + number 2 = 3 //above is string array oArray[0]='1.23', //below is number array w2[0]=1.23 //9807271130 var w2=[0,0]; for(w0=0;w0<oArray.length;w0++) { //9806101704 //parseFloat() convert string number // to number number. w1=parseFloat(oArray[w0]); //no more number? done if(isNaN(w1))break; //9806101714 w2[w0]=w1; //create number array. } return w2; } // function readdata() 9806101214 //from function update0() //9802171511 //--> </script> <br> <br> <br> <!--9902152239--> <a name="figure0801">&lt;a name="figure0801"&gt;</a> <br> Next is first version Power Mean Inequality Curve <br> used in <a href=tute0030.htm#figure0801>tute0030.htm</a>. It is a fake power mean curve. <br> Because it is created from a mathematics equation <br> not created from real x-sequence and p-sequence. <br> <input onclick="javascript:figure0801(1)" type="button" value="Draw Figure0801" /> <input onclick="QDdivGraph0801.innerHTML = QDspanEqnDoc0801.innerHTML = ''" type="button" value="wipe" /> Figure 8.1 ; 2010-02-15-22-42 <br> <font color=red> <span id=QDspanAlert0801> </span> </font> <br> <div id=QDdivGraph0801></div> <br> <span id=QDspanEqnDoc0801> </span> <script lang="javascript"> <!-- function figure0801(Arg1) //9902152250 { var xend,xbgn xbgn=-4 xend= 4 var step5=60 var delta=(xend-xbgn)/step5; var x,b0; QDspanAlert0801.innerHTML=''; var eqn00=eqn01=eqn02=eqn03=''; eqn00='pow(0.3*pow(0.5,(x*1.5))+0.7*pow(3.5,(x*1.5)),1/(x*1.5))'; var MyGraph = new XYGraph(); var MyLine1 = new XYLine(); var MyLine2 = new XYLine(); MyLine1.VMLpointshapetype="none"; MyLine2.VMLpointshapetype="none"; status=''; MyGraph.ymax=4; MyGraph.ymin=-4; MyGraph.xmax=4; MyGraph.xmin=-4; MyGraph.gheight=300; MyGraph.gwidth=300; MyGraph.title= "ISBN 978-0-521-54677-5 page 124 Figure 8.1"; var b1=0; // if(eqn00.length>0) { for(b0=0;b0<=step5;b0++) { x=xbgn+delta*(b0+b1); MyLine1.x[b0] =x; MyLine1.y[b0] =eval('with(Math){'+eqn00+'}'); } //for(b0=0;b0<=step5;b0++) MyLine1.VMLstroke="weight='1pt'; color='red'; dashstyle='solid';"; MyGraph.Plot(MyLine1); } //if(eqn00.length>0) MyLine2.x[0] =-4; MyLine2.y[0] = 3.5; MyLine2.x[1] =+4; MyLine2.y[1] = 3.5; MyLine2.VMLstroke="weight='1pt'; color='blue'; dashstyle='dash';"; MyGraph.Plot(MyLine2); MyLine2.x[0] =-4; MyLine2.y[0] = 0.5; MyLine2.x[1] =+4; MyLine2.y[1] = 0.5; MyGraph.Plot(MyLine2); b1=0; if(eqn01.length>0) { for(b0=0;b0<=step5;b0++) { // x=xbgn+delta*(b0+b1); MyLine2.x[b0] =x; MyLine2.y[b0] =eval('with(Math){'+eqn01+'}'); } //for(b0=0;b0<=step5;b0++) MyLine2.VMLstroke="weight='1pt'; color='blue'; dashstyle='solid';"; MyGraph.Plot(MyLine2); } //if(eqn01.length>0) // draw intercept points var MyLabel = new Label(); MyLabel.labelsize = "10"; MyLabel.VMLpointshapetype="circle"; MyLabel.labelcolor="black"; MyLabel.rotation = +0; MyLabel.x =1.; MyLabel.y =2.8017; MyLabel.label = "M1"; MyGraph.Drawlabel(MyLabel); MyLabel.x =-1.; MyLabel.y =1.0308; MyLabel.label = "M-1"; MyGraph.Drawlabel(MyLabel); MyLabel.rotation = +135; MyLabel.x =2.; MyLabel.y =3.10895; MyLabel.label = "M2"; MyGraph.Drawlabel(MyLabel); MyLabel.x =0.; MyLabel.y =1.9522; MyLabel.label = "M0"; MyGraph.Drawlabel(MyLabel); MyLabel.VMLpointshapetype="none"; MyLabel.rotation = 0; MyLabel.x = 2.25; MyLabel.y =0.6; MyLabel.label = "The Power Mean Curve"; MyGraph.Drawlabel(MyLabel); MyLabel.x =3.8; MyLabel.y =-0.2; MyLabel.label = "t"; MyGraph.Drawlabel(MyLabel); MyLabel.x = 0.5; MyLabel.y =3.5; MyLabel.label = "y=Mt"; MyGraph.Drawlabel(MyLabel); MyLabel.x = -2; MyLabel.y =-1.5; MyLabel.label = "M"=max(x,y)"; MyGraph.Drawlabel(MyLabel); MyLabel.x = -2; MyLabel.y =-2; MyLabel.label = "M2="(pxx+qyy)"; MyGraph.Drawlabel(MyLabel); MyLabel.x = -2; MyLabel.y =-2.5; MyLabel.label = "M1=px + qy"; MyGraph.Drawlabel(MyLabel); MyLabel.x = -2; MyLabel.y =-3; MyLabel.label = "M0=x^p * y^q"; MyGraph.Drawlabel(MyLabel); MyLabel.x = -2; MyLabel.y =-3.5; MyLabel.label = "M-1=1/(p/x +q/y)"; MyGraph.Drawlabel(MyLabel); MyLabel.x = -2; MyLabel.y =-4; MyLabel.label = "M-"=min(x,y)"; MyGraph.Drawlabel(MyLabel); MyLabel.x = 2; MyLabel.y =-1.5; MyLabel.label = "Mt definition, textbook"; MyGraph.Drawlabel(MyLabel); MyLabel.x = 2; MyLabel.y =-2; MyLabel.label = "page 120, equation 8.1"; MyGraph.Drawlabel(MyLabel); MyLabel.x = 2; MyLabel.y =-2.5; MyLabel.label = "define Mt at next line"; MyGraph.Drawlabel(MyLabel); MyLabel.x = 2; MyLabel.y =-3; MyLabel.label = "Mt=[sum(pk*xk^t)]^(1/t)"; MyGraph.Drawlabel(MyLabel); MyLabel.x = 2; MyLabel.y =-3.5; MyLabel.label = "sum over k=1 to n"; MyGraph.Drawlabel(MyLabel); QDdivGraph0801.innerHTML = MyGraph; QDspanEqnDoc0801.innerHTML = "" +"2010-02-16-08-19 start<br>" +"Textbook page 124 figure 8.1<br>" +"If xÿ0, yÿ0, 0ÿpÿ1 and q=1-p, then a <br>" +"qualitative plot of Mt=(px^t+qy^t)^(1/t)<br>" +"for -"ÿtÿ" suggests several basic<br>" +"relationships between the power means.<br>" +"Perhaps the most productive of these<br>" +"is simply the fact that Mt is a<br>" +"monotone increasing function of the<br>" +"power t, but all of the elements of <br>" +"the diagram have their day.<br>" +"<br>" +"Red curve equation is next (Not exact, just for shape)<br>" +"pow(0.3*pow(0.5,(x*1.5))+0.7*pow(3.5,(x*1.5)),1/(x*1.5))<br>" +"2010-02-16-08-27 stop<br>" return; } //function figure0801() //9902152257 /** //9809261416 //fillRand(ouBoxID) use ".form1." //fillRand2(ouBoxID) delete ".form1." //fillRand3(ouBoxID) delete ".form1." //use chkbxcB1, chkbxcB2 for sorting //fillRand4(ouBoxID) delete ".form1." //output complex number a+i*b 9810121232 //9810121458 use ouBoxID2 //function fillRand4(ouBoxID1,ouBoxID2) //9810121233 //fillRand5(ouBoxID) same as fillRand4 //but isolate code from page elements ID //all page elements ID enter from //function argument list. 9902190914 9902190929 arg1 = 0/1, if 1 output complex, else real arg2 = power index 10^this arg3 = precision output this many digit arg4 = generate this many random numbers arg5 = 0/1 for +/0 [0] or +/0/- [1] arg6 = 0/1 for real [0] or integer [1] all 0/1 '0' is default, '1' must be specified function code nover refer to any html element ID 9902190936 Next is an example of calling method [[ <input type="button" value="random5#" onclick="javascript: QEboxb11.value= fillRand5(0, QEboxcA4.value, QEboxcA3.value, QEboxcA1.value, QEchkbxcA3.checked, QEchkbxcA1.checked); QEboxb12.value= probabOne(QEboxcA1.value); " /> ]] html elements ID all show up at calling line (above example) html elements ID never show up at function code. So that function can be used at other web page. (other web page have different html elements) 2010-02-19-12-13 /**/ function fillRand5(arg1,arg2, arg3,arg4,arg5,arg6) //9902190917 { //arg1=parseInt(arg1); //9902240803 delete //arg2=parseInt(arg2); arg2=parseFloat(arg2); //9902210800 use parseFloat() arg3=parseInt(arg3); arg4=parseInt(arg4); if( /**isNaN(arg1)|| /*9902240801 delete. Now T/F, not 1/0*/ isNaN(arg2) ||isNaN(arg3)||isNaN(arg4) ) //return 'calling parameter 1/2/3/4 need integers.\n' //9902240802 return 'calling parameter 2/3/4 need integers.\n' +arg1+',' +arg2+',' +arg3+',' +arg4+',' +arg5+',' +arg6 ; //9902191004 var powIndex=arg2; //9902190946 var precision0; precision0=arg3; if(arg6==1)precision0=powIndex; //if powIndex=3, stretch random // from [0,1] to [0,1000] powIndex=Math.pow(10,powIndex); var precision1=Math.pow(10,precision0); var randRang=precision1; //if(powIndex)randRang=randRang/powIndex; //9902232247 change to next line if(powIndex)randRang=randRang/parseInt(powIndex); var randPoNe1=1; var randPoNe3=1; var randPN=1; if(arg5)randPN=-1; var dataPerS=arg4; var DecInt=0; if(arg6)DecInt=1; var ouStr1=''; var ouStr2=''; var oneCplx=''; var t0,t1,t2,t3; var dbg0=''; //9902232227 dbg0+='function fillRand5()\narg1 to arg6 are\n' +arg1+',' +arg2+',' +arg3+'\n' +arg4+',' +arg5+',' +arg6+'\n' +'precision1 ='+precision1+', ' +'powIndex='+powIndex+'\n' +'randRang='+randRang+'\n' //control precision. 9902240725 var minus1byteReal=0; var minus1byteImag=0; for(t0=0;t0<dataPerS;t0++) { t1=Math.random()*precision1; t3=Math.random()*precision1; dbg0+='*****\n' +'t0 ='+t0+', ' +'t1a='+t1+'\n' +'precision1='+precision1+'\n' /** 2009-10-12-20-00 paid attention that Exercise 2.13 limit to complex number real part be positive. Next check box control complex number real part. complex number imaginary part is +/0/- user can not control. 2009-10-12-20-12 /**/ //control precision. 9902240730 minus1byteReal=0; minus1byteImag=0; if(randPN<0) { t2=(t1+'').charAt((t1+'').length-1); if(t2%2)randPoNe1=-1 else randPoNe1=+1; } t2=(t3+'').charAt((t3+'').length-1); if(t2%2)randPoNe3=-1 else randPoNe3=+1; if(randPoNe1==-1)minus1byteReal=1 if(randPoNe3==-1)minus1byteImag=1 dbg0+='' +'t1b='+t1+', ' +'randPoNe1='+randPoNe1+'\n' +'t1=Math.floor(t1)*randPoNe1='+(Math.floor(t1)*randPoNe1)+'\n' t1=Math.floor(t1)*randPoNe1; t1=t1/randRang; dbg0+='' +'randRang='+randRang+'\n' +'t1=t1/randRang='+t1+'\n' if(DecInt)t1=parseInt(t1); //else t1=bye09(t1); //9902232256 //minus1byteReal //9902240733 change to next , '+1' space for '.' else t1=(''+t1).substring(0,arg3+1+minus1byteReal) //9902232254 include function bye09() //9902240739 delete function bye09(), because //".substring(0,arg3+1+minus1byteReal)" is better. t3=Math.floor(t3)*randPoNe3; t3=t3/randRang; if(DecInt)t3=parseInt(t3); //else t3=bye09(t3); //9902232257 //minus1byteImag //9902240737 change to next [=][][] else t3=(''+t3).substring(0,arg3+1+minus1byteImag) if(arg1) oneCplx='' +t1 +(t3<0?'':'+') +t3+'i'; else oneCplx='' //9902191008 +t1 if(randPoNe1==1)ouStr1+=' '; ouStr1+=oneCplx+'\n'; } QEboxb13.value=dbg0 +'9902232241 dbg\n' ; //9902232228 return ouStr1; //9902191043 } //9902191108 done fillRand5() //9806101352 function fillRand(ouBoxID) //9809261417 function fillRand2(ouBoxID) //fillRand3(ouBoxID) delete ".form1." //use chkbxcB1, chkbxcB2 for sorting //fillRand4(ouBoxID) delete ".form1." //output complex number a+i*b 9810121232 /** 99,02,23 version add poArg2 99,02,23 version inp0 change to ans0 9811281438 probability sum to one if poArg1 is input box ID name program read input box value, assume a list of probability numbers 0<=pj<=1 j=1,2,...,n. program normalize pj if poArg1 is an integer n, program create n probability numbers 0<=pj<=1 j=1,2,...,n and SUM{pj}=1 9811281442 probabOne() read input numbers from boxb12 boxb13.value=probabOne(boxb12.value) probabOne(5) ask program to generate 5 probability numbers. boxb13.value=probabOne(n) 9902191115 include probabOne() to powmean2.htm 9902231541 call probabOne() as following QEboxb12.value= probabOne(QEboxcA1.value,QEchkbxcA4.checked); poArg1 record number of pj elements asked poArg1 can be an array of number to be normalized to sum=1 poArg2 = true return equal probability poArg2 = false return random probability 9902231543 /**/ function probabOne(poArg1,poArg2) { var m0,m1,m2,m3; var rand1,rand2; var ans0=''; rand1=[0,0]; rand2=0; if(isNaN(poArg1)) //poArg1 is input box ID name { rand1=readdata(poArg1); //9811281500 if(poArg2) //9902231547 { m1=1/rand1.length; for(m0=0;m0<rand1.length;m0++) { ans0+=m1+'\n' } return ans0; //9902231550 } for(m0=0;m0<rand1.length;m0++) { if(rand1[m0]<0) { return 'Input box can not have negative number. \n' +'Probability must be positive or zero.'; } rand2+=rand1[m0]; //9811282130 } } else { poArg1=parseInt(poArg1); if(poArg2) //9902231551 { m1=1/poArg1; for(m0=0;m0<poArg1;m0++) { ans0+=m1+'\n' } return ans0; //9902231552 } for(m0=0;m0<poArg1;m0++) { rand1[m0]=Math.random(); //9811281509 rand2+=rand1[m0]; //9811282132 } } //if(isNaN(poArg1)) else //parameter is number if(rand1.length==2&&rand1[0]==0&&rand1[1]==0) { return 'Box 12, input box can not be empty\n' +'Please click [random5#] button first.'; //9811281545 } m1=rand2 //9811282133 for(m0=0;m0<rand1.length;m0++) { rand1[m0]=rand1[m0]/m1; //9811281516 } ans0=(''+rand1).replace(/,/g,'\n');//9811281518 return ans0; //9811281519 } //function probabOne(poArg1,poArg2) //--> </script> <br> <br> <br> <!--9902250306--> <a name="DrawEx0803">&lt;a name="DrawEx0803"&gt;</a> <br> Next is comparison of Power Mean Inequality Curve (red) <br> with probability coefficient sum to one and curve (blue) <br> which drop all probability coefficients. Both curves <br> are fake, made from fabricated math equation. <br> <input onclick="javascript:exercise0803(1)" type="button" value="Draw exercise0803" /> <input onclick="QFdivGraph0803.innerHTML = QFspanEqnDoc0803.innerHTML = ''" type="button" value="wipe" /> Exercise 8.3 ; 2010-02-25-03-09 <br> <font color=red> <span id=QFspanAlert0803> </span> </font> <br> <div id=QFdivGraph0803></div> <br> <span id=QFspanEqnDoc0803> </span> <script lang="javascript"> <!-- function exercise0803(Arg1) //990225 { var xend,xbgn xbgn=-6 xend= 6 var step5=60 var delta=(xend-xbgn)/step5; var x,b0; QFspanAlert0803.innerHTML=''; var eqn00=eqn01=eqn02=eqn03=''; eqn00='1+pow(0.3*pow(0.5,(x*1.5))+0.7*pow(3.5,(x*1.5)),1/(x*1.5))'; //9902250403 use eqn01 and eqn02 separately eqn01='gatef(x,-99,0)*(1.8-3.8*(pow(0.3*pow(0.5,((x+3.5)*1.5))+0.7*pow(3.5,((x+3.5)*1.5)),1/((x+3.5)*1.5)))/7)' eqn02='gatef(x,0,99)*(-sqrt(36-(x-6)*(x-6))+10.7)' //9902250405 OK get what I want var MyGraph = new XYGraph(); var MyLine1 = new XYLine(); var MyLine2 = new XYLine(); MyLine1.VMLpointshapetype="none"; MyLine2.VMLpointshapetype="none"; status=''; MyGraph.ymax=10; MyGraph.ymin= -2; MyGraph.xmax=6; MyGraph.xmin=-6; MyGraph.gheight=300; MyGraph.gwidth=300; MyGraph.title= "ISBN 978-0-521-54677-5 page 132 Exercise 8.3"; var b1=0; // if(eqn00.length>0) { for(b0=0;b0<=step5;b0++) { x=xbgn+delta*(b0+b1); MyLine1.x[b0] =x; MyLine1.y[b0] =eval('with(Math){'+eqn00+'}'); } //for(b0=0;b0<=step5;b0++) MyLine1.VMLstroke="weight='1pt'; color='red'; dashstyle='solid';"; MyGraph.Plot(MyLine1); } //if(eqn00.length>0) MyLine2.x[0] =xend; MyLine2.y[0] = 4.5; MyLine2.x[1] =xbgn; MyLine2.y[1] = 4.5; MyLine2.VMLstroke="weight='1pt'; color='blue'; dashstyle='dash';"; MyGraph.Plot(MyLine2); MyLine2.x[0] =xend; MyLine2.y[0] = 1.5; MyLine2.x[1] =xbgn; MyLine2.y[1] = 1.5; MyGraph.Plot(MyLine2); b1=0; if(eqn01.length>0) { for(b0=0;b0<=step5;b0++) { // x=xbgn+delta*(b0+b1); MyLine2.x[b0] =x; MyLine2.y[b0] =eval('with(Math){'+eqn01+'}'); } //for(b0=0;b0<=step5;b0++) MyLine2.VMLstroke="weight='1pt'; color='blue'; dashstyle='solid';"; MyGraph.Plot(MyLine2); } //if(eqn01.length>0) b1=0; if(eqn02.length>0) { for(b0=0;b0<=step5;b0++) { // x=xbgn+delta*(b0+b1); MyLine2.x[b0] =x; MyLine2.y[b0] =eval('with(Math){'+eqn02+'}'); } //for(b0=0;b0<=step5;b0++) MyLine2.VMLstroke="weight='1pt'; color='blue'; dashstyle='solid';"; MyGraph.Plot(MyLine2); } //if(eqn02.length>0) // draw intercept points var MyLabel = new Label(); MyLabel.labelsize = "10"; MyLabel.VMLpointshapetype="circle"; MyLabel.labelcolor="black"; MyLabel.rotation = +0; QFdivGraph0803.innerHTML = MyGraph; QFspanEqnDoc0803.innerHTML = "" +"2010-02-25-10-57 start<br>" +"Power mean inequality use a equation at Box 5<a href='#powMeanClick'><br>" +"left side</a>. What happen if all probability<br>" +"coefficients set to one that is ignore them.<br>" +"If do so, red Power mean inequality curve<br>" +"change to blue curve.<br>" +"What is upper/lower blue dash line?<br>" +"If observed data has 20 numbers {xj} j=1,20<br>" +"Upper blue dash line is maximum in {xj}<br>" +"Lower blue dash line is minimum in {xj}<br>" +"At power t=-infinity, both red/blue start from min.<br>" +"At power t=+infinity, both red/blue end up at max.<br>" +"What is 'power t'? You need see <a href='#powMeanClick'>equation</a>.<br>" +"Red curve equation is next (Not exact, just for shape)<br>" +"pow(0.3*pow(0.5,(x*1.5))+0.7*pow(3.5,(x*1.5)),1/(x*1.5))<br>" +"2010-02-25-11-02 stop<br>" return; } //function exercise0803() // //9804281114 gate function function gatef(t0,bgn0,end0) { if(arguments.length==0)return 0; if(arguments.length==1)return 0; if(arguments.length==2) //9804281141 { if(t0<bgn0) return 0;else return 1;} if(t0<bgn0) return 0.; if(t0>end0) return 0.; return 1.; // 9804281117 } // end function // gatef(t,3.2,5.6) if t<3.2 get 0 // gatef(t,3.2,5.6) if t>5.6 get 0 // gatef(t,3.2,5.6) if 3.2<=t<=5.6 get 1 // 9804281119 //--> </script> <pre><font size=+2> <a name="docA001">&lt;a name="docA001"&gt;</a> 2010-02-19-16-20 start This file Power Mean Inequality Curve http://freeman2.com/powmean2.htm is written during Liu,Hsinhan study the book<a href=http://www-stat.wharton.upenn.edu/~steele/Publications/Books/CSMC/CSMC_index.html> The Cauchy-Schwarz Master Class</a><a href=http://www-stat.wharton.upenn.edu/~steele/index.html> J. Michael</a> <a href=http://www.wharton.upenn.edu/faculty/steele.html>Steele</a> <a href=http://www.amazon.com/review/product/052154677X/ref=cm_cr_dp_all_helpful?%5Fencoding=UTF8&coliid=&showViewpoints=1&colid=&sortBy=bySubmissionDateDescending>&&&&&</a> <a name="docA002">&lt;a name="docA002"&gt;</a> ISBN 978-0-521-54677-5<!--9807061815 add ISBN--><a href=http://freeman2.com/tute0030.htm#ch08a001> chapter 8</a> The Ladder of Power Means. At first, LiuHH create a <a href="#figure0801">fake curve</a> But not satisfied. Start code from 2010-02-18-14-07 done code at 2010-02-19-12-?? <a name="docA003">&lt;a name="docA003"&gt;</a>0<a href="#pPowBox">pPow</a>0<a href="#powMeanBgn">program</a> Page control panel is next [[ &lt;a name="powMeanBgn"&gt; 2010-02-19-12-53 Graph area size, W:[300] H:[300] x min:[-5], x max:[5] ; y min:[0], y max:[10] ; x/y min/max : £%auto scale, ¡%user scale Click button 10^[1] ; £%+/0 , ¡%+/0/- ; [5] digits Help1 "random5#" fill [20] numbers; ¡%integer; <a name="docA004">&lt;a name="docA004"&gt;</a> Box 1, x<sub>j</sub> sequence Box 2, p<sub>j</sub> sequence Box 3, output Box 4, drawDot t bgn [-5] , t end [5] steps [30] "dt" "ds" Click to RUN "PowerMean" "wipe" "random5#" control center { "[k=n,k=1] p<sub>k</sub>x<sub>k</sub><sup>t</sup> }<sup>1/t</sup> Box 5, dots t values ]] <a name="docA005">&lt;a name="docA005"&gt;</a> Graph area size, W:[300] H:[300] Let user decide drawing board width and height. x min:[-5], x max:[5] ; y min:[0], y max:[10] ; Let user decide x-axis two end values and y-axis two end values. <a name="docA006">&lt;a name="docA006"&gt;</a> x/y min/max : £%auto scale, ¡%user scale Let user decide use auto scale or use user scale. If choose auto scale, above boxes values are ignored. "Click button " let user go to Click button "PowerMean" quickly <a name="docA007">&lt;a name="docA007"&gt;</a> 10^[1] ; Random generated in the range [0,1] If fill 1 to [1], program stretch random number to [0,10] (10^1=10) If fill 2 to [2], program stretch random number to [0,100] (10^2=100) <a name="docA008">&lt;a name="docA008"&gt;</a>0<a href="#pPowBox">pPow</a>0<a href="#powMeanBgn">program</a> £%+/0 , ¡%+/0/- ; If choose £%+/0 , output random positive or zero, no negative. This is default. If choose £%+/0/- , output random positive or zero or negative. In this file x<sub>j</sub> sequence and p<sub>j</sub> sequence must be +/0 Negative number is not allowed. <a name="docA009">&lt;a name="docA009"&gt;</a> [5] digits If fill 5 to [5], output to 1.2345 If fill 8 to [8], output to 32.456789 Help1 Bring user to here. <a name="docA010">&lt;a name="docA010"&gt;</a> "random5#" is execution button. generate random numbers. output to box 1 for x<sub>j</sub> sequence and output to box 2 for p<sub>j</sub> sequence fill [20] numbers; If fill 20 to [20], x<sub>j</sub> sequence has 20 numbers, p<sub>j</sub> sequence has 20 numbers. <a name="docA011">&lt;a name="docA011"&gt;</a> ¡%integer; If check ¡%integer, x<sub>j</sub> sequence is integer only. (p<sub>j</sub> can not be integer) Box 1, x<sub>j</sub> sequence Let user define his own x<sub>j</sub> sequence <a name="docA012">&lt;a name="docA012"&gt;</a> Box 2, p<sub>j</sub> sequence Let user define his own p<sub>j</sub> sequence p<sub>j</sub> must sum to one. tolerance=1.e-8 if abs(sum_p<sub>j</sub>-1)>tolerance ERROR. Box 3, output output curve (t,Mt) coordinates values. <a name="docA013">&lt;a name="docA013"&gt;</a>0<a href="#pPowBox">pPow</a>0<a href="#powMeanBgn">program</a> Box 4, drawDot Output user specified t value (t,Mt) pair. If want to know Mt value for t=1.23456 t=1.23456 may not occur in "Box 3, output" User input 1.23456 to box 5, program send (t=1.23456, Mt) pair to box 4 and draw a dot at t=1.23456. <a name="docA014">&lt;a name="docA014"&gt;</a> t bgn [-5] , t end [5] Program draw (t,Mt) pair lines, start at t="t bgn [-5]", end at t="t end [5]" If "t end [5]" > "t bgn [-5]" autoscale work. If "t end [-5]" < "t bgn [5]" userscale work. <a name="docA015">&lt;a name="docA015"&gt;</a> steps [30] If fill 30 to "steps [30]", program draw 30 short straight lines to build curve. minimum value is 10. "dt" delete "t bgn" and "t end" "ds" delete "steps" <a name="docA016">&lt;a name="docA016"&gt;</a> Click to RUN "PowerMean" powMeanf() execution button is "PowerMean" "wipe" to delete drawing <a name="docA017">&lt;a name="docA017"&gt;</a> "random5#" second random button. control center goto control center quickly <a name="docA018">&lt;a name="docA018"&gt;</a>0<a href="#pPowBox">pPow</a>0<a href="#powMeanBgn">program</a> { "[k=n,k=1] p<sub>k</sub>x<sub>k</sub><sup>t</sup> }<sup>1/t</sup> Equation for Mt and t not=0 Box 5, dots t values default t value be -1 0 1 2 Output to box four <a name="docA019">&lt;a name="docA019"&gt;</a> Drawing output has a top red dash and a bottom red dash lines. Top one is M<sub>+"</sub>=maximum value of x<sub>k</sub> k=1 to n Bottom one is M<sub>-"</sub>=minimum value of x<sub>k</sub>, k=1 to n <a name="docA020">&lt;a name="docA020"&gt;</a> This program may not be perfect. But you have what I have. Happy playing !! Thank you for visiting Freeman's page. 2010-02-19-17-25 stop <hr> <a name="docA021">&lt;a name="docA021"&gt;</a> 2010-02-19-17-52 start powmean2.htm contain the following external javascript files jsgraph2.js tutelink.js rocsitee.js jslist1e.js <a name="docA022">&lt;a name="docA022"&gt;</a> Where graph code is jsgraph2.js, link list is tutelink.js, Javascript program list jslist1e.js Freeman site banner file rocsitee.js <a name="docA023">&lt;a name="docA023"&gt;</a>0<a href="#pPowBox">pPow</a>0<a href="#powMeanBgn">program</a> If you want the drawing program work must include jsgraph2.js Location is http://freeman2.com/jsgraph2.js Other *.js files use same domain http://freeman2.com/filename.js <a name="docA024">&lt;a name="docA024"&gt;</a> jsgraph2.js is XYGraph v2.3 code written by Mr. J. Gebelein. You can find code at http://www.structura.info/XYGraph/XYGraph.zip 2010-02-19-18-00 stop <a name="docA025">&lt;a name="docA025"&gt;</a> 2010-02-22-18-47 start "Update 2010-02-22" made small change. Allow "10^" box fill with non- integer. For example "10^ [ 1.2345 ]" will create random number range in [0, 17.16] Code change is [[ //arg2=parseInt(arg2); arg2=parseFloat(arg2); //9902210800 use parseFloat() ]] <a name="docA026">&lt;a name="docA026"&gt;</a> If you want to keep drawing. Use keyboard "copy screen" function. Paste full screen image to paint.exe and save to file. 2010-02-22-18-53 stop <a name="docA027">&lt;a name="docA027"&gt;</a>0<a href="#pPowBox">pPow</a>0<a href="#powMeanBgn">program</a> 2010-02-23-15-55 start "Update 2010-02-23" change as below. If in your application probability is equal and if you have a data set of twelve elements. You can not fill twelve '1' to "Box 2, pj sequence", because twelve '1' sum to 12 which is not equal to 1, program stop work. <a name="docA028">&lt;a name="docA028"&gt;</a> In this case you can click check box "eq.p" (equal probability), program auto fill twelve 1/12 (0.08333333333333333) for you, avoid hand fill in. Code change please search for "99022315" 2010-02-23-16-00 stop <a name="docA029">&lt;a name="docA029"&gt;</a> 2010-02-24-11-20 start "Update 2010-02-24" main change is let precision digits number work when "10^" box filled noninteger. "Update 2010-02-22" made small change. Correct one point, miss another point. "Update 2010-02-24" key point is at time stamp "9902232247" and "9902240733". <a name="docA030">&lt;a name="docA030"&gt;</a> If user specify "[5] digits" in [[ 10^[ ] ; +/0 , +/0/- ; [5] digits ]] then program output five digits random number even if user assign 10^noninteger. Code change please search for "9902232" <a name="docA031">&lt;a name="docA031"&gt;</a>0<a href="#pPowBox">pPow</a>0<a href="#powMeanBgn">program</a> "Update 2010-02-24" second change is add "complex" checkbox. This file powmean2.htm do not use complex random number. But the fillRand5() function has complex random number capability. If user click check "complex" checkbox, Box 1, xj sequence fill with complex random number. <a name="docA032">&lt;a name="docA032"&gt;</a> User can get complex random number here and use it in other web page or other application program. 2010-02-24-11-34 stop <a name="docA033">&lt;a name="docA033"&gt;</a> 2010-02-25-11-48 start "Update 2010-02-24" third change. 2010-02-25 morning added <a href="#pPowBox">one line</a> [1 ] p<sub>k</sub> power. If not one, use steps=300+ allow user to explore: if p<sub>k</sub> NOT sum to one, what happen? <a name="docA034">&lt;a name="docA034"&gt;</a> If you set p<sub>k</sub> power other than one. For example, fill '0.9' . All probability coefficient change as following p<sub>k</sub>=p<sub>k</sub><sup>0.9</sup> Before change, p<sub>k</sub> must sum to 1. <a name="docA035">&lt;a name="docA035"&gt;</a> After change, p<sub>k</sub> not sum to 1. Curve become non-smooth. Jump to infinity at t=0. You need set greater step number, for example change from 30 to 300 to see abrupt jump. <a name="docA036">&lt;a name="docA036"&gt;</a>0<a href="#pPowBox">pPow</a>0<a href="#powMeanBgn">program</a> This explore arrangement come from <a href="tute0032.htm#textbook">textbook</a> <a href="tute0032.htm#ch08c018">Exercise 8.3</a>. If set p<sub>k</sub> power box to 0. Any number zero th power is one. All p<sub>k</sub> become one, that is to ignore p<sub>k</sub> and this choice is what Exercise 8.3 doing. <a name="docA037">&lt;a name="docA037"&gt;</a> Do not jump from 1 to 0 directly.<a href="#pPowBox"> drawing board</a> show nothing for pPow=0. Change pPow to 0.99 first see the trend. <a name="docA038">&lt;a name="docA038"&gt;</a> p<sub>k</sub> power = 0. has a drawing at <a href="#DrawEx0803">DrawEx0803</a>. You can see DrawEx0803 to get an idea what happen if ignore all p<sub>k</sub>. 2010-02-25-12-09 stop <a name="docA039">&lt;a name="docA039"&gt;</a> 2010-03-02-09-30 start "Update 2010-03-02" change as following 1. Add alert ("9903011048", "9903011052") length (GM) compare length (AM) OK, require "pk=1 exactly. or length^0.731 compare length^1.0?0NO ! See broken curve below if change "p<sub>k</sub> power" box value to non-one, second alert line show up. ("0.731" varies, depend on pk value) <a name="docA040">&lt;a name="docA040"&gt;</a> 2. PowerMeanA modify input. ("9903011945") PowerMeanB not modify input box 3. add "JensenA", "JensenB" click button. in function powMeanf() add Jensen code 2010-03-01-17-28 start Jensen (9903011728 start) 2010-03-01-19-23 done Jensen (9903011923 done) <a name="docA041">&lt;a name="docA041"&gt;</a>0<a href="#pPowBox">pPow</a>0<a href="#powMeanBgn">program</a> Detail as following 1. This program powmean2.htm add control box "p<sub>k</sub> power" allow user change probability coefficients. If change, prob. coef. sum will not be one and cause trouble. This trouble-output is designed on purpose, let user see what happen if compare length^1.1 with length^1.0 If "p<sub>k</sub> power" valueÿ1.0, then "pkÿ1.0 If "p<sub>k</sub> power" valueÿ1.0, then "pkÿ1.0 <a name="docA042">&lt;a name="docA042"&gt;</a>0<a href="#pPowBox">pPow</a>0<a href="#powMeanBgn">program</a> 2. and 3.<font color=red> 'A' button run default setting. 'B' button run user setting. User must uncheck "auto scale", check "user scale"</font> Previous version, only one execution button "PowerMean". Now total four execution buttons "PowerMeanA" modify input. ("9903011945") "PowerMeanB" not modify input box "JensenA" modify input. "JensenB" not modify input box <a name="docA043">&lt;a name="docA043"&gt;</a> The default control panel boxes setting was for x-sequence in [5, 20] range. Need one execution button "PowerMean". 2010-02-26-17-59 start <a href=tute0032.htm#ch08c091>Exercise 8.7</a> 2010-03-01-21-25 done <a href=tute0032.htm#ch08c129>Exercise 8.7</a> During Exercise 8.7 work, LiuHH need to know <a href="tute0032.htm#ch08c097">eqn.AZ044</a> curve shape. Start modify powmean2.htm function powMeanf(). Added JensenDraw=0; //9903011810 to guide Jensen output. <a name="docA044">&lt;a name="docA044"&gt;</a> When Jensen click button is used, the default control boxes values are not suitable for Jensen. Then in Jensen click button added [[ QEboxtBgn.value=0; QEboxtEnd.value=1.5; QEboxStep.value=300; QEboxXmin.value=0 QEboxXmax.value=1.5 QEboxYmin.value=-2 //was -100 QEboxYmax.value=10 //was 100 QEchkbxcD2.checked=1 QEchkbxcD1.checked=0 ]] <a name="docA045">&lt;a name="docA045"&gt;</a> before call powMeanf() Ymin=-100 and Ymax=100 are for x-sequence in [0,17]. LiuHH also test x-sequence in [0,1] then click "Jensen" button, graph auto set Ymin=-100 and Ymax=100 , all three curves are flat on x-axis. I have no control !! For x-sequence in [0,1] I need Ymin=-1 and Ymax=1. Then write "JensenA" button and "JensenB" button. <a name="docA046">&lt;a name="docA046"&gt;</a>0<a href="#pPowBox">pPow</a>0<a href="#powMeanBgn">program</a> "JensenA" button reset several boxes value, suitable for x-seq.=[0,17] "JensenB" button do not reset any box value, use boxes value as is and call powMeanf() directly. This is why write "JensenA" and B two buttons. <a name="docA047">&lt;a name="docA047"&gt;</a> If first run "JensenA" then second run "PowerMean", all control boxes value are for Jensen, not suitable for PowerMean. Split "PowerMean" too "PowerMeanB" button do not reset any box value, <a name="docA048">&lt;a name="docA048"&gt;</a> "PowerMeanA" button reset the following [[ QEboxtBgn.value=-5; QEboxtEnd.value=5; QEboxStep.value=30; QEchkbxcD2.checked=0 QEchkbxcD1.checked=1 ]] before call powMeanf() Please click the right button which is suitable for your case. <a name="docA049">&lt;a name="docA049"&gt;</a> Why added Jensen code? Partial document is recorded at (<a href=tute0032.htm#ch08c115>local</a>)<a href=http://freeman2.com/tute0032.htm#ch08c115> http://freeman2.com/tute0032.htm#ch08c115</a> <a name="docA050">&lt;a name="docA050"&gt;</a>0<a href="#pPowBox">pPow</a>0<a href="#powMeanBgn">program</a> What is Jensen output curve key point? Which point I should pay attention to Jensen curve? Please see Jensen-curve-below document. There tell you two key points to observe. Not repeat here. 2010-03-02-10-29 stop 2010-03-03-15-44 done spelling check <a name="docA051">&lt;a name="docA051"&gt;</a> 2010-03-06-11-15 start "Update 2010-03-06" made the following change <a name="docA052">&lt;a name="docA052"&gt;</a> First: 2010-03-03-21-08 added ÿa href="#contralCenter"ÿ Old version, click "contralCenter" goto ÿa name="powMeanBgn"ÿ This version, click "contralCenter" goto ÿa href="#contralCenter"ÿ <a name="docA053">&lt;a name="docA053"&gt;</a> Second: Add code to find slope value //<a href=tute0032.htm#ch08c128>eqn.AZ064</a> (eqn.8.35) var dfdtat1= //eqn.AZ064 , 9903040358 sum1-sum0*Math.log(sum0); <a name="docA054">&lt;a name="docA054"&gt;</a> Third: draw tangent at t=1 on black curve See code at "9903041110" 2010-03-06-11-23 stop </font></pre> <br><hr><br> Javascript index <br> <a href=http://freeman2.com/jsindex2.htm> http://freeman2.com/jsindex2.htm </a> &nbsp; <a href=jsindex2.htm> local </a> <!--9810201450 add local link--> <br> Save graph code to same folder as htm files. <br> <a href=http://freeman2.com/jsgraph2.js> http://freeman2.com/jsgraph2.js </a> &nbsp; <a href=jsgraph2.js> local </a> <br> <script src="jslist1e.js" language="javascript"></script> <br> <br> This page Power Mean Inequality Curve <br> <a href=http://freeman2.com/powmean2.htm> http://freeman2.com/powmean2.htm </a> <br> powmean2.htm first upload 2010-02-19 <br> <br> Thank you for visiting Freeman's page.0 <br> Freeman <br> 2010-02-19-16-17 <br> <br> <span id="tuteLink2"></span> </BODY> </HTML> <!-- 99,02,18,14,07 open cauchy6e.htm save as powmean2.htm -->