2010-06-28-21-59 start
This page
Majorization transformation
between two sequences.
Given two sequences, find
doubly stochastic matrix
http://freeman2.com/jsmajor2.htm
is a result of study The
Cauchy-Schwarz Master Class
chapter 13 Majorization and
Schur Convexity
<a name="intro002">
jsmajor2.htm has four programs
(1) Given two sequences, find
doubly stochastic matrix.
Input at box 1 and box 2.
Output at box 7.
Example button from 11 to
18, 51 to 53 and 71 to 73.
<a name="intro003">
11 to 18 had no trouble at
early version. 51 to 53 got
negative element matrix at
early version. Now 51 to 53
are OK. Example 71 to 73 do
not have majorization
relation or not compatible.
Run button is [run stoch]
<a name="intro004">
(2) Matrix multiplication.
Input at box M1 and box M2.
Output at box M3.
This is an auxiliary function
Because Bx7 stochastic matrix
need Matrix multiplication,
<a name="intro005">
please see
P2*R2*P1*R1*ß seq. ---eqn.maj01
Run button is [M*M Array] and
[M*M Str]. Difference is here
Example buttons are 01,02,03.
<a name="intro006">
(3) Add quote to comments.
Allow one set comment be on
top of related function and
show up on web page. Serve
two locations. This is an
auxiliary function too.
<a name="intro007">
Inpur at Box M5, output at
Box M6.
Run button is [AddQuote pre]
and [AddQuote br]
This function for programmer
use only. because output to
javascript string code.
<a name="intro008">
(4) Sort number
Input at Box 71, output to
Box 72. Run button is
[Output new index] and
[sorted sequence 321] and
[sorted sequence 123]
<a name="intro009">
Another button [up side down]
change from
[[
aaa
bbb
ccc
]]
to
[[
ccc
bbb
aaa
]]
<a name="intro010">Box 1 top click button [s1]
Box 2 top click button [s2]
use sort function.
Create permutation matrix,
use sort [Output new index]
function.
2010-06-28-22-42 stop
<a name="intro810"> more 0102
2010-07-04-11-05 start
(5) Change fraction to quotient
number. This function is added
because in study notes pagehttp://freeman2.com/tute0047.htm
change decimal number matrix
to quotient number matrix.
<a name="intro811">
Change longer number to shorter
number. First time do it by
hand, second time decide to
write a program to convert.
Paste long decimal number into
[x=:] box, fill [n2=] number
default 3000. Click [fill M5]
<a name="intro812"> more 0102
Program generate sequence from
1 to 3000 at box M5. Next click
[x*M5] button. Output at box M6.
If the only sequence is positive
integer, program need only [n2=]
box, generate internal positive
integer sequence. Actually, this
<a name="intro813">
program read from box M5. Such
design allow any number sequence
be used. For example, user can
build a prime number sequence
for other application.
<a name="intro814">
Left side of [x*M5] button has a
[t] button, [t] is Test. Click t
program generate random number x
and indicate the quotient number
Right side of [x*M5] button has
a check box. If checked, output
sequence of x*Box M5 value.
<a name="intro815">
Number x = 2.353/7 = 2353/7000
= 13*181/(2*2*2*5*5*5*7) =
0.3361428571428572
If fill M5 up to 3000 (no 7000)
output x=NaN/undefined
NaN = Not a Number.
If fill M5 from 6800 to 7200
(has 7000) get normal answer.
2010-07-04-11-36 stop
<a name="intro910">
2010-07-04-12-34 start
(6) Build permutation matrix.
in/output is at Box 71
Paste random ordered data
sequence to Box 71. Click
[output new index] button.
Box 72 has answer.
<a name="intro911">
1st First is index sequence
which correspond to
descending data sequence.
Be alert to index sequence
and data sequence. They
are different.
data sequence is sorted.
index sequence appear random.<a name="intro912">
2nd Box 72 second answer is
permutation matrix which
transform Box 71 random
ordered data sequence to
descending data sequence.
<a name="intro913">
3rd Box 72 third answer is
permutation matrix which
transform Box 71 random
ordered data sequence to
ascending data sequence.
<a name="intro914">
To verify, copy permutation
Permut321 matrix to Box M1
copy Box 71 random ordered
sequence to Box M2, then
click [M*M Array] button.
Output to Box M3. It should
be in descending order. If
<a name="intro915">
you do not want permutation
matrix, just want sorted
number. On top of Box 71,
click [Sorted Seq 321] or
click [Sorted Seq 123] .
Output to Box 72 and no
permutation matrix.
2010-07-04-13-00 stop
<a name="intro011">
2010-06-29-11-31 start
Other click buttons are
Build n=[5] Identity matrix.
This is programming debug button.
In case you need identity matrix
it can help. Output to Box M3.
'5' in n=[5] can be replaced.
<a name="intro012">Verify Bx7 stochastic matrix.
stoch. matrix (SM) must be
all elements non-negative,
each column sum to one,
each row sum to one.
<a name="intro013">
You can do it by hand. But
Verify button do the job for
you. Output to
Box M3 for α_seq. = SM*β_seq
Box M4 for sum to one and
non-negative check.
<a name="intro014">
After find stochastic matrix
(Bx7) then
How to use stochastic matrix?
Please click above link. It
bring you to "How to" section.
<a name="intro015">
You need click
either one of 11 to 53 example
button, then
click "run stoch" button, then
click "How to use?" link.
Result display right below.
<a name="intro016">
How to use stochastic matrix
main point is under
＜a name=how007＞ where you can
verify that individual
alfa[i] = one row product
main point is also under
＜a name=how009＞ where tell you
which study page to read.
<a name="intro017">
This file jsmajor2.htm has many
javascript functions. Main
functions have document displayed
from docA handle
to docH handle
It may help you if you want to
know programming.
<a name="intro018">This file jsmajor2.htm
may still contain error.
If Liu,Hsinhan find error and
if LiuHH correct error, the
update notice is at whatsnew
section. Please visit whatsnew
regularly.
Thank you for visiting Freeman's
page. Freeman 2010-06-29-11-59.
<a name="intro019">
2010-06-29-15-40 start
The important javascript function
in this program are
function jkCheck(arg1,arg2,arg3)
function robinMatrixf(n,j,k,bj,bk,aj,ak)
function matMVecf(arg1,arg2)
If you find error output, above
three functions are first to exam.
<a name="intro020">
Within these three functions.
robinMatrixf() and matMVecf()
are less likely to have error.
LiuHH spend more time on the
function jkCheck().
If j,k determination is wrong,
output matrix has negative
elements or infinite loop.
2010-06-29-15-50 stop
<a name="majorBgn">
Output may contain error, Please verify first.
Program environment is MSIE 6.0, please use MSIE
Majorization transformation
between two sequences.
Input α sequence to box 1, input β sequence to box 2.
(1) α_seq. & β_seq. both be non-negative. alert
(2) α & β both have same number of elements.
(3) α total sum and β total sum are equal.
Blue alert
(4) When arrange both α and β to descending order,
β partial sum is always ≧ α partial sum.
Example button 11,12,13+ are OK. 51+ had negative
matrix elements. Current version improved. (51+ OK)
Example button 71+ do not have majorization relation.
tolerance=
compare elements need tolerance.
maximum iteration=
done in reasonable steps.
Write (slow) all
OR (faster) last
set output.
Box 8 debug output
;
How to use stochastic matrix?
Input Box 1 & 2, output Box 7.
All other are debug.
Box 1, α seq
Box 2, β seq
α sum=βsum; α more average, β more diverse; click [Run Stoch]
;
<a name=docU001>
2010-07-04-13-02 start
This file jsmajor2.htm has two
small programs
fraction to quotient converter
build permutation matrix
<a name=docU002>
fraction to quotient converter
document is at intro810
in/output is at QHboxb15<a name=docU003>
build permutation matrix
document is at intro910
in/output is at Box 71
2010-07-04-13-06 stop
<a name=update001>
2010-06-30-10-15 start
Update 2010-06-30 add few comment
for function jkCheck()
Please see docG007
2010-06-30-10-16 stop
<a name=update002>
2010-06-30-13-03 start
To test negative matrix element
alert. Please click [run stoch]
build a matrix in box 7.
Change numbers to negative value.
(change box 7, NOT change box M1)
<a name=update003>
Then click [verify] button
Box M4 will print " NEG 1".
'1' indicate one negative in
current row.
<a name=update004>
If click [How to use?] At
＜a name=how004＞ there is big
red "negative !"
Both are negative matrix element
alert.
2010-06-30-13-10 stop
<a name=update005>
2010-06-30-16-43 start
New version of jsmajor2.htm
[Box 6 permutation] always get
identity matrix. LiuHH added
program function. In sort area,
if click [output new index]
Box 72 show permutation matrix.
Document is at intro910
2010-06-30-16-48 stop
<a name=update006>
2010-07-04-14-55 start
Update 2010-07-04 add
fraction to quotient code
Please see document at intro810
and in/output at QHboxb15
2010-07-04-14-58 stop
<a name=update007>
2010-07-11-12-49
Update 2010-07-11 change
fraction to quotient control box
from b2 one box
to b and e two boxes
Because during work need to find
<a name=update008>
quotient of 0.02219711236660385
calculation get 884/39825
that is 2*2*13*17/(3*3*3*5*5*59)
run integer list from 1 to 39825
wait for three minutes. Decide
<a name=update009>
change code structure. Allow
begin number 'b', end number 'e'
specified for better control.
Now input b:39000 e:40000
and x:0.02219711236660385
Click [fill], click [x*M5]
get x=884/39825 in one second.
2010-07-11-13-01
<a name=update010>
2010-07-11-14-01
Added [L] button for Leap function
If begin 'b', end number 'e' are
b:1 e:3000 and click [L], program
fill box M5 from 3001 to 6000 and
change b/e box value to
b:3001 e:6000 For the number
x:0.02219711236660385 =884/39825
user click [L], instead of [F]
2010-07-11-14-06
<a name=update011>
Update 2010-07-15 add auto run
function to [F], [L], [t] buttons
2010-07-15-21-05
<a name="sortnumb">
Sort number not text string
Output may contain error, Please verify first.
Program environment is MSIE 6.0, please use MSIE
Box11 accept only numbers, not name list, not non-number string.