Added shabangs

This commit is contained in:
Thomas FORGIONE 2015-10-12 09:30:48 +02:00
parent 5e9a4330b4
commit 918d5a9b5e
5 changed files with 19 additions and 95 deletions

110
analysis/analyse.js Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/node
var lib = require('./lib.js');
function main(path) {
@ -5,106 +6,25 @@ function main(path) {
var db = lib.loadFromFile(path);
var groups = lib.makeGroups(db);
// Erase groups that are not usable
groups = groups.filter(function(elt) {
// An elt is valid if it contains at least 2 exp, BaseRecommendation included
return elt.length > 1 && elt.find(function(e) { return e.recommendation_style[4] === 'B'; }) !== undefined;
});
groups.forEach(function(elt) {
elt.sort(lib.compareRecommendationStyle);
});
console.log(`There were ${db.users.length} users for ${db.experiments.length} experiments`);
var meanTimeNoReco = 0;
var meanTimeArrow = 0;
var meanTimeViewport = 0;
console.log(`There were ${groups.length} groups that were made.`);
groups.forEach(function(elt) {
var ok = true;
// console.log(elt);
elt.sort(compareRecommendationStyle);
// console.log(elt);
elt.forEach(function(subElt) {
if (subElt.coin_combination_id !== elt[0].coin_combination_id) {
ok = false;
}
console.log(elt.length);
});
if (!ok) {
process.stderr.write('Error : assertion failed');
process.exit(-1);
}
console.log(elt.length + ' -> ' + elt[0].coin_combination_id);
});
console.log('-----------------');
var value = minDifferences(groups);
console.log(value);
}
function minDifference(exps) {
var dict = {};
exps.forEach(function(subElt) {
dict[subElt.recommendation_style[4]] = subElt.duration;
});
if (dict.B !== undefined) {
if (dict.A !== undefined && dict.V !== undefined) {
return (
Math.min(dict.A - dict.B, dict.V - dict.B)
);
}
if (dict.A !== undefined) {
return dict.A - dict.B;
}
if (dict.V !== undefined) {
return dict.V - dict.B;
}
}
}
function minDifferences(groups) {
var differences = [];
groups.forEach(function(elt) {
var timesMean = 0;
elt.forEach(function(elt) {
var duration = experimentDuration(elt);
timesMean += experimentDuration(elt);
});
timesMean /= elt.length;
var normalizedElt = [];
elt.forEach(function(subElt) {
normalizedElt.push({
recommendation_style : subElt.recommendation_style,
duration : experimentDuration(subElt) / timesMean
});
});
var diff = minDifference(normalizedElt);
if (diff !== undefined)
differences.push(diff);
});
var sum = 0;
differences.forEach(function(elt) {
sum += elt;
});
return sum / differences.length;
}
if (process.argv.length !== 3) {

1
analysis/generateData.js Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/node
var pgc = require('../private.js');
var url = pgc.url;

1
analysis/numberOfInteractionCurve.js Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/node
// Shows with and without : time to last coin = f(CoinCombination)
var lib = require('./lib.js');

1
analysis/timeBetweenTwoCoins.js Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/node
// Shows with and without : time to last coin = f(CoinCombination)
var lib = require('./lib.js');

1
analysis/timeCurve.js Normal file → Executable file
View File

@ -1,3 +1,4 @@
#!/usr/bin/node
// Shows with and without : time to last coin = f(CoinCombination)
var lib = require('./lib.js');