drbenvincent / delay-discounting-analysis

Hierarchical Bayesian estimation and hypothesis testing for delay discounting tasks
http://www.inferencelab.com/delay-discounting-analysis/
MIT License
23 stars 9 forks source link

clean up Cluster plotting #174

Open drbenvincent opened 7 years ago

drbenvincent commented 7 years ago

In Parametric.m we have some code with a long set of arguments passed in...

clusterPlot(...
    obj.coda,...
    obj.data,...
    [1 0 0],...
    obj.modelFilename,...
    obj.plotOptions,...
    obj.varList.discountFunctionParams)

meaning the the function signature has many entries

function clusterPlot(mcmcContainer, data, col, modelType, plotOptions, vars)
varNames = {vars.name};
if numel(varNames) == 1
    plot1Dclusters(mcmcContainer, data, col, modelType, plotOptions, vars);
elseif numel(varNames) == 2
    plot2Dclusters(mcmcContainer, data, col, modelType, plotOptions, vars);
else
    error('can only deal with plotting univariate or bivariate distributions')
end
end

which in turn means we are passing these values down yet again into plot1Dclusters.m or plot1Dclusters.m

Solutions

  1. Inversion of control. ie create a clusterPlot function with the arguments included (using partials)
  2. Polymorphism