diff --git a/Gruntfile.coffee b/Gruntfile.coffee index de511e1..5ad40da 100644 --- a/Gruntfile.coffee +++ b/Gruntfile.coffee @@ -55,5 +55,4 @@ module.exports = (grunt) -> grunt.registerTask "build" , ["coffee","concat"] grunt.registerTask "compile", ["coffee"] grunt.registerTask "test", ["coffee","jasmine"] - grunt.registerTask "default", ["coffee","concat"] diff --git a/css/SOCR_Tools_style.css b/css/SOCR_Tools_style.css index 0b579ee..4055f87 100644 --- a/css/SOCR_Tools_style.css +++ b/css/SOCR_Tools_style.css @@ -68,7 +68,7 @@ body { } #header { - /* background: #eee url('images/SOCR_Top_Banner.gif') no-repeat center top; */ + background: #eee url('images/SOCR_Top_Banner.gif') no-repeat center top; } #wrapper-header2 { diff --git a/css/bootstrap.css b/css/bootstrap.css index fee37ec..7371031 100644 --- a/css/bootstrap.css +++ b/css/bootstrap.css @@ -281,7 +281,7 @@ a:hover { [class*="span"] { float: left; min-height: 1px; - margin-left: 20px; + /*margin-left: 20px;*/ } .container, diff --git a/favicon.ico b/favicon.ico deleted file mode 100644 index 1ac3e1b..0000000 Binary files a/favicon.ico and /dev/null differ diff --git a/handler.php b/handler.php deleted file mode 100644 index 1107e79..0000000 --- a/handler.php +++ /dev/null @@ -1,23 +0,0 @@ -'couldnt find page', - 'status'=>'failed' -); - -if(isset($_GET['url'])){ - - - $ch = curl_init($_GET['url']); - curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1) ; - $response['data'] = curl_exec($ch); - curl_close($ch); - - $response['status']='success'; - -} - -ob_start(); -echo json_encode($response); -ob_end_flush(); -?> diff --git a/js/appModel.coffee b/js/appModel.coffee index 1714512..1f13f3f 100644 --- a/js/appModel.coffee +++ b/js/appModel.coffee @@ -7,16 +7,16 @@ appModel.js is the model object for the SOCR app. SOCR - Statistical Online Computational Resource ### socr.model = -> - + #::::::: PRIVATE PROPERTIES ::::::::::::::: - #Number of runs to be made when 'run' button is pressed + #Number of runs to be made when 'run' button is pressed #keeps count of number of samples generated from start #Number of datapoints in a bootstrap sample or Sample Size #contains the number of datasets # # Why there are keys and values? Its because in some form of data input (like coin toss), the "key" contains the symbolic meaningful reference whereas the "value" contains the mathematical equivalent value. - # - + # + #::::::: PRIVATE METHODS ::::::::::::::: ### @method : _getRandomInt() @@ -26,7 +26,7 @@ socr.model = -> ### _getRandomInt = (min, max) -> Math.floor(Math.random() * (max - min)) + min - + ### @method : _generateMean @param : {number|string} sampleNumber - the random sample number for which the mean is to be calculated @@ -52,7 +52,7 @@ socr.model = -> else total = _generateCount(sampleNumber, groupNumber) total / socr.dataStore.bootstrapGroup[sampleNumber].values.getData(groupNumber).length - + ### @method : _generateCount @param : sampleNumber - the random sample number for which the count is to be calculated @@ -69,7 +69,7 @@ socr.model = -> total += parseFloat(x[i]) i++ total - + ### @method : _generateStandardDev @param : sampleNumber , groupNumber @@ -77,7 +77,7 @@ socr.model = -> @return : {number} standard deviation for the input sample and group numbers ### _generateStandardDev = (sampleNumber, groupNumber) -> - + #formula used here is SD= ( E(x^2) - (E(x))^2 ) ^ 1/2 _mean = _generateMean(sampleNumber, groupNumber) #E(x) _squaredSum = null #stores E(x^2) @@ -88,11 +88,11 @@ socr.model = -> _squaredSum += _sample[i] * _sample[i] i++ _squaredSum = _squaredSum / _sample.length - + #console.log("_squaredSum"+_squaredSum+"--- _mean:"+_mean); _SD = Math.sqrt(_squaredSum - (_mean) * (_mean)) _SD - + ### @method : _generateF @desc : Generates the F value using the one way ANOVA method @@ -111,7 +111,7 @@ socr.model = -> _ssb = 0 _data = [] if sampleNumber is "dataset" - + #Get the complete dataset from the dataStore. i = 0 @@ -119,8 +119,8 @@ socr.model = -> _data[i] = socr.dataStore.dataset[i].values.getData() i++ else - - #Get the random sample with index @sampleNumber from each group. + + #Get the random sample with index @sampleNumber from each group. _data = socr.dataStore.bootstrapGroup[sampleNumber].values.getData() i = 0 while i < _K @@ -129,15 +129,15 @@ socr.model = -> _total += _ymean[i] i++ _y = _total / _K # grand mean - + #Degree of freedom between = _dofe = K - 1 _dofe = _K - 1 - + #Degree of freedom within = _dofw = N - K _dofw = _N - _K - + #Sum of Squares Total (= Sum of squares between + Sum of squares within) - + #Creating the samplespace of all values. _sspace = [] i = _K - 1 @@ -145,7 +145,7 @@ socr.model = -> while i >= 0 _sspace = _sspace.concat(_data[i]) i-- - + #Mean _m = $.mean(_sspace) i = _sspace.length - 1 @@ -153,9 +153,9 @@ socr.model = -> while i >= 0 _sst = _sst + Math.pow((_m - _sspace[i]), 2) i-- - + #console.log("_sst:"+_sst); - + #SSW - Sum of squares within i = 0 _temp = 0 @@ -168,9 +168,9 @@ socr.model = -> _ssw += _temp * _temp j++ i++ - + #console.log("_ssw:"+_ssw); - + #SSB - Sum of squares between # for (var i = _K; i >= 1; i--) { # if ((d = _data[i].length) !== undefined){ @@ -179,16 +179,16 @@ socr.model = -> # }; #console.log("_ssb:"+_ssb); _ssb = _sst - _ssw - + #MST - Mean sum of squares _mst = _ssb / _dofe - + #MSE - Mean sum of between _msw = _ssw / _dofw fValue: _mst / _msw ndf: _dofe ddf: _dofw - + ### @method : _generateP @desc :Generates p value for the "k" data groups using one way ANOVA method. @@ -202,7 +202,7 @@ socr.model = -> _ndf = _ndf or x.ndf _ddf = _ddf or x.ddf socr.tools.fCal.computeP x.fValue, _ndf, _ddf - + ### @method : _generateZ @desc :Generates p value for the "k" data groups using difference of proportion test. @@ -217,28 +217,28 @@ socr.model = -> _data1 = socr.dataStore.bootstrapGroup[sampleNumber].values.getData() _data2 = _data1[2] _data1 = _data1[1] - + # # p1 - Proportion of dataset 1 # p2 - Proportion of dataset 2 # # Z = (p1 - p1)/(p*(1-p))*((1/n1) + (1/n2)))^1/2 - # Reference : + # Reference : # - http://wiki.stat.ucla.edu/socr/index.php/AP_Statistics_Curriculum_2007_Infer_2Proportions#Hypothesis_Testing_the_Difference_of_Two_Proportions # - http://stattrek.com/hypothesis-test/difference-in-proportions.aspx - # + # n1 = _data1.length p1 = $.sum(_data1) / n1 n2 = _data2.length p2 = $.sum(_data2) / n2 - + #Generate pooled sample proportions p = (p1 * n1 + p2 * n2) / (n1 + n2) - + #Generate Standard Error SE = Math.sqrt(p * (1 - p) * ((1 / n1) + (1 / n2))) zValue: (p1 - p2) / SE - + ### @desc Generates p value for the "k" data groups using difference of proportion. @param sampleNumber @@ -261,7 +261,7 @@ socr.model = -> _K = null _this = this n: _n - + ### @method: [public] generateTrail() @param datasetIndex @@ -277,8 +277,8 @@ socr.model = -> key: _temp.keys.getData(randomIndex) value: _temp.values.getData(randomIndex) - #returning the generated trail into a bootstrap sample array - + #returning the generated trail into a bootstrap sample array + ### @method [public] generateSample() @desc generating a random number between 0 and dataSet size @@ -290,9 +290,9 @@ socr.model = -> valEl = [] i = 0 while i < k - + #EDIT THIS TO MAKE N DYNAMIC - + #var j = _n[k]; j = socr.model.getN()[i] sample = [] @@ -306,13 +306,13 @@ socr.model = -> i++ socr.dataStore.createObject "bootstrapGroup." + _count + ".keys", keyEl socr.dataStore.createObject "bootstrapGroup." + _count + ".values", valEl - + #Object.defineProperty(_bootstrapGroupKeys,_count,{value:keyEl,writable:true,configurable : true}); #Object.defineProperty(_bootstrapGroupValues,_count,{value:valEl,writable:true,configurable : true}); _count++ #incrementing the total count - number of samples generated from start of simulation true - + ### @method getMean() @desc executed when the user presses "infer" button in the controller tile. The click binding of the step button is done in the {experiment}.js @@ -335,7 +335,7 @@ socr.model = -> obj.setData _mean obj.getData() - + ### @method getMeanOf() @desc executed when the user presses "infer" button in the controller tile. @@ -347,11 +347,11 @@ socr.model = -> getMeanOf: (sampleNumber, groupNumber) -> _generateMean sampleNumber, groupNumber - + ### STANDARD DEVIATION METHODS STARTS * ### - + ### @method getStandardDev @param groupNumber @@ -370,12 +370,12 @@ socr.model = -> while j < _count _temp[j] = _generateStandardDev(j, groupNumber) j++ - + #console.log(_sampleStandardDev[j]); _sample.StandardDev[groupNumber] = _temp _sample.StandardDev[groupNumber] - + ### @method getStandardDevOf @param sampleNumber @@ -385,7 +385,7 @@ socr.model = -> getStandardDevOf: (sampleNumber, groupNumber) -> _generateStandardDev sampleNumber, groupNumber - + ### @param K @returns {number} @@ -406,15 +406,15 @@ socr.model = -> console.log "SD of Dataset:" + _SD _SD - + ### STANDARD DEVIATION METHODS ENDS * ### - + ### COUNT METHODS STARTS * ### - + ### @method getCount @param groupNumber @@ -436,7 +436,7 @@ socr.model = -> obj.setData _c obj.getData() - + ### @method getCountOf @param {number | string}sampleNumber @@ -458,15 +458,15 @@ socr.model = -> else _generateCount sampleNumber, K - + ### COUNT METHODS ENDS * ### - + ### PERCENTILE METHODS STARTS * ### - + ### @method getPercentile () @param pvalue - what is the percentile value that is to be calculated. @@ -474,7 +474,7 @@ socr.model = -> ### getPercentile: (pvalue) -> console.log "getPercentile() invoked" - + #if(_samplePercentile.length==bootstrapSampleValues.length) # return _samplePercentile; #else @@ -484,13 +484,13 @@ socr.model = -> while j < _count _sample.Percentile[j] = @getPercentileOf(j, pvalue) j++ - + #console.log(_samplePercentile[j]); _sample.Percentile - + # } - + ### @method getPercentileOf @param sampleNumber @@ -502,12 +502,12 @@ socr.model = -> a - b ) position = Math.floor(bootstrapSampleValues[sampleNumber].length * (pvalue / 100)) - + #console.log(pvalue); #console.log(bootstrapSampleValues[sampleNumber]+"---"+position); temp[position] - + ### @param pvalue @returns {*} @@ -519,11 +519,11 @@ socr.model = -> position = Math.floor(_datasetValues.length * (pvalue / 100)) temp[position] - + ### PERCENTILE METHODS ENDS * ### - + ### @method getF @desc returns the F value computed from the supplied group @@ -546,7 +546,7 @@ socr.model = -> obj.setData _f obj.getData() - + ### @method getFof @desc returns the F value computed from the supplied group @@ -554,13 +554,13 @@ socr.model = -> @returns {Object} ### getFof: (sampleNumber) -> - + #check if K > 1 and there are random samples to compute F. return false if socr.model.getK() <= 1 or socr.dataStore.bootstrapGroup is `undefined` _this = this _generateF sampleNumber - + ### @method getP @return {Object} @@ -582,20 +582,20 @@ socr.model = -> obj.setData _p obj.getData() - + ### @method getPof @param sampleNumber @returns {number} ### getPof: (sampleNumber) -> - + #check if K > 1 and there are random samples to compute P. return false if socr.model.getK() <= 1 and socr.dataStore.bootstrapGroup is `undefined` _this = this _generateP sampleNumber - + ### @method getDOP @return {Object} @@ -616,7 +616,7 @@ socr.model = -> obj.setData _p obj.getData() - + ### @method getDOPof @param sampleNumber @@ -626,7 +626,7 @@ socr.model = -> _this = this _generateDOP sampleNumber - + ### @method getDataset @desc getter function for dataSet variable. @@ -644,7 +644,7 @@ socr.model = -> return false return - + ### @method setDataset @desc sets the data from the input sheet into the app model @@ -652,10 +652,10 @@ socr.model = -> @return {boolean} ### setDataset: (input) -> - + #check for input values...if its empty...then throw error return false if typeof input isnt "object" - + #input.processed is true in case of a simulation -> data mode switch if input.processed ma1 = [] @@ -676,7 +676,7 @@ socr.model = -> else if input.type is "spreadsheet" ma1 = [] ma2 = [] - + #clear previous data. socr.dataStore.removeObject "dataset" #console.log input.values.length @@ -684,7 +684,7 @@ socr.model = -> while i < input.values.length _cells = input.values[i].cells - _id = input.values[i].id - 1 + _id = input.values[i].id _temp = [] j = 0 @@ -703,7 +703,7 @@ socr.model = -> else true - + ### @method : getSample @param : index random sample index @@ -722,7 +722,7 @@ socr.model = -> else _bg.keys.getData K - + ### @method - getSamples @param type @@ -749,12 +749,12 @@ socr.model = -> i++ _temp - + ### getter and setter for variable '_stopCount' ### setStopCount: (y) -> - + #alert(y); _stopCount = y return @@ -762,22 +762,22 @@ socr.model = -> getStopCount: -> _stopCount - + ### getter and setter for variable '_n' ### setN: (z) -> - + #NEED TO MAKE N DYNAMIC - + #if z length != to dataset length, then default the values to the dataset lengths - + #purge _n array _n.length = 0 socr.model.setK() _ds = socr.dataStore.dataset if typeof z is "undefined" or z is null - + #computing default values if typeof _ds isnt "undefined" i = 0 @@ -797,7 +797,7 @@ socr.model = -> ), z _n = _n.concat(z) else - + #some values are missing #this case will come almost never else if typeof z is "number" or typeof z is "string" @@ -814,7 +814,7 @@ socr.model = -> getN: -> _n - + ### getter and setter for variable '_count' ### @@ -825,26 +825,25 @@ socr.model = -> getRSampleCount: -> _count + ### + # App goes back to pristine state. + ### reset: (option) -> if option isnt "undefined" and option is "samples" socr.dataStore.removeObject "bootstrapGroup" - - #setting the global random sample count to 0 - socr.model.setRSampleCount 0 + else - + #all values deleted socr.dataStore.removeObject "all" - - #setting the global random sample count to 0 - socr.model.setRSampleCount 0 - - #setting K and n to 0. + #reset K socr.model.setK() - socr.model.setN() - return - + + #setting the global random sample count to 0 + socr.model.setRSampleCount 0 + return true + ### @method :setK @return : none @@ -859,7 +858,7 @@ socr.model = -> _K = _c return - + ### @method :getK @return : {number} diff --git a/js/appView.coffee b/js/appView.coffee index 067ce31..a51ebfe 100644 --- a/js/appView.coffee +++ b/js/appView.coffee @@ -6,12 +6,12 @@ appView.js is the view object for the SOCR app. SOCR - Statistical Online Computational Resource ### socr.view = (model) -> - - # private properties + + # private properties # [OBJECT] Reference to the App's model object. # [ARRAY] Reference to current inference varaible [mean , SD , count , percentile] # [ARRAY] Reference to current inference variable's value of each random sample. - + ### @method: [private] _create @param : start: the first sample number to be displayed @@ -27,7 +27,7 @@ socr.view = (model) -> return false if size is `undefined` or start is `undefined` console.log "_create(" + start + "," + size + ") function started" $("#sampleList").html "" #first empty the sample list - + #generate the json object for mustache config = entries: [] obj = {} @@ -55,19 +55,19 @@ socr.view = (model) -> $.get "partials/sampleList.tmpl", (data) -> temp = Mustache.render(data, config) $("#sampleList").html temp - + #console.log(temp); $(".tooltips").tooltip() $(".nav-tabs li").click (e) -> e.preventDefault() kIndex = $(this).find("a").html() - + #setting the k-index attribute of toggle-sample icon $(this).parent().parent().find(".toggle-sample").attr "k-index", kIndex $(this).find("a").tab "show" return - + #plot icon present on each child of the sampleList Div . # It basically opens a popup and plots a bar chart of that particular sample. $(".plot").on "click", (e) -> @@ -75,7 +75,7 @@ socr.view = (model) -> $(".chart").html "" id = $(this).attr("sample-number") kIndex = $(this).parent().parent().find(".toggle-sample").attr("k-index") - + #var sampleID=e.target.id; values = model.getSample(id, "values", kIndex) i = 0 @@ -83,7 +83,7 @@ socr.view = (model) -> while i < values.length values[i] = parseFloat(values[i]) i++ - + #console.log("values for plot click:"+values); #var temp=values.sort(function(a,b){return a-b}); #var start=Math.floor(temp[0]); @@ -99,14 +99,14 @@ socr.view = (model) -> return - + #range:[start,stop] #click binding for .plot - + # toggle-sample icon is present on each child of the sampleList Div . # * It basically toggles the data if the sample and sampleValue are different. # * TODO : disable this button if the app is data driven mode (as the sample and sampleValues are same.) - # + # $(".toggle-sample").on "click", (e) -> e.preventDefault() id = $(this).attr("sample-number") @@ -125,11 +125,11 @@ socr.view = (model) -> #click binding for .toggle-sample #get call end $(".contribution").on "click", (e) -> - + # - # Renders the dotplot, + # Renders the dotplot, # @ToDo : show individual contributions on a box chart - # + # createDotplot = (setting) -> if setting.variable is "mean" values = model.getMean() @@ -141,14 +141,14 @@ socr.view = (model) -> console.log "SD Values:" + values else values = model.getPercentile() - + #var datum=model.getStandardDevOfDataset(); datum = Math.floor(datum * 100) / 100 histogram = socr.vis.generate( parent: "#dotplot" data: values height: 390 - + #range: [0,10], datum: datum sample: setting.sample @@ -174,7 +174,7 @@ socr.view = (model) -> return return - + ### @method: [private] _createPagination @param : x: the first sample number to be displayed @@ -213,7 +213,7 @@ socr.view = (model) -> _currentVariable = undefined _currentValues = undefined _currentExperiment = null - + ### @method - toggleControllerHandle @description - Method to toggle the controller slider @@ -234,7 +234,7 @@ socr.view = (model) -> return hide = -> - + # if($target.hasClass('active')){ $target.removeClass("active").animate left: -425 @@ -260,7 +260,7 @@ socr.view = (model) -> false return - + ### @method - disableButtons() @description: Disables step,run and show buttons @@ -273,7 +273,7 @@ socr.view = (model) -> $("#showButton").attr "disabled", "true" return - + ### @method - enableButtons() @description: Enables step,run and show buttons @@ -286,19 +286,19 @@ socr.view = (model) -> $("#showButton").removeAttr "disabled" return - + ### @method - reset() @description: Clears all canvas and div. Resetting the view of the whole App @dependencies : none ### reset: (option) -> - + #reset only the samples in the view. if option isnt "undefined" and option is "samples" $("#sampleList").html "" else - + #$('#displayCount').html('0'); //resetting the count to 0 $("#sampleList").html "" #clear the sample List dive $("#showCount").html "" @@ -309,13 +309,13 @@ socr.view = (model) -> $(".pagination").html "" $("#details").html "" $("#dataset").html "" - - # $("#input").inputtable('clear'); + + # $("#input").inputtable('clear'); _currentValues = [] - $("#controller-content").html "
From the \"data driven\" tab select an experiment or enter data the spreadsheet first!
" + $("#controller-content").html "
Choose a experiment from \"simulation drive\" or enter data in the \"data drive\" first!
" return - + ### Dont know where its called? ### @@ -334,7 +334,7 @@ socr.view = (model) -> ) return - + ### @method : createList(range) @param :start- start sample number @@ -344,10 +344,10 @@ socr.view = (model) -> ### createList: (start, end) -> console.log "createList(" + start + "," + end + ") invoked " - - #if(Object.getOwnPropertyNames(model.bootstrapGroupKeys).length === 0){ + + #if(Object.getOwnPropertyNames(model.bootstrapGroupKeys).length === 0){ if socr.model.getRSampleCount() is 0 - + # if no random samples have been generated, display a alert message! $("#sampleList").html "
x

No Random samples to show!

Please generate a dataset using the list of experiments or manually enter the data. Then generate some random samples from the controller tile before click \"show\"
" else @@ -359,23 +359,23 @@ socr.view = (model) -> PubSub.publish "Sample List generated" return - + ### @method : updateSlider() @description:update the slider value @dependencies : none ### updateSlider: -> - + #get the count and set it as the maximum value $("#displayCount").text model.getRSampleCount() $("#range").slider "option", "max", model.getRSampleCount() $("#range").slider "option", "min", 0 return - + #$( "#showCount" ).html($( "#range" ).slider( "values",0 )+" - " + $( "#range" ).slider( "values", 1 ) ); - + ### @method : createShowSlider() @description:Create the slider for show option @@ -399,18 +399,18 @@ socr.view = (model) -> $("#showCount").html $("#range").slider("values", 0) + " - " + $("#range").slider("values", 1) return - + ### @method: createControllerView @description: called for replacing the controller div with data driven controls. @return : none ### createControllerView: -> - + #get the random sample length - #slice(0) does a shallow copy + #slice(0) does a shallow copy _RSampleLength = socr.model.getN().slice(0) - + #splice the first element _RSampleLength.splice 0, 1 _k = socr.model.getK() @@ -449,7 +449,7 @@ socr.view = (model) -> return - + ### @method: animate @param: setting @@ -457,16 +457,16 @@ socr.view = (model) -> @return : none ### animate: (setting) -> - + # Add the class ui-state-disabled to the headers that you want disabled - + # Now the hack to implement the disabling functionnality - + #disable the back button in the controller tile # data is in the form of an array! # data is in the form of an array! # Number of datapoints in a generated random sample - # keys=array indexs of the datapoints in the dataset which are present in the current random sample + # keys=array indexs of the datapoints in the dataset which are present in the current random sample #first call animation = -> speed = $("#speed-value").html() #calculate the speed currently set from the browser itself @@ -480,11 +480,11 @@ socr.view = (model) -> currentY = $("#device" + sampleNumber + "-container").position().top #get the Y position of current sample canvas console.log "currentY:" + currentY samplesInRow = $("#generatedSamples").width() / _dimensions["width"] - 1 #number of samples in a row - + #Block to adjust the generatedSamples div height divHeight = (stopCount / samplesInRow) * _dimensions["height"] $("#generatedSamples").height divHeight - + #alert(divHeight); # if count < samplesInRow @@ -494,7 +494,7 @@ socr.view = (model) -> console.log "destinationX:" + destinationX destinationY = Math.floor(count / samplesInRow) * _dimensions["height"] + $("#generatedSamples").position().top #calculate the destination Y console.log "destinationY:" + destinationY - + #self.css('-webkit-transition','all 0.5s'); self.transition perspective: "100px" @@ -514,7 +514,7 @@ socr.view = (model) -> else if socr.exp.current.type is "card" k = new Card(document.getElementById("device" + sampleNumber)) k.setValue data[sampleNumber] - + #alert(data[sampleNumber]); else k = new Ball(document.getElementById("device" + sampleNumber)) @@ -548,7 +548,7 @@ socr.view = (model) -> setTimeout animation return - + ### @method: createDotPlot @description: Dot plot tab in the accordion is populated by this call. @@ -559,17 +559,17 @@ socr.view = (model) -> return false unless setting.variable? _currentVariable = setting.variable $("#accordion").accordion "activate", 2 - + # Function to get the Max value in Array Array.max = (array) -> Math.max.apply Math, array - + # Function to get the Min value in Array Array.min = (array) -> Math.min.apply Math, array - + #setting.variable; switch setting.variable when "Mean" @@ -584,14 +584,14 @@ socr.view = (model) -> when "percentile" try pvalue = parseInt($("#percentile-value").html()) - + #console.log(pvalue); catch err console.log "unable to read the percentile value from DOM. setting default value to 50%" pvalue = 50 values = model.getPercentile(pvalue) datum = model.getPercentileOfDataset(pvalue) - + #var datum=model.getStandardDevOfDataset(); console.log "Percentile Values:" + values when "Count" @@ -601,41 +601,41 @@ socr.view = (model) -> when "F-Value" values = model.getF() datum = model.getFof("dataset").fValue - + #console.log("F-values"+values); when "P-Value" values = model.getP() datum = model.getPof("dataset") - + # console.log("P values"+values); when "Difference-Of-Proportions" values = model.getDOP() datum = model.getDOPof("dataset") - + #console.log("DOP values"+values); else values = model.getMean(setting.index) datum = model.getMeanOf("dataset", setting.index) - + #console.log(values); - - # + + # # Cleaning the NaN values generated. # Temporary fix. Need to avoid NaN generation. - # + # $.grep values, (a) -> not isNaN(a) - - # Sorting the array to find start and stop values + + # Sorting the array to find start and stop values temp = values.sort((a, b) -> a - b ) start = Math.floor(temp[0]) stop = Math.ceil(temp[values.length - 1]) console.log "start: " + start + " stop: " + stop - - # Percentage on the right and left side of the intial dataset contribution point. + + # Percentage on the right and left side of the intial dataset contribution point. if setting.variable is "P-Value" or setting.variable is "Difference-Of-Proportions" total = temp.length lSide = undefined @@ -666,10 +666,10 @@ socr.view = (model) -> console.log "index: " + index console.log "R Side : " + rSide + ".... L Side : " + lSide binNo = (if $("input[name=\"binno\"]").val() isnt "" then $("input[name=\"binno\"]").val() else 10) - + #datum = Math.floor(datum*100) / 100; _currentValues = values - + try dotplot = socr.vis.generate( parent: "#dotplot" @@ -686,7 +686,7 @@ socr.view = (model) -> pr: rSide precision:setting.precision ) - + # nature: 'continuous' catch e console.log e @@ -701,9 +701,9 @@ socr.view = (model) -> bins: binNo variable: setting.variable ) - + # nature: 'continuous' - + # try{ # socr.vis.addBar({ # elem: dotplot, @@ -724,7 +724,7 @@ socr.view = (model) -> @updateCtrlMessage "Infer plot created.", "success" true - + ### @method updateSimulationInfo @desc Called when the 'step button' or 'run button' is pressed in the controller tile. @@ -745,7 +745,7 @@ socr.view = (model) -> results: [] rCount: model.getRSampleCount() - + #adding results if config.k > 1 if socr.model.getPof("dataset") isnt false @@ -767,7 +767,7 @@ socr.view = (model) -> obj.number = i config.groups.push obj i++ - + #console.log(config); $.get "partials/info.tmpl", (data) -> temp = Mustache.render(data, config) @@ -776,24 +776,24 @@ socr.view = (model) -> return - + ### @method: CoverPage @description: Called from the index.html page. Called whenever the window is resized! @return : none ### CoverPage: -> - + #console.log('CoverPage() invoked!'); height = $(document).height() width = $(window).width() $("#welcome").css "height", height return - + # $('.welcome-container').css('padding-top',height/3).css('padding-left', height/3); # $('#main').show(); - + ### @method: loadInputSheet @description: Called from the {experiment}.js at the {Experiment}.generate() function. @@ -803,11 +803,11 @@ socr.view = (model) -> console.log "loadInputSheet() has been called....data is : " + data return - + # # Temporarily disabling it, I think we should leave the input matrix for data driven purposes only, perhaps the right place would be in the simulation info - # - + # + #$('#input').inputtable('loadData',data); handleResponse: (content, type, id) -> console.log "handleResponse" @@ -816,7 +816,7 @@ socr.view = (model) -> console.log $("#" + id) $("#" + id).append "
" $response = $("#" + id + "-message") - + #$response=$("#"+id+"-message") || $("#"+id).append("
"); console.log $response $response.html("").slideUp 300 @@ -879,5 +879,5 @@ socr.view = (model) -> # console.log("value: "+_currentValues[Math.floor(index)]); # return _currentValues[Math.floor(index)]; # } -# +# #return diff --git a/js/exp/cardExp.js b/js/exp/cardExp.js index c3559be..8b97537 100644 --- a/js/exp/cardExp.js +++ b/js/exp/cardExp.js @@ -1,5 +1,3 @@ -/* - Playing Card Experiment Revised from Distributome Card Experiment into a separate module @@ -29,7 +27,6 @@ function _dealCard(){ if (_tempK < _K){ var _datum=_d[_tempK][_tempN]; _hand[_count].setValue(_datum); - console.log(typeof _datum); _datasetValues[_tempK][_tempN]=_datasetKeys[_tempK][_tempN]=_datum; _count++; _tempN++; @@ -125,7 +122,7 @@ return{ _d[i] = sample(_deck, _n, 0); } - _stepID = setInterval(_dealCard, 20); + _stepID = setInterval(_dealCard, 70); }, reset:function(){ @@ -222,4 +219,4 @@ return{ return {"height":_height,"width":_width}; } }//return -}(); \ No newline at end of file +}(); diff --git a/js/exp/core.js b/js/exp/core.js index c939816..de262b7 100644 --- a/js/exp/core.js +++ b/js/exp/core.js @@ -231,8 +231,12 @@ function Card(canvas){ this.denomination = this.value - 13 * (this.suit - 1); ctx.drawImage(cardImages, (this.denomination - 1) * width, (this.suit - 1) * height, width, height, 0, 0, width, height); } - //else if (this.value == 0) ctx.drawImage(cardImages, 2 * width, 4 * height, width, height, 0, 0, width, height); - else ctx.clearRect(0, 0, width, height); + else if (this.value == 0){ + ctx.drawImage(cardImages, 2 * width, 4 * height, width, height, 0, 0, width, height); + } + else{ + ctx.clearRect(0, 0, width, height); + } } } diff --git a/js/input/data.js b/js/input/data.js index 6b63482..363c83e 100644 --- a/js/input/data.js +++ b/js/input/data.js @@ -163,7 +163,10 @@ socr.dataTable = function () { return false; }, notify: function () { - view.displayResponse('Dataset Request Initialized..give us few second.', 'success'); + view.displayResponse('Dataset Request Initialized', 'success'); + setTimeout(function () { + $response.slideToggle().html(''); + }, 2000); }, checkRefer: function (url) { var requestHost = document.createElement("a"); @@ -178,18 +181,9 @@ socr.dataTable = function () { } }, request: function (uri) { - console.log(uri); + $.get(uri, function (d) { - d = JSON.parse(d); - if(typeof d.status !== 'undefined' && d.status == 'failed'){ - view.displayResponse('There was no valid table in the input URL.', 'error'); - return false; - } - view.displayResponse('Done!', 'success'); - setTimeout(function () { - $response.slideToggle().html(''); - }, 2000); - d = d.data; + var tableCount = $(d).is('table') ? $(d).length : $(d).find('table').length, tables = $(d).is('table') ? $(d) : $(d).find('table'), table = tableparse.filterBySize(tables), @@ -403,8 +397,8 @@ socr.dataTable = function () { colHeaders: true, rowHeaders: true, manualColumnResize : true, - width: 700, - height: 320, + width: 750, + height: 270, outsideClickDeselects : false, contextMenu:true }); diff --git a/js/input/worldbank.js b/js/input/worldbank.js index eec3b12..5dc4ab2 100644 --- a/js/input/worldbank.js +++ b/js/input/worldbank.js @@ -34,7 +34,6 @@ socr.input.worldbank = function(){ request(req, count); } else{ - console.log(res, interval); var interval = parseInt(requestdata["date"].substr(5,9)) - parseInt(requestdata["date"].substr(0,4)) + 1; var grid = formatResponse(res, interval); socr.dataTable.worldbank.loadComplete(); @@ -94,17 +93,15 @@ socr.input.worldbank = function(){ row = []; row.push(country); - var flag = 1; + for(var j = 0 ; j < yearinterval; j++){ - if(response[1][i+j].value > 0){ - row.push(response[1][i+j].value); - flag = 0; - } + + row.push(response[1][i+j].value); } - if(flag == 0) - table.push(row); + table.push(row); + i += yearinterval; } diff --git a/js/vis/vis.js b/js/vis/vis.js index 8a2f9fe..10f30e3 100644 --- a/js/vis/vis.js +++ b/js/vis/vis.js @@ -289,7 +289,7 @@ socr.vis = (function(){ g.select(".y.axis") .call(yAxis); - if(typeof settings.datum != undefined){ + if(typeof settings.datum != "undefined"){ addBar(); diff --git a/test/spec/dataSpec.js b/test/spec/dataSpec.js index 7e62340..5188d3a 100644 --- a/test/spec/dataSpec.js +++ b/test/spec/dataSpec.js @@ -1,25 +1,24 @@ -(function() { - describe("dataSpec", function() { - var dataStore; - dataStore = null; - beforeEach(function() { - return dataStore = socr.dataStore; - }); - it("should create a dataObject", function() { - dataStore.createObject("name", "socr"); - expect(dataStore.name).toBeDefined(); - return expect(typeof dataStore.name).toEqual("object"); - }); - return it("should append data to existing data entry", function() { - dataStore.createObject("test", [1, 2, 3, 4]); - expect(dataStore.test).toBeDefined(); - dataStore.createObject("test", [1, 2, 4, 5, 6]); - expect(dataStore.test).toBeDefined(); - expect(dataStore.test.getData(1)).toEqual(2); - expect(dataStore.test.getData(3)).toEqual(5); - expect(dataStore.test.getData(4)).toEqual(6); - return expect(dataStore.test.getData().length).toEqual(5); - }); - }); +// Generated by CoffeeScript 1.4.0 -}).call(this); +describe("dataSpec", function() { + var dataStore; + dataStore = null; + beforeEach(function() { + return dataStore = socr.dataStore; + }); + it("should create a dataObject", function() { + dataStore.createObject("name", "socr"); + expect(dataStore.name).toBeDefined(); + return expect(typeof dataStore.name).toEqual("object"); + }); + return it("should append data to existing data entry", function() { + dataStore.createObject("test", [1, 2, 3, 4]); + expect(dataStore.test).toBeDefined(); + dataStore.createObject("test", [1, 2, 4, 5, 6]); + expect(dataStore.test).toBeDefined(); + expect(dataStore.test.getData(1)).toEqual(2); + expect(dataStore.test.getData(3)).toEqual(5); + expect(dataStore.test.getData(4)).toEqual(6); + return expect(dataStore.test.getData().length).toEqual(5); + }); +}); diff --git a/test/spec/modelSpec.js b/test/spec/modelSpec.js index 7243a55..660ff58 100644 --- a/test/spec/modelSpec.js +++ b/test/spec/modelSpec.js @@ -1,86 +1,45 @@ -(function() { - describe("appModel", function() { - var model; - socr.model = new socr.model(); - model = socr.model; - beforeEach(function() {}); - it("should have a generateTrail function", function() { - return expect(model.generateTrail).toBeDefined(); +// Generated by CoffeeScript 1.4.0 + +describe("appModel", function() { + var model; + socr.model = new socr.model(); + model = socr.model; + beforeEach(function() {}); + it("should have a generateTrail function", function() { + return expect(model.generateTrail).toBeDefined(); + }); + it("should be able to set a data set", function() { + var input; + input = { + values: [[0, 1], [2, 3]], + keys: [["H", "T"], ["T", "H"]], + processed: true + }; + return expect(model.setDataset(input)).toEqual(true); + }); + describe("generating random samples", function() { + beforeEach(function() { + var input; + input = { + processed: true, + keys: [["T", "T", "H", "T", "T", "H", "H", "T", "T", "H"], ["H", "H", "H", "T", "H", "T", "H", "T", "T", "T"]], + values: [[0, 0, 1, 0, 0, 1, 1, 0, 0, 1], [1, 1, 1, 0, 1, 0, 1, 0, 0, 0]] + }; + return model.setDataset(input); }); - describe("getting and setting Datasets", function() { - it("should set a dataset from simulations", function() { - var input; - input = { - values: [[0, 1], [2, 3]], - keys: [["H", "T"], ["T", "H"]], - processed: true - }; - return expect(model.setDataset(input)).toEqual(true); - }); - return it("should set a dataset ignoring undefined,null values", function() { - var input; - input = { - values: [ - { - cells: [[0], [1], [void 0], [null]], - id: 1 - }, { - cells: [[2], [3], [null], [""]], - id: 2 - } - ], - keys: [["H", "T", "H", "H"], ["T", "H", "T", "T"]], - type: 'spreadsheet' - }; - expect(model.setDataset(input)).toEqual(true); - expect(model.getDataset(1)).toEqual([0, 1]); - return expect(model.getDataset(2)).toEqual([2, 3]); - }); + return it("should generate a trail", function() { + return expect(typeof model.generateTrail(1)).toEqual("object"); }); - describe("generating random samples", function() { - beforeEach(function() { - var input; - input = { - processed: true, - keys: [["T", "T", "H", "T", "T", "H", "H", "T", "T", "H"], ["H", "H", "H", "T", "H", "T", "H", "T", "T", "T"]], - values: [[0, 0, 1, 0, 0, 1, 1, 0, 0, 1], [1, 1, 1, 0, 1, 0, 1, 0, 0, 0]] - }; - return model.setDataset(input); - }); - it("should generate a trail", function() { - return expect(typeof model.generateTrail(1)).toEqual("object"); - }); - return it("should pool the datasets correctly", function() { - expect(socr.dataStore.sampleSpace).toBeDefined(); - expect(socr.dataStore.sampleSpace.values.getData().length).toEqual(20); - return expect(socr.dataStore.sampleSpace.values.getData()).toEqual([0, 0, 1, 0, 0, 1, 1, 0, 0, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 0]); - }); + }); + return describe("testing calculations", function() { + beforeEach(function() { + return socr.dataStore.removeObject("all"); }); - return describe("testing calculations", function() { - beforeEach(function() { - return socr.dataStore.removeObject("all"); - }); - it("should generate accurate P-value", function() { - socr.dataStore.createObject("dataset.1.values", [1, 2, 3, 4, 5]); - socr.dataStore.createObject("dataset.2.values", [4, 5, 6, 7]); - socr.model.setK(); - return expect(model.getPof("dataset")).toEqual(0.03833372853473627); - }); - it("should generate accurate DOP", function() { - socr.dataStore.createObject("dataset.1.values", [1, 1, 1, 0, 1]); - socr.dataStore.createObject("dataset.2.values", [1, 0, 0, 1, 1, 1, 0, 0, 0]); - socr.model.setK(); - return expect(model.getDOPof("dataset").toFixed(3)).toEqual('0.099'); - }); - return it("should generate accurate Standard deviation", function() { - socr.dataStore.createObject("dataset.1.values", [5.94, 6.82, 7.47, 7.48, 8, 8.11, 8.63, 8.69, 8.69, 9.29, 9.44, 9.5]); - socr.dataStore.createObject("dataset.2.values", [10.14, 10.27, 10.4, 10.47, 10.69, 11.24, 11.47, 11.48, 11.76, 11.76, 12.07, 12.38, 12.43, 12.52, 12.55, 12.56, 12.64, 12.67, 12.78, 12.83, 13.04, 13.07, 13.22, 13.38, 13.58, 14.04, 14.08, 14.11, 14.14, 14.19, 14.22, 14.22, 14.29, 14.32, 14.34, 14.53, 14.71, 15, 15.1, 15.1, 15.25, 15.43, 15.57, 15.63, 15.7, 15.78, 15.98, 16, 16.04, 16.31, 16.32, 16.35, 16.53, 16.53, 16.63, 16.65, 16.75, 16.81, 16.95, 16.96, 17.08, 17.12, 17.14, 17.4, 17.41, 17.45, 17.48, 17.72, 18.38, 18.49, 18.56, 18.64, 18.7, 18.78, 18.93, 18.93, 19.19, 19.47, 19.5, 19.5, 19.65, 19.66, 19.74, 19.79, 19.85]); - socr.dataStore.createObject("dataset.3.values", [20.11, 20.22, 20.3, 20.38, 20.52, 20.54, 20.75, 20.76, 21.11, 21.19, 21.26, 21.33, 21.39, 21.53, 21.71, 21.86, 22.36, 22.39, 22.65, 22.82, 22.89, 23.07, 23.18, 23.26, 23.35, 23.35, 23.42, 23.42, 23.44, 23.69, 23.74, 23.74, 24.32, 24.42, 24.54, 24.6, 24.86, 25, 25.19, 25.46, 25.65, 25.67, 25.9, 26, 26, 26.14, 26.22, 26.43, 26.75, 26.86, 26.9, 27.18, 27.32, 27.39, 27.97, 28.28, 28.65, 28.79, 28.84, 29.03, 29.08, 29.5, 29.75, 29.79]); - expect(model.getStandardDevOfDataset(1).toFixed(5)).toEqual('1.04812'); - expect(model.getStandardDevOfDataset(2).toFixed(5)).toEqual('2.69046'); - return expect(model.getStandardDevOfDataset(3).toFixed(5)).toEqual('2.80058'); - }); + return it("should generate accurate P-value", function() { + socr.dataStore.createObject("dataset.1.values", [1, 2, 3, 4, 5]); + socr.dataStore.createObject("dataset.2.values", [4, 5, 6, 7]); + window["test"] = model; + return expect(model.getPof("dataset")).toEqual(0.03745653509411884); }); }); - -}).call(this); +});