Skip to content

Instantly share code, notes, and snippets.

@alexshpilkin
Created November 23, 2018 19:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexshpilkin/9f7d6c8b838043934d81c22f040535b9 to your computer and use it in GitHub Desktop.
Save alexshpilkin/9f7d6c8b838043934d81c22f040535b9 to your computer and use it in GitHub Desktop.
Blocked fraction as function of domain length
#!/usr/bin/octave
pkg load image;
pkg load statistics;
pop = load("ru.hist");
obs = load("backorder.hist");
obs = padarray(obs, max(0, size(pop)-size(obs)), "post");
[_ var] = binostat(pop, obs./pop);
errorbar(obs./pop, sqrt(var)./pop, "xk");
xlabel("Domain length");
ylabel("Blocked fraction");
ylim([0 0.01]);
printf("png... "); print -dpng "-S1200,600" blocked.png;
printf("svg... "); print -dsvg "-S1200,600" blocked.svg;
printf("done\n");
#!/bin/awk -f
BEGIN {
maxlen = 0;
}
{
hist[length($1)]++
if (maxlen < length($1)) maxlen = length($1)
}
END {
for (i = 1; i <= maxlen; i++) { hist[i] += 0; print hist[i]; }
}
.PHONY: all clean
all: blocked.png blocked.svg
clean:
rm -f backorder.hist ru.hist blocked.png blocked.svg
blocked.png blocked.svg: blocked ru.hist backorder.hist
./$<
backorder.hist: backorder.csv hist
tail +2 $< | cut -d';' -f1 | \
sed -Ene 's/^([-0-9A-Za-z]*)\.ru/\1/p' | \
tr A-Z a-z | uniq | ./hist >$@
ru.hist: ru.zone.txt.xz hist
pv $< | xzcat | \
sed -Ene 's/^([-0-9A-Za-z]*)\.[Rr][Uu]\.\s+[0-9]+\s+IN.*/\1/p' | \
tr A-Z a-z | uniq | ./hist >$@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment