<taskModel about="http://users.wpi.edu/~flveggie/IUI/EXP" xmlns="http://ce.org/cea-2018">
  <!-- assumptions:
  user can identify a normal distribution
  bootstrapping is an acceptable statistic
  user is comparing means
  -->
  <task id="SelectTopLevelAnalysisGoal">
    <!-- Generating confidence interval for a variable or variables -->
    <subtasks id="ParameterEstimation">
      <step name="StepSelectEstimateVariable" task="SelectEstimateVariable"/>
	 <step name="StepCheckNormality" task="CheckNormality"/>
	 <step name="StepRunEstimation" task="RunEstimation"/>
	 <binding slot="$StepCheckNormality.variable" value="$StepSelectEstimateVariable.estimateVar"/>
    </subtasks>
    
    <!-- t-test for two variables -->
    <subtasks id="HypothesisTesting">
      <step name="StepBuildHypothesis" task="BuildHypothesis"/>
	 <step name="StepCheckNormalities" task="CheckNormalities"/>
    </subtasks>
    
    <!-- Determine how much variance a variable accounts for -->
    <subtasks id="ANOVA">
      <step name="StepDoANOVA" task="DoANOVA"/>
    </subtasks>
  </task>
  
  <task id="CheckNormality">
    <input name="variable" type="string"/>
    <postcondition sufficient="true">(normality_check &#62; 0)</postcondition>
    <!--
          ask user (show histogram?)
	compare sum stats?
	violate assumption (ok many times)
        -->
  </task>
  
  <task id="RunEstimation">
    <subtasks id="BootstrapTesting">
      <step name="StepDoBootstrap" task="BootstrapEstimation"/>
	 <applicable>((normality_check &#60; 3) || $this.success == false)</applicable>
    </subtasks>
    
    <subtasks id="NormalTesting">
	 <step name="StepDoNormal" task="NormalEstimation"/>
	 <applicable>(normality_check == 3)</applicable>
    </subtasks>
  </task>
  
  <task id="BootstrapEstimation">
    <input name="pVal" type="number"/>
    <postcondition>p_value &#60; 0.051</postcondition>
  </task>
  <script task="BootstrapEstimation">
    p_value = $this.pVal;
  </script>
  
  <task id="NormalEstimation">
    <input name="pVal" type="number"/>
    <postcondition>p_value &#60; 0.051</postcondition>
  </task>
  <script task="NormalEstimation">
    p_value = $this.pVal;
  </script>
  
  <task id="CheckNormalities">
    <subtasks id="checkBoth">
      <step name="StepCheckSampleVarNormality" task="CheckSampleVarNormality"/>
	 <step name="StepCheckNormality" task="CheckNormality"/>
	 <step name="StepCheckReferenceVarNormality" task="CheckReferenceVarNormality"/>
	 <step name="StepCheckNormality" task="CheckNormality"/>
    </subtasks>
  </task>
  
  <task id="CheckSampleVarNormality"/>
  <script task="CheckSampleVarNormality">
    normality_check = hypothesis.sampleVar;
  </script>
  
  <task id="CheckReferenceVarNormality"/>
  <script task="CheckReferenceVarNormality">
    normality_check = hypothesis.referenceVar;
  </script>
  
  <task id="SelectEstimateVariable">
    <input name="estimateVar" type="string"/>
    <input name="sumStat" type="string"/>
    <input name="isNormal" type="number"/>
  </task>
  <script task="SelectEstimateVariable">
    estimate_var = $this.estimateVar;
    sum_stat = $this.sumStat;
    normality_check = $this.isNormal;
  </script>
  
  <task id="DoANOVA"/>
  
  <task id="BuildHypothesis">
    <subtasks id="BuildHypothesisDecomp" ordered="false">
      <step name="StepSelectSampleVar" task="SelectSampleVar"/>
	 <step name="StepSelectSampleSumStat" task="SelectSampleSumStat"/>
	 <step name="StepSelectRelation" task="SelectRelation"/>
	 <step name="StepSelectReferenceVar" task="SelectReferenceVar"/>
	 <step name="StepSelectReferenceSumStat" task="SelectReferenceSumStat"/>
    </subtasks>
  </task>
  
  <task id="SelectSampleVar">
    <input name="sampleVar" type="string"/>
    <input name="isPop" type="boolean"/>
  </task>
  <script task="SelectSampleVar">
    hypothesis.sampleVar = $this.sampleVar;
    hypothesis.sampleVarIsPop = $this.isPop;
  </script>
  
  <task id="SelectSampleSumStat">
    <input name="sampleSumStat" type="string"/>
    <postcondition sufficient="true">hypothesis.sumStat != null</postcondition>
  </task>
  <script task="SelectSampleSumStat">
    hypothesis.sumStat = $this.sampleSumStat;
  </script>
  
  <task id="SelectRelation">
    <input name="relation" type="string"/>
  </task>
  <script task="SelectRelation">
    hypothesis.relation = $this.relation;
  </script>
  
  <task id="SelectReferenceVar">
    <input name="referenceVar" type="string"/>
    <input name="isPop" type="boolean"/>
  </task>
  <script task="SelectReferenceVar">
    hypothesis.referenceVar = $this.referenceVar;
    hypothesis.referenceVarIsPop = $this.isPop;
  </script>
  
  <task id="SelectReferenceSumStat">
    <input name="referenceSumStat" type="string"/>
    <postcondition sufficient="true">hypothesis.sumStat != null</postcondition>
  </task>
  <script task="SelectReferenceSumStat">
    hypothesis.sumStat = $this.referenceSumStat;
  </script>
  
  <script init="true">
    <![CDATA[
    normality_check = 0;
    p_value = 1;
    
    function Hypothesis() {
      this.sampleVar = null;
	 this.sampleVarIsPop = null;
	 this.referenceVar = null;
	 this.referenceVarIsPop = null;
	 this.relation = null;
      this.sumStat = null;
    }
    
    hypothesis = new Hypothesis();
    estimate_var = null;

    function Variable(name, type) {
      this.name = name;
      this.type = type;
    }
    
    function getVarNames() {
      results = new Array()
      for (i=0; i<somevars.length; i++) {
	   results[i] = somevars[i].name;
	 }
	 return results;
    }
    
    var variable1 = new Variable("power", "interval");
    var variable2 = new Variable("squish-factor", "ordinal");
    var variable3 = new Variable("response", "interval");
    var variable4 = new Variable("platform", "nominal");
    
    var somevars = new Array(variable1, variable2, variable3, variable4);
    ]]>
  </script>
</taskModel>