changeset 67:1aa38f4846e0

showalgo: show the rank
author Jordi Gutiérrez Hermoso <jordigh@octave.org>
date Wed, 18 May 2016 17:43:45 -0400
parents 916349600c4b
children 5510ac95a3d3
files talk/code/show_mc.py talk/code/showalgo.m
diffstat 2 files changed, 12 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/talk/code/show_mc.py
+++ b/talk/code/show_mc.py
@@ -95,6 +95,7 @@
     RemFile = open("remaining", "w")
     Ptotfile = open("Ptotal", "w")
     Qtotfile = open("Qtotal", "w")
+    medc_idxfile = open("medc_idx", "w")
     jackpot = open("jackpot", "w")
     
     # FIXME: Figure out what to do about NaNs.
@@ -166,6 +167,7 @@
     Ltot = 0
     Rtot = n_minus*n_plus
     medc_idx = Rtot//2
+    medc_idxfile.write("%s\n" % medc_idx)
 
     Lfile.write("%s\n" % L)
     Rfile.write("%s\n" % R)
@@ -259,7 +261,7 @@
 
 
 def main():
-    data = np.random.uniform(size=18)
+    data = np.random.uniform(size=26)
 
     mc = medcouple_1d(data)
     with open("mc", "w") as f:
--- a/talk/code/showalgo.m
+++ b/talk/code/showalgo.m
@@ -9,6 +9,7 @@
 mc = load("mc");
 jackpot = load("jackpot");
 Am = load("Am");
+medc_idx = load("medc_idx");
 Am(end+1) = mc;
 
 colidx = 1:columns(H);
@@ -18,7 +19,7 @@
 for iter = 1:length(Am)
   ## Reset the image
   imgH = origH;
-  
+
   ## Make greater-than red
   red = imgH(:,:,1);
   red(colidx < L(iter, :)') = 1;
@@ -29,6 +30,7 @@
   blue(colidx > R(iter, :)')  = 1;
   imgH(:, :, 3) = blue;
 
+  printf("Remaining: %d\n", remaining(iter))
   imshow(imgH);
   pause
 
@@ -54,7 +56,7 @@
 
   ## Brighten blue
   blue(idx) = 1;
-  
+
   ## Dim red and green
   red(idx) .*= 0.5;
   green(idx) .*= 0.5;
@@ -66,7 +68,7 @@
   [i,j] = find(Am(iter) == H);
   imgH(i,j,1) = imgH(i,j,2) = 1;
   imgH(i,j,3) = 0;
-  
+
   imshow(imgLeft);
   pause
 
@@ -80,7 +82,7 @@
 
   ## Brighten red
   blue(idx) = 1;
-  
+
   ## Dim blue and green
   blue(idx) .*= 0.5;
   green(idx) .*= 0.5;
@@ -92,7 +94,9 @@
   [i,j] = find(Am(iter) == H);
   imgH(i,j,1) = imgH(i,j,2) = 1;
   imgH(i,j,3) = 0;
-  
+
+  printf("rank is between %d and %d (target: %d)\n",
+         Ptot(iter), Qtot(iter), medc_idx)
   imshow(imgRight);
   pause