1. dan mackinlay
  2. bubble-economy

Commits

dan mackinlay  committed 6ac33f4

graph updates to fix sundry axis problems

  • Participants
  • Parent commits b7fdb07
  • Branches default

Comments (0)

Files changed (2)

File swept_stats.R

View file
 #boxplot(val ~ n_steps, data = this.stat.example, xlab="window size", ylab="MI")
 
 #parameterized boxplot
+#optionally correct param values between Wicks' normalise noise and Vicsek's \eta
+this.stat$param = this.stat$param/2
 this.stat$param.as.factor = ordered(this.stat$param)
 
 n.lines = length(window.vals)
 used.lines = seq(1, n.lines, 2)
 n.used.lines = length(used.lines)
 used.window.vals = window.vals[used.lines]
-used.param.vals = 1:12
-this.stat.lite = subset(this.stat, param.as.factor %in% param.vals[used.param.vals])
+used.param.vals = 1:14
+this.stat.lite = subset(this.stat, param %in% param.vals[used.param.vals])
 
 plotchar = seq(1, 1+n.used.lines,1)
 linetype = c(1:n.used.lines) #why is this different?
 #colors = brewer.pal(n.used.lines, "Spectral")
 colors = rep.int(1, n.used.lines)
 
-xrange = range(this.stat.lite$param)
-#yrange = c(0, max(m.this.line$value))
+xrange = range(param.vals[used.param.vals])
+#yrange = c(0, max(this.stat.lite$val))
+yrange = c(0, 0.7)
 
-yrange = c(0, max(this.stat.lite$val))
 plot(xrange, yrange, type="n", xlab=expression("Noise " * eta), ylab="Mutual Information (bits)")
+#plot(xrange, yrange, type="n", xlab=expression("Noise " * eta), ylab="Mutual Information (bits)", xaxt='n')
+#axis(side=1, at=param.vals[used.param.vals])
 for (i in 1:n.used.lines) {
   this.line = subset(this.stat.lite, n_steps == used.window.vals[i])
   n.obs = nrow(this.line)
   )
   # error bars
   arrows(
-    this.line.xs, this.line.quantiles$X2.5,
+    this.line.xs, pmax(this.line.quantiles$X2.5,0),
     this.line.xs, this.line.quantiles$X97.5,
-    angle=90, code=3, length=0.1, col=colors[i]
+    angle=90, code=3, length=0.02, col=colors[i]
   )
 }
 
-
+#MSE version - not used?
 yrange = c(0, 0.6)
 plot(xrange, yrange, type="n", xlab=expression("Noise " * eta), ylab="Mutual Information (bits)")
 for (i in 1:n.used.lines) {
   arrows(
     this.line.xs, this.line.pred-this.line.sd.ys,
     this.line.xs, this.line.pred+this.line.sd.ys,
-    angle=90, code=3, length=0.1
+    angle=90, code=3, length=0.02
   )
 }
 

File wicksish_graph.R

View file
 setwd("~/src/me/bubble_economy")
-obs = read.csv('../bubble_economy.Data/experiments/text/wicks_fig5.mi_wicks_2d_piecewise.csv')
-obs = read.csv('../bubble_economy.Data/experiments/text/wicks_fig5.mi_angular_vel_apriori_particlewise_2_200.csv')
-obs = read.csv('../bubble_economy.Data/experiments/text/wicks_fig5.mi_angular_vel_particlewise_2_200.csv')
-obs = read.csv('../bubble_economy.Data/experiments/text/wicks_fig5.mi_wicks_2d_piecewise_alt.csv')
-obs = read.csv('../bubble_economy.Data/experiments/text/wicks_fig5.mi_angular_vel_particlewise_2_200_alt.csv')
-obs=obs[obs$param < pi,]
-obs$param.as.factor=ordered(obs$param)
-xrange = range(obs$param)
-yrange = range(obs$val)
-boxplot(val ~ param.as.factor, data=obs, xlab=expression("Noise " * eta), ylab="Mutual Information (bits)")
 
-######
-library(reshape)
-obs = read.csv('../bubble_economy.Data/experiments/text/wicks_fig5.order.csv')
-obs=obs[obs$param < pi,]
-param.pts=sort(unique(obs$param))
-xrange=c(0,pi)
-yrange=c(0,1)
-#plot(xrange, yrange, type="n", )
-obs.lo = loess(val ~ param, data=obs)
-obs.pred = predict(obs.lo, newdata=param.pts)
-plot(param.pts, obs.pred, xlab=expression("Noise " * eta), ylab="Order")
-lines(param.pts, obs.pred)
-#or:
-#obs.nplo=npreg(val~param, data=obs, regtype="ll")
-#lines(param.pts, predict(obs.nplo, exdat=param.pts))
-#maybe jsut do a straight variance estimate here using a pivot
-#variance = npreg(residuals(obs.lo)^2 ~ param, data=obs)
-obs$param.as.factor=ordered(obs$param)
-m.obs.res = melt(obs, id.vars="param.as.factor", measure.vars="val")
-obs.sd = cast(m.obs.res, param.as.factor ~ ., sd)[,2]
-obs.sd.xs = as.numeric(levels(obs.sd$param.as.factor))
-arrows(
-  obs.sd.xs, obs.pred-obs.sd,
-  obs.sd.xs, obs.pred+obs.sd,
-  angle=90, code=3, length=0.1
-)
-######
-#obs = read.csv('../bubble_economy.Data/experiments/text/wicks_fig5.mi_angular_vel_particlewise_2_200_alt.csv')
-#obs = read.csv('../bubble_economy.Data/experiments/text/wicks_fig5.mi_angular_vel_apriori_particlewise_2_200_alt.csv')
-obs = read.csv('../bubble_economy.Data/experiments/text/wicks_fig5.mi_wicks_2d_piecewise_alt.csv')
-#obs = read.csv('../bubble_economy.Data/experiments/text/wicks_fig5.acc_acc_axiswise_mi_adaptive_hi_d_swept.csv')
-obs=obs[obs$param < pi,]
-obs$param.as.factor=ordered(obs$param)
-param.pts=sort(unique(obs$param))
-xrange=c(0,pi)
-yrange=c(0,max(obs$val))
-obs.lo = loess(val ~ param, data=obs)
-obs.pred = predict(obs.lo, newdata=param.pts)
-obs$res = residuals(obs.lo)
-plot(param.pts, obs.pred, xlab=expression("Noise " * eta), ylab="Mutual Information (bits)")
-lines(param.pts, obs.pred)
-obs$param.as.factor=ordered(obs$param)
-m.obs = melt(obs, id.vars="param.as.factor", measure.vars="res")
-obs.sd = cast(m.obs, param.as.factor ~ ., sd)
-obs.sd.ys = obs.sd[,2]/2
-obs.sd.xs = as.numeric(levels(obs.sd$param.as.factor))
-arrows(
-  obs.sd.xs, obs.pred-obs.sd.ys,
-  obs.sd.xs, obs.pred+obs.sd.ys,
-  angle=90, code=3, length=0.1
-)
-######
 library(np)
 library(reshape)
-#obs = read.csv('../bubble_economy.Data/experiments/text/wicks_fig5.mi_angular_vel_particlewise_2_200_alt.csv')
-#obs = read.csv('../bubble_economy.Data/experiments/text/wicks_fig5.mi_angular_vel_apriori_particlewise_2_200_alt.csv')
-#obs = read.csv('../bubble_economy.Data/experiments/text/wicks_fig5.mi_wicks_2d_piecewise_alt.csv')
-#obs = read.csv('../bubble_economy.Data/experiments/text/wicks_fig5.mi_wicks_2d_piecewise_squished.csv')
-obs = read.csv('../bubble_economy.Data/experiments/text/wicks_fig5.mi_distance_angular_vel_particlewise_macerated_100_5_squished.csv')
-#obs = read.csv('../bubble_economy.Data/experiments/text/wicks_fig5.mi_wicks_2d_piecewise.csv')
-#obs = read.csv('../bubble_economy.Data/experiments/text/correlation_quick_dirty.mi_distance_angular_vel_particlewise_macerated_100_5.csv')
-#obs = read.csv('../bubble_economy.Data/experiments/text/correlation_quick_dirty.mi_distance_angular_vel_particlewise_macerated_1_500.csv')
-#obs = read.csv('../bubble_economy.Data/experiments/text/correlation_quick_dirty.mi_distance_angular_vel_particlewise_macerated_all_50.csv')
-obs=obs[obs$param < pi,]
-if (nrow(obs)>10000) {obs=obs[sample(nrow(obs),10000),]}
-obs$param.as.factor=ordered(obs$param)
-param.pts=sort(unique(obs$param))
-xrange=c(0,pi)
-yrange=c(0,max(obs$val))
-obs.np = npreg(val ~ param, data=obs, regtype='ll')
-obs.pred = predict(obs.np, newdata=data.frame(param=param.pts))
-obs$res = residuals(obs.np)
-plot(param.pts, obs.pred, xlab=expression("Noise " * eta), ylab="Mutual Information (bits)")
-lines(param.pts, obs.pred)
-#plot(obs.pred)
-obs$param.as.factor=ordered(obs$param)
-m.obs = melt(obs, id.vars="param.as.factor", measure.vars="res")
-obs.sd = cast(m.obs, param.as.factor ~ ., sd)
-obs.sd.ys = obs.sd[,2]/2
-obs.sd.xs = as.numeric(levels(obs.sd$param.as.factor))
-arrows(
-  obs.sd.xs, obs.pred-obs.sd.ys,
-	obs.sd.xs, obs.pred+obs.sd.ys,
-	angle=90, code=3, length=0.1
-)
+
+ plot.mi.fit = function(obs){
+	obs$param.as.factor=ordered(obs$param)
+	param.pts=sort(unique(obs$param))
+	xrange=c(0,pi)
+	yrange=c(0,max(obs$val))
+	obs.np = npreg(val ~ param, data=obs, regtype='ll')
+	obs.pred = predict(obs.np, newdata=data.frame(param=param.pts))
+	obs$res = residuals(obs.np)
+	plot(param.pts, obs.pred, xlab=expression("Noise " * eta), ylab="Mutual Information (bits)")
+	lines(param.pts, obs.pred)
+	#plot(obs.pred)
+	obs$param.as.factor=ordered(obs$param)
+	m.obs = melt(obs, id.vars="param.as.factor", measure.vars="res")
+	obs.sd = cast(m.obs, param.as.factor ~ ., sd)
+	obs.sd.ys = obs.sd[,2]
+	obs.sd.xs = as.numeric(levels(obs.sd$param.as.factor))
+	arrows(
+	  obs.sd.xs, obs.pred-obs.sd.ys,
+	  obs.sd.xs, obs.pred+obs.sd.ys,
+	  angle=90, code=3, length=0.0
+	)
+}
+
+#mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_distance_angular_vel_particlewise_macerated_100_5_adaptive_ince.csv')
+#mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_distance_angular_vel_particlewise_macerated_100_5_adaptive_ince_modern.csv')
+#mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_distance_angular_vel_particlewise_macerated_100_5_apriori.csv')
+#mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_distance_angular_vel_particlewise_macerated_100_5_apriori_ince.csv')
+#mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_distance_angular_vel_particlewise_macerated_100_5_cont.csv')
+#mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_distance_angular_vel_particlewise_macerated_100_5_cont_ince.csv')
+#mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_distance_angular_vel_particlewise_macerated_100_5_squished_ince.csv')
+#mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_distance_angular_vel_particlewise_macerated_100_5_squished_ince_modern.csv')
+#mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_wicks_2d_piecewise_adaptive.csv')
+#mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_wicks_2d_piecewise_adaptive_ince.csv')
+mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_wicks_2d_piecewise_adaptive_ince_modern.csv')
+#mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_wicks_2d_piecewise_squished.csv')
+#mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_wicks_2d_piecewise_squished_ince.csv')
+#mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_wicks_2d_stepwise_adaptive.csv')
+#mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_wicks_2d_stepwise_adaptive_ince.csv')
+#mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_wicks_2d_stepwise_adaptive_ince_modern.csv')
+#mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_wicks_2d_stepwise_squished.csv')
+#mi.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.mi_wicks_2d_stepwise_squished_ince.csv')
+plot(mi.obs)
+if (nrow(mi.obs)>10000) {mi.obs=mi.obs[sample(nrow(mi.obs),10000),]}
+#fix re-scaling issue
+mi.obs$param = mi.obs$param/2
+plot.mi.fit(mi.obs)
+
+#order.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.order_complete.csv')
+order.obs = read.csv('../bubble_economy.Data/experiments/text/fuckfuckfuck_emergency_wicks_panic.order_continuous.csv')
+if (nrow(order.obs)>10000) {order.obs=order.obs[sample(nrow(order.obs),10000),]}
+order.obs$param = order.obs$param/2
+plot.mi.fit(order.obs)