diff --git a/analysis/analyse.js b/analysis/analyse.js old mode 100644 new mode 100755 index e1e153c..a73e684 --- a/analysis/analyse.js +++ b/analysis/analyse.js @@ -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; - } - }); - - if (!ok) { - process.stderr.write('Error : assertion failed'); - process.exit(-1); - } - - console.log(elt.length + ' -> ' + elt[0].coin_combination_id); + console.log(elt.length); }); - 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) { diff --git a/analysis/generateData.js b/analysis/generateData.js old mode 100644 new mode 100755 index 9cb354f..8b8065d --- a/analysis/generateData.js +++ b/analysis/generateData.js @@ -1,3 +1,4 @@ +#!/usr/bin/node var pgc = require('../private.js'); var url = pgc.url; diff --git a/analysis/numberOfInteractionCurve.js b/analysis/numberOfInteractionCurve.js old mode 100644 new mode 100755 index ecc2129..096815b --- a/analysis/numberOfInteractionCurve.js +++ b/analysis/numberOfInteractionCurve.js @@ -1,3 +1,4 @@ +#!/usr/bin/node // Shows with and without : time to last coin = f(CoinCombination) var lib = require('./lib.js'); diff --git a/analysis/timeBetweenTwoCoins.js b/analysis/timeBetweenTwoCoins.js old mode 100644 new mode 100755 index 8cb064d..de6a177 --- a/analysis/timeBetweenTwoCoins.js +++ b/analysis/timeBetweenTwoCoins.js @@ -1,3 +1,4 @@ +#!/usr/bin/node // Shows with and without : time to last coin = f(CoinCombination) var lib = require('./lib.js'); diff --git a/analysis/timeCurve.js b/analysis/timeCurve.js old mode 100644 new mode 100755 index 5ef627c..cfe1b0f --- a/analysis/timeCurve.js +++ b/analysis/timeCurve.js @@ -1,3 +1,4 @@ +#!/usr/bin/node // Shows with and without : time to last coin = f(CoinCombination) var lib = require('./lib.js');