Power Mean Inequality Curve
program   click   explore   help   Update 2012-04-03
XYGraph v2.3 - web page graph   ☜☞   donate   get code
The Cauchy-Schwarz Master Class   J. Michael Steele   ★★★★★
This file is personal home work. No one
proofread. Cannot promise correctness.
If you suspect any view point wrong,
please ask a math expert near by.
Freeman 2009-06-19-10-46

Please use MSIE browser to read this file.
Did not test other browser. This file is
written under MSIE 6.0

<a name="powMeanBgn"> 2010-02-19-12-53
Output may contain error, Please verify first
Program environment is MSIE 6.0, please use MSIE
If you save this file powmean2.htm to your computer
and open local powmean2.htm, it can not draw figure.
You need also save http://freeman2.com/jsgraph2.js
to your computer stay in same folder as powmean2.htm

Graph area size, W: H:   complex
x min: , x max: ; y min: , y max: ;
x/y min/max : auto scale, user scale Click button
10^ ; +/0 , +/0/- ; digits Help1
fill numbers; integer; eq.p
Box 1, xj sequence
Box 2, pj sequence
Box 3, output
Box 4, drawDot
pk power. If not one, use steps=300+ 2010-02-25-11-22

t bgn , t end steps    
Click to RUN control center
Why 'A', 'B' ?
pkxkt }
Box 5, dots t values

<a name="figure0801">
Next is first version Power Mean Inequality Curve
used in tute0030.htm. It is a fake power mean curve.
Because it is created from a mathematics equation
not created from real x-sequence and p-sequence.
Figure 8.1 ; 2010-02-15-22-42

<a name="DrawEx0803">
Next is comparison of Power Mean Inequality Curve (red)
with probability coefficient sum to one and curve (blue)
which drop all probability coefficients. Both curves
are fake, made from fabricated math equation.
Exercise 8.3 ; 2010-02-25-03-09

<a name="docA001">
2010-02-19-16-20 start
This file Power Mean Inequality Curve 
is written during Liu,Hsinhan study
the book
The Cauchy-Schwarz Master Class
J. Michael Steele ★★★★★
<a name="docA002">
ISBN 978-0-521-54677-5
chapter 8 The Ladder of Power Means.
At first, LiuHH create a fake curve
But not satisfied. 
Start code from 2010-02-18-14-07
done  code  at  2010-02-19-12-??

<a name="docA003"> pPow program
Page control panel is next
<a name="powMeanBgn"> 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">
Box 1, xj sequence   
Box 2, pj 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] pkxkt }1/t
Box 5, dots t values   
<a name="docA005">
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">
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">
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"> pPow program
 ▣+/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
xj sequence and pj sequence must be +/0
Negative number is not allowed.

<a name="docA009">
 [5] digits 
If fill 5 to [5], output to 1.2345
If fill 8 to [8], output to 32.456789

Bring user to here.

<a name="docA010">
is execution button. generate random
numbers. output to box 1 for xj sequence 
and output to box 2 for pj sequence

fill [20] numbers;
If fill 20 to [20], xj sequence has 20
numbers, pj sequence has 20 numbers.

<a name="docA011">
If check □integer, xj sequence is
integer only. (pj can not be integer)

Box 1, xj sequence  
Let user define his own xj sequence
<a name="docA012">
Box 2, pj sequence   
Let user define his own pj sequence
pj must sum to one. tolerance=1.e-8
if abs(sum_pj-1)>tolerance ERROR.

Box 3, output   
output curve (t,Mt) coordinates values.

<a name="docA013"> pPow program
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">
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">
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">
Click to RUN "PowerMean"
powMeanf() execution button is 

to delete drawing

<a name="docA017">
second random button.

 control center
goto control center quickly

<a name="docA018"> pPow program
 { ∑[k=n,k=1] pkxkt }1/t
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">
Drawing output has a top red dash
and a bottom red dash lines.
Top one is M+∞=maximum value of xk
k=1 to n
Bottom one is M-∞=minimum value of 
xk, k=1 to n

<a name="docA020">
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

<a name="docA021"> 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"> 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"> pPow program 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"> 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"> 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"> 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"> pPow program 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"> 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"> 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"> 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"> pPow program "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"> 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"> 2010-02-25-11-48 start "Update 2010-02-24" third change. 2010-02-25 morning added one line [1 ] pk power. If not one, use steps=300+ allow user to explore: if pk NOT sum to one, what happen? <a name="docA034"> If you set pk power other than one. For example, fill '0.9' . All probability coefficient change as following pk=pk0.9 Before change, pk must sum to 1. <a name="docA035"> After change, pk 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"> pPow program This explore arrangement come from textbook Exercise 8.3. If set pk power box to 0. Any number zero th power is one. All pk become one, that is to ignore pk and this choice is what Exercise 8.3 doing. <a name="docA037"> Do not jump from 1 to 0 directly. drawing board show nothing for pPow=0. Change pPow to 0.99 first see the trend. <a name="docA038"> pk power = 0. has a drawing at DrawEx0803. You can see DrawEx0803 to get an idea what happen if ignore all pk. 2010-02-25-12-09 stop <a name="docA039"> 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? NO ! See broken curve below if change "pk power" box value to non-one, second alert line show up. ("0.731" varies, depend on pk value) <a name="docA040"> 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"> pPow program Detail as following 1. This program powmean2.htm add control box "pk 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 "pk power" value>1.0, then ∑pk<1.0 If "pk power" value<1.0, then ∑pk>1.0 <a name="docA042"> pPow program 2. and 3. 'A' button run default setting. 'B' button run user setting. User must uncheck "auto scale", check "user scale" 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"> 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 Exercise 8.7 2010-03-01-21-25 done Exercise 8.7 During Exercise 8.7 work, LiuHH need to know eqn.AZ044 curve shape. Start modify powmean2.htm function powMeanf(). Added JensenDraw=0; //9903011810 to guide Jensen output. <a name="docA044"> 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"> 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"> pPow program "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"> 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"> "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"> Why added Jensen code? Partial document is recorded at (local) http://freeman2.com/tute0032.htm#ch08c115 <a name="docA050"> pPow program 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"> 2010-03-06-11-15 start "Update 2010-03-06" made the following change <a name="docA052"> 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"> Second: Add code to find slope value //eqn.AZ064 (eqn.8.35) var dfdtat1= //eqn.AZ064 , 9903040358 sum1-sum0*Math.log(sum0); <a name="docA054"> Third: draw tangent at t=1 on black curve See code at "9903041110" 2010-03-06-11-23 stop <a name="docA055"> 2012-04-03-13-52 start "Update 2012-04-03" corrected spelling error. Web page surface spelling error is easier to find out. Copy screen and do the spelling check. But /*code notes*/, and "quoted code string" do not show up on web page surface. Many spelling error buried in deep. <a name="docA056"> On 2012-03-09 LiuHH uploaded spelling check program to next URL http://freeman2.com/dict000a.htm From 2012-03-26 to 2012-04-03 LiuHH write pickdata.htm to extract text from //code notes and from 'quoted code string' dig them out and check spelling error. <a name="docA057"> LiuHH use http://freeman2.com/powmean2.htm do the test run. Now upload code notes spelling checked powmean2.htm . I need time to test/debug pickdata.htm when it is ready, I will upload to http://freeman2.com/pickdata.htm Today 2012-04-03 above URL is not valid. 2012-04-03-14-07 stop

Javascript index
http://freeman2.com/jsindex2.htm   local
Save graph code to same folder as htm files.
http://freeman2.com/jsgraph2.js   local

This page Power Mean Inequality Curve
powmean2.htm first upload 2010-02-19

Thank you for visiting Freeman's page.