(* Content-type: application/vnd.wolfram.mathematica *)

(*** Wolfram Notebook File ***)
(* http://www.wolfram.com/nb *)

(* CreatedBy='Mathematica 9.0' *)

(*CacheID: 234*)
(* Internal cache information:
NotebookFileLineBreakTest
NotebookFileLineBreakTest
NotebookDataPosition[       157,          7]
NotebookDataLength[    478895,      11938]
NotebookOptionsPosition[    464970,      11680]
NotebookOutlinePosition[    465741,      11706]
CellTagsIndexPosition[    465671,      11701]
WindowFrame->Normal*)

(* Beginning of Notebook Content *)
Notebook[{

Cell[CellGroupData[{
Cell["DataAnalysis", "Title"],

Cell[CellGroupData[{

Cell["Begin package", "Section",ExpressionUUID->"9d9e5efc-5729-48c9-b296-8e123767f5d5"],

Cell[BoxData[
 RowBox[{
  RowBox[{"BeginPackage", "[", 
   RowBox[{"\"\<DataAnalysis`\>\"", ",", 
    RowBox[{"{", "\[IndentingNewLine]", 
     RowBox[{
     "\"\<SciDraw`\>\"", ",", "\[IndentingNewLine]", "\"\<StyleOptions`\>\"", 
      ",", "\[IndentingNewLine]", "\"\<CustomTicks`\>\"", ",", 
      "\[IndentingNewLine]", "\"\<NETLink`\>\"", ",", "\[IndentingNewLine]", 
      "\"\<ErrorBarPlots`\>\""}], "\[IndentingNewLine]", "}"}]}], "]"}], 
  ";"}]], "Input",
 InitializationCell->
  True,ExpressionUUID->"3016a4ef-eca9-4385-877e-cf2ad253e825"],

Cell[BoxData[
 RowBox[{
  RowBox[{"Unprotect", "[", 
   RowBox[{"Evaluate", "[", 
    RowBox[{"$Context", "<>", "\"\<*\>\""}], "]"}], "]"}], ";"}]], "Input",
 InitializationCell->True]
}, Open  ]],

Cell[CellGroupData[{

Cell["Public symbols", "Section",ExpressionUUID->"1d83d6e5-66cb-44d4-87f9-e782c399f237"],

Cell[CellGroupData[{

Cell["Functions", "Subsection"],

Cell[BoxData[{
 RowBox[{"IV", ";"}], "\[IndentingNewLine]", 
 RowBox[{"DV", ";"}], "\[IndentingNewLine]", 
 RowBox[{"NDV", ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"SetConfidenceLevel", ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{"DVEvaluate", ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"DVE", ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{"DVMeans", ";"}], "\[IndentingNewLine]", 
 RowBox[{"DVSEs", ";"}], "\[IndentingNewLine]", 
 RowBox[{"DVCIs", ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"NumericDVQ", ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{"MonteCarloSimulation", ";"}], "\[IndentingNewLine]", 
 RowBox[{"MonteCarloResult", ";"}], "\[IndentingNewLine]", 
 RowBox[{"MCEvaluate", ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"MCE", ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"EffectiveVarianceFit", ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{"DataTable", ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"ToArray", ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"ReplaceDatum", ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{"QueryTo", ";"}], "\[IndentingNewLine]", 
 RowBox[{"KeyFind", ";"}], "\[IndentingNewLine]", 
 RowBox[{"KeyExcept", ";"}], "\[IndentingNewLine]", 
 RowBox[{"GroupByKey", ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"JoinT", ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"DefineItemErrors", ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{"FV", ";"}], "\[IndentingNewLine]", 
 RowBox[{"NV", ";"}], "\[IndentingNewLine]", 
 RowBox[{"ColNames", ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"NK", ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{"FoldValues", ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"PartitionAssociation", ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{"LSDataStyles", ";"}], "\[IndentingNewLine]", 
 RowBox[{"Fig", ";"}], "\[IndentingNewLine]", 
 RowBox[{"SciDrawPlot", ";"}], "\[IndentingNewLine]", 
 RowBox[{"FigColumn", ";"}], "\[IndentingNewLine]", 
 RowBox[{"FigGrid", ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"AnchorName", ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"DTPlot", ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"VarKey", ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{"MeanAndStandardError", ";"}], "\[IndentingNewLine]", 
 RowBox[{"MeanAndStandardDeviation", ";"}], "\[IndentingNewLine]", 
 RowBox[{"FixedEffectMetaAnalysis", ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"RandomEffectsMetaAnalysis", ";"}], "\[IndentingNewLine]", 
  "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{
   "MeanAndStandardErrorWithEV", ";", "\[IndentingNewLine]", 
    "MeanAndStandardDeviationWithEV", ";"}], "*)"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"(*", 
   RowBox[{"EVMultiplyE", ";"}], "*)"}]}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"ae205faf-3b29-4a1c-90c5-941fdaa67198"]
}, Open  ]],

Cell[CellGroupData[{

Cell["Variables", "Subsection"],

Cell[BoxData[
 RowBox[{"$UsePlusMinusForm", ";"}]], "Input",
 InitializationCell->
  True,ExpressionUUID->"9935e195-a0b8-4785-8e55-afe9d69e84bd"]
}, Open  ]],

Cell[CellGroupData[{

Cell["Options", "Subsection"],

Cell[BoxData[{
 RowBox[{"CorrelatedErrors", ";"}], "\[IndentingNewLine]", 
 RowBox[{"UseParallelKernels", ";"}], "\[IndentingNewLine]", 
 RowBox[{"AssumeND", ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"MatchPattern", ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{"XLogScale", ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"YLogScale", ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{"XErrorBars", ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"YErrorBars", ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{"FigPanelExtras", ";"}], "\[IndentingNewLine]", 
 RowBox[{"ShowLegend", ";"}]}], "Input",
 InitializationCell->True]
}, Open  ]]
}, Open  ]],

Cell[CellGroupData[{

Cell["Begin private context", "Section"],

Cell[BoxData[
 RowBox[{
  RowBox[{"Begin", "[", "\"\<`Private`\>\"", "]"}], ";"}]], "Input",
 InitializationCell->True]
}, Open  ]],

Cell[CellGroupData[{

Cell["Error handling", "Section"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"SetAttributes", "[", 
   RowBox[{"ErrorMessage", ",", "HoldFirst"}], "]"}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"ErrorMessage", "[", "Args___", "]"}], ":=", 
   RowBox[{"Module", "[", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"Message", "[", "Args", "]"}], ";", "\[IndentingNewLine]", 
      RowBox[{"Abort", "[", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}]}], 
  ";"}]}], "Input",
 InitializationCell->True],

Cell[BoxData[{
 RowBox[{
  RowBox[{"SetAttributes", "[", 
   RowBox[{"CatchError", ",", "HoldAll"}], "]"}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"CatchError", "[", "Body_", "]"}], ":=", 
   RowBox[{"(", 
    RowBox[{
     RowBox[{"Catch", "[", "Body", "]"}], "===", "$ErrorFlag"}], ")"}]}], 
  ";"}]}], "Input",
 InitializationCell->True]
}, Open  ]],

Cell[CellGroupData[{

Cell["Profiling", "Section"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"SetAttributes", "[", 
   RowBox[{"PrintTiming", ",", "HoldFirst"}], "]"}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"PrintTiming", "[", "f_", "]"}], ":=", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", "res", "}"}], ",", 
     RowBox[{
      RowBox[{"res", "=", 
       RowBox[{"Timing", "[", "f", "]"}]}], ";", 
      RowBox[{"Print", "[", 
       RowBox[{"res", "[", 
        RowBox[{"[", "1", "]"}], "]"}], "]"}], ";", 
      RowBox[{"res", "[", 
       RowBox[{"[", "2", "]"}], "]"}]}]}], "]"}]}], ";"}]}], "Input",
 InitializationCell->True]
}, Closed]],

Cell[CellGroupData[{

Cell["Values with uncertainties (NDV, IV, ...)", "Section"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"NumPattern", "=", 
   RowBox[{"_Real", "|", "_Rational", "|", "_Integer"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"NumPatternQ", "[", "x_", "]"}], ":=", 
    StyleBox[
     RowBox[{"MatchQ", "[", 
      RowBox[{"x", ",", "NumPattern"}], "]"}],
     ShowSpecialCharacters->False,
     ShowStringCharacters->True,
     NumberMarks->True]}], ";"}], " "}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"PosNumPatternQ", "[", "x_", "]"}], ":=", 
   StyleBox[
    RowBox[{
     RowBox[{"MatchQ", "[", 
      RowBox[{"x", ",", "NumPattern"}], "]"}], "&&", 
     RowBox[{"x", ">=", "0"}]}],
    ShowSpecialCharacters->False,
    ShowStringCharacters->True,
    NumberMarks->True]}], 
  StyleBox[";",
   ShowSpecialCharacters->False,
   ShowStringCharacters->True,
   NumberMarks->True]}]}], "Input",
 InitializationCell->True],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"$UsePlusMinusForm", "::", "usage"}], "=", 
   "\"\<$UsePlusMinusForm is a boolean value specifying whether uncertanties \
are displayed with the \[PlusMinus] form or with parentheses.\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"$UsePlusMinusForm", "=", "False"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"$ConfidenceLevel", "=", "0.95"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"$ZValue", "=", 
   RowBox[{"InverseCDF", "[", 
    RowBox[{
     RowBox[{"NormalDistribution", "[", "]"}], ",", 
     RowBox[{"1", "-", 
      RowBox[{
       RowBox[{"(", 
        RowBox[{"1", "-", "$ConfidenceLevel"}], ")"}], "/", "2"}]}]}], 
    "]"}]}], ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"889557f4-e06c-44cd-bf3a-2f7c979216aa"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"SetConfidenceLevel", "::", "usage"}], "=", 
   "\"\<SetConfidenceLevel[\!\(\*StyleBox[\"n\",FontSlant->\"Italic\"]\)] \
sets the confidence level for the DataAnalysis functions, for example to \
control the output display. The default confidence level is 0.95.\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"SetConfidenceLevel", "[", 
    RowBox[{"v_:", "NumPattern"}], "]"}], ":=", 
   RowBox[{"(", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"$ConfidenceLevel", "=", 
      RowBox[{"Abs", "[", "v", "]"}]}], ";", "\[IndentingNewLine]", 
     RowBox[{"$ZValue", "=", 
      RowBox[{"InverseCDF", "[", 
       RowBox[{
        RowBox[{"NormalDistribution", "[", "]"}], ",", 
        RowBox[{"1", "-", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"1", "-", 
            RowBox[{"Abs", "[", "v", "]"}]}], ")"}], "/", "2"}]}]}], "]"}]}], 
     ";", "\[IndentingNewLine]", "v"}], "\[IndentingNewLine]", ")"}]}], 
  ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"0e77bc0f-00f9-4e7c-b110-6d1a422085c5"],

Cell[CellGroupData[{

Cell["DV", "Subsection"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"DV", "::", "usage"}], "=", 
   "\"\<DV[v,se] represents a value v associated with a standard error se.\n\
DV[v,se,i] represents a value associated with an uncertainty in the form of \
mean v corresponding and standard error \
\!\(\*StyleBox[\"se\",FontSlant->\"Italic\"]\) as well as symmetric relative \
confidence interval i.\nDV[v,se,{il,iu}] specifies a confidence interval from \
v-il to v+iu.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"DV", "[", 
    RowBox[{
     RowBox[{"v_", "?", "NumPatternQ"}], ",", 
     RowBox[{"se_", "?", "NumPatternQ"}]}], "]"}], ":=", 
   RowBox[{"DV", "[", 
    RowBox[{"v", ",", "se", ",", "Null", ",", 
     RowBox[{"Unique", "[", "Global`dv", "]"}]}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"DV", "[", 
    RowBox[{
     RowBox[{"v_", "?", "NumPatternQ"}], ",", 
     RowBox[{"se_", "?", "NumPatternQ"}], ",", 
     RowBox[{"i_", "?", "PosNumPatternQ"}]}], "]"}], ":=", 
   RowBox[{"DV", "[", 
    RowBox[{"v", ",", "se", ",", "i", ",", 
     RowBox[{"Unique", "[", "Global`dv", "]"}]}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"DV", "[", 
     RowBox[{
      RowBox[{"v_", "?", "NumPatternQ"}], ",", 
      RowBox[{"se_", "?", "NumPatternQ"}], ",", 
      RowBox[{"i", ":", 
       RowBox[{"{", 
        RowBox[{
         RowBox[{"rl_", "?", "PosNumPatternQ"}], ",", 
         RowBox[{"ru_", "?", "PosNumPatternQ"}]}], "}"}]}]}], "]"}], ":=", 
    RowBox[{"DV", "[", 
     RowBox[{"v", ",", "se", ",", "i", ",", 
      RowBox[{"Unique", "[", "Global`dv", "]"}]}], "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"DVMeans", "::", "usage"}], "=", 
   "\"\<DVMeans[expr] replaces all DV, NDV and IV objects in an expression \
with their mean value.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"DVMeans", "[", "expr_", "]"}], ":=", 
    RowBox[{"ReplaceAllDT", "[", 
     RowBox[{"expr", ",", 
      RowBox[{"{", 
       RowBox[{
        RowBox[{
         RowBox[{"NDV", "[", 
          RowBox[{"v_", ",", "se_", ",", "n_"}], "]"}], "\[RuleDelayed]", 
         "v"}], ",", 
        RowBox[{
         RowBox[{"DV", "[", 
          RowBox[{"v_", ",", "se_", ",", "i_", ",", "n_"}], "]"}], 
         "\[RuleDelayed]", "v"}], ",", 
        RowBox[{
         RowBox[{"IV", "[", 
          RowBox[{"v_", ",", "i_"}], "]"}], "\[RuleDelayed]", "v"}]}], 
       "}"}]}], "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"DVSEs", "::", "usage"}], "=", 
   "\"\<DVSEs[expr] replaces all DV and NDV objects in an expression with \
their standard error.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"DVSEs", "[", "expr_", "]"}], ":=", 
    RowBox[{"ReplaceAllDT", "[", 
     RowBox[{"expr", ",", 
      RowBox[{"{", 
       RowBox[{
        RowBox[{
         RowBox[{"NDV", "[", 
          RowBox[{"v_", ",", "se_", ",", "n_"}], "]"}], "\[RuleDelayed]", 
         "se"}], ",", 
        RowBox[{
         RowBox[{"DV", "[", 
          RowBox[{"v_", ",", "se_", ",", "i_", ",", "n_"}], "]"}], 
         "\[RuleDelayed]", "se"}]}], "}"}]}], "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"DVCIs", "::", "usage"}], "=", 
  "\"\<DVCIs[expr] gives the confidence intervals for DV and NDV \
values.\>\""}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"DVCIs", "[", "expr_", "]"}], ":=", 
    RowBox[{"ReplaceAllDT", "[", 
     RowBox[{"expr", ",", 
      RowBox[{"{", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{
         RowBox[{"NDV", "[", 
          RowBox[{"v_", ",", "se_", ",", "n_"}], "]"}], "\[RuleDelayed]", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"v", "-", 
            RowBox[{"se", "*", "$ZValue"}]}], ",", 
           RowBox[{"v", "+", 
            RowBox[{"se", "*", "$ZValue"}]}]}], "}"}]}], ",", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"DV", "[", 
          RowBox[{"v_", ",", "se_", ",", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"rl_", "?", "PosNumPatternQ"}], ",", 
             RowBox[{"ru_", "?", "PosNumPatternQ"}]}], "}"}], ",", "n_"}], 
          "]"}], "\[RuleDelayed]", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"v", "-", "rl"}], ",", 
           RowBox[{"v", "+", "ru"}]}], "}"}]}], ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"DV", "[", 
          RowBox[{"v_", ",", "se_", ",", 
           RowBox[{"i_", "?", "PosNumPatternQ"}], ",", "n_"}], "]"}], 
         "\[RuleDelayed]", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"v", "-", "i"}], ",", 
           RowBox[{"v", "+", "i"}]}], "}"}]}], ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"DV", "[", 
          RowBox[{"v_", ",", "se_", ",", "n_"}], "]"}], "\[RuleDelayed]", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"v", "-", 
            RowBox[{"se", "*", "$ZValue"}]}], ",", 
           RowBox[{"v", "+", 
            RowBox[{"se", "*", "$ZValue"}]}]}], "}"}]}]}], 
       "\[IndentingNewLine]", "}"}]}], "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"NumericDVQ", "::", "usage"}], "=", 
   "\"\<NumericDVQ[expr] gives True if expr is a real number or an DV or NDV \
object with real mean and standard error, and False otherwise.\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"NumericDVQ", "[", "expr_", "]"}], ":=", 
   RowBox[{
    RowBox[{"MatchQ", "[", 
     RowBox[{"expr", ",", "NumPattern"}], "]"}], "||", "\[IndentingNewLine]", 
    
    RowBox[{"(", 
     RowBox[{
      RowBox[{"(", 
       RowBox[{
        RowBox[{
         RowBox[{"Head", "[", "expr", "]"}], "===", "NDV"}], "||", 
        RowBox[{
         RowBox[{"Head", "[", "expr", "]"}], "===", "DV"}]}], ")"}], "&&", 
      RowBox[{"MatchQ", "[", 
       RowBox[{
        RowBox[{"expr", "[", 
         RowBox[{"[", "1", "]"}], "]"}], ",", "NumPattern"}], "]"}], "&&", 
      RowBox[{"MatchQ", "[", 
       RowBox[{
        RowBox[{"expr", "[", 
         RowBox[{"[", "2", "]"}], "]"}], ",", "NumPattern"}], "]"}], "&&", 
      RowBox[{
       RowBox[{"expr", "[", 
        RowBox[{"[", "2", "]"}], "]"}], ">", "0"}]}], ")"}]}]}], 
  ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"6d257516-a69a-4ecc-80ef-f04cfd893179"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MakeBoxes", "[", 
     RowBox[{
      RowBox[{"dv", ":", 
       RowBox[{"DV", "[", 
        RowBox[{
         RowBox[{"v_", "?", "NumPatternQ"}], ",", 
         RowBox[{"se_", "?", "PosNumPatternQ"}], ",", "Null", ",", "_"}], 
        "]"}]}], ",", "StandardForm"}], "]"}], "^:=", 
    RowBox[{
     RowBox[{"Interpretation", "[", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Style", "[", 
        RowBox[{
         RowBox[{"SForm", "[", 
          RowBox[{"v", ",", "se"}], "]"}], ",", 
         RowBox[{"ShowStringCharacters", "\[Rule]", "False"}]}], "]"}], ",", 
       "dv"}], "]"}], "//", "ToBoxes"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MakeBoxes", "[", 
     RowBox[{
      RowBox[{"DV", "[", 
       RowBox[{
        RowBox[{"v_", "?", "NumPatternQ"}], ",", 
        RowBox[{"se_", "?", "PosNumPatternQ"}], ",", "Null", ",", "_"}], 
       "]"}], ",", "OutputForm"}], "]"}], "^:=", 
    RowBox[{
     RowBox[{"OutputSForm", "[", 
      RowBox[{"v", ",", "se"}], "]"}], "//", "ToBoxes"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"ToString", "[", 
     RowBox[{"DV", "[", 
      RowBox[{
       RowBox[{"v_", "?", "NumPatternQ"}], ",", 
       RowBox[{"se_", "?", "PosNumPatternQ"}], ",", "Null", ",", "_"}], "]"}],
      "]"}], "^:=", 
    RowBox[{"OutputSForm", "[", 
     RowBox[{"v", ",", "se"}], "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MakeBoxes", "[", 
     RowBox[{
      RowBox[{"dv", ":", 
       RowBox[{"DV", "[", 
        RowBox[{
         RowBox[{"v_", "?", "NumPatternQ"}], ",", 
         RowBox[{"se_", "?", "PosNumPatternQ"}], ",", 
         RowBox[{"i_", "?", "PosNumPatternQ"}], ",", "_"}], "]"}]}], ",", 
      "StandardForm"}], "]"}], "^:=", 
    RowBox[{
     RowBox[{"Interpretation", "[", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Style", "[", 
        RowBox[{
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"TrueQ", "[", "$UsePlusMinusForm", "]"}], ",", 
           RowBox[{"PMForm", "[", 
            RowBox[{"v", ",", "i"}], "]"}], ",", 
           RowBox[{"ParenthesisForm", "[", 
            RowBox[{"v", ",", "i"}], "]"}]}], "]"}], ",", 
         RowBox[{"ShowStringCharacters", "\[Rule]", "False"}]}], "]"}], ",", 
       "dv"}], "]"}], "//", "ToBoxes"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MakeBoxes", "[", 
     RowBox[{
      RowBox[{"DV", "[", 
       RowBox[{
        RowBox[{"v_", "?", "NumPatternQ"}], ",", 
        RowBox[{"se_", "?", "PosNumPatternQ"}], ",", 
        RowBox[{"i_", "?", "PosNumPatternQ"}], ",", "_"}], "]"}], ",", 
      "OutputForm"}], "]"}], "^:=", 
    RowBox[{
     RowBox[{"If", "[", 
      RowBox[{
       RowBox[{"TrueQ", "[", "$UsePlusMinusForm", "]"}], ",", 
       RowBox[{"OutputPMForm", "[", 
        RowBox[{"v", ",", "i"}], "]"}], ",", 
       RowBox[{"OutputParenthesisForm", "[", 
        RowBox[{"v", ",", "i"}], "]"}]}], "]"}], "//", "ToBoxes"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"ToString", "[", 
     RowBox[{"DV", "[", 
      RowBox[{
       RowBox[{"v_", "?", "NumPatternQ"}], ",", 
       RowBox[{"se_", "?", "PosNumPatternQ"}], ",", 
       RowBox[{"i_", "?", "PosNumPatternQ"}], ",", "_"}], "]"}], "]"}], "^:=", 
    RowBox[{"If", "[", 
     RowBox[{
      RowBox[{"TrueQ", "[", "$UsePlusMinusForm", "]"}], ",", 
      RowBox[{"OutputPMForm", "[", 
       RowBox[{"v", ",", "i"}], "]"}], ",", 
      RowBox[{"OutputParenthesisForm", "[", 
       RowBox[{"v", ",", "i"}], "]"}]}], "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MakeBoxes", "[", 
     RowBox[{
      RowBox[{"dv", ":", 
       RowBox[{"DV", "[", 
        RowBox[{
         RowBox[{"v_", "?", "NumPatternQ"}], ",", 
         RowBox[{"se_", "?", "PosNumPatternQ"}], ",", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"rl_", "?", "PosNumPatternQ"}], ",", 
           RowBox[{"ru_", "?", "PosNumPatternQ"}]}], "}"}], ",", "_"}], 
        "]"}]}], ",", "StandardForm"}], "]"}], "^:=", 
    RowBox[{
     RowBox[{"Interpretation", "[", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Style", "[", 
        RowBox[{
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"TrueQ", "[", "$UsePlusMinusForm", "]"}], ",", 
           RowBox[{"PMForm", "[", 
            RowBox[{"v", ",", "rl", ",", "ru"}], "]"}], ",", 
           RowBox[{"ParenthesisForm", "[", 
            RowBox[{"v", ",", "rl", ",", "ru"}], "]"}]}], "]"}], ",", 
         RowBox[{"ShowStringCharacters", "\[Rule]", "False"}]}], "]"}], ",", 
       "dv"}], "]"}], "//", "ToBoxes"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MakeBoxes", "[", 
     RowBox[{
      RowBox[{"DV", "[", 
       RowBox[{
        RowBox[{"v_", "?", "NumPatternQ"}], ",", 
        RowBox[{"se_", "?", "PosNumPatternQ"}], ",", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"rl_", "?", "PosNumPatternQ"}], ",", 
          RowBox[{"ru_", "?", "PosNumPatternQ"}]}], "}"}], ",", "_"}], "]"}], 
      ",", "OutputForm"}], "]"}], "^:=", 
    RowBox[{
     RowBox[{"If", "[", 
      RowBox[{
       RowBox[{"TrueQ", "[", "$UsePlusMinusForm", "]"}], ",", 
       RowBox[{"OutputPMForm", "[", 
        RowBox[{"v", ",", "rl", ",", "ru"}], "]"}], ",", 
       RowBox[{"OutputParenthesisForm", "[", 
        RowBox[{"v", ",", "rl", ",", "ru"}], "]"}]}], "]"}], "//", 
     "ToBoxes"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"ToString", "[", 
    RowBox[{"DV", "[", 
     RowBox[{
      RowBox[{"v_", "?", "NumPatternQ"}], ",", 
      RowBox[{"se_", "?", "PosNumPatternQ"}], ",", 
      RowBox[{"{", 
       RowBox[{
        RowBox[{"rl_", "?", "PosNumPatternQ"}], ",", 
        RowBox[{"ru_", "?", "PosNumPatternQ"}]}], "}"}], ",", "_"}], "]"}], 
    "]"}], "^:=", 
   RowBox[{"If", "[", 
    RowBox[{
     RowBox[{"TrueQ", "[", "$UsePlusMinusForm", "]"}], ",", 
     RowBox[{"OutputPMForm", "[", 
      RowBox[{"v", ",", "rl", ",", "ru"}], "]"}], ",", 
     RowBox[{"OutputParenthesisForm", "[", 
      RowBox[{"v", ",", "rl", ",", "ru"}], "]"}]}], "]"}]}], ";"}]}], "Input",\

 InitializationCell->
  True,ExpressionUUID->"921e3ce1-23a5-4f09-ae33-ec7f37e631e9"]
}, Open  ]],

Cell[CellGroupData[{

Cell["NDV", "Subsection"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"NDV", "::", "usage"}], "=", 
   "\"\<NDV[v,se] represents a value associated with an uncertainty in the \
form of a normal distribution with mean v and standard error se.\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"NDV", "[", 
    RowBox[{
     RowBox[{"v_", "?", "NumPatternQ"}], ",", 
     RowBox[{"se_", "?", "PosNumPatternQ"}]}], "]"}], ":=", 
   RowBox[{"NDV", "[", 
    RowBox[{"v", ",", "se", ",", 
     RowBox[{"Unique", "[", "Global`dv", "]"}]}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"NDV", "[", 
    RowBox[{
     RowBox[{"v_", "?", "NumPatternQ"}], ",", "0"}], "]"}], ":=", "v"}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"NDV", "[", 
    RowBox[{
     RowBox[{"v_", "?", "NumPatternQ"}], ",", "0."}], "]"}], ":=", "v"}], 
  ";"}]}], "Input",
 InitializationCell->True],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MakeBoxes", "[", 
     RowBox[{
      RowBox[{"ndv", ":", 
       RowBox[{"NDV", "[", 
        RowBox[{
         RowBox[{"v_", "?", "NumPatternQ"}], ",", 
         RowBox[{"se_", "?", "PosNumPatternQ"}], ",", "_"}], "]"}]}], ",", 
      "StandardForm"}], "]"}], "^:=", 
    RowBox[{
     RowBox[{"Interpretation", "[", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Style", "[", 
        RowBox[{
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"TrueQ", "[", "$UsePlusMinusForm", "]"}], ",", 
           RowBox[{"PMForm", "[", 
            RowBox[{"v", ",", 
             RowBox[{"se", "*", "$ZValue"}]}], "]"}], ",", 
           RowBox[{"ParenthesisForm", "[", 
            RowBox[{"v", ",", 
             RowBox[{"se", "*", "$ZValue"}]}], "]"}]}], "]"}], ",", 
         RowBox[{"ShowStringCharacters", "\[Rule]", "False"}]}], "]"}], ",", 
       "ndv"}], "]"}], "//", "ToBoxes"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MakeBoxes", "[", 
     RowBox[{
      RowBox[{"NDV", "[", 
       RowBox[{
        RowBox[{"v_", "?", "NumPatternQ"}], ",", 
        RowBox[{"se_", "?", "PosNumPatternQ"}], ",", "_"}], "]"}], ",", 
      "OutputForm"}], "]"}], "^:=", 
    RowBox[{
     RowBox[{"If", "[", 
      RowBox[{
       RowBox[{"TrueQ", "[", "$UsePlusMinusForm", "]"}], ",", 
       RowBox[{"OutputPMForm", "[", 
        RowBox[{"v", ",", 
         RowBox[{"se", "*", "$ZValue"}]}], "]"}], ",", 
       RowBox[{"OutputParenthesisForm", "[", 
        RowBox[{"v", ",", 
         RowBox[{"se", "*", "$ZValue"}]}], "]"}]}], "]"}], "//", 
     "ToBoxes"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"ToString", "[", 
    RowBox[{"NDV", "[", 
     RowBox[{
      RowBox[{"v_", "?", "NumPatternQ"}], ",", 
      RowBox[{"se_", "?", "PosNumPatternQ"}], ",", "_"}], "]"}], "]"}], "^:=", 
   RowBox[{"If", "[", 
    RowBox[{
     RowBox[{"TrueQ", "[", "$UsePlusMinusForm", "]"}], ",", 
     RowBox[{"OutputPMForm", "[", 
      RowBox[{"v", ",", 
       RowBox[{"se", "*", "$ZValue"}]}], "]"}], ",", 
     RowBox[{"OutputParenthesisForm", "[", 
      RowBox[{"v", ",", 
       RowBox[{"se", "*", "$ZValue"}]}], "]"}]}], "]"}]}], ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"e88723a7-8831-4785-923b-5a59fb2a23b3"]
}, Open  ]],

Cell[CellGroupData[{

Cell["IV", "Subsection"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"IV", "::", "usage"}], "=", 
   "\"\<IV[v,r] represents a value associated with a confidence interval that \
ranges from v-r to v+r.\nIV[v,{r1,r2}] represents a value associated with a \
confidence interval from v-r1 to v+r2.\nIV[NDV[..]] gives the IV for a NDV \
object.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"IV", "[", 
    RowBox[{"NDV", "[", 
     RowBox[{
      RowBox[{"v_", "?", "NumPatternQ"}], ",", 
      RowBox[{"se_", "?", "PosNumPatternQ"}], ",", "_"}], "]"}], "]"}], ":=", 
   
   RowBox[{"IV", "[", 
    RowBox[{"v", ",", 
     RowBox[{"se", "*", "$ZValue"}]}], "]"}]}], ";"}]}], "Input",
 InitializationCell->True],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MakeBoxes", "[", 
     RowBox[{
      RowBox[{"iv", ":", 
       RowBox[{"IV", "[", 
        RowBox[{
         RowBox[{"v_", "?", "NumPatternQ"}], ",", 
         RowBox[{"r_", "?", "PosNumPatternQ"}]}], "]"}]}], ",", 
      "StandardForm"}], "]"}], "^:=", 
    RowBox[{
     RowBox[{"Interpretation", "[", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Style", "[", 
        RowBox[{
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"TrueQ", "[", "$UsePlusMinusForm", "]"}], ",", 
           RowBox[{"PMForm", "[", 
            RowBox[{"v", ",", "r"}], "]"}], ",", 
           RowBox[{"ParenthesisForm", "[", 
            RowBox[{"v", ",", "r"}], "]"}]}], "]"}], ",", 
         RowBox[{"ShowStringCharacters", "\[Rule]", "False"}]}], "]"}], ",", 
       "iv"}], "]"}], "//", "ToBoxes"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MakeBoxes", "[", 
     RowBox[{
      RowBox[{"IV", "[", 
       RowBox[{
        RowBox[{"v_", "?", "NumPatternQ"}], ",", 
        RowBox[{"r_", "?", "PosNumPatternQ"}]}], "]"}], ",", "OutputForm"}], 
     "]"}], "^:=", 
    RowBox[{
     RowBox[{"If", "[", 
      RowBox[{
       RowBox[{"TrueQ", "[", "$UsePlusMinusForm", "]"}], ",", 
       RowBox[{"OutputPMForm", "[", 
        RowBox[{"v", ",", "r"}], "]"}], ",", 
       RowBox[{"OutputParenthesisForm", "[", 
        RowBox[{"v", ",", "r"}], "]"}]}], "]"}], "//", "ToBoxes"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"ToString", "[", 
    RowBox[{"IV", "[", 
     RowBox[{
      RowBox[{"v_", "?", "NumPatternQ"}], ",", 
      RowBox[{"r_", "?", "PosNumPatternQ"}]}], "]"}], "]"}], "^:=", 
   RowBox[{"If", "[", 
    RowBox[{
     RowBox[{"TrueQ", "[", "$UsePlusMinusForm", "]"}], ",", 
     RowBox[{"OutputPMForm", "[", 
      RowBox[{"v", ",", "r"}], "]"}], ",", 
     RowBox[{"OutputParenthesisForm", "[", 
      RowBox[{"v", ",", "r"}], "]"}]}], "]"}]}], ";"}]}], "Input",ExpressionUU\
ID->"8f3496c4-d247-4688-b149-182d4c095bc0"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MakeBoxes", "[", 
     RowBox[{
      RowBox[{"iv", ":", 
       RowBox[{"IV", "[", 
        RowBox[{
         RowBox[{"v_", "?", "NumPatternQ"}], ",", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"rl_", "?", "PosNumPatternQ"}], ",", 
           RowBox[{"ru_", "?", "PosNumPatternQ"}]}], "}"}]}], "]"}]}], ",", 
      "StandardForm"}], "]"}], "^:=", 
    RowBox[{
     RowBox[{"Interpretation", "[", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Style", "[", 
        RowBox[{
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"TrueQ", "[", "$UsePlusMinusForm", "]"}], ",", 
           RowBox[{"PMForm", "[", 
            RowBox[{"v", ",", "rl", ",", "ru"}], "]"}], ",", 
           RowBox[{"ParenthesisForm", "[", 
            RowBox[{"v", ",", "rl", ",", "ru"}], "]"}]}], "]"}], ",", 
         RowBox[{"ShowStringCharacters", "\[Rule]", "False"}]}], "]"}], ",", 
       "iv"}], "]"}], "//", "ToBoxes"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MakeBoxes", "[", 
     RowBox[{
      RowBox[{"IV", "[", 
       RowBox[{
        RowBox[{"v_", "?", "NumPatternQ"}], ",", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"rl_", "?", "PosNumPatternQ"}], ",", 
          RowBox[{"ru_", "?", "PosNumPatternQ"}]}], "}"}]}], "]"}], ",", 
      "OutputForm"}], "]"}], "^:=", 
    RowBox[{
     RowBox[{"If", "[", 
      RowBox[{
       RowBox[{"TrueQ", "[", "$UsePlusMinusForm", "]"}], ",", 
       RowBox[{"OutputPMForm", "[", 
        RowBox[{"v", ",", "rl", ",", "ru"}], "]"}], ",", 
       RowBox[{"OutputParenthesisForm", "[", 
        RowBox[{"v", ",", "rl", ",", "ru"}], "]"}]}], "]"}], "//", 
     "ToBoxes"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"ToString", "[", 
    RowBox[{"IV", "[", 
     RowBox[{
      RowBox[{"v_", "?", "NumPatternQ"}], ",", 
      RowBox[{"{", 
       RowBox[{
        RowBox[{"rl_", "?", "PosNumPatternQ"}], ",", 
        RowBox[{"ru_", "?", "PosNumPatternQ"}]}], "}"}]}], "]"}], "]"}], "^:=", 
   RowBox[{"If", "[", 
    RowBox[{
     RowBox[{"TrueQ", "[", "$UsePlusMinusForm", "]"}], ",", 
     RowBox[{"OutputPMForm", "[", 
      RowBox[{"v", ",", "rl", ",", "ru"}], "]"}], ",", 
     RowBox[{"OutputParenthesisForm", "[", 
      RowBox[{"v", ",", "rl", ",", "ru"}], "]"}]}], "]"}]}], ";"}]}], "Input",\
ExpressionUUID->"85d7c7c5-25a9-42ff-8b60-72e5b3b378ad"]
}, Open  ]],

Cell[CellGroupData[{

Cell["Output display", "Subsection"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"OutputParenthesisForm", "[", 
     RowBox[{"v_", ",", "r_"}], "]"}], ":=", 
    RowBox[{"Module", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"{", "PF", "}"}], ",", "\[IndentingNewLine]", 
      RowBox[{"(", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"PF", "=", 
         RowBox[{"ParenthesisForm", "[", 
          RowBox[{"v", ",", "r"}], "]"}]}], ";", "\[IndentingNewLine]", 
        RowBox[{"PF", "=", 
         RowBox[{"PF", "/.", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{"Superscript", "[", 
             RowBox[{"10", ",", "Pow_"}], "]"}], "\[RuleDelayed]", 
            RowBox[{"(", 
             RowBox[{"\"\<10^\>\"", "<>", 
              RowBox[{"ToString", "[", "Pow", "]"}]}], ")"}]}], "}"}]}]}], 
        ";", "\[IndentingNewLine]", 
        RowBox[{"ToString", "[", "PF", "]"}]}], "\[IndentingNewLine]", 
       ")"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"ParenthesisForm", "[", 
     RowBox[{"v_", ",", "r_"}], "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"Pow", ",", 
        RowBox[{"n", "=", 
         RowBox[{
          RowBox[{"Ceiling", "[", 
           RowBox[{"-", 
            RowBox[{"Log10", "[", "r", "]"}]}], "]"}], "+", "1"}]}]}], "}"}], 
      ",", "\[IndentingNewLine]", 
      RowBox[{"(", "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"v", "\[NotEqual]", "0"}], "&&", 
          RowBox[{"(", 
           RowBox[{
            RowBox[{
             RowBox[{"Abs", "[", "v", "]"}], "<", 
             RowBox[{"10", "^", 
              RowBox[{"-", "3"}]}]}], "||", 
            RowBox[{
             RowBox[{"Abs", "[", "v", "]"}], "\[GreaterEqual]", 
             RowBox[{"10", "^", "4"}]}]}], ")"}]}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"Pow", "=", 
           RowBox[{"Ceiling", "[", 
            RowBox[{"-", 
             RowBox[{"Log10", "[", 
              RowBox[{"Abs", "[", "v", "]"}], "]"}]}], "]"}]}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"n", "=", 
           RowBox[{
            RowBox[{"Ceiling", "[", 
             RowBox[{"-", 
              RowBox[{"Log10", "[", 
               RowBox[{"r", "*", 
                RowBox[{"10", "^", "Pow"}]}], "]"}]}], "]"}], "+", "1"}]}], 
          ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"n", "\[LessEqual]", "0"}], ",", "\[IndentingNewLine]", 
            RowBox[{"Row", "[", 
             RowBox[{"{", 
              RowBox[{
               RowBox[{"Round", "[", 
                RowBox[{"v", "*", 
                 RowBox[{"10", "^", "Pow"}]}], "]"}], ",", "\"\<(\>\"", ",", 
               RowBox[{"Round", "[", 
                RowBox[{"r", "*", 
                 RowBox[{"10", "^", "Pow"}]}], "]"}], ",", 
               "\"\<)\[Times]\>\"", ",", 
               RowBox[{"Superscript", "[", 
                RowBox[{"10", ",", 
                 RowBox[{"-", "Pow"}]}], "]"}]}], "}"}], "]"}], ",", 
            "\[IndentingNewLine]", 
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{"!", 
               RowBox[{"NumberQ", "[", "n", "]"}]}], ",", 
              "\[IndentingNewLine]", "v", ",", "\[IndentingNewLine]", 
              RowBox[{"Row", "[", 
               RowBox[{"{", 
                RowBox[{
                 RowBox[{"NumberForm", "[", 
                  RowBox[{
                   RowBox[{
                    RowBox[{"v", "*", 
                    RowBox[{"10", "^", "Pow"}]}], "//", "N"}], ",", 
                   RowBox[{"{", 
                    RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                   RowBox[{"ExponentFunction", "\[Rule]", 
                    RowBox[{"(", 
                    RowBox[{"Null", "&"}], ")"}]}]}], "]"}], ",", "\"\<(\>\"",
                  ",", 
                 RowBox[{"Round", "[", 
                  RowBox[{"r", "*", 
                   RowBox[{"10", "^", "Pow"}], "*", 
                   RowBox[{"10", "^", "n"}]}], "]"}], ",", 
                 "\"\<)\[Times]\>\"", ",", 
                 RowBox[{"Superscript", "[", 
                  RowBox[{"10", ",", 
                   RowBox[{"-", "Pow"}]}], "]"}]}], "}"}], "]"}]}], 
             "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", "]"}]}], 
         ",", "\[IndentingNewLine]", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"TrueQ", "[", 
            RowBox[{"n", "\[LessEqual]", "0"}], "]"}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{"Row", "[", 
            RowBox[{"{", 
             RowBox[{
              RowBox[{"Round", "[", "v", "]"}], ",", "\"\<(\>\"", ",", 
              RowBox[{"Round", "[", "r", "]"}], ",", "\"\<)\>\""}], "}"}], 
            "]"}], ",", "\[IndentingNewLine]", 
           RowBox[{"If", "[", 
            RowBox[{
             RowBox[{"!", 
              RowBox[{"NumberQ", "[", "n", "]"}]}], ",", 
             "\[IndentingNewLine]", "v", ",", "\[IndentingNewLine]", 
             RowBox[{"Row", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"NumberForm", "[", 
                 RowBox[{
                  RowBox[{"v", "//", "N"}], ",", 
                  RowBox[{"{", 
                   RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                  RowBox[{"ExponentFunction", "\[Rule]", 
                   RowBox[{"(", 
                    RowBox[{"Null", "&"}], ")"}]}]}], "]"}], ",", "\"\<(\>\"",
                 ",", 
                RowBox[{"Round", "[", 
                 RowBox[{"r", "*", 
                  RowBox[{"10", "^", "n"}]}], "]"}], ",", "\"\<)\>\""}], 
               "}"}], "]"}]}], "\[IndentingNewLine]", "]"}]}], 
          "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", "]"}], 
       "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"OutputParenthesisForm", "[", 
     RowBox[{"v_", ",", "rl_", ",", "ru_"}], "]"}], ":=", 
    RowBox[{"Module", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"{", "PF", "}"}], ",", "\[IndentingNewLine]", 
      RowBox[{"(", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"PF", "=", 
         RowBox[{"ParenthesisForm", "[", 
          RowBox[{"v", ",", "rl", ",", "ru"}], "]"}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"PF", "=", 
         RowBox[{"PF", "/.", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{"Superscript", "[", 
             RowBox[{"10", ",", "Pow_"}], "]"}], "\[RuleDelayed]", 
            RowBox[{"(", 
             RowBox[{"\"\<10^\>\"", "<>", 
              RowBox[{"ToString", "[", "Pow", "]"}]}], ")"}]}], "}"}]}]}], 
        ";", "\[IndentingNewLine]", 
        RowBox[{"ToString", "[", "PF", "]"}]}], "\[IndentingNewLine]", 
       ")"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"ParenthesisForm", "[", 
   RowBox[{"v_", ",", "rl_", ",", "ru_"}], "]"}], ":=", 
  RowBox[{"Module", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"Pow", ",", 
      RowBox[{"n", "=", 
       RowBox[{
        RowBox[{"Ceiling", "[", 
         RowBox[{"-", 
          RowBox[{"Log10", "[", 
           RowBox[{"Min", "[", 
            RowBox[{"rl", ",", "ru"}], "]"}], "]"}]}], "]"}], "+", "1"}]}]}], 
     "}"}], ",", "\[IndentingNewLine]", 
    RowBox[{"(", "\[IndentingNewLine]", 
     RowBox[{"If", "[", 
      RowBox[{
       RowBox[{
        RowBox[{"v", "\[NotEqual]", "0"}], "&&", 
        RowBox[{"(", 
         RowBox[{
          RowBox[{
           RowBox[{"Abs", "[", "v", "]"}], "<", 
           RowBox[{"10", "^", 
            RowBox[{"-", "3"}]}]}], "||", 
          RowBox[{
           RowBox[{"Abs", "[", "v", "]"}], "\[GreaterEqual]", 
           RowBox[{"10", "^", "4"}]}]}], ")"}]}], ",", "\[IndentingNewLine]", 
       
       RowBox[{
        RowBox[{"Pow", "=", 
         RowBox[{"Ceiling", "[", 
          RowBox[{"-", 
           RowBox[{"Log10", "[", 
            RowBox[{"Abs", "[", "v", "]"}], "]"}]}], "]"}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"n", "=", 
         RowBox[{
          RowBox[{"Ceiling", "[", 
           RowBox[{"-", 
            RowBox[{"Log10", "[", 
             RowBox[{
              RowBox[{"Min", "[", 
               RowBox[{"rl", ",", "ru"}], "]"}], "*", 
              RowBox[{"10", "^", "Pow"}]}], "]"}]}], "]"}], "+", "1"}]}], ";",
         "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"TrueQ", "[", 
           RowBox[{"n", "\[LessEqual]", "0"}], "]"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"Row", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"Round", "[", 
              RowBox[{"v", "*", 
               RowBox[{"10", "^", "Pow"}]}], "]"}], ",", "\"\<(-\>\"", ",", 
             RowBox[{"Round", "[", 
              RowBox[{"rl", "*", 
               RowBox[{"10", "^", "Pow"}]}], "]"}], ",", "\"\<+\>\"", ",", 
             RowBox[{"Round", "[", 
              RowBox[{"ru", "*", 
               RowBox[{"10", "^", "Pow"}]}], "]"}], ",", "\"\<)\[Times]\>\"", 
             ",", 
             RowBox[{"Superscript", "[", 
              RowBox[{"10", ",", 
               RowBox[{"-", "Pow"}]}], "]"}]}], "}"}], "]"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"!", 
             RowBox[{"NumberQ", "[", "n", "]"}]}], ",", "\[IndentingNewLine]",
             "v", ",", "\[IndentingNewLine]", 
            RowBox[{"Row", "[", 
             RowBox[{"{", 
              RowBox[{
               RowBox[{"NumberForm", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"v", "*", 
                   RowBox[{"10", "^", "Pow"}]}], "//", "N"}], ",", 
                 RowBox[{"{", 
                  RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                 RowBox[{"ExponentFunction", "\[Rule]", 
                  RowBox[{"(", 
                   RowBox[{"Null", "&"}], ")"}]}]}], "]"}], ",", "\"\<(-\>\"",
                ",", 
               RowBox[{"Round", "[", 
                RowBox[{"rl", "*", 
                 RowBox[{"10", "^", "Pow"}], "*", 
                 RowBox[{"10", "^", "n"}]}], "]"}], ",", "\"\<+\>\"", ",", 
               RowBox[{"Round", "[", 
                RowBox[{"ru", "*", 
                 RowBox[{"10", "^", "Pow"}], "*", 
                 RowBox[{"10", "^", "n"}]}], "]"}], ",", "\"\<)\[Times]\>\"", 
               ",", 
               RowBox[{"Superscript", "[", 
                RowBox[{"10", ",", 
                 RowBox[{"-", "Pow"}]}], "]"}]}], "}"}], "]"}]}], 
           "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", "]"}]}], 
       ",", "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{"TrueQ", "[", 
          RowBox[{"n", "\[LessEqual]", "0"}], "]"}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{"Row", "[", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{"Round", "[", "v", "]"}], ",", "\"\<(-\>\"", ",", 
            RowBox[{"Round", "[", "rl", "]"}], ",", "\"\<+\>\"", ",", 
            RowBox[{"Round", "[", "ru", "]"}], ",", "\"\<)\>\""}], "}"}], 
          "]"}], ",", "\[IndentingNewLine]", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"!", 
            RowBox[{"NumberQ", "[", "n", "]"}]}], ",", "\[IndentingNewLine]", 
           "v", ",", "\[IndentingNewLine]", 
           RowBox[{"Row", "[", 
            RowBox[{"{", 
             RowBox[{
              RowBox[{"NumberForm", "[", 
               RowBox[{
                RowBox[{"v", "//", "N"}], ",", 
                RowBox[{"{", 
                 RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                RowBox[{"ExponentFunction", "\[Rule]", 
                 RowBox[{"(", 
                  RowBox[{"Null", "&"}], ")"}]}]}], "]"}], ",", "\"\<(-\>\"", 
              ",", 
              RowBox[{"Round", "[", 
               RowBox[{"rl", "*", 
                RowBox[{"10", "^", "n"}]}], "]"}], ",", "\"\<+\>\"", ",", 
              RowBox[{"Round", "[", 
               RowBox[{"ru", "*", 
                RowBox[{"10", "^", "n"}]}], "]"}], ",", "\"\<)\>\""}], "}"}], 
            "]"}]}], "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", 
        "]"}]}], "\[IndentingNewLine]", "]"}], "\[IndentingNewLine]", ")"}]}],
    "\[IndentingNewLine]", "]"}]}]}], "Input",
 InitializationCell->True],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"OutputPMForm", "[", 
     RowBox[{"v_", ",", "r_"}], "]"}], ":=", 
    RowBox[{"Module", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"{", "PF", "}"}], ",", "\[IndentingNewLine]", 
      RowBox[{"(", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"PF", "=", 
         RowBox[{"PMForm", "[", 
          RowBox[{"v", ",", "r"}], "]"}]}], ";", "\[IndentingNewLine]", 
        RowBox[{"PF", "=", 
         RowBox[{"PF", "/.", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{"Superscript", "[", 
             RowBox[{"10", ",", "Pow_"}], "]"}], "\[RuleDelayed]", 
            RowBox[{"(", 
             RowBox[{"\"\<10^\>\"", "<>", 
              RowBox[{"ToString", "[", "Pow", "]"}]}], ")"}]}], "}"}]}]}], 
        ";", "\[IndentingNewLine]", 
        RowBox[{"ToString", "[", "PF", "]"}]}], "\[IndentingNewLine]", 
       ")"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"PMForm", "[", 
     RowBox[{"v_", ",", "r_"}], "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"Pow", ",", 
        RowBox[{"n", "=", 
         RowBox[{
          RowBox[{"Ceiling", "[", 
           RowBox[{"-", 
            RowBox[{"Log10", "[", "r", "]"}]}], "]"}], "+", "1"}]}]}], "}"}], 
      ",", "\[IndentingNewLine]", 
      RowBox[{"(", "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"v", "\[NotEqual]", "0"}], "&&", 
          RowBox[{"(", 
           RowBox[{
            RowBox[{
             RowBox[{"Abs", "[", "v", "]"}], "<", 
             RowBox[{"10", "^", 
              RowBox[{"-", "3"}]}]}], "||", 
            RowBox[{
             RowBox[{"Abs", "[", "v", "]"}], "\[GreaterEqual]", 
             RowBox[{"10", "^", "4"}]}]}], ")"}]}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"Pow", "=", 
           RowBox[{"Ceiling", "[", 
            RowBox[{"-", 
             RowBox[{"Log10", "[", 
              RowBox[{"Abs", "[", "v", "]"}], "]"}]}], "]"}]}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"n", "=", 
           RowBox[{
            RowBox[{"Ceiling", "[", 
             RowBox[{"-", 
              RowBox[{"Log10", "[", 
               RowBox[{"r", "*", 
                RowBox[{"10", "^", "Pow"}]}], "]"}]}], "]"}], "+", "1"}]}], 
          ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"n", "\[LessEqual]", "0"}], ",", "\[IndentingNewLine]", 
            RowBox[{"Row", "[", 
             RowBox[{"{", 
              RowBox[{
               RowBox[{"Round", "[", 
                RowBox[{"v", "*", 
                 RowBox[{"10", "^", "Pow"}]}], "]"}], ",", 
               "\"\<\[PlusMinus]\>\"", ",", 
               RowBox[{"Round", "[", 
                RowBox[{"r", "*", 
                 RowBox[{"10", "^", "Pow"}]}], "]"}], ",", "\"\<\[Times]\>\"",
                ",", 
               RowBox[{"Superscript", "[", 
                RowBox[{"10", ",", 
                 RowBox[{"-", "Pow"}]}], "]"}]}], "}"}], "]"}], ",", 
            "\[IndentingNewLine]", 
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{"!", 
               RowBox[{"NumberQ", "[", "n", "]"}]}], ",", 
              "\[IndentingNewLine]", "v", ",", "\[IndentingNewLine]", 
              RowBox[{"Row", "[", 
               RowBox[{"{", 
                RowBox[{
                 RowBox[{"NumberForm", "[", 
                  RowBox[{
                   RowBox[{
                    RowBox[{"v", "*", 
                    RowBox[{"10", "^", "Pow"}]}], "//", "N"}], ",", 
                   RowBox[{"{", 
                    RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                   RowBox[{"ExponentFunction", "\[Rule]", 
                    RowBox[{"(", 
                    RowBox[{"Null", "&"}], ")"}]}]}], "]"}], ",", 
                 "\"\<\[PlusMinus]\>\"", ",", 
                 RowBox[{"NumberForm", "[", 
                  RowBox[{
                   RowBox[{
                    RowBox[{"r", "*", 
                    RowBox[{"10", "^", "Pow"}]}], "//", "N"}], ",", 
                   RowBox[{"{", 
                    RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                   RowBox[{"ExponentFunction", "\[Rule]", 
                    RowBox[{"(", 
                    RowBox[{"Null", "&"}], ")"}]}]}], "]"}], ",", 
                 "\"\<\[Times]\>\"", ",", 
                 RowBox[{"Superscript", "[", 
                  RowBox[{"10", ",", 
                   RowBox[{"-", "Pow"}]}], "]"}]}], "}"}], "]"}]}], 
             "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", "]"}]}], 
         ",", "\[IndentingNewLine]", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"TrueQ", "[", 
            RowBox[{"n", "\[LessEqual]", "0"}], "]"}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{"Row", "[", 
            RowBox[{"{", 
             RowBox[{
              RowBox[{"Round", "[", "v", "]"}], ",", "\"\<\[PlusMinus]\>\"", 
              ",", 
              RowBox[{"Round", "[", "r", "]"}]}], "}"}], "]"}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{"If", "[", 
            RowBox[{
             RowBox[{"!", 
              RowBox[{"NumberQ", "[", "n", "]"}]}], ",", 
             "\[IndentingNewLine]", "v", ",", "\[IndentingNewLine]", 
             RowBox[{"Row", "[", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"NumberForm", "[", 
                 RowBox[{
                  RowBox[{"v", "//", "N"}], ",", 
                  RowBox[{"{", 
                   RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                  RowBox[{"ExponentFunction", "\[Rule]", 
                   RowBox[{"(", 
                    RowBox[{"Null", "&"}], ")"}]}]}], "]"}], ",", 
                "\"\<\[PlusMinus]\>\"", ",", 
                RowBox[{"NumberForm", "[", 
                 RowBox[{
                  RowBox[{"r", "//", "N"}], ",", 
                  RowBox[{"{", 
                   RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                  RowBox[{"ExponentFunction", "\[Rule]", 
                   RowBox[{"(", 
                    RowBox[{"Null", "&"}], ")"}]}]}], "]"}]}], "}"}], "]"}]}],
             "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", "]"}]}], 
        "\[IndentingNewLine]", "]"}], "\[IndentingNewLine]", ")"}]}], 
     "\[IndentingNewLine]", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"OutputPMForm", "[", 
     RowBox[{"v_", ",", "rl_", ",", "ru_"}], "]"}], ":=", 
    RowBox[{"Module", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"{", "PF", "}"}], ",", "\[IndentingNewLine]", 
      RowBox[{"(", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"PF", "=", 
         RowBox[{"PMForm", "[", 
          RowBox[{"v", ",", "rl", ",", "ru"}], "]"}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"PF", "=", 
         RowBox[{"PF", "/.", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{"Superscript", "[", 
             RowBox[{"10", ",", "Pow_"}], "]"}], "\[RuleDelayed]", 
            RowBox[{"(", 
             RowBox[{"\"\<10^\>\"", "<>", 
              RowBox[{"ToString", "[", "Pow", "]"}]}], ")"}]}], "}"}]}]}], 
        ";", "\[IndentingNewLine]", 
        RowBox[{"ToString", "[", "PF", "]"}]}], "\[IndentingNewLine]", 
       ")"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"PMForm", "[", 
   RowBox[{"v_", ",", "rl_", ",", "ru_"}], "]"}], ":=", 
  RowBox[{"Module", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"Pow", ",", 
      RowBox[{"n", "=", 
       RowBox[{
        RowBox[{"Ceiling", "[", 
         RowBox[{"-", 
          RowBox[{"Log10", "[", 
           RowBox[{"Min", "[", 
            RowBox[{"rl", ",", "ru"}], "]"}], "]"}]}], "]"}], "+", "1"}]}]}], 
     "}"}], ",", "\[IndentingNewLine]", 
    RowBox[{"(", "\[IndentingNewLine]", 
     RowBox[{"If", "[", 
      RowBox[{
       RowBox[{
        RowBox[{"v", "\[NotEqual]", "0"}], "&&", 
        RowBox[{"(", 
         RowBox[{
          RowBox[{
           RowBox[{"Abs", "[", "v", "]"}], "<", 
           RowBox[{"10", "^", 
            RowBox[{"-", "3"}]}]}], "||", 
          RowBox[{
           RowBox[{"Abs", "[", "v", "]"}], "\[GreaterEqual]", 
           RowBox[{"10", "^", "4"}]}]}], ")"}]}], ",", "\[IndentingNewLine]", 
       
       RowBox[{
        RowBox[{"Pow", "=", 
         RowBox[{"Ceiling", "[", 
          RowBox[{"-", 
           RowBox[{"Log10", "[", 
            RowBox[{"Abs", "[", "v", "]"}], "]"}]}], "]"}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"n", "=", 
         RowBox[{
          RowBox[{"Ceiling", "[", 
           RowBox[{"-", 
            RowBox[{"Log10", "[", 
             RowBox[{
              RowBox[{"Min", "[", 
               RowBox[{"rl", ",", "ru"}], "]"}], "*", 
              RowBox[{"10", "^", "Pow"}]}], "]"}]}], "]"}], "+", "1"}]}], ";",
         "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"n", "\[LessEqual]", "0"}], ",", "\[IndentingNewLine]", 
          RowBox[{"Row", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"Round", "[", 
              RowBox[{"v", "*", 
               RowBox[{"10", "^", "Pow"}]}], "]"}], ",", 
             "\"\<\[PlusMinus][-\>\"", ",", 
             RowBox[{"Round", "[", 
              RowBox[{"rl", "*", 
               RowBox[{"10", "^", "Pow"}]}], "]"}], ",", "\"\<+\>\"", ",", 
             RowBox[{"Round", "[", 
              RowBox[{"ru", "*", 
               RowBox[{"10", "^", "Pow"}]}], "]"}], ",", "\"\<]\[Times]\>\"", 
             ",", 
             RowBox[{"Superscript", "[", 
              RowBox[{"10", ",", 
               RowBox[{"-", "Pow"}]}], "]"}]}], "}"}], "]"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"!", 
             RowBox[{"NumberQ", "[", "n", "]"}]}], ",", "\[IndentingNewLine]",
             "v", ",", "\[IndentingNewLine]", 
            RowBox[{"Row", "[", 
             RowBox[{"{", 
              RowBox[{
               RowBox[{"NumberForm", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"v", "*", 
                   RowBox[{"10", "^", "Pow"}]}], "//", "N"}], ",", 
                 RowBox[{"{", 
                  RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                 RowBox[{"ExponentFunction", "\[Rule]", 
                  RowBox[{"(", 
                   RowBox[{"Null", "&"}], ")"}]}]}], "]"}], ",", 
               "\"\<\[PlusMinus][-\>\"", ",", 
               RowBox[{"NumberForm", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"rl", "*", 
                   RowBox[{"10", "^", "Pow"}]}], "//", "N"}], ",", 
                 RowBox[{"{", 
                  RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                 RowBox[{"ExponentFunction", "\[Rule]", 
                  RowBox[{"(", 
                   RowBox[{"Null", "&"}], ")"}]}]}], "]"}], ",", "\"\<+\>\"", 
               ",", 
               RowBox[{"NumberForm", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"ru", "*", 
                   RowBox[{"10", "^", "Pow"}]}], "//", "N"}], ",", 
                 RowBox[{"{", 
                  RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                 RowBox[{"ExponentFunction", "\[Rule]", 
                  RowBox[{"(", 
                   RowBox[{"Null", "&"}], ")"}]}]}], "]"}], ",", 
               "\"\<]\[Times]\>\"", ",", 
               RowBox[{"Superscript", "[", 
                RowBox[{"10", ",", 
                 RowBox[{"-", "Pow"}]}], "]"}]}], "}"}], "]"}]}], 
           "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", "]"}]}], 
       ",", "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{"TrueQ", "[", 
          RowBox[{"n", "\[LessEqual]", "0"}], "]"}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{"Row", "[", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{"Round", "[", "v", "]"}], ",", "\"\<\[PlusMinus][-\>\"", 
            ",", 
            RowBox[{"Round", "[", "rl", "]"}], ",", "\"\<+\>\"", ",", 
            RowBox[{"Round", "[", "ru", "]"}], ",", "\"\<]\>\""}], "}"}], 
          "]"}], ",", "\[IndentingNewLine]", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"!", 
            RowBox[{"NumberQ", "[", "n", "]"}]}], ",", "\[IndentingNewLine]", 
           "v", ",", "\[IndentingNewLine]", 
           RowBox[{"Row", "[", 
            RowBox[{"{", 
             RowBox[{
              RowBox[{"NumberForm", "[", 
               RowBox[{
                RowBox[{"v", "//", "N"}], ",", 
                RowBox[{"{", 
                 RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                RowBox[{"ExponentFunction", "\[Rule]", 
                 RowBox[{"(", 
                  RowBox[{"Null", "&"}], ")"}]}]}], "]"}], ",", 
              "\"\<\[PlusMinus][-\>\"", ",", 
              RowBox[{"NumberForm", "[", 
               RowBox[{
                RowBox[{"rl", "//", "N"}], ",", 
                RowBox[{"{", 
                 RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                RowBox[{"ExponentFunction", "\[Rule]", 
                 RowBox[{"(", 
                  RowBox[{"Null", "&"}], ")"}]}]}], "]"}], ",", "\"\<+\>\"", 
              ",", 
              RowBox[{"NumberForm", "[", 
               RowBox[{
                RowBox[{"ru", "//", "N"}], ",", 
                RowBox[{"{", 
                 RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                RowBox[{"ExponentFunction", "\[Rule]", 
                 RowBox[{"(", 
                  RowBox[{"Null", "&"}], ")"}]}]}], "]"}], ",", "\"\<]\>\""}],
              "}"}], "]"}]}], "\[IndentingNewLine]", "]"}]}], 
        "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", "]"}], 
     "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}]}], "Input",\

 InitializationCell->True],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"OutputSForm", "[", 
     RowBox[{"v_", ",", "se_"}], "]"}], ":=", 
    RowBox[{"Module", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"{", "PF", "}"}], ",", "\[IndentingNewLine]", 
      RowBox[{"(", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"PF", "=", 
         RowBox[{"PMForm", "[", 
          RowBox[{"v", ",", "se"}], "]"}]}], ";", "\[IndentingNewLine]", 
        RowBox[{"PF", "=", 
         RowBox[{"PF", "/.", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{"Superscript", "[", 
             RowBox[{"10", ",", "Pow_"}], "]"}], "\[RuleDelayed]", 
            RowBox[{"(", 
             RowBox[{"\"\<10^\>\"", "<>", 
              RowBox[{"ToString", "[", "Pow", "]"}]}], ")"}]}], "}"}]}]}], 
        ";", "\[IndentingNewLine]", 
        RowBox[{"ToString", "[", "PF", "]"}]}], "\[IndentingNewLine]", 
       ")"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"SForm", "[", 
   RowBox[{"v_", ",", "se_"}], "]"}], ":=", 
  RowBox[{"Module", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"Pow", ",", 
      RowBox[{"n", "=", 
       RowBox[{
        RowBox[{"Ceiling", "[", 
         RowBox[{"-", 
          RowBox[{"Log10", "[", "se", "]"}]}], "]"}], "+", "1"}]}]}], "}"}], 
    ",", "\[IndentingNewLine]", 
    RowBox[{"(", "\[IndentingNewLine]", 
     RowBox[{"If", "[", 
      RowBox[{
       RowBox[{
        RowBox[{"v", "\[NotEqual]", "0"}], "&&", 
        RowBox[{"(", 
         RowBox[{
          RowBox[{
           RowBox[{"Abs", "[", "v", "]"}], "<", 
           RowBox[{"10", "^", 
            RowBox[{"-", "3"}]}]}], "||", 
          RowBox[{
           RowBox[{"Abs", "[", "v", "]"}], "\[GreaterEqual]", 
           RowBox[{"10", "^", "4"}]}]}], ")"}]}], ",", "\[IndentingNewLine]", 
       
       RowBox[{
        RowBox[{"Pow", "=", 
         RowBox[{"Ceiling", "[", 
          RowBox[{"-", 
           RowBox[{"Log10", "[", 
            RowBox[{"Abs", "[", "v", "]"}], "]"}]}], "]"}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"n", "=", 
         RowBox[{
          RowBox[{"Ceiling", "[", 
           RowBox[{"-", 
            RowBox[{"Log10", "[", 
             RowBox[{"se", "*", 
              RowBox[{"10", "^", "Pow"}]}], "]"}]}], "]"}], "+", "1"}]}], ";",
         "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"n", "\[LessEqual]", "0"}], ",", "\[IndentingNewLine]", 
          RowBox[{"Row", "[", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"Round", "[", 
              RowBox[{"v", "*", 
               RowBox[{"10", "^", "Pow"}]}], "]"}], ",", "\"\<(SE=\>\"", ",", 
             
             RowBox[{"Round", "[", 
              RowBox[{"se", "*", 
               RowBox[{"10", "^", "Pow"}]}], "]"}], ",", "\"\<\[Times]\>\"", 
             ",", 
             RowBox[{"Superscript", "[", 
              RowBox[{"10", ",", 
               RowBox[{"-", "Pow"}]}], "]"}], ",", "\"\<)\>\""}], "}"}], 
           "]"}], ",", "\[IndentingNewLine]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"!", 
             RowBox[{"NumberQ", "[", "n", "]"}]}], ",", "\[IndentingNewLine]",
             "v", ",", "\[IndentingNewLine]", 
            RowBox[{"Row", "[", 
             RowBox[{"{", 
              RowBox[{
               RowBox[{"NumberForm", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"v", "*", 
                   RowBox[{"10", "^", "Pow"}]}], "//", "N"}], ",", 
                 RowBox[{"{", 
                  RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                 RowBox[{"ExponentFunction", "\[Rule]", 
                  RowBox[{"(", 
                   RowBox[{"Null", "&"}], ")"}]}]}], "]"}], ",", 
               "\"\<(SE=\>\"", ",", 
               RowBox[{"NumberForm", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"se", "*", 
                   RowBox[{"10", "^", "Pow"}]}], "//", "N"}], ",", 
                 RowBox[{"{", 
                  RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                 RowBox[{"ExponentFunction", "\[Rule]", 
                  RowBox[{"(", 
                   RowBox[{"Null", "&"}], ")"}]}]}], "]"}], ",", 
               "\"\<\[Times]\>\"", ",", 
               RowBox[{"Superscript", "[", 
                RowBox[{"10", ",", 
                 RowBox[{"-", "Pow"}]}], "]"}], ",", "\"\<)\>\""}], "}"}], 
             "]"}]}], "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", 
         "]"}]}], ",", "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{"TrueQ", "[", 
          RowBox[{"n", "\[LessEqual]", "0"}], "]"}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{"Row", "[", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{"Round", "[", "v", "]"}], ",", "\"\<(SE=\>\"", ",", 
            RowBox[{"Round", "[", "se", "]"}], ",", "\"\<)\>\""}], "}"}], 
          "]"}], ",", "\[IndentingNewLine]", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"!", 
            RowBox[{"NumberQ", "[", "n", "]"}]}], ",", "\[IndentingNewLine]", 
           "v", ",", "\[IndentingNewLine]", 
           RowBox[{"Row", "[", 
            RowBox[{"{", 
             RowBox[{
              RowBox[{"NumberForm", "[", 
               RowBox[{
                RowBox[{"v", "//", "N"}], ",", 
                RowBox[{"{", 
                 RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                RowBox[{"ExponentFunction", "\[Rule]", 
                 RowBox[{"(", 
                  RowBox[{"Null", "&"}], ")"}]}]}], "]"}], ",", 
              "\"\<(SE=\>\"", ",", 
              RowBox[{"NumberForm", "[", 
               RowBox[{
                RowBox[{"se", "//", "N"}], ",", 
                RowBox[{"{", 
                 RowBox[{"\[Infinity]", ",", "n"}], "}"}], ",", 
                RowBox[{"ExponentFunction", "\[Rule]", 
                 RowBox[{"(", 
                  RowBox[{"Null", "&"}], ")"}]}]}], "]"}], ",", "\"\<)\>\""}],
              "}"}], "]"}]}], "\[IndentingNewLine]", "]"}]}], 
        "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", "]"}], 
     "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}]}], "Input",\

 InitializationCell->True]
}, Open  ]],

Cell[CellGroupData[{

Cell["Forward error propagation", "Subsection"],

Cell[CellGroupData[{

Cell["Linearization (DVEvaluate)", "Subsubsection"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"Options", "[", "DVEvaluate", "]"}], "=", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"CorrelatedErrors", "\[Rule]", "False"}], ",", 
     RowBox[{"AssumeND", "\[Rule]", "True"}]}], "}"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"CorrelatedErrors", "::", "usage"}], "=", 
   "\"\<CorrelatedErrors is an option for DVEvaluate to specify whether to \
assume that all random errors are perfectly correlated (True) or completely \
uncorrelated (False).\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"AssumeND", "::", "usage"}], "=", 
    "\"\<AssumeND is an option for DVEvaluate to specify whether to assume \
that the resulting distribution is a normal distribution (True) or not \
(False).\>\""}], ";"}], "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{
     RowBox[{"DVEvaluate", "[", 
      RowBox[{"expr_", ",", 
       RowBox[{"opts", ":", 
        RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
     RowBox[{"expr", "/.", 
      RowBox[{"{", 
       RowBox[{
        RowBox[{"p_", "?", "EVExpressionQ"}], "\[RuleDelayed]", 
        RowBox[{"DVEvaluateSingle", "[", 
         RowBox[{"p", ",", "opts"}], "]"}]}], "}"}]}]}], ";"}], "*)"}], 
  "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{
     RowBox[{"Attributes", "[", "DVEvaluate", "]"}], "=", 
     RowBox[{"{", "HoldFirst", "}"}]}], ";"}], "*)"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"DVEvaluate", "::", "usage"}], "=", 
   "\"\<DVEvaluate[expr] evaluates expr while propagating standard errors of \
DV and NDV values by linearizing the functions in the expression.\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"DVEvaluate", "[", 
    RowBox[{"expr_", ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
   RowBox[{"Module", "[", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"Params", ",", "Rules", ",", "V", ",", "S", ",", "F"}], "}"}], 
     ",", "\[IndentingNewLine]", 
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"F", "=", "expr"}], 
       RowBox[{"(*", 
        RowBox[{"/.", 
         RowBox[{
          RowBox[{"EV", "[", 
           RowBox[{"v_", ",", "s_"}], "]"}], "\[RuleDelayed]", 
          RowBox[{"EV", "[", 
           RowBox[{"v", ",", "s", ",", 
            RowBox[{"Unique", "[", "Global`ev", "]"}]}], "]"}]}]}], "*)"}], 
       ";", "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{
         RowBox[{"F", "=", 
          RowBox[{
           RowBox[{"Hold", "[", "expr", "]"}], "/.", 
           RowBox[{"ev_EV", "\[RuleDelayed]", 
            RowBox[{"With", "[", 
             RowBox[{
              RowBox[{"{", 
               RowBox[{"eval", "=", 
                RowBox[{"Evaluate", "[", "ev", "]"}]}], "}"}], ",", 
              RowBox[{"eval", "/;", "True"}]}], "]"}]}]}]}], ";"}], "*)"}], 
       "\[IndentingNewLine]", 
       RowBox[{"Params", "=", 
        RowBox[{"Cases", "[", 
         RowBox[{"F", ",", 
          RowBox[{"_DV", "|", "_NDV"}], ",", 
          RowBox[{"{", 
           RowBox[{"0", ",", "Infinity"}], "}"}]}], "]"}]}], ";", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"Length", "[", "Params", "]"}], ">", "0"}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{"(", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"Params", "=", 
            RowBox[{"DeleteDuplicates", "[", "Params", "]"}]}], ";", 
           "\[IndentingNewLine]", 
           RowBox[{"V", "=", 
            RowBox[{
             RowBox[{"F", 
              RowBox[{"(*", 
               RowBox[{"//", "ReleaseHold"}], "*)"}], "//", "DVMeans"}], "//",
              "Quiet"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
           
           RowBox[{"If", "[", 
            RowBox[{"(*", 
             RowBox[{"(", 
              RowBox[{
               RowBox[{"Quiet", "[", 
                RowBox[{"Depth", "[", "F", 
                 RowBox[{"(*", 
                  RowBox[{"//", "ReleaseHold"}], "*)"}], "]"}], "]"}], ">", 
               "2"}], ")"}], "*)"}], 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{"Quiet", "[", 
                RowBox[{"!", 
                 RowBox[{"MatchQ", "[", 
                  RowBox[{"F", ",", 
                   RowBox[{"_DV", "|", "_NDV"}]}], "]"}]}], "]"}], ")"}], "&&", 
              RowBox[{"NumericQ", "[", "V", "]"}]}], ",", 
             "\[IndentingNewLine]", 
             RowBox[{"(", "\[IndentingNewLine]", 
              RowBox[{
               RowBox[{"Rules", "=", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Rule", "[", 
                   RowBox[{
                    RowBox[{"Unique", "[", "dvslot", "]"}], ",", "#"}], "]"}],
                   "&"}], "/@", "Params"}]}], ";", "\[IndentingNewLine]", 
               RowBox[{"F", "=", 
                RowBox[{"Quiet", "[", 
                 RowBox[{"F", "/.", 
                  RowBox[{"(", 
                   RowBox[{"Reverse", "/@", "Rules"}], ")"}]}], 
                 RowBox[{"(*", 
                  RowBox[{"//", "ReleaseHold"}], "*)"}], "]"}]}], ";", 
               "\[IndentingNewLine]", "\[IndentingNewLine]", 
               RowBox[{"S", "=", 
                RowBox[{
                 RowBox[{"If", "[", 
                  RowBox[{
                   RowBox[{"TrueQ", "[", 
                    RowBox[{"OptionValue", "[", "CorrelatedErrors", "]"}], 
                    "]"}], ",", "\[IndentingNewLine]", 
                   RowBox[{"(", "\[IndentingNewLine]", 
                    RowBox[{"Sqrt", "[", "\[IndentingNewLine]", 
                    RowBox[{
                    RowBox[{"Plus", "@@", 
                    RowBox[{"Map", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"D", "[", 
                    RowBox[{"F", ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}], "]"}], "/.", 
                    RowBox[{"DVMeans", "[", "Rules", "]"}]}], ")"}], "^", 
                    "2"}], "*", 
                    RowBox[{
                    RowBox[{"DVSEs", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], "]"}], "^", "2"}]}], 
                    "&"}], ",", "Rules"}], "]"}]}], "+", 
                    "\[IndentingNewLine]", 
                    RowBox[{"2", "*", 
                    RowBox[{"Plus", "@@", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"D", "[", 
                    RowBox[{"F", ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "1"}], "]"}], "]"}]}], "]"}], "/.", 
                    RowBox[{"DVMeans", "[", "Rules", "]"}]}], ")"}], "*", 
                    "\[IndentingNewLine]", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"D", "[", 
                    RowBox[{"F", ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "1"}], "]"}], "]"}]}], "]"}], "/.", 
                    RowBox[{"DVMeans", "[", "Rules", "]"}]}], ")"}], "*", 
                    "\[IndentingNewLine]", 
                    RowBox[{"DVSEs", "[", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "2"}], "]"}], "]"}], ")"}], "*", 
                    RowBox[{"(", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "2"}], "]"}], "]"}], ")"}]}], ")"}], 
                    "]"}]}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
                    ")"}], "&"}], "/@", 
                    RowBox[{"Subsets", "[", 
                    RowBox[{
                    RowBox[{"Cases", "[", 
                    RowBox[{"Rules", ",", 
                    RowBox[{"HoldPattern", "[", 
                    RowBox[{"_", "\[Rule]", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"DV", "[", "___", "]"}], "|", 
                    RowBox[{"NDV", "[", "___", "]"}]}], ")"}]}], "]"}]}], 
                    "]"}], ",", 
                    RowBox[{"{", "2", "}"}]}], "]"}]}], ")"}]}]}]}], 
                    "\[IndentingNewLine]", "]"}], "\[IndentingNewLine]", 
                    ")"}], ",", "\[IndentingNewLine]", 
                   RowBox[{"(", "\[IndentingNewLine]", 
                    RowBox[{"Sqrt", "[", 
                    RowBox[{"Plus", "@@", 
                    RowBox[{"Map", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"D", "[", 
                    RowBox[{"F", ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}], "]"}], "/.", 
                    RowBox[{"DVMeans", "[", "Rules", "]"}]}], ")"}], "^", 
                    "2"}], "*", 
                    RowBox[{
                    RowBox[{"DVSEs", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], "]"}], "^", "2"}]}], 
                    "&"}], ",", "Rules"}], "]"}]}], "]"}], 
                    "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", 
                  "]"}], "//", "Quiet"}]}], ";", "\[IndentingNewLine]", 
               "\[IndentingNewLine]", 
               RowBox[{
                RowBox[{"If", "[", 
                 RowBox[{
                  RowBox[{"!", 
                   RowBox[{"NumericQ", "[", "S", "]"}]}], ",", 
                  "\[IndentingNewLine]", 
                  RowBox[{"Map", "[", 
                   RowBox[{
                    RowBox[{
                    RowBox[{"DVEvaluate", "[", 
                    RowBox[{"#", ",", "opts"}], "]"}], "&"}], ",", "F"}], 
                   "]"}], 
                  RowBox[{"(*", 
                   RowBox[{"Replace", "[", 
                    RowBox[{
                    RowBox[{"Quiet", "[", "expr", "]"}], ",", 
                    RowBox[{"x_", "\[RuleDelayed]", 
                    RowBox[{"DVEvaluate", "[", 
                    RowBox[{"x", ",", "opts"}], "]"}]}], ",", 
                    RowBox[{"{", "1", "}"}]}], "]"}], "*)"}], ",", 
                  "\[IndentingNewLine]", 
                  RowBox[{"If", "[", 
                   RowBox[{
                    RowBox[{"S", "\[Equal]", "0"}], ",", "V", ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"TrueQ", "[", 
                    RowBox[{"OptionValue", "[", "AssumeND", "]"}], "]"}], ",", 
                    RowBox[{"NDV", "[", 
                    RowBox[{
                    RowBox[{"V", "//", "N"}], ",", 
                    RowBox[{"S", "//", "N"}]}], "]"}], ",", 
                    RowBox[{"DV", "[", 
                    RowBox[{
                    RowBox[{"V", "//", "N"}], ",", 
                    RowBox[{"S", "//", "N"}]}], "]"}]}], "]"}]}], "]"}]}], 
                 "\[IndentingNewLine]", "]"}], "//", "Quiet"}]}], 
              "\[IndentingNewLine]", ")"}], ",", "\[IndentingNewLine]", 
             RowBox[{"(", "\[IndentingNewLine]", 
              RowBox[{"(*", 
               RowBox[{
                RowBox[{
                 RowBox[{"Map", "[", 
                  RowBox[{
                   RowBox[{"\"\<fubar\>\"", "&"}], ",", "F"}], "]"}], "//", 
                 "Print"}], ";", 
                RowBox[{"Abort", "[", "]"}], ";"}], "*)"}], 
              "\[IndentingNewLine]", 
              RowBox[{"Map", "[", 
               RowBox[{
                RowBox[{
                 RowBox[{"DVEvaluate", "[", 
                  RowBox[{"#", ",", "opts"}], "]"}], "&"}], ",", "F"}], "]"}],
               "\[IndentingNewLine]", 
              RowBox[{"(*", 
               RowBox[{"Replace", "[", 
                RowBox[{
                 RowBox[{"Quiet", "[", "F", 
                  RowBox[{"(*", 
                   RowBox[{"//", "ReleaseHold"}], "*)"}], "]"}], ",", 
                 RowBox[{"x_", "\[RuleDelayed]", 
                  RowBox[{"DVEvaluate", "[", 
                   RowBox[{"x", ",", "opts"}], "]"}]}], ",", 
                 RowBox[{"{", "1", "}"}]}], "]"}], "*)"}], 
              "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}], 
          "\[IndentingNewLine]", ")"}], "\[IndentingNewLine]", ",", 
         "\[IndentingNewLine]", "expr"}], "\[IndentingNewLine]", "]"}]}], 
      "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"Options", "[", "DVE", "]"}], "=", 
    RowBox[{"{", 
     RowBox[{"CorrelatedErrors", "\[Rule]", "False"}], "}"}]}], ";"}], 
  "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{
     RowBox[{"Attributes", "[", "DVE", "]"}], "=", 
     RowBox[{"{", "HoldFirst", "}"}]}], ";"}], "*)"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"DVE", "::", "usage"}], "=", 
   "\"\<DVE[expr] represents a short form of DVEvaluate[expr].\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"DVE", "[", 
     RowBox[{"expr_", ",", 
      RowBox[{"opts", ":", 
       RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
    RowBox[{"(", 
     RowBox[{"DVEvaluate", "[", 
      RowBox[{"expr", ",", "opts"}], "]"}], ")"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"(*", 
   RowBox[{
    RowBox[{
     RowBox[{"Options", "[", "DVEvaluateSingle", "]"}], "=", 
     RowBox[{"{", 
      RowBox[{"CorrelatedErrors", "\[Rule]", "False"}], "}"}]}], ";", 
    "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"DVEvaluateSingle", "[", 
      RowBox[{"expr_", ",", 
       RowBox[{"opts", ":", 
        RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
     RowBox[{"Module", "[", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"Params", ",", "Rules"}], "}"}], ",", "\[IndentingNewLine]", 
       RowBox[{"(", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"Params", "=", 
          RowBox[{"Cases", "[", 
           RowBox[{"expr", ",", "_EV", ",", 
            RowBox[{"{", 
             RowBox[{"0", ",", "Infinity"}], "}"}]}], "]"}]}], ";", 
         "\[IndentingNewLine]", "\[IndentingNewLine]", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{
            RowBox[{"Length", "[", "Params", "]"}], ">", "0"}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{"(", "\[IndentingNewLine]", 
            RowBox[{
             RowBox[{"Params", "=", 
              RowBox[{"Params", "/.", 
               RowBox[{
                RowBox[{"EV", "[", 
                 RowBox[{"v_", ",", "s_"}], "]"}], "\[RuleDelayed]", 
                RowBox[{"EV", "[", 
                 RowBox[{"v", ",", "s", ",", 
                  RowBox[{"Unique", "[", "Global`ev", "]"}]}], "]"}]}]}]}], 
             ";", "\[IndentingNewLine]", 
             RowBox[{"Params", "=", 
              RowBox[{"DeleteDuplicates", "[", "Params", "]"}]}], ";", 
             "\[IndentingNewLine]", "\[IndentingNewLine]", 
             RowBox[{"Rules", "=", 
              RowBox[{
               RowBox[{
                RowBox[{"Rule", "[", 
                 RowBox[{"#", ",", 
                  RowBox[{"Unique", "[", "dvslot", "]"}]}], "]"}], "&"}], "/@",
                "Params"}]}], ";", "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"expr", "/.", "Rules"}], "/.", 
              RowBox[{"If", "[", 
               RowBox[{
                RowBox[{"TrueQ", "[", 
                 RowBox[{"OptionValue", "[", "CorrelatedErrors", "]"}], "]"}],
                 ",", 
                RowBox[{"CorrelatedEVRules", "[", 
                 RowBox[{"Sequence", "@@", 
                  RowBox[{"(", 
                   RowBox[{"Reverse", "/@", "Rules"}], ")"}]}], "]"}], ",", 
                RowBox[{"EVRules", "[", 
                 RowBox[{"Sequence", "@@", 
                  RowBox[{"(", 
                   RowBox[{"Reverse", "/@", "Rules"}], ")"}]}], "]"}]}], 
               "]"}]}]}], "\[IndentingNewLine]", ")"}], "\[IndentingNewLine]",
            ",", "\[IndentingNewLine]", "expr"}], "\[IndentingNewLine]", 
          "]"}]}], "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", 
      "]"}]}]}], "*)"}]}]}], "Input",
 InitializationCell->True]
}, Open  ]],

Cell[CellGroupData[{

Cell["Monte Carlo (NDVEvaluate, MonteCarloSimulation)", "Subsubsection"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"$DistributionList", "=", 
   RowBox[{"ToExpression", "/@", 
    RowBox[{"Names", "[", "\"\<*Distribution\>\"", "]"}]}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"$DistributionRandomRules", "=", 
   RowBox[{"(", 
    RowBox[{
     RowBox[{
      RowBox[{
       RowBox[{"(", 
        RowBox[{"ToExpression", "[", 
         RowBox[{"\"\<x_\>\"", "<>", 
          RowBox[{"ToString", "[", "#", "]"}]}], "]"}], ")"}], 
       "\[RuleDelayed]", 
       RowBox[{"RandomVariate", "[", "x", "]"}]}], "&"}], "/@", 
     "$DistributionList"}], ")"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"$DistributionMeanRules", "=", 
   RowBox[{"(", 
    RowBox[{
     RowBox[{
      RowBox[{
       RowBox[{"(", 
        RowBox[{"ToExpression", "[", 
         RowBox[{"\"\<x_\>\"", "<>", 
          RowBox[{"ToString", "[", "#", "]"}]}], "]"}], ")"}], 
       "\[RuleDelayed]", 
       RowBox[{"Mean", "[", "x", "]"}]}], "&"}], "/@", "$DistributionList"}], 
    ")"}]}], ";"}]}], "Input",
 InitializationCell->True],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"RandomData", "[", "dat_", "]"}], ":=", 
   RowBox[{"Module", "[", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{"ReplaceAllDT", "[", 
       RowBox[{
        RowBox[{"ReplaceAllDT", "[", 
         RowBox[{"dat", ",", "$DistributionRandomRules"}], "]"}], ",", 
        RowBox[{"(", 
         RowBox[{
          RowBox[{"NDV", "[", 
           RowBox[{"v_", ",", "se_", ",", "_"}], "]"}], "\[RuleDelayed]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"se", ">", "0"}], ",", 
            RowBox[{"RandomVariate", "[", 
             RowBox[{"NormalDistribution", "[", 
              RowBox[{"v", ",", "se"}], "]"}], "]"}], ",", "v"}], "]"}]}], 
         ")"}]}], "]"}], "\[IndentingNewLine]", ")"}]}], 
    "\[IndentingNewLine]", "]"}]}], ";"}]], "Input",
 InitializationCell->True],

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"ReplaceMeans", "[", "dat_", "]"}], ":=", 
   RowBox[{"Module", "[", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{"DVMeans", "[", 
       RowBox[{"ReplaceAllDT", "[", 
        RowBox[{"dat", ",", "$DistributionMeanRules"}], "]"}], "]"}], 
      "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}], 
  ";"}]], "Input",
 InitializationCell->True],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"ReleaseHoldAt", "[", 
    RowBox[{"expr_", ",", "partspec_"}], "]"}], ":=", 
   RowBox[{"ReplacePart", "[", 
    RowBox[{"expr", ",", 
     RowBox[{"partspec", "\[Rule]", 
      RowBox[{"Extract", "[", 
       RowBox[{"expr", ",", "partspec"}], "]"}]}]}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"EvaluateAssocValues", "[", "expr_", "]"}], ":=", 
   RowBox[{"ReplaceAll", "[", 
    RowBox[{"expr", ",", 
     RowBox[{
      RowBox[{"a", ":", 
       RowBox[{"Association", "[", "___", "]"}]}], "\[RuleDelayed]", 
      RowBox[{"(", 
       RowBox[{"(", 
        RowBox[{
         RowBox[{
          RowBox[{"EvaluateAssocValues", "[", "#", "]"}], "&"}], "/@", "a"}], 
        ")"}], ")"}]}]}], "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"ReplaceAllDT", "[", 
    RowBox[{"expr_", ",", "rules_"}], "]"}], ":=", 
   RowBox[{
    RowBox[{"(", 
     RowBox[{"expr", "/.", "rules"}], ")"}], "/.", 
    RowBox[{"d_DataTable", "\[RuleDelayed]", 
     RowBox[{"(", 
      RowBox[{"d", "/.", "rules"}], ")"}]}]}]}], ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"54e4cbde-7d46-4123-ae66-c33eb4778061"],

Cell[BoxData[
 RowBox[{
  RowBox[{"(*", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"MonteCarloSimulation", ",", "HoldFirst"}], "]"}], ";"}], "*)"}],
   "\[IndentingNewLine]", 
  RowBox[{
   RowBox[{
    RowBox[{
     RowBox[{"Options", "[", "MonteCarloSimulation", "]"}], "=", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"UseParallelKernels", "\[Rule]", "False"}], ",", 
       RowBox[{"MatchPattern", "\[Rule]", 
        RowBox[{"Blank", "[", "]"}]}], ",", 
       RowBox[{"MissingBehavior", "\[Rule]", "Automatic"}]}], "}"}]}], ";"}], 
   "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{
     RowBox[{"UseParallelKernels", "::", "usage"}], "=", 
     "\"\<UseParallelKernels is an option for MonteCarloSimulation[...] which \
specifies whether parallel kernels should be used for the simulation.\>\""}], 
    ";"}], "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{
     RowBox[{"MatchPattern", "::", "usage"}], "=", 
     "\"\<MatchPattern is an option for MonteCarloSimulation[...] which \
specifies that only function results matching this pattern should be used \
(default is Blank[]).\>\""}], ";"}], "\[IndentingNewLine]", 
   "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{
     RowBox[{"MonteCarloSimulation", "::", "minnum"}], "=", 
     "\"\<The number of simulations i has to be greater than 1.\>\""}], ";"}],
    "\[IndentingNewLine]", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{
     RowBox[{"MonteCarloSimulation", "::", "usage"}], "=", 
     "\"\<MonteCarloSimulation[expr,i,{\!\(\*SubscriptBox[\(param\), \(1\)]\)\
\[Rule]\!\(\*SubscriptBox[\(distribution\), \
\(1\)]\),\!\(\*SubscriptBox[\(param\), \
\(2\)]\)\[Rule]\!\(\*SubscriptBox[\(distribution\), \(2\)]\)}] carries out a \
Monte Carlo simulation with i iterations, to propagate uncertainties (in NDV \
objects or standard Mathematica Distribution objects) in expr. Parameters in \
expr may be separately specified as rules \!\(\*SubscriptBox[\(param\), \
\(i\)]\)\[Rule]\!\(\*SubscriptBox[\(distribution\), \(i\)]\), where \
\!\(\*SubscriptBox[\(distribution\), \(i\)]\) can be either an NDV object or \
a standard Mathematica distribution object.\>\""}], ";"}], 
   "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"MonteCarloSimulation", "[", 
     RowBox[{"f_", ",", "i_Integer", ",", "params_", ",", 
      RowBox[{"opts", ":", 
       RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
    RowBox[{"Module", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
       "TmpRes", ",", "Counter", ",", "StartCounter", ",", "SingleRes", ",", 
        RowBox[{"MP", "=", 
         RowBox[{"OptionValue", "[", "MatchPattern", "]"}]}]}], "}"}], ",", 
      "\[IndentingNewLine]", 
      RowBox[{"(", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"MissingBehavior", "===", "Automatic"}], "&&", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{"!", 
              RowBox[{"FreeQ", "[", 
               RowBox[{"params", ",", 
                RowBox[{"Missing", "[", "___", "]"}]}], "]"}]}], "||", 
             RowBox[{"!", 
              RowBox[{"FreeQ", "[", 
               RowBox[{
                RowBox[{"Hold", "[", "f", "]"}], ",", 
                RowBox[{"Missing", "[", "___", "]"}]}], "]"}]}]}], ")"}]}], 
          ",", 
          RowBox[{"Return", "[", 
           RowBox[{"Missing", "[", "]"}], "]"}]}], "]"}], ";", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"i", "<", "2"}], ",", 
          RowBox[{
           RowBox[{"ErrorMessage", "[", 
            RowBox[{"MonteCarloSimulation", "::", "minnum"}], "]"}], ";"}]}], 
         "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"TrueQ", "[", 
           RowBox[{"OptionValue", "[", "UseParallelKernels", "]"}], "]"}], 
          ",", "\[IndentingNewLine]", 
          RowBox[{"(", "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"Counter", "=", "0"}], ";", "\[IndentingNewLine]", 
            RowBox[{"StartCounter", "=", "0"}], ";", "\[IndentingNewLine]", 
            RowBox[{"SetSharedVariable", "[", 
             RowBox[{"Counter", ",", "StartCounter"}], "]"}], ";", 
            "\[IndentingNewLine]", "\[IndentingNewLine]", 
            RowBox[{"Monitor", "[", 
             RowBox[{
              RowBox[{
               RowBox[{"TmpRes", "=", 
                RowBox[{"Flatten", "[", 
                 RowBox[{
                  RowBox[{"ParallelEvaluate", "[", 
                   RowBox[{
                    RowBox[{"Module", "[", 
                    RowBox[{
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"Res", "=", 
                    RowBox[{"{", "}"}]}], ",", "ThisRes", ",", "P"}], "}"}], 
                    ",", 
                    RowBox[{"(", "\[IndentingNewLine]", 
                    RowBox[{
                    RowBox[{"While", "[", 
                    RowBox[{
                    RowBox[{"StartCounter", "<", "i"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{
                    RowBox[{"StartCounter", "++"}], ";", 
                    "\[IndentingNewLine]", 
                    RowBox[{"P", "=", 
                    RowBox[{"EvaluateAssocValues", "@", 
                    RowBox[{"(", 
                    RowBox[{"params", "//", "RandomData"}], ")"}]}]}], ";", 
                    "\[IndentingNewLine]", "\[IndentingNewLine]", 
                    RowBox[{"ThisRes", "=", 
                    RowBox[{"(*", 
                    RowBox[{"EvaluateAssocValues", "@"}], "*)"}], 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"f", "//", "RandomData"}], ")"}], "/.", "P"}], "//",
                     "ReleaseHold"}], ")"}]}], ";", "\[IndentingNewLine]", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"MatchQ", "[", 
                    RowBox[{
                    RowBox[{"Evaluate", "[", "ThisRes", "]"}], ",", "MP"}], 
                    "]"}], ",", "\[IndentingNewLine]", 
                    RowBox[{"(", "\[IndentingNewLine]", 
                    RowBox[{
                    RowBox[{"AppendTo", "[", 
                    RowBox[{"Res", ",", 
                    RowBox[{"{", 
                    RowBox[{"ThisRes", ",", "P"}], "}"}]}], "]"}], ";", 
                    "\[IndentingNewLine]", 
                    RowBox[{"Counter", "++"}], ";"}], "\[IndentingNewLine]", 
                    ")"}], ",", 
                    RowBox[{"(", "\[IndentingNewLine]", 
                    RowBox[{
                    RowBox[{"StartCounter", "--"}], ";"}], 
                    "\[IndentingNewLine]", ")"}]}], "]"}], ";"}]}], 
                    "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
                    "Res"}], "\[IndentingNewLine]", ")"}]}], "]"}], ",", 
                    RowBox[{"DistributedContexts", "\[RuleDelayed]", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"ListQ", "[", "$DistributedContexts", "]"}], ",", 
                    
                    RowBox[{"Append", "[", 
                    RowBox[{
                    "$DistributedContexts", ",", 
                    "\"\<DataAnalysis`Private`\>\""}], "]"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"StringQ", "[", "$DistributedContexts", "]"}], 
                    ",", 
                    RowBox[{"{", 
                    RowBox[{
                    "$DistributedContexts", ",", 
                    "\"\<DataAnalysis`Private`\>\""}], "}"}], ",", 
                    "$DistributedContexts"}], "]"}]}], "]"}]}]}], "]"}], ",", 
                  "1"}], "]"}]}], ";"}], ",", 
              RowBox[{"Column", "[", 
               RowBox[{"{", "\[IndentingNewLine]", 
                RowBox[{
                 RowBox[{
                  RowBox[{"ToString", "[", "Counter", "]"}], "<>", 
                  "\"\</\>\"", "<>", 
                  RowBox[{"ToString", "[", "i", "]"}]}], ",", 
                 "\[IndentingNewLine]", 
                 RowBox[{"ProgressIndicator", "[", 
                  RowBox[{"Counter", ",", 
                   RowBox[{"{", 
                    RowBox[{"0", ",", "i"}], "}"}]}], "]"}]}], 
                "\[IndentingNewLine]", "}"}], "]"}]}], "]"}], ";", 
            "\[IndentingNewLine]", "\[IndentingNewLine]", 
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{
               RowBox[{"Length", "[", "TmpRes", "]"}], ">", "i"}], ",", 
              RowBox[{"TmpRes", "=", 
               RowBox[{"TmpRes", "[", 
                RowBox[{"[", 
                 RowBox[{";;", "i"}], "]"}], "]"}]}]}], "]"}], ";"}], 
           "\[IndentingNewLine]", ")"}], ",", "\[IndentingNewLine]", 
          RowBox[{"(", "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"Counter", "=", "0"}], ";", "\[IndentingNewLine]", 
            RowBox[{"TmpRes", "=", 
             RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", 
            RowBox[{"Monitor", "[", 
             RowBox[{
              RowBox[{"Module", "[", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{"ThisRes", ",", "P"}], "}"}], ",", 
                RowBox[{"(", "\[IndentingNewLine]", 
                 RowBox[{
                  RowBox[{"While", "[", 
                   RowBox[{
                    RowBox[{"Counter", "<", "i"}], ",", "\[IndentingNewLine]", 
                    RowBox[{
                    RowBox[{"P", "=", 
                    RowBox[{"EvaluateAssocValues", "@", 
                    RowBox[{"(", 
                    RowBox[{"params", "//", "RandomData"}], ")"}]}]}], ";", 
                    "\[IndentingNewLine]", 
                    RowBox[{"ThisRes", "=", 
                    RowBox[{"(*", 
                    RowBox[{"EvaluateAssocValues", "@"}], "*)"}], 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"f", "//", "RandomData"}], ")"}], "/.", "P"}], "//",
                     "ReleaseHold"}], ")"}]}], ";", "\[IndentingNewLine]", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"MatchQ", "[", 
                    RowBox[{"ThisRes", ",", "MP"}], "]"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"(", "\[IndentingNewLine]", 
                    RowBox[{
                    RowBox[{"AppendTo", "[", 
                    RowBox[{"TmpRes", ",", 
                    RowBox[{"{", 
                    RowBox[{"ThisRes", ",", "P"}], "}"}]}], "]"}], ";", 
                    "\[IndentingNewLine]", 
                    RowBox[{"Counter", "++"}], ";"}], "\[IndentingNewLine]", 
                    ")"}]}], "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], 
                  ";"}], "\[IndentingNewLine]", ")"}]}], "]"}], ",", 
              "\[IndentingNewLine]", 
              RowBox[{"Column", "[", 
               RowBox[{"{", "\[IndentingNewLine]", 
                RowBox[{
                 RowBox[{
                  RowBox[{"ToString", "[", "Counter", "]"}], "<>", 
                  "\"\</\>\"", "<>", 
                  RowBox[{"ToString", "[", "i", "]"}]}], ",", 
                 "\[IndentingNewLine]", 
                 RowBox[{"ProgressIndicator", "[", 
                  RowBox[{"Counter", ",", 
                   RowBox[{"{", 
                    RowBox[{"0", ",", "i"}], "}"}]}], "]"}]}], 
                "\[IndentingNewLine]", "}"}], "]"}]}], "\[IndentingNewLine]", 
             "]"}], ";"}], "\[IndentingNewLine]", ")"}]}], 
         "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", 
        RowBox[{"SingleRes", "=", 
         RowBox[{
          RowBox[{
           RowBox[{"(", 
            RowBox[{"f", "//", "ReplaceMeans"}], ")"}], "/.", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{"params", "//", "ReplaceMeans"}], "//", 
             "EvaluateAssocValues"}], ")"}]}], "//", "ReleaseHold"}]}], 
        RowBox[{"(*", 
         RowBox[{"//", "EvaluateAssocValues"}], "*)"}], ";", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"MonteCarloResult", "[", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"SingleRes", ",", "TmpRes"}], "}"}], "\[IndentingNewLine]", 
         
         RowBox[{"(*", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"AssociationQ", "[", "SingleRes", "]"}], ",", 
            RowBox[{"{", 
             RowBox[{
              RowBox[{"Map", "[", 
               RowBox[{
                RowBox[{"#", "&"}], ",", "SingleRes", ",", "Infinity"}], 
               "]"}], ",", 
              RowBox[{"Map", "[", 
               RowBox[{
                RowBox[{"#", "&"}], ",", "TmpRes", ",", 
                RowBox[{"{", "3", "}"}]}], "]"}]}], "}"}], ",", 
            RowBox[{"{", 
             RowBox[{"SingleRes", ",", "TmpRes"}], "}"}]}], "]"}], "*)"}], 
         "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", ")"}]}], 
     "\[IndentingNewLine]", "]"}]}]}]}]], "Input",
 InitializationCell->
  True,ExpressionUUID->"03d83ee6-6849-42d5-a40e-50be13234828"],

Cell[BoxData["\[IndentingNewLine]"], "Input"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MakeBoxes", "[", 
     RowBox[{
      RowBox[{"res", ":", 
       RowBox[{"MonteCarloResult", "[", "data_List", "]"}]}], ",", 
      "StandardForm"}], "]"}], "^:=", 
    RowBox[{
     RowBox[{"MonteCarloResult", "[", 
      RowBox[{"Panel", "[", 
       RowBox[{
        RowBox[{"Row", "[", 
         RowBox[{"{", 
          RowBox[{"\"\<n = \>\"", ",", 
           RowBox[{
            RowBox[{"data", "[", 
             RowBox[{"[", "2", "]"}], "]"}], "//", "Length"}]}], "}"}], "]"}],
         ",", 
        RowBox[{"FrameMargins", "\[Rule]", "5"}]}], "]"}], "]"}], "//", 
     "ToBoxes"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"MonteCarloResult", "::", "usage"}], "=", 
   "\"\<MonteCarloResult[...] represents the symbolic result obtained from a \
MonteCarloSimulation.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"MonteCarloResult", "::", "unknownproperty"}], "=", 
   "\"\<The property \\\"`1`\\\" is not defined.\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"MonteCarloResult", "::", "resultform"}], "=", 
   "\"\<This output can only be generated if the result of the function is \
numeric, a flat list, or a flat association.\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"MonteCarloResult", "::", "reslist"}], "=", 
   "\"\<This output can only be generated for numerical results (e.g. not for \
lists or associations).\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"MonteCarloResult", "::", "paramlist"}], "=", 
   "\"\<Sensitifity plots can only be generated for numerical parameters \
(e.g. not if one parameter is a list or association).\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"MonteCarloResult", "::", "notnormal"}], "=", 
   "\"\<A DistributionFitTest indicates that the simulated results are not \
normally distributed. This NDV value has to be treated with caution, as NDV \
value are assumed to be normally distributed.\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MonteCarloResult", "[", "data_", "]"}], "[", "property_String", 
    "]"}], ":=", 
   RowBox[{"Module", "[", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{"Switch", "[", 
       RowBox[{
       "property", ",", "\[IndentingNewLine]", "\"\<SingleMean\>\"", ",", 
        "\[IndentingNewLine]", 
        RowBox[{"data", "[", 
         RowBox[{"[", "1", "]"}], "]"}], ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "\"\<SingleMeanDV\>\"", ",", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"CheckResultForm", "[", 
          RowBox[{"data", "[", 
           RowBox[{"[", "1", "]"}], "]"}], "]"}], ";", "\[IndentingNewLine]", 
         
         RowBox[{"Switch", "[", 
          RowBox[{
           RowBox[{"data", "[", 
            RowBox[{"[", "1", "]"}], "]"}], ",", "\[IndentingNewLine]", 
           "_List", ",", 
           RowBox[{"MapThread", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{"DV", "[", 
                RowBox[{"#1", ",", 
                 RowBox[{"StandardDeviation", "[", "#2", "]"}], ",", 
                 RowBox[{
                  RowBox[{"{", 
                   RowBox[{
                    RowBox[{"-", "1"}], ",", "1"}], "}"}], "*", 
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"QuantileCI", "[", "#2", "]"}], "-", "#1"}], 
                   ")"}]}]}], "]"}], ")"}], "&"}], ",", 
             RowBox[{"{", 
              RowBox[{
               RowBox[{"data", "[", 
                RowBox[{"[", "1", "]"}], "]"}], ",", 
               RowBox[{
                RowBox[{"data", "[", 
                 RowBox[{"[", 
                  RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "//", 
                "Transpose"}]}], "}"}], ",", 
             RowBox[{
              RowBox[{"Depth", "[", 
               RowBox[{"data", "[", 
                RowBox[{"[", "1", "]"}], "]"}], "]"}], "-", "1"}]}], "]"}], 
           ",", "\[IndentingNewLine]", "_Association", ",", 
           RowBox[{"MapAssoc", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{"DV", "[", 
                RowBox[{"#1", ",", 
                 RowBox[{"StandardDeviation", "[", "#2", "]"}], ",", 
                 RowBox[{
                  RowBox[{"{", 
                   RowBox[{
                    RowBox[{"-", "1"}], ",", "1"}], "}"}], "*", 
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"QuantileCI", "[", "#2", "]"}], "-", "#1"}], 
                   ")"}]}]}], "]"}], ")"}], "&"}], ",", "data"}], "]"}], ",", 
           "\[IndentingNewLine]", "NumPattern", ",", 
           RowBox[{"(", 
            RowBox[{"DV", "[", 
             RowBox[{
              RowBox[{"data", "[", 
               RowBox[{"[", "1", "]"}], "]"}], ",", 
              RowBox[{"StandardDeviation", "[", 
               RowBox[{"data", "[", 
                RowBox[{"[", 
                 RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}], 
              ",", 
              RowBox[{
               RowBox[{"{", 
                RowBox[{
                 RowBox[{"-", "1"}], ",", "1"}], "}"}], "*", 
               RowBox[{"(", 
                RowBox[{
                 RowBox[{"QuantileCI", "[", 
                  RowBox[{"data", "[", 
                   RowBox[{"[", 
                    RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}], 
                 "-", 
                 RowBox[{"data", "[", 
                  RowBox[{"[", "1", "]"}], "]"}]}], ")"}]}]}], "]"}], ")"}]}],
           "\[IndentingNewLine]", "]"}]}], ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "\"\<SingleMeanNDV\>\"", ",", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"CheckResultForm", "[", 
          RowBox[{"data", "[", 
           RowBox[{"[", "1", "]"}], "]"}], "]"}], ";", "\[IndentingNewLine]", 
         
         RowBox[{"Switch", "[", 
          RowBox[{
           RowBox[{"data", "[", 
            RowBox[{"[", "1", "]"}], "]"}], ",", "\[IndentingNewLine]", 
           "_List", ",", 
           RowBox[{"MapThread", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{"CheckNormality", "[", "#2", "]"}], ";", 
                RowBox[{"NDV", "[", 
                 RowBox[{"#1", ",", 
                  RowBox[{"StandardDeviation", "[", "#2", "]"}]}], "]"}]}], 
               ")"}], "&"}], ",", 
             RowBox[{"{", 
              RowBox[{
               RowBox[{"data", "[", 
                RowBox[{"[", "1", "]"}], "]"}], ",", 
               RowBox[{
                RowBox[{"data", "[", 
                 RowBox[{"[", 
                  RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "//", 
                "Transpose"}]}], "}"}], ",", 
             RowBox[{
              RowBox[{"Depth", "[", 
               RowBox[{"data", "[", 
                RowBox[{"[", "1", "]"}], "]"}], "]"}], "-", "1"}]}], "]"}], 
           ",", "\[IndentingNewLine]", "_Association", ",", 
           RowBox[{"MapAssoc", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{"CheckNormality", "[", "#2", "]"}], ";", 
                RowBox[{"NDV", "[", 
                 RowBox[{"#1", ",", 
                  RowBox[{"StandardDeviation", "[", "#2", "]"}]}], "]"}]}], 
               ")"}], "&"}], ",", "data"}], "]"}], ",", "\[IndentingNewLine]",
            "NumPattern", ",", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{"CheckNormality", "[", 
              RowBox[{"data", "[", 
               RowBox[{"[", 
                RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}], ";", 
             RowBox[{"NDV", "[", 
              RowBox[{
               RowBox[{"data", "[", 
                RowBox[{"[", "1", "]"}], "]"}], ",", 
               RowBox[{"StandardDeviation", "[", 
                RowBox[{"data", "[", 
                 RowBox[{"[", 
                  RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}]}], 
              "]"}]}], ")"}]}], "\[IndentingNewLine]", "]"}]}], ",", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", "\"\<QuantileCI\>\"", 
        ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"CheckResultForm", "[", 
          RowBox[{"data", "[", 
           RowBox[{"[", "1", "]"}], "]"}], "]"}], ";", "\[IndentingNewLine]", 
         
         RowBox[{"Switch", "[", 
          RowBox[{
           RowBox[{"data", "[", 
            RowBox[{"[", "1", "]"}], "]"}], ",", "\[IndentingNewLine]", 
           "_List", ",", 
           RowBox[{"MapThread", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{"QuantileCI", "[", "#2", "]"}], ")"}], "&"}], ",", 
             RowBox[{"{", 
              RowBox[{
               RowBox[{"data", "[", 
                RowBox[{"[", "1", "]"}], "]"}], ",", 
               RowBox[{
                RowBox[{"data", "[", 
                 RowBox[{"[", 
                  RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "//", 
                "Transpose"}]}], "}"}], ",", 
             RowBox[{
              RowBox[{"Depth", "[", 
               RowBox[{"data", "[", 
                RowBox[{"[", "1", "]"}], "]"}], "]"}], "-", "1"}]}], "]"}], 
           ",", "\[IndentingNewLine]", "_Association", ",", 
           RowBox[{"MapAssoc", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{"QuantileCI", "[", "#2", "]"}], ")"}], "&"}], ",", 
             "data"}], "]"}], ",", "\[IndentingNewLine]", "NumPattern", ",", 
           RowBox[{"(", 
            RowBox[{"QuantileCI", "[", 
             RowBox[{"data", "[", 
              RowBox[{"[", 
               RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}], 
            ")"}]}], "\[IndentingNewLine]", "]"}]}], ",", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        "\"\<DistributionMean\>\"", ",", "\[IndentingNewLine]", 
        RowBox[{"Mean", "[", 
         RowBox[{"data", "[", 
          RowBox[{"[", 
           RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}], ",", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        "\"\<DistributionMeanDV\>\"", ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"CheckResultForm", "[", 
          RowBox[{"data", "[", 
           RowBox[{"[", 
            RowBox[{"2", ",", "1", ",", "1"}], "]"}], "]"}], "]"}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"Switch", "[", 
          RowBox[{
           RowBox[{"data", "[", 
            RowBox[{"[", 
             RowBox[{"2", ",", "1", ",", "1"}], "]"}], "]"}], ",", 
           "\[IndentingNewLine]", "_List", ",", 
           RowBox[{
            RowBox[{
             RowBox[{"DV", "[", 
              RowBox[{
               RowBox[{"Mean", "[", "#", "]"}], ",", 
               RowBox[{"StandardDeviation", "[", "#", "]"}], ",", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{
                  RowBox[{"-", "1"}], ",", "1"}], "}"}], "*", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"QuantileCI", "[", "#", "]"}], "-", 
                  RowBox[{"Mean", "[", "#", "]"}]}], ")"}]}]}], "]"}], "&"}], 
            "/@", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"data", "[", 
               RowBox[{"[", 
                RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "//", 
              "Transpose"}], ")"}]}], ",", "\[IndentingNewLine]", 
           "_Association", ",", 
           RowBox[{"MapAssoc", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"DV", "[", 
               RowBox[{
                RowBox[{"Mean", "[", "#2", "]"}], ",", 
                RowBox[{"StandardDeviation", "[", "#2", "]"}], ",", 
                RowBox[{
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"-", "1"}], ",", "1"}], "}"}], "*", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"QuantileCI", "[", "#2", "]"}], "-", 
                   RowBox[{"Mean", "[", "#2", "]"}]}], ")"}]}]}], "]"}], 
              "&"}], ",", "data"}], "]"}], ",", "\[IndentingNewLine]", 
           "NumPattern", ",", 
           RowBox[{"DV", "[", 
            RowBox[{
             RowBox[{"Mean", "[", 
              RowBox[{"data", "[", 
               RowBox[{"[", 
                RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}], ",", 
             RowBox[{"StandardDeviation", "[", 
              RowBox[{"data", "[", 
               RowBox[{"[", 
                RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}], ",", 
             RowBox[{
              RowBox[{"{", 
               RowBox[{
                RowBox[{"-", "1"}], ",", "1"}], "}"}], "*", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{"QuantileCI", "[", 
                 RowBox[{"data", "[", 
                  RowBox[{"[", 
                   RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}], 
                "-", 
                RowBox[{"Mean", "[", 
                 RowBox[{"data", "[", 
                  RowBox[{"[", 
                   RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}]}],
                ")"}]}]}], "]"}]}], "\[IndentingNewLine]", "]"}]}], ",", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        "\"\<DistributionMeanNDV\>\"", ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"CheckResultForm", "[", 
          RowBox[{"data", "[", 
           RowBox[{"[", 
            RowBox[{"2", ",", "1", ",", "1"}], "]"}], "]"}], "]"}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"Switch", "[", 
          RowBox[{
           RowBox[{"data", "[", 
            RowBox[{"[", 
             RowBox[{"2", ",", "1", ",", "1"}], "]"}], "]"}], ",", 
           "\[IndentingNewLine]", "_List", ",", 
           RowBox[{
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{"CheckNormality", "[", "#", "]"}], ";", 
               RowBox[{"NDV", "[", 
                RowBox[{
                 RowBox[{"Mean", "[", "#", "]"}], ",", 
                 RowBox[{"StandardDeviation", "[", "#", "]"}]}], "]"}]}], 
              ")"}], "&"}], "/@", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"data", "[", 
               RowBox[{"[", 
                RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "//", 
              "Transpose"}], ")"}]}], ",", "\[IndentingNewLine]", 
           "_Association", ",", 
           RowBox[{"MapAssoc", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{"CheckNormality", "[", "#2", "]"}], ";", 
                RowBox[{"NDV", "[", 
                 RowBox[{
                  RowBox[{"Mean", "[", "#2", "]"}], ",", 
                  RowBox[{"StandardDeviation", "[", "#2", "]"}]}], "]"}]}], 
               ")"}], "&"}], ",", "data"}], "]"}], ",", "\[IndentingNewLine]",
            "NumPattern", ",", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{"CheckNormality", "[", 
              RowBox[{"data", "[", 
               RowBox[{"[", 
                RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}], ";", 
             RowBox[{"NDV", "[", 
              RowBox[{
               RowBox[{"Mean", "[", 
                RowBox[{"data", "[", 
                 RowBox[{"[", 
                  RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}], 
               ",", 
               RowBox[{"StandardDeviation", "[", 
                RowBox[{"data", "[", 
                 RowBox[{"[", 
                  RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}]}], 
              "]"}]}], ")"}]}], "\[IndentingNewLine]", "]"}]}], ",", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        "\"\<FindDistribution\>\"", ",", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"CheckResultForm", "[", 
          RowBox[{"data", "[", 
           RowBox[{"[", 
            RowBox[{"2", ",", "1", ",", "1"}], "]"}], "]"}], "]"}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"Switch", "[", 
          RowBox[{
           RowBox[{"data", "[", 
            RowBox[{"[", 
             RowBox[{"2", ",", "1", ",", "1"}], "]"}], "]"}], ",", 
           "\[IndentingNewLine]", "_List", ",", 
           RowBox[{
            RowBox[{
             RowBox[{"FindDistribution", "[", "#", "]"}], "&"}], "/@", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"data", "[", 
               RowBox[{"[", 
                RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "//", 
              "Transpose"}], ")"}]}], ",", "\[IndentingNewLine]", 
           "_Association", ",", 
           RowBox[{"MapAssoc", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{"FindDistribution", "[", "#2", "]"}], ")"}], "&"}], 
             ",", "data"}], "]"}], ",", "\[IndentingNewLine]", "NumPattern", 
           ",", 
           RowBox[{"FindDistribution", "[", 
            RowBox[{"data", "[", 
             RowBox[{"[", 
              RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}]}], 
          "\[IndentingNewLine]", "]"}]}], ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "\"\<EmpiricalDistribution\>\"", ",", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"CheckResultForm", "[", 
          RowBox[{"data", "[", 
           RowBox[{"[", 
            RowBox[{"2", ",", "1", ",", "1"}], "]"}], "]"}], "]"}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"Switch", "[", 
          RowBox[{
           RowBox[{"data", "[", 
            RowBox[{"[", 
             RowBox[{"2", ",", "1", ",", "1"}], "]"}], "]"}], ",", 
           "\[IndentingNewLine]", "_List", ",", 
           RowBox[{
            RowBox[{
             RowBox[{"EmpiricalDistribution", "[", "#", "]"}], "&"}], "/@", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"data", "[", 
               RowBox[{"[", 
                RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "//", 
              "Transpose"}], ")"}]}], ",", "\[IndentingNewLine]", 
           "_Association", ",", 
           RowBox[{"MapAssoc", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"EmpiricalDistribution", "[", "#2", "]"}], "&"}], ",", 
             "data"}], "]"}], ",", "\[IndentingNewLine]", "NumPattern", ",", 
           RowBox[{"EmpiricalDistribution", "[", 
            RowBox[{"data", "[", 
             RowBox[{"[", 
              RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}]}], 
          "\[IndentingNewLine]", "]"}]}], ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "\"\<StandardDeviation\>\"", ",", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"CheckResultForm", "[", 
          RowBox[{"data", "[", 
           RowBox[{"[", 
            RowBox[{"2", ",", "1", ",", "1"}], "]"}], "]"}], "]"}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"Switch", "[", 
          RowBox[{
           RowBox[{"data", "[", 
            RowBox[{"[", 
             RowBox[{"2", ",", "1", ",", "1"}], "]"}], "]"}], ",", 
           "\[IndentingNewLine]", "_List", ",", 
           RowBox[{"StandardDeviation", "[", 
            RowBox[{"data", "[", 
             RowBox[{"[", 
              RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}], ",", 
           "\[IndentingNewLine]", "_Association", ",", 
           RowBox[{"MapAssoc", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"StandardDeviation", "[", "#2", "]"}], "&"}], ",", 
             "data"}], "]"}], ",", "\[IndentingNewLine]", "NumPattern", ",", 
           RowBox[{"StandardDeviation", "[", 
            RowBox[{"data", "[", 
             RowBox[{"[", 
              RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}]}], 
          "\[IndentingNewLine]", "]"}]}], ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "\"\<Histogram\>\"", ",", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"CheckResultForm", "[", 
          RowBox[{"data", "[", 
           RowBox[{"[", 
            RowBox[{"2", ",", "1", ",", "1"}], "]"}], "]"}], "]"}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"Switch", "[", 
          RowBox[{
           RowBox[{"data", "[", 
            RowBox[{"[", 
             RowBox[{"2", ",", "1", ",", "1"}], "]"}], "]"}], ",", 
           "\[IndentingNewLine]", "_List", ",", 
           RowBox[{
            RowBox[{
             RowBox[{"Histogram", "[", "#", "]"}], "&"}], "/@", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"data", "[", 
               RowBox[{"[", 
                RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "//", 
              "Transpose"}], ")"}]}], ",", "\[IndentingNewLine]", 
           "_Association", ",", 
           RowBox[{"MapAssoc", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"Histogram", "[", "#2", "]"}], "&"}], ",", "data"}], 
            "]"}], ",", "\[IndentingNewLine]", "NumPattern", ",", 
           RowBox[{"Histogram", "[", 
            RowBox[{"data", "[", 
             RowBox[{"[", 
              RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}], "]"}]}], 
          "\[IndentingNewLine]", "]"}]}], ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "\"\<SensitivityPlots\>\"", ",", 
        RowBox[{"Module", "[", "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"{", "Params", "}"}], ",", "\[IndentingNewLine]", 
          RowBox[{"(", "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{"!", 
               RowBox[{"NumericQ", "[", 
                RowBox[{"data", "[", 
                 RowBox[{"[", "1", "]"}], "]"}], "]"}]}], ",", 
              RowBox[{"ErrorMessage", "[", 
               RowBox[{"MonteCarloResult", "::", "reslist"}], "]"}]}], "]"}], 
            ";", "\[IndentingNewLine]", 
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{"!", 
               RowBox[{"(", 
                RowBox[{"And", "@@", 
                 RowBox[{"(", 
                  RowBox[{"NumericQ", "/@", 
                   RowBox[{"data", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "1", ",", "2", ",", "All", ",", "2"}], 
                    "]"}], "]"}]}], ")"}]}], ")"}]}], ",", 
              RowBox[{"ErrorMessage", "[", 
               RowBox[{"MonteCarloResult", "::", "paramlist"}], "]"}]}], 
             "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
            RowBox[{"Params", "=", 
             RowBox[{"data", "[", 
              RowBox[{"[", 
               RowBox[{"2", ",", "1", ",", "2", ",", "All", ",", "1"}], "]"}],
               "]"}]}], ";", "\[IndentingNewLine]", 
            RowBox[{
             RowBox[{
              RowBox[{"Multicolumn", "[", 
               RowBox[{"#", ",", "1", ",", 
                RowBox[{"Spacings", "\[Rule]", "5"}]}], "]"}], "&"}], "@", 
             RowBox[{"(", 
              RowBox[{
               RowBox[{
                RowBox[{"ListPlot", "[", "\[IndentingNewLine]", 
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{"MapThread", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"{", 
                    RowBox[{"#1", ",", "#2"}], "}"}], "&"}], ",", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "/.", 
                    RowBox[{"data", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "All", ",", "2"}], "]"}], "]"}]}], ",", 
                    
                    RowBox[{"data", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}]}], 
                    "}"}]}], "]"}], ")"}], ",", "\[IndentingNewLine]", 
                  RowBox[{"Frame", "\[Rule]", "True"}], ",", 
                  "\[IndentingNewLine]", 
                  RowBox[{"FrameStyle", "\[Rule]", "Black"}], ",", 
                  "\[IndentingNewLine]", 
                  RowBox[{"PlotRange", "\[Rule]", "All"}], ",", 
                  "\[IndentingNewLine]", 
                  RowBox[{"ImageSize", "\[Rule]", "450"}], ",", 
                  "\[IndentingNewLine]", 
                  RowBox[{"PlotMarkers", "\[Rule]", "$DefaultPlotMarkers"}], 
                  ",", "\[IndentingNewLine]", 
                  RowBox[{"PlotStyle", "\[Rule]", "$DefaultPlotColors"}], ",",
                   "\[IndentingNewLine]", 
                  RowBox[{"FrameTicksStyle", "\[Rule]", "12"}], ",", 
                  "\[IndentingNewLine]", 
                  RowBox[{"LabelStyle", "\[Rule]", "12"}], ",", 
                  "\[IndentingNewLine]", 
                  RowBox[{"Axes", "\[Rule]", "False"}], ",", 
                  "\[IndentingNewLine]", 
                  RowBox[{"PlotLabel", "\[Rule]", 
                   RowBox[{"Style", "[", 
                    RowBox[{"#", ",", "16", ",", "Black"}], "]"}]}]}], 
                 "\[IndentingNewLine]", "]"}], "&"}], "/@", "Params"}], 
              ")"}]}]}], "\[IndentingNewLine]", ")"}]}], 
         "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "\"\<SimulationData\>\"", ",", 
        "\[IndentingNewLine]", 
        RowBox[{"data", "[", 
         RowBox[{"[", "2", "]"}], "]"}], ",", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "_", ",", "\[IndentingNewLine]", 
        RowBox[{"ErrorMessage", "[", 
         RowBox[{
          RowBox[{"MonteCarloResult", "::", "unknownproperty"}], ",", 
          "property"}], "]"}]}], "\[IndentingNewLine]", "]"}], 
      "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MapAssoc", "[", 
     RowBox[{"f_", ",", "data_"}], "]"}], ":=", 
    RowBox[{"Association", "@", 
     RowBox[{"(", 
      RowBox[{
       RowBox[{
        RowBox[{"Module", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"KeyName", ",", "Res"}], "}"}], ",", "\[IndentingNewLine]", 
          RowBox[{"(", "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"KeyName", "=", "#"}], ";", "\[IndentingNewLine]", 
            RowBox[{"Res", "=", 
             RowBox[{
              RowBox[{
               RowBox[{"#", "[", "KeyName", "]"}], "&"}], "/@", 
              RowBox[{"data", "[", 
               RowBox[{"[", 
                RowBox[{"2", ",", "All", ",", "1"}], "]"}], "]"}]}]}], ";", 
            "\[IndentingNewLine]", "\[IndentingNewLine]", 
            RowBox[{"KeyName", "\[Rule]", 
             RowBox[{"If", "[", 
              RowBox[{
               RowBox[{"AssociationQ", "[", 
                RowBox[{
                 RowBox[{"data", "[", 
                  RowBox[{"[", "1", "]"}], "]"}], "[", "KeyName", "]"}], 
                "]"}], ",", "\[IndentingNewLine]", 
               RowBox[{"MapSubAssoc", "[", 
                RowBox[{"f", ",", 
                 RowBox[{
                  RowBox[{"data", "[", 
                   RowBox[{"[", "1", "]"}], "]"}], "[", "KeyName", "]"}], ",",
                  "Res"}], "]"}], ",", "\[IndentingNewLine]", 
               RowBox[{"f", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"data", "[", 
                   RowBox[{"[", "1", "]"}], "]"}], "[", "KeyName", "]"}], ",",
                  "Res"}], "]"}]}], "\[IndentingNewLine]", "]"}]}]}], 
           "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}], 
        "&"}], "/@", 
       RowBox[{"Keys", "[", 
        RowBox[{"data", "[", 
         RowBox[{"[", "1", "]"}], "]"}], "]"}]}], ")"}]}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MapSubAssoc", "[", 
     RowBox[{"f_", ",", "data0_", ",", "data_"}], "]"}], ":=", 
    RowBox[{"Association", "@", 
     RowBox[{"(", 
      RowBox[{
       RowBox[{
        RowBox[{"Module", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"KeyName", ",", "Res"}], "}"}], ",", "\[IndentingNewLine]", 
          RowBox[{"(", "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"KeyName", "=", "#"}], ";", "\[IndentingNewLine]", 
            RowBox[{"Res", "=", 
             RowBox[{
              RowBox[{
               RowBox[{"#", "[", "KeyName", "]"}], "&"}], "/@", "data"}]}], 
            ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
            RowBox[{"KeyName", "\[Rule]", 
             RowBox[{"If", "[", 
              RowBox[{
               RowBox[{"AssociationQ", "[", 
                RowBox[{"data0", "[", "KeyName", "]"}], "]"}], ",", 
               "\[IndentingNewLine]", 
               RowBox[{"MapSubAssoc", "[", 
                RowBox[{"f", ",", 
                 RowBox[{"data0", "[", "KeyName", "]"}], ",", "Res"}], "]"}], 
               ",", "\[IndentingNewLine]", 
               RowBox[{"f", "[", 
                RowBox[{
                 RowBox[{"data0", "[", "KeyName", "]"}], ",", "Res"}], 
                "]"}]}], "\[IndentingNewLine]", "]"}]}]}], 
           "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}], 
        "&"}], "/@", 
       RowBox[{"Keys", "[", "data0", "]"}]}], ")"}]}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"CheckResultForm", "[", "res_", "]"}], ":=", 
    RowBox[{"If", "[", 
     RowBox[{
      RowBox[{"MatchQ", "[", 
       RowBox[{"res", ",", 
        RowBox[{
         RowBox[{"(", 
          RowBox[{"_Real", "|", "_Integer", "|", "_Rational"}], ")"}], "|", 
         RowBox[{"(", 
          RowBox[{"<|", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"_", "\[Rule]", 
              RowBox[{
              "_Real", "|", "_Integer", "|", "_Rational", "|", 
               "_Association"}]}], ")"}], "..."}], "|>"}], ")"}], "|", 
         RowBox[{"(", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"_Real", "|", "_Integer", "|", "_Rational"}], ")"}], 
            "..."}], "}"}], ")"}]}]}], 
       RowBox[{"(*", 
        RowBox[{"(", 
         RowBox[{"x_", "/;", 
          RowBox[{"(", 
           RowBox[{
            RowBox[{"ListQ", "[", "x", "]"}], "&&", 
            RowBox[{"ArrayQ", "[", "x", "]"}]}], ")"}]}], ")"}], "*)"}], 
       "]"}], ",", "True", ",", 
      RowBox[{"ErrorMessage", "[", 
       RowBox[{"MonteCarloResult", "::", "resultform"}], "]"}]}], "]"}]}], 
   ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"CheckNormality", "[", "data_", "]"}], ":=", 
    RowBox[{"If", "[", 
     RowBox[{
      RowBox[{
       RowBox[{"DistributionFitTest", "[", "data", "]"}], "<", 
       RowBox[{"(", 
        RowBox[{"1", "-", "$ConfidenceLevel"}], ")"}]}], ",", 
      RowBox[{"Message", "[", 
       RowBox[{"MonteCarloResult", "::", "notnormal"}], "]"}]}], "]"}]}], 
   ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"QuantileCI", "[", "data_", "]"}], ":=", 
    RowBox[{"Quantile", "[", 
     RowBox[{"data", ",", 
      RowBox[{"{", 
       RowBox[{
        RowBox[{
         RowBox[{"(", 
          RowBox[{"1", "-", "$ConfidenceLevel"}], ")"}], "/", "2"}], ",", 
        RowBox[{"1", "-", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"1", "-", "$ConfidenceLevel"}], ")"}], "/", "2"}]}]}], 
       "}"}]}], "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"QuantileMeanRelCI", "[", "data_", "]"}], ":=", 
   RowBox[{"Abs", "[", 
    RowBox[{
     RowBox[{"Quantile", "[", 
      RowBox[{"data", ",", 
       RowBox[{"{", 
        RowBox[{
         RowBox[{
          RowBox[{"(", 
           RowBox[{"1", "-", "$ConfidenceLevel"}], ")"}], "/", "2"}], ",", 
         RowBox[{"1", "-", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{"1", "-", "$ConfidenceLevel"}], ")"}], "/", "2"}]}]}], 
        "}"}]}], "]"}], "-", 
     RowBox[{"Mean", "[", "data", "]"}]}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"(*", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", "BootSample", "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"BootSample", "=", 
        RowBox[{"Table", "[", 
         RowBox[{
          RowBox[{"Mean", "[", 
           RowBox[{"RandomChoice", "[", 
            RowBox[{"data", ",", 
             RowBox[{"Length", "@", "data"}]}], "]"}], "]"}], ",", 
          RowBox[{"{", "n", "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"Abs", "[", 
        RowBox[{
         RowBox[{"Quantile", "[", 
          RowBox[{"BootSample", ",", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{"1", "-", "$ConfidenceLevel"}], ")"}], "/", "2"}], ",", 
             RowBox[{"1", "-", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"1", "-", "$ConfidenceLevel"}], ")"}], "/", "2"}]}]}],
             "}"}]}], "]"}], "-", 
         RowBox[{"Mean", "[", "BootSample", "]"}]}], "]"}]}], 
      "\[IndentingNewLine]", ")"}]}], "]"}], "*)"}]}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"f9fabc4a-7b46-4f2f-a35f-c7ec826895a0"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"Options", "[", "MCEvaluate", "]"}], "=", 
    RowBox[{"Options", "[", "MonteCarloSimulation", "]"}]}], ";"}], 
  "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"MCEvaluate", ",", "HoldFirst"}], "]"}], ";"}], "*)"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"MCEvaluate", "::", "usage"}], "=", 
   "\"\<MCEvaluate[expr] evaluates expr while propagating errors in NDV \
values using a Monte Carlo simulation with 1000 iterations.\n\
MCEvaluate[expr,i] evaluates expr while propagating errors in NDV values \
using a Monte Carlo simulation with i iterations.\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MCEvaluate", "[", 
     RowBox[{"expr_", ",", 
      RowBox[{"i_:", "10000"}], ",", 
      RowBox[{"opts", ":", 
       RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
    RowBox[{
     RowBox[{"MonteCarloSimulation", "[", 
      RowBox[{"expr", ",", "i", ",", 
       RowBox[{"{", "}"}], ",", "opts"}], "]"}], "[", "\"\<SingleMeanDV\>\"", 
     "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"Options", "[", "MCE", "]"}], "=", 
    RowBox[{"Options", "[", "MCEvaluate", "]"}]}], ";"}], 
  "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{"SetAttributes", "[", 
     RowBox[{"MCE", ",", "HoldFirst"}], "]"}], ";"}], 
   "*)"}]}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"MCE", "[", 
    RowBox[{"expr_", ",", 
     RowBox[{"i_:", "1000"}], ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
   RowBox[{"MCEvaluate", "[", 
    RowBox[{"expr", ",", "i", ",", "opts"}], "]"}]}], ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"75d7004c-21a1-4651-9379-0d64be44fbc9"]
}, Open  ]]
}, Open  ]],

Cell[CellGroupData[{

Cell["Inverse error propagation (EffectiveVarianceFit)", "Subsection"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"Options", "[", "EffectiveVarianceFit", "]"}], "=", 
    RowBox[{"Options", "[", "NonlinearModelFit", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"EffectiveVarianceFit", "::", "usage"}], "=", 
   "\"\<EffectiveVarianceFit[{{\!\(\*SubscriptBox[\(x\), \
\(11\)]\),\!\(\*SubscriptBox[\(x\), \(12\)]\),\[Ellipsis],\!\(\*SubscriptBox[\
\(y\), \(1\)]\)},{\!\(\*SubscriptBox[\(x\), \
\(21\)]\),\!\(\*SubscriptBox[\(x\), \(22\)]\),\[Ellipsis],\!\(\*SubscriptBox[\
\(y\), \(2\)]\)},\[Ellipsis]},{{s\!\(\*SubscriptBox[\(x\), \
\(11\)]\),s\!\(\*SubscriptBox[\(x\), \
\(12\)]\),\[Ellipsis],s\!\(\*SubscriptBox[\(y\), \
\(1\)]\)},{s\!\(\*SubscriptBox[\(x\), \(21\)]\),s\!\(\*SubscriptBox[\(x\), \
\(22\)]\),\[Ellipsis],s\!\(\*SubscriptBox[\(y\), \
\(2\)]\)},\[Ellipsis]},form,{\!\(\*SubscriptBox[\(\[Beta]\), \(1\)]\),\
\[Ellipsis]},{\!\(\*SubscriptBox[\(x\), \(1\)]\),\[Ellipsis]},i] constructs a \
nonlinear model with structure form where form depends on variables \
\!\(\*SubscriptBox[\(x\), \(i\)]\) using the parameters \!\(\*SubscriptBox[\(\
\[Beta]\), \(i\)]\). An effective variance technique is used to fit the data \
using errors \!\(\*SubscriptBox[\(sx\), \(ij\)]\) and \!\(\*SubscriptBox[\(sy\
\), \(j\)]\) in the data points \!\(\*SubscriptBox[\(x\), \(ij\)]\) and \
\!\(\*SubscriptBox[\(y\), \(j\)]\) using i iterations.\n\
EffectiveVarianceFit[datatable,form,{\!\(\*SubscriptBox[\(\[Beta]\), \
\(1\)]\),\[Ellipsis]},{\!\(\*SubscriptBox[\(x\), \(1\)]\),\[Ellipsis]},i] \
constructs a nonlinear model with structure form where form depends on \
variables \!\(\*SubscriptBox[\(x\), \(i\)]\) using the parameters \
\!\(\*SubscriptBox[\(\[Beta]\), \(i\)]\). An effective variance technique is \
used to fit the values and errors in the DataTable using i iterations.\n\
\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"EffectiveVarianceFit", "[", 
     RowBox[{
     "data_List", ",", "errors_List", ",", "form_", ",", "params_", ",", 
      "vars_", ",", "runs_", ",", 
      RowBox[{"opts", ":", 
       RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
    RowBox[{"Module", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"YErrors", ",", "FitRes", ",", "DSquares"}], "}"}], ",", 
      "\[IndentingNewLine]", 
      RowBox[{"(", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"YErrors", "=", 
         RowBox[{"errors", "[", 
          RowBox[{"[", 
           RowBox[{"All", ",", 
            RowBox[{"-", "1"}]}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", 
        RowBox[{"Do", "[", 
         RowBox[{
          RowBox[{"(", "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"FitRes", "=", 
             RowBox[{"NonlinearModelFit", "[", 
              RowBox[{
              "data", ",", "form", ",", "params", ",", "vars", ",", "opts", 
               ",", 
               RowBox[{"VarianceEstimatorFunction", "\[Rule]", 
                RowBox[{"(", 
                 RowBox[{"1", "&"}], ")"}]}], ",", 
               RowBox[{"Weights", "\[Rule]", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"1", "/", 
                    RowBox[{"#", "^", "2"}]}], "&"}], "/@", "YErrors"}], 
                 ")"}]}]}], "]"}]}], ";", "\[IndentingNewLine]", 
            "\[IndentingNewLine]", 
            RowBox[{"DSquares", "=", 
             RowBox[{
              RowBox[{
               RowBox[{"(", 
                RowBox[{
                 RowBox[{"D", "[", 
                  RowBox[{
                   RowBox[{
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"ListQ", "@", "form"}], ",", 
                    RowBox[{"form", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", "form"}], "]"}], "/.", 
                    RowBox[{
                    "FitRes", "[", "\"\<BestFitParameters\>\"", "]"}]}], ",", 
                   "#"}], "]"}], "^", "2"}], ")"}], "&"}], "/@", "vars"}]}], 
            ";", "\[IndentingNewLine]", 
            RowBox[{"DSquares", "=", 
             RowBox[{"(", 
              RowBox[{
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"#", "*", "DSquares"}], ")"}], "&"}], "/@", 
               RowBox[{"(", 
                RowBox[{
                 RowBox[{"errors", "[", 
                  RowBox[{"[", 
                   RowBox[{"All", ",", 
                    RowBox[{";;", 
                    RowBox[{"-", "2"}]}]}], "]"}], "]"}], "^", "2"}], ")"}]}],
               ")"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
            RowBox[{"DSquares", "=", 
             RowBox[{"MapThread", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"#1", "/.", "#2"}], "&"}], ",", 
               RowBox[{"{", "\[IndentingNewLine]", 
                RowBox[{"DSquares", ",", "\[IndentingNewLine]", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"MapThread", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"#1", "\[Rule]", "#2"}], "&"}], ",", 
                    RowBox[{"{", 
                    RowBox[{"vars", ",", 
                    RowBox[{"#", "//", "Most"}]}], "}"}]}], "]"}], "&"}], "/@",
                   "data"}]}], "\[IndentingNewLine]", "}"}]}], "]"}]}], ";", 
            "\[IndentingNewLine]", "\[IndentingNewLine]", 
            RowBox[{"YErrors", "=", 
             RowBox[{"MapThread", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"Sqrt", "[", 
                 RowBox[{"#1", "+", "#2"}], "]"}], "&"}], ",", 
               RowBox[{"{", 
                RowBox[{
                 RowBox[{
                  RowBox[{"errors", "[", 
                   RowBox[{"[", 
                    RowBox[{"All", ",", 
                    RowBox[{"-", "1"}]}], "]"}], "]"}], "^", "2"}], ",", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{
                    RowBox[{"Plus", "@@", "#"}], "&"}], "/@", "DSquares"}], 
                  ")"}]}], "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", 
           ")"}], ",", 
          RowBox[{"{", "runs", "}"}]}], "]"}], ";", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", "FitRes"}], "\[IndentingNewLine]", ")"}]}], 
     "\[IndentingNewLine]", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"EffectiveVarianceFit", "::", "noerror"}], "=", 
   "\"\<Some of the input data are not NDV items.\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"EffectiveVarianceFit", "[", 
    RowBox[{
    "tbl_DataTable", ",", "form_", ",", "params_", ",", "vars_", ",", "runs_",
      ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
   RowBox[{"Module", "[", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"Dat", ",", "VarMap", ",", "FitRes"}], "}"}], ",", 
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Dat", "=", 
        RowBox[{"tbl", "[", 
         RowBox[{"All", ",", 
          RowBox[{"Append", "[", 
           RowBox[{"vars", ",", 
            RowBox[{"Last", "@", 
             RowBox[{"ColNames", "@", "tbl"}]}]}], "]"}]}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"Dat", "=", 
        RowBox[{"Dat", "[", 
         RowBox[{
          RowBox[{"Select", "[", 
           RowBox[{"#", ",", 
            RowBox[{
             RowBox[{"MatchQ", "[", 
              RowBox[{"#", ",", 
               RowBox[{"<|", 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"_", "\[Rule]", 
                   RowBox[{"_", "?", "NumericDVQ"}]}], ")"}], ".."}], 
                "|>"}]}], "]"}], "&"}]}], "]"}], "&"}], "]"}]}], ";", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"VarMap", "=", 
        RowBox[{
         RowBox[{
          RowBox[{"#", "\[Rule]", 
           RowBox[{"VarKey", "[", "#", "]"}]}], "&"}], "/@", "vars"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"Unprotect", "[", "DataAnalysis`VarKey", "]"}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"FitRes", "=", 
        RowBox[{"EffectiveVarianceFit", "[", 
         RowBox[{
          RowBox[{"NV", "@", 
           RowBox[{"Dat", "[", 
            RowBox[{"All", ",", "All", ",", "DVMeans"}], "]"}]}], ",", 
          RowBox[{"NV", "@", 
           RowBox[{"Dat", "[", 
            RowBox[{"All", ",", "All", ",", 
             RowBox[{
              RowBox[{"If", "[", 
               RowBox[{
                RowBox[{
                 RowBox[{"Head", "[", "#", "]"}], "===", "NDV"}], ",", 
                RowBox[{"DVSEs", "@", "#"}], ",", 
                RowBox[{"ErrorMessage", "[", 
                 RowBox[{"EffectiveVarianceFit", "::", "noerror"}], "]"}]}], 
               "]"}], "&"}]}], "]"}]}], ",", 
          RowBox[{"form", "/.", "VarMap"}], ",", "params", ",", 
          RowBox[{"vars", "/.", "VarMap"}], ",", "runs", ",", "opts"}], 
         "]"}]}], ";", "\[IndentingNewLine]", "FitRes"}], 
      "\[IndentingNewLine]", ")"}]}], "]"}]}], ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"7f3b9870-4bb5-4c73-ad90-41f778a6fb67"]
}, Open  ]],

Cell[CellGroupData[{

Cell["Basic error propagation rules (not in use)", "Subsection"],

Cell[CellGroupData[{

Cell["Independent variables", "Subsubsection"],

Cell[BoxData[
 RowBox[{"(*", 
  RowBox[{"(*", " ", "Addition", " ", "*)"}], "\[IndentingNewLine]", 
  RowBox[{
   RowBox[{
    RowBox[{"Plus", "[", 
     RowBox[{
      RowBox[{"EV", "[", 
       RowBox[{"v1_", ",", "s1_"}], "]"}], ",", 
      RowBox[{"EV", "[", 
       RowBox[{"v2_", ",", "s2_"}], "]"}]}], "]"}], "^:=", 
    "\[IndentingNewLine]", 
    RowBox[{"EV", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"v1", "+", "v2"}], ",", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Sqrt", "[", 
        RowBox[{
         RowBox[{"s1", "^", "2"}], "+", 
         RowBox[{"s2", "^", "2"}]}], "]"}], "//", "N"}]}], 
     "\[IndentingNewLine]", "]"}]}], ";", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Plus", "[", 
     RowBox[{
      RowBox[{"v1_", "?", 
       RowBox[{"(", 
        RowBox[{
         RowBox[{"MatchQ", "[", 
          RowBox[{
           RowBox[{"N", "[", "#", "]"}], ",", 
           RowBox[{"_Integer", "|", "_Rational", "|", "_Real"}]}], "]"}], 
         "&"}], ")"}]}], ",", 
      RowBox[{"EV", "[", 
       RowBox[{"v2_", ",", "s2_", ",", "n2_"}], "]"}]}], "]"}], "^:=", 
    "\[IndentingNewLine]", 
    RowBox[{"EV", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"v1", "+", "v2"}], ",", "\[IndentingNewLine]", "s2"}], 
     "\[IndentingNewLine]", "]"}]}], ";", "\[IndentingNewLine]", 
   "\[IndentingNewLine]", 
   RowBox[{"(*", " ", "Multiplication", " ", "*)"}], "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Times", "[", 
     RowBox[{
      RowBox[{"EV", "[", 
       RowBox[{"v1_", ",", "s1_"}], "]"}], ",", 
      RowBox[{"EV", "[", 
       RowBox[{"v2_", ",", "s2_"}], "]"}]}], "]"}], "^:=", 
    "\[IndentingNewLine]", 
    RowBox[{"EV", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"v1", "*", "v2"}], ",", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Abs", "[", 
        RowBox[{"v1", "*", "v2"}], "]"}], "*", 
       RowBox[{"Sqrt", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"(", 
           RowBox[{"s1", "/", "v1"}], ")"}], "^", "2"}], "+", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"s2", "/", "v2"}], ")"}], "^", "2"}]}], "]"}]}]}], 
     "\[IndentingNewLine]", "]"}]}], ";", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Times", "[", 
     RowBox[{
      RowBox[{"v1_", "?", 
       RowBox[{"(", 
        RowBox[{
         RowBox[{"MatchQ", "[", 
          RowBox[{
           RowBox[{"N", "[", "#", "]"}], ",", 
           RowBox[{"_Integer", "|", "_Rational", "|", "_Real"}]}], "]"}], 
         "&"}], ")"}]}], ",", 
      RowBox[{"EV", "[", 
       RowBox[{"v2_", ",", "s2_", ",", "n2_"}], "]"}]}], "]"}], "^:=", 
    "\[IndentingNewLine]", 
    RowBox[{"EV", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"v1", "*", "v2"}], ",", "\[IndentingNewLine]", 
      RowBox[{"N", "[", 
       RowBox[{
        RowBox[{"Abs", "[", "v1", "]"}], "*", "s2"}], "]"}]}], 
     "\[IndentingNewLine]", "]"}]}], ";", "\[IndentingNewLine]", 
   "\[IndentingNewLine]", 
   RowBox[{"(*", " ", "Power", " ", "*)"}], "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Power", "[", 
     RowBox[{
      RowBox[{"EV", "[", 
       RowBox[{"v1_", ",", "s1_"}], "]"}], ",", 
      RowBox[{"EV", "[", 
       RowBox[{"v2_", ",", "s2_"}], "]"}]}], "]"}], "^:=", 
    "\[IndentingNewLine]", 
    RowBox[{"EV", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"v1", "^", "v2"}], ",", "\[IndentingNewLine]", 
      RowBox[{"N", "[", 
       RowBox[{
        RowBox[{"Abs", "[", 
         RowBox[{"v1", "^", "v2"}], "]"}], "*", 
        RowBox[{"Sqrt", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             RowBox[{"v2", "/", "v1"}], "*", "s1"}], ")"}], "^", "2"}], "+", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             RowBox[{"Log", "[", "v1", "]"}], "*", "s2"}], ")"}], "^", 
           "2"}]}], "]"}]}], "]"}]}], "\[IndentingNewLine]", "]"}]}], ";", 
   "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Power", "[", 
     RowBox[{
      RowBox[{"EV", "[", 
       RowBox[{"v1_", ",", "s1_"}], "]"}], ",", 
      RowBox[{"c_", "?", 
       RowBox[{"(", 
        RowBox[{
         RowBox[{"MatchQ", "[", 
          RowBox[{
           RowBox[{"N", "[", "#", "]"}], ",", 
           RowBox[{"_Integer", "|", "_Rational", "|", "_Real"}]}], "]"}], 
         "&"}], ")"}]}]}], "]"}], "^:=", "\[IndentingNewLine]", 
    RowBox[{"EV", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"v1", "^", "c"}], ",", "\[IndentingNewLine]", 
      RowBox[{"N", "[", 
       RowBox[{"Abs", "[", 
        RowBox[{
         RowBox[{"v1", "^", "c"}], "*", "c", "*", 
         RowBox[{"s1", "/", "v1"}]}], "]"}], "]"}]}], "\[IndentingNewLine]", 
     "]"}]}], ";", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Power", "[", 
     RowBox[{
      RowBox[{"c_", "?", 
       RowBox[{"(", 
        RowBox[{
         RowBox[{"MatchQ", "[", 
          RowBox[{
           RowBox[{"N", "[", "#", "]"}], ",", 
           RowBox[{"_Integer", "|", "_Rational", "|", "_Real"}]}], "]"}], 
         "&"}], ")"}]}], ",", 
      RowBox[{"EV", "[", 
       RowBox[{"v1_", ",", "s1_"}], "]"}]}], "]"}], "^:=", 
    "\[IndentingNewLine]", 
    RowBox[{"EV", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"c", "^", "v1"}], ",", "\[IndentingNewLine]", 
      RowBox[{"N", "[", 
       RowBox[{"Abs", "[", 
        RowBox[{
         RowBox[{"c", "^", "v1"}], "*", 
         RowBox[{"Log", "[", "c", "]"}], "*", "s1"}], "]"}], "]"}]}], 
     "\[IndentingNewLine]", "]"}]}], ";", "\[IndentingNewLine]", 
   "\[IndentingNewLine]", 
   RowBox[{"(*", " ", "Log", " ", "*)"}], "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Log", "[", 
     RowBox[{"EV", "[", 
      RowBox[{"v1_", ",", "s1_"}], "]"}], "]"}], "^:=", "\[IndentingNewLine]", 
    RowBox[{"EV", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"Log", "[", "v1", "]"}], ",", "\[IndentingNewLine]", 
      RowBox[{"N", "[", 
       RowBox[{"Abs", "[", 
        RowBox[{"s1", "/", "v1"}], "]"}], "]"}]}], "\[IndentingNewLine]", 
     "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
   RowBox[{"(*", " ", 
    RowBox[{"Basic", " ", "trigonometric", " ", "functions"}], " ", "*)"}], 
   "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Sin", "[", 
     RowBox[{"EV", "[", 
      RowBox[{"v1_", ",", "s1_"}], "]"}], "]"}], "^:=", 
    RowBox[{"EV", "[", 
     RowBox[{
      RowBox[{"Sin", "[", "v1", "]"}], ",", 
      RowBox[{"N", "[", 
       RowBox[{"Abs", "[", 
        RowBox[{"s1", "*", 
         RowBox[{"Cos", "[", "v1", "]"}]}], "]"}], "]"}]}], "]"}]}], ";", 
   "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Cos", "[", 
     RowBox[{"EV", "[", 
      RowBox[{"v1_", ",", "s1_"}], "]"}], "]"}], "^:=", 
    RowBox[{"EV", "[", 
     RowBox[{
      RowBox[{"Cos", "[", "v1", "]"}], ",", 
      RowBox[{"N", "[", 
       RowBox[{"Abs", "[", 
        RowBox[{"s1", "*", 
         RowBox[{"Sin", "[", "v1", "]"}]}], "]"}], "]"}]}], "]"}]}], ";", 
   "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"Tan", "[", 
     RowBox[{"EV", "[", 
      RowBox[{"v1_", ",", "s1_"}], "]"}], "]"}], "^:=", 
    RowBox[{"EV", "[", 
     RowBox[{
      RowBox[{"Tan", "[", "v1", "]"}], ",", 
      RowBox[{"N", "[", 
       RowBox[{"s1", "*", 
        RowBox[{
         RowBox[{"Abs", "[", 
          RowBox[{"Sec", "[", "v1", "]"}], "]"}], "^", "2"}]}], "]"}]}], 
     "]"}]}], ";"}], "*)"}]], "Input",
 InitializationCell->True]
}, Open  ]],

Cell[CellGroupData[{

Cell["Named variables", "Subsubsection"],

Cell[BoxData[
 RowBox[{
  RowBox[{"(*", " ", "Assignments", " ", "*)"}], "\[IndentingNewLine]", 
  "\[IndentingNewLine]", 
  RowBox[{"(*", " ", "Rule", " ", "*)"}], "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{
     RowBox[{"Rule", "[", 
      RowBox[{"lhs_", ",", 
       RowBox[{"EV", "[", 
        RowBox[{"v_", ",", "s_"}], "]"}]}], "]"}], "^:=", 
     RowBox[{"Rule", "[", 
      RowBox[{"lhs", ",", 
       RowBox[{"EV", "[", 
        RowBox[{"v", ",", "s", ",", 
         RowBox[{"Unique", "[", "Global`ev", "]"}]}], "]"}]}], "]"}]}], ";"}],
    "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
  RowBox[{"(*", " ", "Replace", " ", "*)"}], "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{
     RowBox[{"ReplaceAll", "[", 
      RowBox[{"expr_", ",", 
       RowBox[{"EVRules", "[", "rules__", "]"}]}], "]"}], "^:=", 
     "\[IndentingNewLine]", 
     RowBox[{"Module", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"ValueRuleList", ",", "Err"}], "}"}], ",", 
       "\[IndentingNewLine]", 
       RowBox[{"(", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"ValueRuleList", "=", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{"List", "@", "rules"}], ")"}], "/.", 
           RowBox[{
            RowBox[{"EV", "[", 
             RowBox[{"v_", ",", "s_", ",", "n_"}], "]"}], "\[RuleDelayed]", 
            "v"}]}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
         RowBox[{"Err", "=", 
          RowBox[{
           RowBox[{"Sqrt", "[", 
            RowBox[{"Plus", "@@", 
             RowBox[{"Map", "[", "\[IndentingNewLine]", 
              RowBox[{
               RowBox[{
                RowBox[{
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"D", "[", 
                    RowBox[{"expr", ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}], "]"}], "/.", 
                    "ValueRuleList"}], ")"}], "^", "2"}], "*", 
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], "/.", 
                    RowBox[{
                    RowBox[{"EV", "[", 
                    RowBox[{"v_", ",", "s_", ",", "n_"}], "]"}], 
                    "\[RuleDelayed]", "s"}]}], ")"}], "^", "2"}]}], "&"}], 
               ",", "\[IndentingNewLine]", 
               RowBox[{"Cases", "[", 
                RowBox[{
                 RowBox[{"List", "@", "rules"}], ",", 
                 RowBox[{"HoldPattern", "[", 
                  RowBox[{"_", "\[Rule]", 
                   RowBox[{"EV", "[", "___", "]"}]}], "]"}]}], "]"}]}], 
              "\[IndentingNewLine]", "]"}]}], "]"}], "//", "N"}]}], ";", 
         "\[IndentingNewLine]", "\[IndentingNewLine]", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"Err", "\[Equal]", "0"}], ",", "\[IndentingNewLine]", 
           RowBox[{"expr", "/.", "ValueRuleList"}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{"EV", "[", "\[IndentingNewLine]", 
            RowBox[{
             RowBox[{"expr", "/.", "ValueRuleList"}], ",", 
             "\[IndentingNewLine]", "Err"}], "\[IndentingNewLine]", "]"}]}], 
          "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", ")"}]}], 
      "\[IndentingNewLine]", "]"}]}], ";", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"ReplaceAll", "[", 
      RowBox[{"expr_", ",", 
       RowBox[{"CorrelatedEVRules", "[", "rules__", "]"}]}], "]"}], "^:=", 
     "\[IndentingNewLine]", 
     RowBox[{"Module", "[", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{"ValueRuleList", ",", "Err"}], "}"}], ",", 
       "\[IndentingNewLine]", 
       RowBox[{"(", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"ValueRuleList", "=", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{"List", "@", "rules"}], ")"}], "/.", 
           RowBox[{
            RowBox[{"EV", "[", 
             RowBox[{"v_", ",", "s_", ",", "n_"}], "]"}], "\[RuleDelayed]", 
            "v"}]}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
         RowBox[{"Err", "=", 
          RowBox[{
           RowBox[{"Sqrt", "[", 
            RowBox[{
             RowBox[{"Plus", "@@", 
              RowBox[{"Map", "[", "\[IndentingNewLine]", 
               RowBox[{
                RowBox[{
                 RowBox[{
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"D", "[", 
                    RowBox[{"expr", ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}], "]"}], "/.", 
                    "ValueRuleList"}], ")"}], "^", "2"}], "*", 
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], "/.", 
                    RowBox[{
                    RowBox[{"EV", "[", 
                    RowBox[{"v_", ",", "s_", ",", "n_"}], "]"}], 
                    "\[RuleDelayed]", "s"}]}], ")"}], "^", "2"}]}], "&"}], 
                ",", "\[IndentingNewLine]", 
                RowBox[{"Cases", "[", 
                 RowBox[{
                  RowBox[{"List", "@", "rules"}], ",", 
                  RowBox[{"HoldPattern", "[", 
                   RowBox[{"_", "\[Rule]", 
                    RowBox[{"EV", "[", "___", "]"}]}], "]"}]}], "]"}]}], 
               "\[IndentingNewLine]", "]"}]}], "+", "\[IndentingNewLine]", 
             RowBox[{"2", "*", 
              RowBox[{"Plus", "@@", 
               RowBox[{"(", 
                RowBox[{
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"D", "[", 
                    RowBox[{"expr", ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "1"}], "]"}], "]"}]}], "]"}], "/.", 
                    "ValueRuleList"}], ")"}], "*", "\[IndentingNewLine]", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"D", "[", 
                    RowBox[{"expr", ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "1"}], "]"}], "]"}]}], "]"}], "/.", 
                    "ValueRuleList"}], ")"}], "*", "\[IndentingNewLine]", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "2"}], "]"}], "]"}], "/.", 
                    "ValueRuleList"}], ")"}], "*", 
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "2"}], "]"}], "]"}], "/.", 
                    "ValueRuleList"}], ")"}]}], ")"}]}], "/.", 
                    RowBox[{
                    RowBox[{"EV", "[", 
                    RowBox[{"v_", ",", "s_", ",", "n_"}], "]"}], 
                    "\[RuleDelayed]", "s"}]}], "\[IndentingNewLine]", 
                   "\[IndentingNewLine]", ")"}], "&"}], "/@", 
                 RowBox[{"Subsets", "[", 
                  RowBox[{
                   RowBox[{"Cases", "[", 
                    RowBox[{
                    RowBox[{"List", "@", "rules"}], ",", 
                    RowBox[{"HoldPattern", "[", 
                    RowBox[{"_", "\[Rule]", 
                    RowBox[{"EV", "[", "___", "]"}]}], "]"}]}], "]"}], ",", 
                   RowBox[{"{", "2", "}"}]}], "]"}]}], ")"}]}]}]}], 
            "\[IndentingNewLine]", "]"}], "//", "N"}]}], ";", 
         "\[IndentingNewLine]", "\[IndentingNewLine]", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"Err", "\[Equal]", "0"}], ",", "\[IndentingNewLine]", 
           RowBox[{"expr", "/.", "ValueRuleList"}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{"EV", "[", "\[IndentingNewLine]", 
            RowBox[{
             RowBox[{"expr", "/.", "ValueRuleList"}], ",", 
             "\[IndentingNewLine]", "Err"}], "\[IndentingNewLine]", "]"}]}], 
          "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", ")"}]}], 
      "\[IndentingNewLine]", "]"}]}], ";"}], "*)"}], "\[IndentingNewLine]", 
  "\[IndentingNewLine]", 
  RowBox[{"(*", " ", "Function", " ", "*)"}], "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{
     RowBox[{
      RowBox[{"Function", "[", "f_", "]"}], "[", 
      RowBox[{"pre___", ",", 
       RowBox[{"EV", "[", 
        RowBox[{"v1_", ",", "s1_"}], "]"}], ",", "suff___"}], "]"}], "^:=", 
     RowBox[{"Module", "[", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"{", 
        RowBox[{
        "Args", ",", "ValueList", ",", "OutF", ",", "EVs", ",", "Expr", ",", 
         "Rules"}], "}"}], ",", "\[IndentingNewLine]", 
       RowBox[{"(", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"Args", "=", 
          RowBox[{"Join", "[", 
           RowBox[{
            RowBox[{"List", "@", "pre"}], ",", 
            RowBox[{"{", 
             RowBox[{"EV", "[", 
              RowBox[{"v1", ",", "s1"}], "]"}], "}"}], ",", 
            RowBox[{"List", "@", "suff"}]}], "]"}]}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"Args", "=", 
          RowBox[{"Args", "/.", 
           RowBox[{
            RowBox[{"EV", "[", 
             RowBox[{"v_", ",", "s_"}], "]"}], "\[RuleDelayed]", 
            RowBox[{"EV", "[", 
             RowBox[{"v", ",", "s", ",", 
              RowBox[{"Unique", "[", "Global`ev", "]"}]}], "]"}]}]}]}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"(*", 
          RowBox[{
           RowBox[{"ValueArgList", "=", 
            RowBox[{"Args", "/.", 
             RowBox[{
              RowBox[{"EV", "[", 
               RowBox[{"v_", ",", "s_"}], "]"}], "\[RuleDelayed]", "v"}]}]}], 
           ";", "\[IndentingNewLine]", 
           RowBox[{"IDList", "=", 
            RowBox[{"Table", "[", 
             RowBox[{
              RowBox[{"Unique", "[", "ev", "]"}], ",", 
              RowBox[{"{", 
               RowBox[{"Count", "[", 
                RowBox[{"Args", ",", "_EV"}], "]"}], "}"}]}], "]"}]}], ";"}], 
          "*)"}], "\[IndentingNewLine]", 
         RowBox[{"(*", 
          RowBox[{
           RowBox[{"ValueList", "=", 
            RowBox[{"Args", "/.", 
             RowBox[{
              RowBox[{"EV", "[", 
               RowBox[{"v_", ",", "s_", ",", "n_"}], "]"}], "\[RuleDelayed]", 
              "v"}]}]}], ";"}], "*)"}], "\[IndentingNewLine]", 
         "\[IndentingNewLine]", 
         RowBox[{"OutF", "=", 
          RowBox[{
           RowBox[{"Function", "[", "f", "]"}], "[", 
           RowBox[{"Sequence", "@@", "Args"}], "]"}]}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"EVs", "=", 
          RowBox[{"Cases", "[", 
           RowBox[{"Args", ",", "_EV"}], "]"}]}], ";", "\[IndentingNewLine]", 
         
         RowBox[{"Rules", "=", 
          RowBox[{
           RowBox[{
            RowBox[{"Rule", "[", 
             RowBox[{"#", ",", 
              RowBox[{"Unique", "[", "dvslot", "]"}]}], "]"}], "&"}], "/@", 
           RowBox[{"Cases", "[", 
            RowBox[{"Args", ",", "_EV"}], "]"}]}]}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"OutF", "/.", "Rules"}], "/.", 
          RowBox[{"EVRules", "[", 
           RowBox[{"Sequence", "@@", 
            RowBox[{"(", 
             RowBox[{"Reverse", "/@", "Rules"}], ")"}]}], "]"}]}]}], 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{"EV", "[", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{
            RowBox[{"Function", "[", "f", "]"}], "[", 
            RowBox[{"Sequence", "@@", "ValueList"}], "]"}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{"Sqrt", "[", 
            RowBox[{"Plus", "@@", 
             RowBox[{"Map", "[", "\[IndentingNewLine]", 
              RowBox[{
               RowBox[{
                RowBox[{"(", "\[IndentingNewLine]", 
                 RowBox[{
                  RowBox[{"SlotN", "=", "#"}], ";", "\[IndentingNewLine]", 
                  RowBox[{"(*", 
                   RowBox[{
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"Function", "[", 
                    RowBox[{"D", "[", 
                    RowBox[{"f", ",", 
                    RowBox[{"Slot", "[", "#", "]"}]}], "]"}], "]"}], "[", 
                    RowBox[{"Sequence", "@@", "ValueList"}], "]"}], ")"}], 
                    "^", "2"}], "*", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{"Args", "[", 
                    RowBox[{"[", "#", "]"}], "]"}], "/.", 
                    RowBox[{
                    RowBox[{"EV", "[", 
                    RowBox[{"v_", ",", "s_", ",", "n_"}], "]"}], 
                    "\[RuleDelayed]", "s"}]}], ")"}], "^", "2"}]}], "*)"}], 
                  "\[IndentingNewLine]", 
                  RowBox[{"D", "[", 
                   RowBox[{"f", ",", 
                    RowBox[{"Slot", "[", 
                    RowBox[{"Slot", "[", "1", "]"}], "]"}]}], "]"}]}], 
                 "\[IndentingNewLine]", ")"}], "&"}], ",", 
               "\[IndentingNewLine]", 
               RowBox[{
                RowBox[{"Position", "[", 
                 RowBox[{"Args", ",", "_EV"}], "]"}], "//", "Flatten"}]}], 
              "\[IndentingNewLine]", "]"}]}], "]"}]}], "\[IndentingNewLine]", 
          "]"}], "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{
          RowBox[{"Function", "[", "f", "]"}], "[", 
          RowBox[{"Sequence", "@@", "Args"}], "]"}], "*)"}], 
        "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}], ";"}],
    "*)"}]}]], "Input",
 InitializationCell->True],

Cell[BoxData[
 RowBox[{
  RowBox[{"(*", " ", "Addition", " ", "*)"}], "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{
     RowBox[{"Plus", "[", 
      RowBox[{
       RowBox[{"EV", "[", 
        RowBox[{"v1_", ",", "s1_", ",", "n1_"}], "]"}], ",", 
       RowBox[{"EV", "[", 
        RowBox[{"v1_", ",", "s1_", ",", "n1_"}], "]"}]}], "]"}], "^:=", 
     "\[IndentingNewLine]", 
     RowBox[{"EV", "[", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"2", "*", "v1"}], ",", "\[IndentingNewLine]", 
       RowBox[{"2", "*", "s1"}], ",", "\[IndentingNewLine]", "n1"}], 
      "\[IndentingNewLine]", "]"}]}], ";", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"Plus", "[", 
      RowBox[{
       RowBox[{"v1_", "?", 
        RowBox[{"(", 
         RowBox[{
          RowBox[{"MatchQ", "[", 
           RowBox[{
            RowBox[{"N", "[", "#", "]"}], ",", 
            RowBox[{"_Integer", "|", "_Rational", "|", "_Real"}]}], "]"}], 
          "&"}], ")"}]}], ",", 
       RowBox[{"EV", "[", 
        RowBox[{"v2_", ",", "s2_", ",", "n2_"}], "]"}]}], "]"}], "^:=", 
     "\[IndentingNewLine]", 
     RowBox[{"EV", "[", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"v1", "+", "v2"}], ",", "\[IndentingNewLine]", "s2", ",", 
       "\[IndentingNewLine]", "n2"}], "\[IndentingNewLine]", "]"}]}], ";"}], 
   "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
  RowBox[{"(*", " ", "Multiplication", " ", "*)"}], "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{
     RowBox[{"Times", "[", 
      RowBox[{
       RowBox[{"EV", "[", 
        RowBox[{"v1_", ",", "s1_", ",", "n1_"}], "]"}], ",", 
       RowBox[{"EV", "[", 
        RowBox[{"v1_", ",", "s1_", ",", "n1_"}], "]"}]}], "]"}], "^:=", 
     "\[IndentingNewLine]", 
     RowBox[{"EV", "[", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"v1", "^", "2"}], ",", "\[IndentingNewLine]", 
       RowBox[{"Abs", "[", 
        RowBox[{
         RowBox[{"v1", "^", "2"}], "*", "2", "*", 
         RowBox[{"s1", "/", "v1"}]}], "]"}], ",", "\[IndentingNewLine]", 
       "n1"}], "\[IndentingNewLine]", "]"}]}], ";"}], "*)"}], 
  "\[IndentingNewLine]", "\[IndentingNewLine]", 
  RowBox[{"(*", " ", "Power", " ", "*)"}], "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{
     RowBox[{"Power", "[", 
      RowBox[{
       RowBox[{"EV", "[", 
        RowBox[{"v1_", ",", "s1_", ",", "n1_"}], "]"}], ",", 
       RowBox[{"EV", "[", 
        RowBox[{"v1_", ",", "s1_", ",", "n1_"}], "]"}]}], "]"}], "^:=", 
     "\[IndentingNewLine]", 
     RowBox[{"EV", "[", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"v1", "^", "v2"}], ",", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"Abs", "[", 
         RowBox[{"v1", "^", "v2"}], "]"}], "*", 
        RowBox[{"Sqrt", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             RowBox[{"v2", "/", "v1"}], "*", "s1"}], ")"}], "^", "2"}], "+", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{
             RowBox[{"Log", "[", "v1", "]"}], "*", "s2"}], ")"}], "^", 
           "2"}]}], "]"}]}], ",", "\[IndentingNewLine]", "n1"}], 
      "\[IndentingNewLine]", "]"}]}], ";"}], "*)"}]}]], "Input",
 InitializationCell->True],

Cell[CellGroupData[{

Cell[BoxData[
 RowBox[{
  RowBox[{
   RowBox[{"Abs", "[", 
    RowBox[{"D", "[", 
     RowBox[{
      RowBox[{"ArcSin", "[", "v1", "]"}], ",", "v1"}], "]"}], "]"}], "*", 
   "s1"}], "//", "InputForm"}]], "Input"],

Cell["s1/Sqrt[Abs[1 - v1^2]]", "Output"]
}, Open  ]],

Cell[BoxData[
 RowBox[{
  RowBox[{"(*", 
   RowBox[{
    RowBox[{"EVExpressionQ", "[", "expr_", "]"}], ":=", 
    RowBox[{
     RowBox[{"(", 
      RowBox[{
       RowBox[{"Depth", "[", "expr", "]"}], ">", "2"}], ")"}], "&&", 
     RowBox[{"(", 
      RowBox[{"And", "@@", 
       RowBox[{"(", 
        RowBox[{
         RowBox[{
          RowBox[{"MatchQ", "[", 
           RowBox[{"#", ",", 
            RowBox[{"_Integer", "|", "_Real", "|", 
             RowBox[{"EV", "[", "__", "]"}], "|", 
             RowBox[{"_", "?", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"StringMatchQ", "[", 
                  RowBox[{
                   RowBox[{"ToString", "[", "#", "]"}], ",", 
                   RowBox[{"\"\<ev$\>\"", "~~", "NumberString"}]}], "]"}], 
                 ")"}], "&"}], ")"}]}], "|", "_Plus", "|", "_Times"}]}], 
           "]"}], "&"}], "/@", 
         RowBox[{"(", 
          RowBox[{"Level", "[", 
           RowBox[{"expr", ",", "Infinity"}], "]"}], ")"}]}], ")"}]}], 
      ")"}]}]}], "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{"EVExpressionQ", "[", "expr_", "]"}], ":=", 
    RowBox[{
     RowBox[{"(", 
      RowBox[{
       RowBox[{"Depth", "[", "expr", "]"}], ">", "1"}], ")"}], "&&", 
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{"NumericQ", "[", 
       RowBox[{"expr", "/.", 
        RowBox[{
         RowBox[{"EV", "[", 
          RowBox[{"v_", ",", "s_", ",", "n_"}], "]"}], "\[RuleDelayed]", 
         "v"}]}], "]"}], "\[IndentingNewLine]", ")"}]}]}], "*)"}]}]], "Input",\

 InitializationCell->True]
}, Open  ]]
}, Closed]]
}, Open  ]],

Cell[CellGroupData[{

Cell["DataTable", "Section"],

Cell[CellGroupData[{

Cell["Generate DataTable from data", "Subsection"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"DataTable", "::", "usage"}], "=", 
   "\"\<DataTable[data] represents a structured data table, based on and \
extending the Dataset structure.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"DataTable", "[", "data_Association", "]"}], ":=", 
    RowBox[{"DataTable", "[", 
     RowBox[{"Dataset", "[", "data", "]"}], "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"DataListQ", "[", "tbl_", "]"}], ":=", 
   RowBox[{
    RowBox[{"ArrayQ", "[", 
     RowBox[{"tbl", ",", "2"}], "]"}], "&&", 
    RowBox[{"MatchQ", "[", 
     RowBox[{"tbl", ",", 
      RowBox[{"{", 
       RowBox[{
        RowBox[{"{", "__", "}"}], ".."}], "}"}]}], "]"}]}]}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"DataTable", "::", "wrongdimensions"}], "=", 
   "\"\<The list must a full 2-dimensional array.\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"DataTable", "[", "data_List", "]"}], ":=", 
  RowBox[{"Module", "[", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{
     "Columns", ",", "ID", ",", "IDs", ",", "Out", ",", "FFun", ",", "CheckQ",
       ",", "i"}], "}"}], ",", "\[IndentingNewLine]", 
    RowBox[{"(", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{"!", 
         RowBox[{"DataListQ", "[", "data", "]"}]}], ",", 
        RowBox[{"ErrorMessage", "[", 
         RowBox[{"DataTable", "::", "wrongdimensions"}], "]"}]}], "]"}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Out", "=", 
       RowBox[{"data", "/.", 
        RowBox[{"(", 
         RowBox[{
          RowBox[{"Global`", "\[Placeholder]"}], "\[Rule]", 
          RowBox[{"Missing", "[", "]"}]}], ")"}]}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"Columns", "=", 
       RowBox[{
        RowBox[{"Out", "//", "First"}], "//", "Rest"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"IDs", "=", 
       RowBox[{"{", "}"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       StyleBox["Out",
        ShowSpecialCharacters->False,
        ShowStringCharacters->True,
        NumberMarks->True], 
       StyleBox["=",
        ShowSpecialCharacters->False,
        ShowStringCharacters->True,
        NumberMarks->True], 
       RowBox[{
        RowBox[{
         RowBox[{"(", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"ID", "=", 
            RowBox[{"#", "//", "First"}]}], ";", "\[IndentingNewLine]", 
           RowBox[{"i", "=", "2"}], ";", "\[IndentingNewLine]", 
           RowBox[{"While", "[", 
            RowBox[{
             RowBox[{"MemberQ", "[", 
              RowBox[{"IDs", ",", "ID"}], "]"}], ",", 
             RowBox[{"ID", "=", 
              RowBox[{
               RowBox[{"ToString", "[", "ID", "]"}], "<>", "\"\<-\>\"", "<>", 
               
               RowBox[{"ToString", "[", 
                RowBox[{"i", "++"}], "]"}]}]}]}], "]"}], ";", 
           "\[IndentingNewLine]", 
           RowBox[{"AppendTo", "[", 
            RowBox[{"IDs", ",", "ID"}], "]"}], ";", "\[IndentingNewLine]", 
           RowBox[{"ID", "\[Rule]", 
            RowBox[{"Association", "@", 
             RowBox[{"MapThread", "[", 
              RowBox[{
               RowBox[{
                RowBox[{
                 RowBox[{"ToString", "[", "#1", "]"}], "\[Rule]", "#2"}], 
                "&"}], ",", 
               RowBox[{"{", 
                RowBox[{"Columns", ",", 
                 RowBox[{"#", "//", "Rest"}]}], "}"}]}], "]"}]}]}]}], 
          "\[IndentingNewLine]", ")"}], "&"}], "/@", 
        RowBox[{"Rest", "[", "Out", "]"}]}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"(*", 
       RowBox[{
        RowBox[{
         RowBox[{"CheckQ", "[", "x_", "]"}], ":=", 
         RowBox[{
          RowBox[{"Length", "[", "x", "]"}], "\[Equal]", "1"}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"FFun", "[", 
          RowBox[{"x_", "?", "CheckQ"}], "]"}], ":=", 
         RowBox[{"First", "[", "x", "]"}]}], ";", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", 
        RowBox[{"Out", "=", 
         RowBox[{"Merge", "[", 
          RowBox[{"Out", ",", "FFun"}], "]"}]}], ";", "\[IndentingNewLine]", 
        RowBox[{"Out", "=", 
         RowBox[{"Association", "@", 
          RowBox[{"(", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"Normal", "@", "Out"}], ")"}], "/.", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"HoldPattern", "[", 
               RowBox[{"name_", "\[Rule]", 
                RowBox[{"FFun", "[", "val_", "]"}]}], "]"}], "\[RuleDelayed]", 
              RowBox[{"Sequence", "@@", 
               RowBox[{"MapIndexed", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{
                   RowBox[{
                    RowBox[{"ToString", "[", "name", "]"}], "<>", "\"\<-\>\"",
                     "<>", 
                    RowBox[{"ToString", "[", 
                    RowBox[{"First", "[", "#2", "]"}], "]"}]}], "\[Rule]", 
                   "#1"}], "&"}], ",", "val"}], "]"}]}]}], ")"}]}], ")"}]}]}],
         ";"}], "*)"}], "\[IndentingNewLine]", 
      RowBox[{"Out", "=", 
       RowBox[{"DataTable", "[", 
        RowBox[{"Dataset", "[", 
         RowBox[{"Association", "[", "Out", "]"}], "]"}], "]"}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", "Out"}], 
     "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}]}], "Input",\

 InitializationCell->
  True,ExpressionUUID->"1a5c75c5-cd65-4484-b69c-ba45c2706050"]
}, Open  ]],

Cell[CellGroupData[{

Cell["Map functions to Dataset", "Subsection"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"ProcessingQ", "[", "f_", "]"}], ":=", 
    RowBox[{"Or", "@@", 
     RowBox[{"(", 
      RowBox[{
       RowBox[{
        RowBox[{"(", 
         RowBox[{"(", 
          RowBox[{
           RowBox[{
            RowBox[{"Head", "[", "f", "]"}], "===", "#"}], "||", 
           RowBox[{"f", "===", "#"}]}], ")"}], ")"}], "&"}], "/@", 
       RowBox[{"{", 
        RowBox[{
        "Function", ",", "Map", ",", "MapAt", ",", "MapIndexed", ",", 
         "KeyValueMap", ",", "Apply", ",", "ReplacePart", ",", "ReplaceAll", 
         ",", "Total", ",", "Mean", ",", "Median", ",", "Variance", ",", 
         "StandardDeviation"}], "}"}]}], ")"}]}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"DTPP", "[", "arg_Dataset", "]"}], ":=", 
   RowBox[{"DataTable", "[", "arg", "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"DTPP", "[", "arg_", "]"}], ":=", "arg"}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"DTPQ", "[", 
     RowBox[{"ds_", ",", "ops___"}], "]"}], ":=", 
    RowBox[{"Module", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"{", "OPs", "}"}], ",", "\[IndentingNewLine]", 
      RowBox[{"(", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"OPs", "=", 
         RowBox[{"List", "@", "ops"}]}], ";", "\[IndentingNewLine]", 
        RowBox[{"OPs", "=", 
         RowBox[{"Replace", "[", 
          RowBox[{"OPs", ",", 
           RowBox[{"{", "\[IndentingNewLine]", 
            RowBox[{
             RowBox[{
              RowBox[{"s", ":", 
               RowBox[{"StringExpression", "[", "___", "]"}]}], 
              "\[RuleDelayed]", 
              RowBox[{"KeyFind", "[", "s", "]"}]}], ",", 
             "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"Not", "[", 
               RowBox[{"s", ":", 
                RowBox[{"StringExpression", "[", "___", "]"}]}], "]"}], 
              "\[RuleDelayed]", 
              RowBox[{"KeyExcept", "[", "s", "]"}]}]}], "\[IndentingNewLine]",
             "}"}], ",", 
           RowBox[{"{", "1", "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"Or", "@@", 
           RowBox[{"ProcessingQ", "/@", "OPs"}]}], ",", "\[IndentingNewLine]", 
          RowBox[{"DTPP", "[", 
           RowBox[{"DVEvaluate", "[", 
            RowBox[{"ds", "[", 
             RowBox[{"Sequence", "@@", "OPs"}], "]"}], "]"}], "]"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"DTPP", "[", 
           RowBox[{"ds", "[", 
            RowBox[{"Sequence", "@@", "OPs"}], "]"}], "]"}]}], 
         "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", ")"}]}], 
     "\[IndentingNewLine]", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"Dataset", "[", 
     RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], "^:=", "ds"}], 
   ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Normal", "[", 
    RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], "^:=", 
   RowBox[{"DTPP", "[", 
    RowBox[{"Normal", "[", "ds", "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{
     RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "\[LeftDoubleBracket]", 
     "spec___", "\[RightDoubleBracket]"}], "^:=", 
    RowBox[{"DTPP", "[", 
     RowBox[{"ds", "\[LeftDoubleBracket]", "spec", "\[RightDoubleBracket]"}], 
     "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"UpValues", "[", "DataTable", "]"}], "=", 
    RowBox[{"Join", "[", 
     RowBox[{
      RowBox[{"UpValues", "[", "DataTable", "]"}], ",", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{
        RowBox[{"#", "/.", 
         RowBox[{"{", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{
            RowBox[{"Verbatim", "[", 
             RowBox[{
             "Dataset`Integration`PackagePrivate`ds_Dataset", "?", 
              "Dataset`ValidDatasetQ"}], "]"}], "\[Rule]", 
            RowBox[{"DataTable", "[", "ds_Dataset", "]"}]}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{"Dataset`Integration`PackagePrivate`ds", "\[Rule]", "ds"}],
            ",", "\[IndentingNewLine]", 
           RowBox[{
           "Dataset`Integration`PackagePrivate`rest", "\[Rule]", "rest"}], 
           ",", "\[IndentingNewLine]", 
           RowBox[{
           "Dataset`Integration`PackagePrivate`key", "\[Rule]", "key"}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{
           "Dataset`Integration`PackagePrivate`first", "\[Rule]", "first"}], 
           ",", "\[IndentingNewLine]", 
           RowBox[{
           "Dataset`Integration`PackagePrivate`arg", "\[Rule]", "arg"}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{"Dataset`EvaluateNormal", "\[Rule]", "DTPP"}]}], 
          "\[IndentingNewLine]", "}"}]}], "&"}], "/@", 
       RowBox[{"Cases", "[", 
        RowBox[{
         RowBox[{"UpValues", "[", "Dataset", "]"}], ",", 
         RowBox[{"HoldPattern", "[", 
          RowBox[{
           RowBox[{"(", 
            RowBox[{"(*", 
             RowBox[{"Except", "[", 
              RowBox[{
               RowBox[{"Verbatim", "[", "HoldPattern", "]"}], "[", 
               RowBox[{"(", 
                RowBox[{
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{
                   "Map", "|", "MapAt", "|", "MapIndexed", "|", 
                    "KeyValueMap"}], ")"}], "[", "___", "]"}], "|", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{
                    "Map", "|", "MapAt", "|", "MapIndexed", "|", 
                    "KeyValueMap"}], ")"}], "[", "___", "]"}], "[", "___", 
                  "]"}]}], ")"}], "]"}], "]"}], "*)"}], 
            RowBox[{"_", "\[RuleDelayed]", 
             RowBox[{"Dataset`EvaluateNormal", "[", "_", "]"}]}], ")"}], "|", 
           
           RowBox[{"(", 
            RowBox[{"_", "\[RuleDelayed]", 
             RowBox[{"_", "[", 
              RowBox[{
               RowBox[{"Normal", "[", "_", "]"}], ",", "___"}], "]"}]}], 
            ")"}]}], "]"}]}], "]"}]}]}], "\[IndentingNewLine]", "]"}]}], 
   ";"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{
     RowBox[{"Join", "[", 
      RowBox[{
       RowBox[{"DataTable", "[", "ds_Dataset", "]"}], ",", "rest__"}], "]"}], 
     "^:=", 
     RowBox[{"DTPP", "[", 
      RowBox[{"Join", "[", 
       RowBox[{"ds", ",", "rest"}], "]"}], "]"}]}], ";", 
    "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"Join", "[", 
      RowBox[{"left__", ",", 
       RowBox[{"DataTable", "[", "ds_Dataset", "]"}], ",", "right___"}], 
      "]"}], "^:=", 
     RowBox[{"DTPP", "[", 
      RowBox[{"Join", "[", 
       RowBox[{"left", ",", "ds", ",", "right"}], "]"}], "]"}]}], ";"}], 
   "*)"}], "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{
     RowBox[{"Join", "[", 
      RowBox[{"ms", ":", 
       RowBox[{"DataTable", "[", "ds_Dataset", "]"}]}], "]"}], "^:=", "ms"}], 
    ";"}], "*)"}]}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"JoinAcross", "[", 
     RowBox[{
      RowBox[{"DataTable", "[", "ds1_Dataset", "]"}], ",", 
      RowBox[{"DataTable", "[", "ds2_Dataset", "]"}], ",", "rest___"}], "]"}],
     "^:=", 
    RowBox[{"DTPP", "[", 
     RowBox[{"JoinAcross", "[", 
      RowBox[{"ds1", ",", "ds2", ",", "rest"}], "]"}], "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Map", "[", 
    RowBox[{"first_", ",", 
     RowBox[{"DataTable", "[", "ds_Dataset", "]"}], ",", "rest___"}], "]"}], "^:=", 
   RowBox[{"DTPQ", "[", 
    RowBox[{"Map", "[", 
     RowBox[{"first", ",", "ds", ",", "rest"}], "]"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"MapAt", "[", 
    RowBox[{"first_", ",", 
     RowBox[{"DataTable", "[", "ds_Dataset", "]"}], ",", "rest___"}], "]"}], "^:=", 
   RowBox[{"DTPQ", "[", 
    RowBox[{"MapAt", "[", 
     RowBox[{"first", ",", "ds", ",", "rest"}], "]"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"MapIndexed", "[", 
    RowBox[{"first_", ",", 
     RowBox[{"DataTable", "[", "ds_Dataset", "]"}], ",", "rest___"}], "]"}], "^:=", 
   RowBox[{"DTPQ", "[", 
    RowBox[{"MapIndexed", "[", 
     RowBox[{"first", ",", "ds", ",", "rest"}], "]"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"KeyValueMap", "[", 
    RowBox[{"first_", ",", 
     RowBox[{"DataTable", "[", "ds_Dataset", "]"}], ",", "rest___"}], "]"}], "^:=", 
   RowBox[{"DTPQ", "[", 
    RowBox[{"KeyValueMap", "[", 
     RowBox[{"first", ",", "ds", ",", "rest"}], "]"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Apply", "[", 
    RowBox[{"first_", ",", 
     RowBox[{"DataTable", "[", "ds_Dataset", "]"}], ",", "rest___"}], "]"}], "^:=", 
   RowBox[{"DTPQ", "[", 
    RowBox[{"Apply", "[", 
     RowBox[{"first", ",", "ds", ",", "rest"}], "]"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"ReplacePart", "[", 
    RowBox[{
     RowBox[{"DataTable", "[", "ds_Dataset", "]"}], ",", "rest___"}], "]"}], "^:=", 
   RowBox[{"DTPQ", "[", 
    RowBox[{"ReplacePart", "[", 
     RowBox[{"ds", ",", "rest"}], "]"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{
     RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "/.", "rest___"}], "^:=", 
    
    RowBox[{"DTPQ", "[", 
     RowBox[{"ds", "/.", "rest"}], "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"Map", "[", "arg_", "]"}], "[", 
    RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], "^:=", 
   RowBox[{"DTPQ", "[", 
    RowBox[{"Map", "[", 
     RowBox[{"arg", ",", "ds"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"MapIndexed", "[", "arg_", "]"}], "[", 
    RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], "^:=", 
   RowBox[{"DTPQ", "[", 
    RowBox[{"MapIndexed", "[", 
     RowBox[{"arg", ",", "ds"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"KeyValueMap", "[", "arg_", "]"}], "[", 
    RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], "^:=", 
   RowBox[{"DTPQ", "[", 
    RowBox[{"KeyValueMap", "[", 
     RowBox[{"arg", ",", "ds"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"Apply", "[", "arg_", "]"}], "[", 
    RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], "^:=", 
   RowBox[{"DTPQ", "[", 
    RowBox[{"Apply", "[", 
     RowBox[{"arg", ",", "ds"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"ReplacePart", "[", "arg_", "]"}], "[", 
    RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], "^:=", 
   RowBox[{"DTPQ", "[", 
    RowBox[{"ReplacePart", "[", 
     RowBox[{"arg", ",", "ds"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{
     RowBox[{"ReplaceAll", "[", "arg_", "]"}], "[", 
     RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], "^:=", 
    RowBox[{"DTPQ", "[", 
     RowBox[{"ReplaceAll", "[", 
      RowBox[{"arg", ",", "ds"}], "]"}], "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Total", "[", 
    RowBox[{
     RowBox[{"DataTable", "[", "ds_Dataset", "]"}], ",", "rest___"}], "]"}], "^:=", 
   RowBox[{"DVEvaluate", "[", 
    RowBox[{"Total", "[", 
     RowBox[{
      RowBox[{"Normal", "[", "ds", "]"}], ",", "rest"}], "]"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Mean", "[", 
    RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], "^:=", 
   RowBox[{"DVEvaluate", "[", 
    RowBox[{"Mean", "[", 
     RowBox[{"Normal", "[", "ds", "]"}], "]"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Median", "[", 
    RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], "^:=", 
   RowBox[{"DVEvaluate", "[", 
    RowBox[{"Median", "[", 
     RowBox[{"Normal", "[", "ds", "]"}], "]"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Variance", "[", 
    RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], "^:=", 
   RowBox[{"DVEvaluate", "[", 
    RowBox[{"Variance", "[", 
     RowBox[{"Normal", "[", "ds", "]"}], "]"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"StandardDeviation", "[", 
     RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], "^:=", 
    RowBox[{"DVEvaluate", "[", 
     RowBox[{"StandardDeviation", "[", 
      RowBox[{"Normal", "[", "ds", "]"}], "]"}], "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"DataTable", "/:", 
   RowBox[{
    RowBox[{"Query", "[", "ops___", "]"}], "[", 
    RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], ":=", 
   RowBox[{"DTPQ", "[", 
    RowBox[{"ds", ",", "ops"}], "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "[", "ops___", "]"}], ":=", 
   RowBox[{"DTPQ", "[", 
    RowBox[{"ds", ",", "ops"}], "]"}]}], ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"694c9784-a0cc-4a40-aa27-b4520f5b12b0"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{
     RowBox[{"DataTable", "[", "ds_", "]"}], "[", 
     RowBox[{"op__", ",", 
      RowBox[{"opts", ":", 
       RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
    RowBox[{"Module", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"EVOps", ",", "Out"}], "}"}], ",", "\[IndentingNewLine]", 
      RowBox[{"(", "\[IndentingNewLine]", 
       RowBox[{"(*", 
        RowBox[{
         RowBox[{"EVOps", "=", 
          RowBox[{
           RowBox[{"List", "[", "op", "]"}], "/.", 
           RowBox[{
            RowBox[{"Function", "[", "x_", "]"}], "\[RuleDelayed]", 
            RowBox[{"Function", "[", 
             RowBox[{"DVEvaluate", "[", "x", "]"}], "]"}]}]}]}], ";", 
         "\[IndentingNewLine]", 
         RowBox[{"Out", "=", 
          RowBox[{
           RowBox[{"Dataset", "[", "data", "]"}], "[", 
           RowBox[{"Sequence", "@@", "EVOps"}], "]"}]}], ";"}], "*)"}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"Off", "[", 
         StyleBox[
          RowBox[{"MapAt", "::", "partw"}], "MessageName"], "]"}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"Out", "=", 
         RowBox[{"ds", "[", "op", "]"}]}], ";", "\[IndentingNewLine]", 
        RowBox[{"On", "[", 
         StyleBox[
          RowBox[{"MapAt", "::", "partw"}], "MessageName"], "]"}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{
          RowBox[{"Out", "=", 
           RowBox[{"Map", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"If", "[", 
               RowBox[{
                RowBox[{
                 RowBox[{"ListQ", "[", "#", "]"}], "||", 
                 RowBox[{"AssociationQ", "[", "#", "]"}]}], ",", 
                RowBox[{"DVEvaluate", "/@", "#"}], ",", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"#", "//", "Print"}], ";", 
                  RowBox[{"DVEvaluate", "[", "#", "]"}]}], ")"}]}], "]"}], 
              "&"}], ",", "Out"}], "]"}]}], ";"}], "*)"}], 
        "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{
          RowBox[{"Map", "[", 
           RowBox[{
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{"#", "//", "Print"}], ";", 
               RowBox[{"DVEvaluate", "[", "#", "]"}]}], ")"}], "&"}], ",", 
            "Out", ",", "Infinity"}], "]"}], ";"}], "*)"}], 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"FailureQ", "[", "Out", "]"}], ",", 
          RowBox[{"Return", "[", "Out", "]"}]}], "]"}], ";", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{"(*", 
          RowBox[{"Or", "@@", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{
                 RowBox[{"Head", "[", "#", "]"}], "===", "Function"}], "||", 
                RowBox[{"MatchQ", "[", 
                 RowBox[{"#", ",", 
                  RowBox[{
                  "Total", "|", "Min", "|", "Max", "|", "Mean", "|", "Median",
                    "|", "Quantile", "|", "Histogram", "|", "ListPlot", "|", 
                   RowBox[{"Merge", "[", "__", "]"}], "|", "Catenate", "|", 
                   "Counts", "|", 
                   RowBox[{"CountsBy", "[", "_", "]"}], "|", "CountDistinct", 
                   "|", 
                   RowBox[{"CountDistinctBy", "[", "_", "]"}], "|", 
                   RowBox[{"Query", "[", "___", "]"}]}]}], "]"}]}], 
               "\[IndentingNewLine]", ")"}], "&"}], "/@", 
             RowBox[{"List", "@", "op"}]}], ")"}]}], "*)"}], 
         "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"!", 
           RowBox[{"(", 
            RowBox[{"And", "@@", 
             RowBox[{"(", 
              RowBox[{
               RowBox[{
                RowBox[{"(", "\[IndentingNewLine]", 
                 RowBox[{"MatchQ", "[", 
                  RowBox[{"#", ",", 
                   RowBox[{
                   "All", "|", "_Integer", "|", "_String", "|", "_Span", "|", 
                    "_Key", "|", "Keys", "|", "Values", "|", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{"_Integer", "|", "_String"}], ")"}], "..."}], 
                    "}"}], "|", "_Select", "|", "_SelectFirst", "|", 
                    "_KeySelect", "|", "_KeyMap", "|", "_MaximalBy", "|", 
                    "_MinimalBy", "|", "_SortBy", "|", "_KeySortBy", "|", 
                    "_DeleteDuplicates", "|", "_DeleteDuplicatesBy", "|", 
                    "\[IndentingNewLine]", "DeleteMissing", "|", 
                    "_DeleteMissing"}]}], "]"}], "\[IndentingNewLine]", ")"}],
                 "&"}], "/@", 
               RowBox[{"List", "@", "op"}]}], ")"}]}], ")"}]}], ",", 
          "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"Out", "=", 
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{"AssociationQ", "[", 
               RowBox[{"Normal", "@", "Out"}], "]"}], ",", 
              "\[IndentingNewLine]", 
              RowBox[{
               RowBox[{
                RowBox[{"DVEvaluate", "[", 
                 RowBox[{"#", ",", 
                  RowBox[{"Join", "[", 
                   RowBox[{
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"CorrelatedErrors", "\[Rule]", "False"}], ",", 
                    RowBox[{"AssumeND", "\[Rule]", "True"}]}], "}"}], ",", 
                    RowBox[{"FilterRules", "[", 
                    RowBox[{
                    RowBox[{"{", "opts", "}"}], ",", 
                    RowBox[{"Options", "[", "DVEvaluate", "]"}]}], "]"}]}], 
                   "]"}]}], "]"}], "&"}], "/@", "Out"}], ",", 
              "\[IndentingNewLine]", 
              RowBox[{"DVEvaluate", "[", 
               RowBox[{
                RowBox[{"Evaluate", "[", "Out", "]"}], ",", 
                RowBox[{"Join", "[", 
                 RowBox[{
                  RowBox[{"{", 
                   RowBox[{
                    RowBox[{"CorrelatedErrors", "\[Rule]", "False"}], ",", 
                    RowBox[{"AssumeND", "\[Rule]", "True"}]}], "}"}], ",", 
                  RowBox[{"FilterRules", "[", 
                   RowBox[{
                    RowBox[{"{", "opts", "}"}], ",", 
                    RowBox[{"Options", "[", "DVEvaluate", "]"}]}], "]"}]}], 
                 "]"}]}], "]"}]}], "\[IndentingNewLine]", "]"}]}], ";"}]}], 
         "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{
          RowBox[{"Out", "=", 
           RowBox[{"Map", "[", 
            RowBox[{"ReleaseHold", ",", "Out", ",", 
             RowBox[{"{", "2", "}"}]}], "]"}]}], ";"}], "*)"}], 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{
            RowBox[{"Head", "[", "Out", "]"}], "===", "Dataset"}], ",", 
           RowBox[{"DataTable", "@", 
            RowBox[{"Normal", "@", "Out"}]}], ",", "Out"}], "]"}], "*)"}], 
        "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"Head", "[", "Out", "]"}], "===", "Dataset"}], ",", 
          RowBox[{"DataTable", "[", "Out", "]"}], ",", "Out"}], "]"}]}], 
       "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], 
  "\[IndentingNewLine]", "\[IndentingNewLine]", 
  RowBox[{"(*", 
   RowBox[{
    RowBox[{"Unprotect", "[", "Query", "]"}], ";", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"Options", "[", "Query", "]"}], "=", 
     RowBox[{"{", 
      RowBox[{
       RowBox[{"FailureAction", "\[Rule]", "\"\<Abort\>\""}], ",", 
       RowBox[{"MissingBehavior", "\[Rule]", "Automatic"}], ",", 
       RowBox[{"PartBehavior", "\[Rule]", "Automatic"}], ",", 
       RowBox[{"CorrelatedErrors", "\[Rule]", "False"}], ",", 
       RowBox[{"AssumeND", "\[Rule]", "True"}]}], "}"}]}], ";", 
    "\[IndentingNewLine]", 
    RowBox[{"Protect", "[", "Query", "]"}], ";"}], "*)"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{
     RowBox[{"Query", "[", 
      RowBox[{"op__", ",", 
       RowBox[{"opts", ":", 
        RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], "[", 
     RowBox[{"DataTable", "[", "ds_", "]"}], "]"}], "^:=", 
    "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"DataTable", "[", 
      RowBox[{"ds", ",", "opts"}], "]"}], "[", "op", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Length", "[", 
    RowBox[{"DataTable", "[", "ds_", "]"}], "]"}], "^:=", 
   RowBox[{"Length", "[", "ds", "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Dimensions", "[", 
    RowBox[{"DataTable", "[", "ds_", "]"}], "]"}], "^:=", 
   RowBox[{"Dimensions", "[", "ds", "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Depth", "[", 
    RowBox[{"DataTable", "[", "ds_", "]"}], "]"}], "^:=", 
   RowBox[{"Depth", "[", "ds", "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"ReplaceAll", "[", 
    RowBox[{
     RowBox[{"DataTable", "[", "ds_", "]"}], ",", "rules_"}], "]"}], "^:=", 
   RowBox[{"DataTable", "[", 
    RowBox[{"Dataset", "[", 
     RowBox[{"ReplaceAll", "[", 
      RowBox[{"ds", ",", "rules"}], "]"}], "]"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Transpose", "[", 
    RowBox[{"DataTable", "[", "ds_", "]"}], "]"}], "^:=", 
   RowBox[{"DataTable", "[", 
    RowBox[{"Transpose", "[", "ds", "]"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Normal", "[", 
    RowBox[{"DataTable", "[", "ds_", "]"}], "]"}], "^:=", 
   RowBox[{"Normal", "[", "ds", "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Keys", "[", 
    RowBox[{"DataTable", "[", "ds_", "]"}], "]"}], "^:=", 
   RowBox[{"Keys", "[", "ds", "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Values", "[", 
    RowBox[{"DataTable", "[", "ds_", "]"}], "]"}], "^:=", 
   RowBox[{"Values", "[", "ds", "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Map", "[", 
    RowBox[{"f_", ",", 
     RowBox[{"DataTable", "[", "ds_", "]"}]}], "]"}], "^:=", 
   RowBox[{"DataTable", "[", 
    RowBox[{"Map", "[", 
     RowBox[{"f", ",", "ds"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Map", "[", 
    RowBox[{"f_", ",", 
     RowBox[{"DataTable", "[", "ds_", "]"}], ",", "ls_"}], "]"}], "^:=", 
   RowBox[{"DataTable", "[", 
    RowBox[{"Map", "[", 
     RowBox[{"f", ",", "ds", ",", "ls"}], "]"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Min", "[", 
    RowBox[{"DataTable", "[", "ds_", "]"}], "]"}], "^:=", 
   RowBox[{"Min", "[", "ds", "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Max", "[", 
    RowBox[{"DataTable", "[", "ds_", "]"}], "]"}], "^:=", 
   RowBox[{"Max", "[", "ds", "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"DeleteMissing", "[", 
    RowBox[{"DataTable", "[", "ds_", "]"}], "]"}], "^:=", 
   RowBox[{"DataTable", "[", 
    RowBox[{"DeleteMissing", "[", "ds", "]"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"DeleteMissing", "[", 
    RowBox[{
     RowBox[{"DataTable", "[", "ds_", "]"}], ",", "n_"}], "]"}], "^:=", 
   RowBox[{"DataTable", "[", 
    RowBox[{"DeleteMissing", "[", 
     RowBox[{"ds", ",", "n"}], "]"}], "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"DeleteMissing", "[", 
    RowBox[{
     RowBox[{"DataTable", "[", "ds_", "]"}], ",", "n_", ",", "d_"}], "]"}], "^:=", 
   RowBox[{"DataTable", "[", 
    RowBox[{"DeleteMissing", "[", 
     RowBox[{"ds", ",", "n", ",", "d"}], "]"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"ReplacePart", "[", 
     RowBox[{
      RowBox[{"DataTable", "[", "ds_", "]"}], ",", "args__"}], "]"}], "^:=", 
    RowBox[{"DataTable", "[", 
     RowBox[{"ReplacePart", "[", 
      RowBox[{"ds", ",", "args"}], "]"}], "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Join", "[", 
    RowBox[{"dt0_DataTable", ",", 
     RowBox[{"Longest", "[", "dts__DataTable", "]"}], ",", 
     RowBox[{"n_Integer:", "1"}]}], "]"}], "^:=", 
   RowBox[{"DataTable", "@", 
    RowBox[{"Join", "[", 
     RowBox[{
      RowBox[{"Sequence", "@@", 
       RowBox[{"(", 
        RowBox[{"First", "/@", 
         RowBox[{"Prepend", "[", 
          RowBox[{
           RowBox[{"List", "@", "dts"}], ",", "dt0"}], "]"}]}], ")"}]}], ",", 
      "n"}], "]"}]}]}], ";"}]}], "Input",ExpressionUUID->"e181f1f6-dc6a-429a-\
8264-ef6338c7f8f6"]
}, Open  ]],

Cell[CellGroupData[{

Cell["Additional functions", "Subsection"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"Grid", "[", 
    RowBox[{"dt_DataTable", ",", "args___"}], "]"}], "^:=", 
   RowBox[{"Grid", "[", 
    RowBox[{
     RowBox[{"ToArray", "@", "dt"}], ",", "args"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"Depth", "[", 
     RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], "^:=", 
    RowBox[{"Depth", "[", "ds", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"Join", "[", 
     RowBox[{"dt0_DataTable", ",", 
      RowBox[{"Longest", "[", "dts__DataTable", "]"}], ",", 
      RowBox[{"n_Integer:", "1"}]}], "]"}], "^:=", 
    RowBox[{"(", "\[IndentingNewLine]", 
     RowBox[{"DataTable", "@", 
      RowBox[{"Join", "[", 
       RowBox[{
        RowBox[{"Sequence", "@@", 
         RowBox[{"(", 
          RowBox[{"Dataset", "/@", 
           RowBox[{"Prepend", "[", 
            RowBox[{
             RowBox[{"List", "@", "dts"}], ",", "dt0"}], "]"}]}], ")"}]}], 
        ",", "n"}], "]"}]}], "\[IndentingNewLine]", ")"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"JoinT", "::", "usage"}], "=", 
   "\"\<JoinT[\!\(\*SubscriptBox[\(data\), \(1\)]\),\!\(\*SubscriptBox[\(data\
\), \(2\)]\),...] returns a DataTable, Dataset, Association or List which \
results from first transposing the \!\(\*SubscriptBox[\(data\), \(i\)]\), \
then using Join, and transposing the resulting data object again.\>\""}], ";", 
  RowBox[{
   RowBox[{"JoinT", "[", 
    RowBox[{"dt0_DataTable", ",", 
     RowBox[{"Longest", "[", "dts__DataTable", "]"}], ",", 
     RowBox[{"n_Integer:", "1"}]}], "]"}], ":=", 
   RowBox[{"DataTable", "@", 
    RowBox[{"Normal", "@", 
     RowBox[{"Transpose", "@", 
      RowBox[{"Join", "[", 
       RowBox[{
        RowBox[{"Sequence", "@@", 
         RowBox[{"(", 
          RowBox[{"Transpose", "/@", 
           RowBox[{"Prepend", "[", 
            RowBox[{
             RowBox[{"List", "@", "dts"}], ",", "dt0"}], "]"}]}], ")"}]}], 
        ",", "n"}], "]"}]}]}]}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"JoinT", "[", "dt0_DataTable", "]"}], ":=", "dt0"}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"JoinT", "[", 
     RowBox[{"dt0_Dataset", ",", 
      RowBox[{"Longest", "[", "dts__Dataset", "]"}], ",", 
      RowBox[{"n_Integer:", "1"}]}], "]"}], ":=", 
    RowBox[{"Dataset", "@", 
     RowBox[{"Normal", "@", 
      RowBox[{"Transpose", "@", 
       RowBox[{"Join", "[", 
        RowBox[{
         RowBox[{"Sequence", "@@", 
          RowBox[{"(", 
           RowBox[{"Transpose", "/@", 
            RowBox[{"Prepend", "[", 
             RowBox[{
              RowBox[{"List", "@", "dts"}], ",", "dt0"}], "]"}]}], ")"}]}], 
         ",", "n"}], "]"}]}]}]}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"JoinT", "[", 
    RowBox[{"dt0_Association", ",", 
     RowBox[{"Longest", "[", "dts__Association", "]"}], ",", 
     RowBox[{"n_Integer:", "1"}]}], "]"}], ":=", 
   RowBox[{"Transpose", "@", 
    RowBox[{"Join", "[", 
     RowBox[{
      RowBox[{"Sequence", "@@", 
       RowBox[{"(", 
        RowBox[{"Transpose", "/@", 
         RowBox[{"Prepend", "[", 
          RowBox[{
           RowBox[{"List", "@", "dts"}], ",", "dt0"}], "]"}]}], ")"}]}], ",", 
      "n"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"JoinT", "[", 
    RowBox[{"dt0_List", ",", 
     RowBox[{"Longest", "[", "dts__List", "]"}], ",", 
     RowBox[{"n_Integer:", "1"}]}], "]"}], ":=", 
   RowBox[{"Transpose", "@", 
    RowBox[{"Join", "[", 
     RowBox[{
      RowBox[{"Sequence", "@@", 
       RowBox[{"(", 
        RowBox[{"Transpose", "/@", 
         RowBox[{"Prepend", "[", 
          RowBox[{
           RowBox[{"List", "@", "dts"}], ",", "dt0"}], "]"}]}], ")"}]}], ",", 
      "n"}], "]"}]}]}], ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"bfe1ef11-ddda-4fb7-a28e-c17182acd4a8"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"ToArray", "::", "usage"}], "=", 
   "\"\<ToArray[data] returns a two dimensional List object of the DataTable \
or Dataset.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"ToArray", "[", "ds_Dataset", "]"}], ":=", 
   RowBox[{"Module", "[", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"Dat", ",", "Columns", ",", "Lvls", ",", "TmpDat"}], "}"}], ",", 
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Dat", "=", 
        RowBox[{"Normal", "@", "ds"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"Lvls", "=", 
        RowBox[{"Depth", "[", 
         RowBox[{"DVMeans", "@", "Dat"}], "]"}]}], ";", "\[IndentingNewLine]",
        "\[IndentingNewLine]", 
       RowBox[{"Which", "[", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"Lvls", "<", "3"}], ",", "\[IndentingNewLine]", 
         RowBox[{"Prepend", "[", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"MapThread", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"{", 
               RowBox[{"#1", ",", "#2"}], "}"}], "&"}], ",", 
             RowBox[{"{", 
              RowBox[{
               RowBox[{"Keys", "@", 
                RowBox[{"Normal", "@", "ds"}]}], ",", 
               RowBox[{"Values", "@", 
                RowBox[{"Normal", "@", "ds"}]}]}], "}"}]}], "]"}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{"{", 
            RowBox[{"\"\<ID\>\"", ",", "\"\<Value\>\""}], "}"}]}], 
          "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", 
         "\[IndentingNewLine]", 
         RowBox[{"Lvls", "\[GreaterEqual]", "3"}], ",", 
         RowBox[{"(", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"Columns", "=", 
            RowBox[{"DeleteDuplicates", "@", 
             RowBox[{"Flatten", "[", 
              RowBox[{"Values", "@", 
               RowBox[{"Normal", "@", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"(", "Keys", ")"}], "/@", "Dat"}], ")"}]}]}], 
              "]"}]}]}], ";", "\[IndentingNewLine]", 
           RowBox[{"Prepend", "[", 
            RowBox[{
             RowBox[{"Values", "@", 
              RowBox[{"MapIndexed", "[", 
               RowBox[{
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"Prepend", "[", 
                   RowBox[{
                    RowBox[{"Values", "@", 
                    RowBox[{"Normal", "@", "#1"}]}], ",", 
                    RowBox[{
                    RowBox[{"Normal", "[", "#2", "]"}], "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "1"}], "]"}], "]"}]}], "]"}], ")"}], 
                 "&"}], ",", 
                RowBox[{"Normal", "@", 
                 RowBox[{"ds", "[", 
                  RowBox[{"All", ",", "Columns"}], "]"}]}]}], "]"}]}], ",", 
             RowBox[{"Prepend", "[", 
              RowBox[{"Columns", ",", "\"\<ID\>\""}], "]"}]}], "]"}]}], 
          "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}], 
      "\[IndentingNewLine]", ")"}]}], "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"ToArray", "[", 
    RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], ":=", 
   RowBox[{"ToArray", "[", "ds", "]"}]}], ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"a5efba51-bf4c-473d-abd5-63c655a6be0d"],

Cell[BoxData[
 RowBox[{
  RowBox[{"DefineItemErrors", "[", 
   RowBox[{"data_Association", ",", "errors_Association"}], "]"}], ":=", 
  RowBox[{"Module", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"{", "OutA", "}"}], ",", "\[IndentingNewLine]", 
    RowBox[{"(", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"OutA", "=", "data"}], ";", "\[IndentingNewLine]", 
      RowBox[{"KeyValueMap", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"(", 
          RowBox[{
           RowBox[{
            RowBox[{"OutA", "[", "#1", "]"}], "=", 
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{"NumericQ", "[", 
               RowBox[{"OutA", "[", "#1", "]"}], "]"}], ",", 
              RowBox[{"NDV", "[", 
               RowBox[{
                RowBox[{"OutA", "[", "#1", "]"}], ",", "#2"}], "]"}], ",", 
              RowBox[{"OutA", "[", "#1", "]"}]}], "]"}]}], ";"}], ")"}], 
         "&"}], ",", "errors"}], "]"}], ";", "\[IndentingNewLine]", "OutA"}], 
     "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}]], "Input",\

 InitializationCell->
  True,ExpressionUUID->"9195cd2d-1e43-4e7e-af40-bb5eb689d99c"]
}, Open  ]],

Cell[CellGroupData[{

Cell["Display", "Subsection"],

Cell[BoxData[
 RowBox[{
  RowBox[{"(*", 
   RowBox[{"If", "[", 
    RowBox[{
     RowBox[{"$VersionNumber", "\[GreaterEqual]", "11"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"MakeBoxes", "[", 
       RowBox[{"tbl_DataTable", ",", "StandardForm"}], "]"}], "^:=", 
      RowBox[{"(", "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"Length", "[", "tbl", "]"}], ">", "19"}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{"(", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"Column", "[", 
            RowBox[{"{", "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"Row", "[", 
               RowBox[{
                RowBox[{"{", "\[IndentingNewLine]", 
                 RowBox[{
                  RowBox[{"Button", "[", 
                   RowBox[{"\"\<Show in Excel\>\"", ",", 
                    RowBox[{"DataTableView", "@", "tbl"}]}], "]"}], ",", 
                  "\[IndentingNewLine]", 
                  RowBox[{"Button", "[", 
                   RowBox[{"\"\<Show using \[PlusMinus]\>\"", ",", 
                    RowBox[{"DataTableView", "[", 
                    RowBox[{"tbl", ",", "True"}], "]"}]}], "]"}]}], 
                 "\[IndentingNewLine]", "}"}], ",", 
                RowBox[{"ImageSize", "\[Rule]", 
                 RowBox[{"{", 
                  RowBox[{"All", ",", "Automatic"}], "}"}]}]}], "]"}], ",", 
              "\[IndentingNewLine]", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"tbl", "//", "First"}], ")"}], "/.", 
               RowBox[{"(", 
                RowBox[{"x_EV", "\[RuleDelayed]", 
                 RowBox[{"ToString", "[", "x", "]"}]}], ")"}]}]}], 
             "\[IndentingNewLine]", "}"}], "]"}], "//", "ToBoxes"}], 
          "\[IndentingNewLine]", ")"}], ",", "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{
            RowBox[{"(", 
             RowBox[{"tbl", "//", "First"}], ")"}], "/.", 
            RowBox[{"(", 
             RowBox[{"x_EV", "\[RuleDelayed]", 
              RowBox[{"ToString", "[", "x", "]"}]}], ")"}]}], ")"}], "//", 
          "ToBoxes"}]}], "\[IndentingNewLine]", "]"}], "\[IndentingNewLine]", 
       ")"}]}], ",", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"MakeBoxes", "[", 
       RowBox[{"tbl_DataTable", ",", "StandardForm"}], "]"}], "^:=", 
      RowBox[{"(", "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"Length", "[", "tbl", "]"}], ">", "19"}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{"(", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"Column", "[", 
            RowBox[{"{", "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"Row", "[", 
               RowBox[{
                RowBox[{"{", "\[IndentingNewLine]", 
                 RowBox[{
                  RowBox[{"Button", "[", 
                   RowBox[{"\"\<Show in Excel\>\"", ",", 
                    RowBox[{"DataTableView", "@", "tbl"}]}], "]"}], ",", 
                  "\[IndentingNewLine]", 
                  RowBox[{"Button", "[", 
                   RowBox[{"\"\<Show using \[PlusMinus]\>\"", ",", 
                    RowBox[{"DataTableView", "[", 
                    RowBox[{"tbl", ",", "True"}], "]"}]}], "]"}]}], 
                 "\[IndentingNewLine]", "}"}], ",", 
                RowBox[{"ImageSize", "\[Rule]", 
                 RowBox[{"{", 
                  RowBox[{"All", ",", "Automatic"}], "}"}]}]}], "]"}], ",", 
              "\[IndentingNewLine]", 
              RowBox[{"(", 
               RowBox[{"tbl", "//", "First"}], ")"}]}], "\[IndentingNewLine]",
              "}"}], "]"}], "//", "ToBoxes"}], "\[IndentingNewLine]", ")"}], 
         ",", "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"tbl", "//", "First"}], ")"}], "//", "ToBoxes"}]}], 
        "\[IndentingNewLine]", "]"}], "\[IndentingNewLine]", ")"}]}]}], 
    "\[IndentingNewLine]", "]"}], "*)"}], "\[IndentingNewLine]", 
  "\[IndentingNewLine]", 
  RowBox[{
   RowBox[{"MakeBoxes", "[", 
    RowBox[{"tbl_DataTable", ",", "StandardForm"}], "]"}], "^:=", 
   RowBox[{"(", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"Column", "[", "\[IndentingNewLine]", 
      RowBox[{"{", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"Row", "[", 
         RowBox[{
          RowBox[{"Join", "[", "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"If", "[", 
             RowBox[{"$UseExcel", ",", "\[IndentingNewLine]", 
              RowBox[{"{", "\[IndentingNewLine]", 
               RowBox[{
                RowBox[{"Button", "[", 
                 RowBox[{"\"\<Show in Excel\>\"", ",", 
                  RowBox[{"DataTableViewExcel", "@", 
                   RowBox[{"PrepareListData", "@", "tbl"}]}]}], "]"}], ",", 
                "\[IndentingNewLine]", 
                RowBox[{"Button", "[", 
                 RowBox[{"\"\<Show using \[PlusMinus]\>\"", ",", 
                  RowBox[{"DataTableViewExcel", "@", 
                   RowBox[{"PrepareListData", "[", 
                    RowBox[{"tbl", ",", "True"}], "]"}]}]}], "]"}]}], 
               "\[IndentingNewLine]", "}"}], ",", "\[IndentingNewLine]", 
              RowBox[{"{", "}"}]}], "\[IndentingNewLine]", "]"}], ",", 
            "\[IndentingNewLine]", 
            RowBox[{"{", "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"Button", "[", 
               RowBox[{"\"\<Copy TSV\>\"", ",", 
                RowBox[{"CopyToClipboard", "[", 
                 RowBox[{"ExportString", "[", 
                  RowBox[{
                   RowBox[{"PrepareListData", "@", "tbl"}], ",", 
                   "\"\<TSV\>\""}], "]"}], "]"}]}], "]"}], ",", 
              "\[IndentingNewLine]", 
              RowBox[{"Button", "[", 
               RowBox[{"\"\<Copy using \[PlusMinus]\>\"", ",", 
                RowBox[{"CopyToClipboard", "[", 
                 RowBox[{"ExportString", "[", 
                  RowBox[{
                   RowBox[{"PrepareListData", "[", 
                    RowBox[{"tbl", ",", "True"}], "]"}], ",", "\"\<TSV\>\""}],
                   "]"}], "]"}]}], "]"}]}], "\[IndentingNewLine]", "}"}]}], 
           "\[IndentingNewLine]", "]"}], ",", 
          RowBox[{"ImageSize", "\[Rule]", 
           RowBox[{"{", 
            RowBox[{"All", ",", "Automatic"}], "}"}]}]}], "]"}], ",", 
        "\[IndentingNewLine]", 
        RowBox[{"(", 
         RowBox[{"Dataset", "[", "tbl", "]"}], ")"}]}], "\[IndentingNewLine]",
        "}"}], "\[IndentingNewLine]", "]"}], "//", "ToBoxes"}], 
    "\[IndentingNewLine]", "\[IndentingNewLine]", 
    RowBox[{"(*", 
     RowBox[{"If", "[", 
      RowBox[{
       RowBox[{
        RowBox[{"Length", "[", "tbl", "]"}], ">", "19"}], ",", 
       "\[IndentingNewLine]", 
       RowBox[{"(", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"Column", "[", 
          RowBox[{"{", "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"Row", "[", 
             RowBox[{
              RowBox[{"{", "\[IndentingNewLine]", 
               RowBox[{
                RowBox[{"Button", "[", 
                 RowBox[{"\"\<Show in Excel\>\"", ",", 
                  RowBox[{"DataTableView", "@", "tbl"}]}], "]"}], ",", 
                "\[IndentingNewLine]", 
                RowBox[{"Button", "[", 
                 RowBox[{"\"\<Show using \[PlusMinus]\>\"", ",", 
                  RowBox[{"DataTableView", "[", 
                   RowBox[{"tbl", ",", "True"}], "]"}]}], "]"}]}], 
               "\[IndentingNewLine]", "}"}], ",", 
              RowBox[{"ImageSize", "\[Rule]", 
               RowBox[{"{", 
                RowBox[{"All", ",", "Automatic"}], "}"}]}]}], "]"}], ",", 
            "\[IndentingNewLine]", 
            RowBox[{"(", 
             RowBox[{"tbl", "//", "First"}], ")"}]}], "\[IndentingNewLine]", 
           "}"}], "]"}], "//", "ToBoxes"}], "\[IndentingNewLine]", ")"}], ",",
        "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"(", 
         RowBox[{"tbl", "//", "First"}], ")"}], "//", "ToBoxes"}]}], 
      "\[IndentingNewLine]", "]"}], "*)"}], "\[IndentingNewLine]", 
    ")"}]}]}]], "Input",
 InitializationCell->
  True,ExpressionUUID->"b9251a51-ae21-4107-8583-93381c01c153"],

Cell[BoxData[{
 RowBox[{"$ExcelInstance", ";"}], "\[IndentingNewLine]", 
 RowBox[{"$ExcelWorkbook", ";"}], "\[IndentingNewLine]", 
 RowBox[{"$ExcelWorksheet", ";"}], "\[IndentingNewLine]", 
 RowBox[{"$ExcelListObject", ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"$ExcelCharacters", "=", 
   RowBox[{"CharacterRange", "[", 
    RowBox[{"\"\<A\>\"", ",", "\"\<Z\>\""}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"$ExcelColumnRange", "=", 
   RowBox[{"Flatten", "@", 
    RowBox[{"Prepend", "[", 
     RowBox[{
      RowBox[{
       RowBox[{
        RowBox[{"Module", "[", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"c1", "=", "#"}], "}"}], ",", 
          RowBox[{"(", 
           RowBox[{
            RowBox[{
             RowBox[{"c1", "<>", "#"}], "&"}], "/@", "$ExcelCharacters"}], 
           ")"}]}], "]"}], "&"}], "/@", "$ExcelCharacters"}], ",", 
      "$ExcelCharacters"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"$UseExcel", "=", "True"}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Quiet", "[", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"If", "[", 
      RowBox[{
       RowBox[{
        RowBox[{"!", 
         RowBox[{"NETObjectQ", "[", "$ExcelInstance", "]"}]}], "||", 
        RowBox[{"(", "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"$ExcelInstance", "@", "Visible"}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"GetNETException", "[", "]"}], "\[NotEqual]", "Null"}]}], 
         "\[IndentingNewLine]", ")"}]}], ",", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"$ExcelInstance", "=", 
         RowBox[{"CreateCOMObject", "[", "\"\<Excel.Application\>\"", "]"}]}],
         ";", "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"!", 
           RowBox[{"NETObjectQ", "[", "$ExcelInstance", "]"}]}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"$UseExcel", "=", "False"}], ";"}]}], 
         "\[IndentingNewLine]", "]"}], ";"}]}], "\[IndentingNewLine]", "]"}], 
     ";"}], "\[IndentingNewLine]", "]"}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"PrepareListData", "[", 
   RowBox[{"tbl_DataTable", ",", 
    RowBox[{"separateErrors_:", "False"}]}], "]"}], ":=", 
  RowBox[{"Module", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"{", "\[IndentingNewLine]", 
     RowBox[{
     "DataList", ",", "Test", ",", "HeaderList", ",", "i", ",", 
      "TempWState"}], "\[IndentingNewLine]", "}"}], ",", 
    "\[IndentingNewLine]", 
    RowBox[{"(", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"If", "[", 
       RowBox[{"separateErrors", ",", "\[IndentingNewLine]", 
        RowBox[{"Module", "[", 
         RowBox[{
          RowBox[{"{", "ECols", "}"}], ",", 
          RowBox[{"(", "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"DataList", "=", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{"tbl", "//", "ToArray"}], ")"}], "/.", 
              RowBox[{"{", "\[IndentingNewLine]", 
               RowBox[{"(*", 
                RowBox[{
                 RowBox[{
                  RowBox[{"NDV", "[", 
                   RowBox[{"v_", ",", "e_", ",", "_"}], "]"}], 
                  "\[RuleDelayed]", 
                  RowBox[{"{", 
                   RowBox[{"v", ",", 
                    RowBox[{"e", "*", "$ZValue"}]}], "}"}]}], ",", 
                 "\[IndentingNewLine]", 
                 RowBox[{
                  RowBox[{"DV", "[", 
                   RowBox[{"v_", ",", "e_", ",", "__"}], "]"}], 
                  "\[RuleDelayed]", 
                  RowBox[{"{", 
                   RowBox[{"v", ",", "e"}], "}"}]}], ","}], "*)"}], 
               "\[IndentingNewLine]", "\[IndentingNewLine]", 
               RowBox[{
                RowBox[{
                 RowBox[{"NDV", "[", 
                  RowBox[{"v_", ",", "se_", ",", "n_"}], "]"}], 
                 "\[RuleDelayed]", 
                 RowBox[{"{", 
                  RowBox[{"v", ",", 
                   RowBox[{"se", "*", "$ZValue"}]}], "}"}]}], ",", 
                "\[IndentingNewLine]", 
                RowBox[{
                 RowBox[{"DV", "[", 
                  RowBox[{"v_", ",", "se_", ",", 
                   RowBox[{"{", 
                    RowBox[{
                    RowBox[{"rl_", "?", "PosNumPatternQ"}], ",", 
                    RowBox[{"ru_", "?", "PosNumPatternQ"}]}], "}"}], ",", 
                   "n_"}], "]"}], "\[RuleDelayed]", 
                 RowBox[{"{", 
                  RowBox[{"v", ",", 
                   RowBox[{"{", 
                    RowBox[{"rl", ",", "ru"}], "}"}]}], "}"}]}], ",", 
                "\[IndentingNewLine]", 
                RowBox[{
                 RowBox[{"DV", "[", 
                  RowBox[{"v_", ",", "se_", ",", 
                   RowBox[{"i_", "?", "PosNumPatternQ"}], ",", "n_"}], "]"}], 
                 "\[RuleDelayed]", 
                 RowBox[{"{", 
                  RowBox[{"v", ",", "i"}], "}"}]}], ",", 
                "\[IndentingNewLine]", 
                RowBox[{
                 RowBox[{"DV", "[", 
                  RowBox[{"v_", ",", "se_", ",", "n_"}], "]"}], 
                 "\[RuleDelayed]", 
                 RowBox[{"{", 
                  RowBox[{"v", ",", 
                   RowBox[{"se", "*", "$ZValue"}]}], "}"}]}]}], 
               "\[IndentingNewLine]", "}"}]}]}], ";", "\[IndentingNewLine]", 
            RowBox[{"DataList", "=", 
             RowBox[{"Map", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"Switch", "[", 
                 RowBox[{
                 "#", ",", "\[IndentingNewLine]", "_Real", ",", "#", ",", 
                  "\[IndentingNewLine]", "_Integer", ",", "#", ",", 
                  "\[IndentingNewLine]", "_List", ",", "#", ",", 
                  "\[IndentingNewLine]", "_Missing", ",", "Null", ",", 
                  "\[IndentingNewLine]", "_DateObject", ",", 
                  RowBox[{"DateString", "[", 
                   RowBox[{"#", ",", 
                    RowBox[{"{", 
                    RowBox[{
                    "\"\<Date\>\"", ",", "\"\< \>\"", ",", "\"\<Time\>\""}], 
                    "}"}]}], "]"}], ",", "\[IndentingNewLine]", "_", ",", 
                  RowBox[{"ToString", "[", "#", "]"}]}], 
                 "\[IndentingNewLine]", "]"}], "&"}], ",", "DataList", ",", 
               RowBox[{"{", "2", "}"}]}], "]"}]}], ";", "\[IndentingNewLine]", 
            RowBox[{"ECols", "=", 
             RowBox[{"Or", "@@@", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{"Map", "[", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"ListQ", "[", "#", "]"}], "&"}], ",", "DataList", 
                  ",", 
                  RowBox[{"{", "2", "}"}]}], "]"}], "//", "Transpose"}], 
               ")"}]}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
            RowBox[{
             RowBox[{"DataList", "[", 
              RowBox[{"[", "1", "]"}], "]"}], "=", 
             RowBox[{"Flatten", "[", 
              RowBox[{"MapThread", "[", 
               RowBox[{
                RowBox[{
                 RowBox[{"If", "[", 
                  RowBox[{"#1", ",", 
                   RowBox[{"{", 
                    RowBox[{"#2", ",", 
                    RowBox[{
                    "\"\<\[Sigma](\>\"", "<>", "#2", "<>", "\"\<)\>\""}]}], 
                    "}"}], ",", "#2"}], "]"}], "&"}], ",", 
                RowBox[{"{", 
                 RowBox[{"ECols", ",", 
                  RowBox[{"DataList", "//", "First"}]}], "}"}]}], "]"}], 
              "]"}]}], ";", "\[IndentingNewLine]", 
            RowBox[{
             RowBox[{"DataList", "[", 
              RowBox[{"[", 
               RowBox[{"2", ";;"}], "]"}], "]"}], "=", 
             RowBox[{"Map", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"MapThread", "[", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"#1", "&&", 
                    RowBox[{"!", 
                    RowBox[{"ListQ", "[", "#2", "]"}]}]}], ",", 
                    RowBox[{"{", 
                    RowBox[{"#2", ",", "Null"}], "}"}], ",", "#2"}], "]"}], 
                   "&"}], ",", 
                  RowBox[{"{", 
                   RowBox[{"ECols", ",", "#"}], "}"}]}], "]"}], "&"}], ",", 
               RowBox[{"DataList", "[", 
                RowBox[{"[", 
                 RowBox[{"2", ";;"}], "]"}], "]"}]}], "]"}]}], ";", 
            "\[IndentingNewLine]", 
            RowBox[{"DataList", "=", 
             RowBox[{"Flatten", "/@", "DataList"}]}], ";"}], 
           "\[IndentingNewLine]", ")"}]}], "]"}], ",", "\[IndentingNewLine]", 
        
        RowBox[{"(", "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"DataList", "=", 
           RowBox[{"Map", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"Switch", "[", 
               RowBox[{
               "#", ",", "\[IndentingNewLine]", "_Real", ",", "#", ",", 
                "\[IndentingNewLine]", "_Integer", ",", "#", ",", 
                "\[IndentingNewLine]", "_Missing", ",", "Null", ",", 
                "\[IndentingNewLine]", "_DateObject", ",", 
                RowBox[{"DateString", "[", 
                 RowBox[{"#", ",", 
                  RowBox[{"{", 
                   RowBox[{
                   "\"\<Date\>\"", ",", "\"\< \>\"", ",", "\"\<Time\>\""}], 
                   "}"}]}], "]"}], ",", "\[IndentingNewLine]", "_", ",", 
                RowBox[{"ToString", "[", 
                 RowBox[{"If", "[", 
                  RowBox[{
                   RowBox[{"AssociationQ", "[", "#", "]"}], ",", 
                   RowBox[{"EvaluateAssocValues", "[", 
                    RowBox[{"#", "/.", 
                    RowBox[{"x_NDV", "\[RuleDelayed]", 
                    RowBox[{"ToString", "[", "x", "]"}]}]}], "]"}], ",", 
                   RowBox[{"#", "/.", 
                    RowBox[{"x_NDV", "\[RuleDelayed]", 
                    RowBox[{"ToString", "[", "x", "]"}]}]}]}], "]"}], "]"}]}],
                "\[IndentingNewLine]", "]"}], "&"}], ",", 
             RowBox[{"tbl", "//", "ToArray"}], ",", 
             RowBox[{"{", "2", "}"}]}], "]"}]}], ";"}], "\[IndentingNewLine]",
          ")"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", "DataList"}], "\[IndentingNewLine]", 
     "\[IndentingNewLine]", 
     RowBox[{"(*", 
      RowBox[{
       RowBox[{"TempWState", "=", 
        RowBox[{"$ExcelWorkbook", "@", 
         RowBox[{"Windows", "@", 
          RowBox[{
           RowBox[{"Item", "[", "1", "]"}], "@", "WindowState"}]}]}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"$ExcelWorkbook", "@", 
         RowBox[{"Windows", "@", 
          RowBox[{
           RowBox[{"Item", "[", "1", "]"}], "@", "WindowState"}]}]}], "=", 
        RowBox[{"-", "4140"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"$ExcelWorkbook", "@", 
         RowBox[{"Windows", "@", 
          RowBox[{
           RowBox[{"Item", "[", "1", "]"}], "@", "WindowState"}]}]}], "=", 
        "TempWState"}], ";"}], "*)"}], "\[IndentingNewLine]", ")"}]}], 
   "\[IndentingNewLine]", "]"}]}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"673244c1-5c14-4c7f-a240-fa4822493103"],

Cell[BoxData[
 RowBox[{
  RowBox[{"DataTableViewExcel", "[", "data_List", "]"}], ":=", 
  RowBox[{"Module", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"DataList", ",", "HeaderList"}], "}"}], ",", 
    "\[IndentingNewLine]", 
    RowBox[{"(", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"DataList", "=", "data"}], ";", "\[IndentingNewLine]", 
      RowBox[{"HeaderList", "=", 
       RowBox[{"DataList", "[", 
        RowBox[{"[", "1", "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"DataList", "[", 
        RowBox[{"[", "1", "]"}], "]"}], "=", 
       RowBox[{
        RowBox[{"Null", "&"}], "/@", 
        RowBox[{"DataList", "[", 
         RowBox[{"[", "1", "]"}], "]"}]}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"Quiet", "[", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"!", 
            RowBox[{"NETObjectQ", "[", "$ExcelInstance", "]"}]}], "||", 
           RowBox[{"(", "\[IndentingNewLine]", 
            RowBox[{
             RowBox[{"$ExcelInstance", "@", "Visible"}], ";", 
             "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"GetNETException", "[", "]"}], "\[NotEqual]", 
              "Null"}]}], "\[IndentingNewLine]", ")"}]}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"$ExcelInstance", "=", 
            RowBox[{
            "CreateCOMObject", "[", "\"\<Excel.Application\>\"", "]"}]}], ";",
            "\[IndentingNewLine]", 
           RowBox[{"If", "[", 
            RowBox[{
             RowBox[{"!", 
              RowBox[{"NETObjectQ", "[", "$ExcelInstance", "]"}]}], ",", 
             "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"Return", "[", "$Failed", "]"}], ";"}]}], 
            "\[IndentingNewLine]", "]"}], ";"}]}], "\[IndentingNewLine]", 
         "]"}], ";", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"$ExcelInstance", "@", "Visible"}], "=", "True"}], ";", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"!", 
            RowBox[{"NETObjectQ", "[", "$ExcelWorkbook", "]"}]}], "||", 
           RowBox[{
            RowBox[{"$ExcelWorkbook", "@", "Worksheets"}], "\[Equal]", 
            "$Failed"}], "||", 
           RowBox[{"(", "\[IndentingNewLine]", 
            RowBox[{
             RowBox[{"$ExcelWorkbook", "@", "Worksheets"}], ";", 
             "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"GetNETException", "[", "]"}], "\[NotEqual]", 
              "Null"}]}], "\[IndentingNewLine]", ")"}]}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"$ExcelWorkbook", " ", "=", " ", 
            RowBox[{"$ExcelInstance", "@", 
             RowBox[{"Workbooks", "@", 
              RowBox[{"Add", "[", "]"}]}]}]}], ";"}]}], "\[IndentingNewLine]",
          "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"NETObjectQ", "[", "$ExcelWorksheet", "]"}], "&&", 
           RowBox[{"(", 
            RowBox[{
             RowBox[{
              RowBox[{"$ExcelWorksheet", "@", "Visible"}], "\[Equal]", 
              "$Failed"}], "||", 
             RowBox[{"(", "\[IndentingNewLine]", 
              RowBox[{
               RowBox[{"$ExcelWorksheet", "@", "Visible"}], ";", 
               "\[IndentingNewLine]", 
               RowBox[{
                RowBox[{"GetNETException", "[", "]"}], "\[NotEqual]", 
                "Null"}]}], "\[IndentingNewLine]", ")"}]}], ")"}]}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"ReleaseNETObject", "[", "$ExcelWorksheet", "]"}], ";", 
           "\[IndentingNewLine]", 
           RowBox[{"$ExcelWorksheet", " ", "=", " ", 
            RowBox[{"$ExcelWorkbook", "@", 
             RowBox[{"Worksheets", "@", 
              RowBox[{"Add", "[", "]"}]}]}]}], ";"}]}], "\[IndentingNewLine]",
          "]"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"!", 
           RowBox[{"NETObjectQ", "[", "$ExcelWorksheet", "]"}]}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"ReleaseNETObject", "[", "$ExcelWorksheet", "]"}], ";", 
           "\[IndentingNewLine]", 
           RowBox[{"$ExcelWorksheet", " ", "=", " ", 
            RowBox[{"$ExcelWorkbook", "@", 
             RowBox[{"Worksheets", "@", 
              RowBox[{"Item", "[", "1", "]"}]}]}]}], ";", 
           "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"$ExcelInstance", "@", "Visible"}], " ", "=", " ", 
            "True"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
           RowBox[{"$ExcelWorksheet", "@", 
            RowBox[{
             RowBox[{"Range", "[", "\"\<B2\>\"", "]"}], "@", 
             RowBox[{"Select", "[", "]"}]}]}], ";", "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"$ExcelWorkbook", "@", 
             RowBox[{"Windows", "@", 
              RowBox[{
               RowBox[{"Item", "[", "1", "]"}], "@", "FreezePanes"}]}]}], "=",
             "True"}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"NETObjectQ", "[", "$ExcelListObject", "]"}], ",", 
          RowBox[{"$ExcelListObject", "@", 
           RowBox[{"Delete", "[", "]"}]}]}], "]"}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"ReleaseNETObject", "[", "$ExcelListObject", "]"}], ";"}], 
       "\[IndentingNewLine]", "\[IndentingNewLine]", "]"}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"$ExcelWorksheet", "@", 
        RowBox[{
         RowBox[{"Range", "[", 
          RowBox[{"\"\<B2\>\"", ",", "\"\<ZZ2\>\""}], "]"}], "@", 
         RowBox[{"EntireColumn", "@", "HorizontalAlignment"}]}]}], "=", "4"}],
       ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"$ExcelWorksheet", "@", 
        RowBox[{
         RowBox[{"Range", "[", 
          RowBox[{"\"\<A1\>\"", ",", "\"\<A2\>\""}], "]"}], "@", 
         RowBox[{"EntireColumn", "@", "HorizontalAlignment"}]}]}], "=", "1"}],
       ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"$ExcelWorksheet", "@", 
        RowBox[{
         RowBox[{"Range", "[", 
          RowBox[{"\"\<A1\>\"", ",", "\"\<ZZ1\>\""}], "]"}], "@", 
         RowBox[{"EntireRow", "@", "HorizontalAlignment"}]}]}], "=", "3"}], 
      ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"$ExcelWorksheet", "@", 
        RowBox[{
         RowBox[{"Range", "[", 
          RowBox[{"\"\<A1\>\"", ",", 
           RowBox[{
            RowBox[{"$ExcelColumnRange", "[", 
             RowBox[{"[", 
              RowBox[{
               RowBox[{"DataList", "//", "First"}], "//", "Length"}], "]"}], 
             "]"}], "<>", 
            RowBox[{"ToString", "[", 
             RowBox[{"DataList", "//", "Length"}], "]"}]}]}], "]"}], "@", 
         "Value"}]}], "=", "DataList"}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"$ExcelWorksheet", "@", 
        RowBox[{
         RowBox[{"Range", "[", 
          RowBox[{"\"\<A1\>\"", ",", 
           RowBox[{
            RowBox[{"$ExcelColumnRange", "[", 
             RowBox[{"[", 
              RowBox[{
               RowBox[{"DataList", "//", "First"}], "//", "Length"}], "]"}], 
             "]"}], "<>", "\"\<1\>\""}]}], "]"}], "@", "Value"}]}], "=", 
       "HeaderList"}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"$ExcelWorksheet", "@", 
       RowBox[{
        RowBox[{"Range", "[", 
         RowBox[{"\"\<A1\>\"", ",", 
          RowBox[{
           RowBox[{"$ExcelColumnRange", "[", 
            RowBox[{"[", 
             RowBox[{
              RowBox[{"DataList", "//", "First"}], "//", "Length"}], "]"}], 
            "]"}], "<>", 
           RowBox[{"ToString", "[", 
            RowBox[{"DataList", "//", "Length"}], "]"}]}]}], "]"}], "@", 
        RowBox[{"Columns", "@", 
         RowBox[{"AutoFit", "[", "]"}]}]}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"$ExcelListObject", "=", 
       RowBox[{"$ExcelWorksheet", "@", 
        RowBox[{"ListObjects", "@", 
         RowBox[{"Add", "[", 
          RowBox[{"1", ",", 
           RowBox[{"$ExcelWorksheet", "@", 
            RowBox[{"Range", "[", 
             RowBox[{"\"\<A1\>\"", ",", 
              RowBox[{
               RowBox[{"$ExcelColumnRange", "[", 
                RowBox[{"[", 
                 RowBox[{
                  RowBox[{"DataList", "//", "First"}], "//", "Length"}], 
                 "]"}], "]"}], "<>", 
               RowBox[{"ToString", "[", 
                RowBox[{"DataList", "//", "Length"}], "]"}]}]}], "]"}]}], ",",
            "False", ",", "1"}], "]"}]}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"$ExcelListObject", "@", "TableStyle"}], "=", 
       RowBox[{"$ExcelWorkbook", "@", 
        RowBox[{"TableStyles", "@", 
         RowBox[{"Item", "[", "23", "]"}]}]}]}], ";", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"$ExcelListObject", "@", "ShowAutoFilter"}], "=", "False"}], 
      ";"}], "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", 
   "]"}]}]], "Input",
 InitializationCell->
  True,ExpressionUUID->"43daebab-6dc0-468c-bb78-3c253ee7ec6c"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"$DataWindowWidth", "=", "200"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"$DataWindowHeight", "=", "300"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{"$DataNotebook", ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"$DataWindow", ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"DataTableViewWindow", "[", "data_List", "]"}], ":=", 
  RowBox[{"Module", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", 
    RowBox[{"(", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{"!", 
         RowBox[{"MemberQ", "[", 
          RowBox[{
           RowBox[{
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{"{", "WindowTitle", "}"}], "/.", 
               RowBox[{"Options", "[", "#", "]"}]}], ")"}], "&"}], "/@", 
            RowBox[{"Notebooks", "[", "]"}]}], ",", 
           RowBox[{"{", "\"\<Data Table\>\"", "}"}]}], "]"}]}], ",", 
        "\[IndentingNewLine]", 
        RowBox[{"CreateWindow", "[", 
         RowBox[{
          RowBox[{"$DataNotebook", "=", 
           RowBox[{"PaletteNotebook", "[", "\[IndentingNewLine]", 
            RowBox[{
             RowBox[{"{", 
              RowBox[{"Grid", "[", 
               RowBox[{"data", ",", 
                RowBox[{"ItemSize", "\[Rule]", "All"}]}], "]"}], "}"}], 
             "\[IndentingNewLine]", ",", 
             RowBox[{"WindowTitle", "\[Rule]", "\"\<Data Table\>\""}], ",", 
             RowBox[{"WindowFloating", "\[Rule]", "False"}], ",", 
             RowBox[{"Editable", "\[Rule]", "True"}], ",", 
             RowBox[{"WindowSize", "\[Rule]", 
              RowBox[{"Dynamic", "[", 
               RowBox[{"{", 
                RowBox[{"$DataWindowWidth", ",", "$DataWindowHeight"}], "}"}],
                "]"}]}], ",", 
             RowBox[{"WindowFrameElements", "\[Rule]", 
              RowBox[{"{", 
               RowBox[{
               "\"\<ResizeArea\>\"", ",", "\"\<ZoomBox\>\"", ",", 
                "\"\<MinimizeBox\>\"", ",", "\"\<CloseBox\>\""}], "}"}]}], 
             ",", 
             RowBox[{"WindowElements", "\[Rule]", 
              RowBox[{"{", 
               RowBox[{
               "\"\<HorizontalScrollBar\>\"", ",", 
                "\"\<VerticalScrollBar\>\""}], "}"}]}], ",", 
             RowBox[{"WindowMargins", "\[Rule]", 
              RowBox[{"{", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{"0", ",", "Automatic"}], "}"}], ",", 
                RowBox[{"{", 
                 RowBox[{"0", ",", "Automatic"}], "}"}]}], "}"}]}]}], 
            "\[IndentingNewLine]", "]"}]}], ",", "\[IndentingNewLine]", 
          RowBox[{"ClosingSaveDialog", "\[Rule]", "False"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"CellDingbat", "\[Rule]", "None"}], ",", 
          RowBox[{"CellMargins", "\[Rule]", "10"}], ",", 
          RowBox[{"ShowCellBracket", "\[Rule]", "False"}]}], 
         "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", 
        RowBox[{"(", "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"CreatePalette", "[", "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"$DataNotebook", "=", 
             RowBox[{"PaletteNotebook", "[", "\[IndentingNewLine]", 
              RowBox[{
               RowBox[{"{", 
                RowBox[{"Grid", "[", 
                 RowBox[{"data", ",", 
                  RowBox[{"ItemSize", "\[Rule]", "All"}]}], "]"}], "}"}], 
               "\[IndentingNewLine]", ",", 
               RowBox[{"WindowTitle", "\[Rule]", "\"\<Data Table\>\""}], ",", 
               
               RowBox[{"WindowFloating", "\[Rule]", "False"}], ",", 
               RowBox[{"Editable", "\[Rule]", "True"}], ",", 
               RowBox[{"WindowSize", "\[Rule]", 
                RowBox[{"Dynamic", "[", 
                 RowBox[{"{", 
                  RowBox[{"$DataWindowWidth", ",", "$DataWindowHeight"}], 
                  "}"}], "]"}]}], ",", 
               RowBox[{"WindowFrameElements", "\[Rule]", 
                RowBox[{"{", 
                 RowBox[{
                 "\"\<ResizeArea\>\"", ",", "\"\<ZoomBox\>\"", ",", 
                  "\"\<MinimizeBox\>\"", ",", "\"\<CloseBox\>\""}], "}"}]}], 
               ",", 
               RowBox[{"WindowElements", "\[Rule]", 
                RowBox[{"{", 
                 RowBox[{
                 "\"\<HorizontalScrollBar\>\"", ",", 
                  "\"\<VerticalScrollBar\>\""}], "}"}]}], ",", 
               RowBox[{"WindowMargins", "\[Rule]", 
                RowBox[{"{", 
                 RowBox[{
                  RowBox[{"{", 
                   RowBox[{"0", ",", "Automatic"}], "}"}], ",", 
                  RowBox[{"{", 
                   RowBox[{"0", ",", "Automatic"}], "}"}]}], "}"}]}]}], 
              "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", ",", 
            "$DataNotebook"}], "]"}], ";", "\[IndentingNewLine]", 
          "\[IndentingNewLine]", 
          RowBox[{"SetSelectedNotebook", "@", "$DataNotebook"}]}], 
         "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}], ";"}], 
     "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}]}], "Input"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"$DataWindowHeight", "=", 
   RowBox[{"800", "-", "20"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"$DataWindowWidth", "=", 
   RowBox[{"800", "-", "20"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"DataWindowContent", "=", "\"\<\>\""}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"DataTableView", "[", "tbl_DataTable", "]"}], ":=", 
  RowBox[{"DynamicModule", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{"Tbl", ",", "Out", ",", 
      RowBox[{"Sx", "=", "0"}], ",", 
      RowBox[{"Sy", "=", "0"}], ",", 
      RowBox[{"MaxRows", "=", 
       RowBox[{"Floor", "[", 
        RowBox[{
         RowBox[{"$DataWindowHeight", "/", "26.5789"}], "/", "1.1"}], 
        "]"}]}]}], "}"}], ",", "\[IndentingNewLine]", 
    RowBox[{"(", "\[IndentingNewLine]", 
     RowBox[{"(*", 
      RowBox[{
       RowBox[{"DataWindowContent", "=", 
        RowBox[{"Column", "[", "\[IndentingNewLine]", 
         RowBox[{"Table", "[", 
          RowBox[{
           RowBox[{"tbl", "[", 
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"i", "-", "1"}], ")"}], "*", "RowN"}], "+", "1"}], 
              ")"}], ";;", 
             RowBox[{"(", 
              RowBox[{"i", "*", "RowN"}], ")"}]}], "]"}], ",", 
           RowBox[{"{", 
            RowBox[{"i", ",", "1", ",", 
             RowBox[{"Ceiling", "[", 
              RowBox[{
               RowBox[{"Length", "[", "tbl", "]"}], "/", "RowN"}], "]"}]}], 
            "}"}]}], "]"}], "\[IndentingNewLine]", "]"}]}], ";"}], "*)"}], 
     "\[IndentingNewLine]", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{"!", 
         RowBox[{"MemberQ", "[", 
          RowBox[{
           RowBox[{
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{"{", "WindowTitle", "}"}], "/.", 
               RowBox[{"Options", "[", "#", "]"}]}], ")"}], "&"}], "/@", 
            RowBox[{"Notebooks", "[", "]"}]}], ",", 
           RowBox[{"{", "\"\<Data Tables\>\"", "}"}]}], "]"}]}], ",", 
        "\[IndentingNewLine]", 
        RowBox[{"CreateWindow", "[", 
         RowBox[{
          RowBox[{"PaletteNotebook", "[", "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"Dynamic", "[", "DataWindowContent", "]"}], 
            "\[IndentingNewLine]", ",", 
            RowBox[{"WindowTitle", "\[Rule]", "\"\<Data Tables\>\""}], ",", 
            RowBox[{"WindowFloating", "\[Rule]", "False"}], ",", 
            RowBox[{"Editable", "\[Rule]", "True"}], ",", 
            RowBox[{"WindowSize", "\[Rule]", 
             RowBox[{"Dynamic", "[", 
              RowBox[{"{", 
               RowBox[{"$DataWindowWidth", ",", "$DataWindowHeight"}], "}"}], 
              "]"}]}], ",", 
            RowBox[{"WindowFrameElements", "\[Rule]", 
             RowBox[{"{", 
              RowBox[{
              "\"\<ResizeArea\>\"", ",", "\"\<ZoomBox\>\"", ",", 
               "\"\<MinimizeBox\>\"", ",", "\"\<CloseBox\>\""}], "}"}]}], ",", 
            RowBox[{"WindowElements", "\[Rule]", 
             RowBox[{"{", "}"}]}], ",", 
            RowBox[{"WindowMargins", "\[Rule]", 
             RowBox[{"{", 
              RowBox[{
               RowBox[{"{", 
                RowBox[{"0", ",", "Automatic"}], "}"}], ",", 
               RowBox[{"{", 
                RowBox[{"0", ",", "Automatic"}], "}"}]}], "}"}]}]}], 
           "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", 
          RowBox[{"ClosingSaveDialog", "\[Rule]", "False"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"CellDingbat", "\[Rule]", "None"}], ",", 
          RowBox[{"CellMargins", "\[Rule]", 
           RowBox[{"-", "1"}]}], ",", 
          RowBox[{"ShowCellBracket", "\[Rule]", "False"}]}], 
         "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", 
        RowBox[{"SetSelectedNotebook", "@", 
         RowBox[{"(", 
          RowBox[{
           RowBox[{"Select", "[", 
            RowBox[{
             RowBox[{"Notebooks", "[", "]"}], ",", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{"First", "[", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"{", "WindowTitle", "}"}], "/.", 
                   RowBox[{"Options", "[", "#", "]"}]}], ")"}], "]"}], 
                "\[Equal]", "\"\<Data Tables\>\""}], ")"}], "&"}]}], "]"}], "//",
            "First"}], ")"}]}]}], "\[IndentingNewLine]", "]"}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Tbl", "=", 
       RowBox[{"ToList", "[", "tbl", "]"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"Tbl", "=", 
       RowBox[{"Tbl", "/.", 
        RowBox[{
         RowBox[{"Missing", "[", "]"}], "\[Rule]", 
         RowBox[{"Style", "[", 
          RowBox[{"\"\<missing\>\"", ",", "Gray"}], "]"}]}]}]}], ";", 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"(*", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"Widths", "=", 
         RowBox[{"MapIndexed", "[", 
          RowBox[{
           RowBox[{
            RowBox[{
             RowBox[{"(", 
              RowBox[{
               RowBox[{"ColWidth", "[", "#1", "]"}], "+", "2"}], ")"}], "/", 
             "Magic"}], "&"}], ",", 
           RowBox[{"(", 
            RowBox[{"Tbl", "//", "Transpose"}], ")"}]}], "]"}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"Widths", "[", 
          RowBox[{"[", "1", "]"}], "]"}], "=", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{
            RowBox[{"Max", "[", 
             RowBox[{
              RowBox[{
               RowBox[{"StringLength", "[", 
                RowBox[{"ColWidthHelper", "[", "#", "]"}], "]"}], "&"}], "/@", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{"(", 
                 RowBox[{"Tbl", "//", "Transpose"}], ")"}], "[", 
                RowBox[{"[", "1", "]"}], "]"}], ")"}]}], "]"}], "+", "1"}], 
           ")"}], "/", "Magic"}]}], ";", "\[IndentingNewLine]", 
        RowBox[{"Height", "=", 
         RowBox[{
          RowBox[{"(", 
           RowBox[{"Tbl", "//", "Length"}], ")"}], "*", 
          RowBox[{"(", 
           RowBox[{
            RowBox[{
             RowBox[{"CurrentValue", "[", "\"\<FontLineHeight\>\"", "]"}], 
             "*", "2"}], "+", "0.5"}], ")"}]}]}], ";"}], "*)"}], 
      "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Out", "=", 
       RowBox[{"Overlay", "[", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"{", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"Pane", "[", 
            RowBox[{
             RowBox[{"Deploy", "[", 
              RowBox[{"Graphics", "[", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{"Transparent", ",", 
                  RowBox[{"Rectangle", "[", 
                   RowBox[{
                    RowBox[{"{", 
                    RowBox[{"0", ",", "0"}], "}"}], ",", 
                    RowBox[{"{", 
                    RowBox[{"1", ",", "1"}], "}"}]}], "]"}]}], "}"}], ",", 
                RowBox[{"ImageSize", "\[Rule]", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{
                    RowBox[{"(", 
                    RowBox[{"$DataWindowWidth", "-", "20"}], ")"}], "*", 
                    RowBox[{
                    RowBox[{"Length", "[", 
                    RowBox[{"Tbl", "//", "First"}], "]"}], "/", "5"}]}], ",", 
                   
                   RowBox[{
                    RowBox[{"(", 
                    RowBox[{"$DataWindowHeight", "-", "10"}], ")"}], "*", 
                    RowBox[{
                    RowBox[{"Length", "[", "tbl", "]"}], "/", "MaxRows"}]}]}],
                   "}"}]}]}], "]"}], "]"}], ",", 
             RowBox[{"Scrollbars", "\[Rule]", "True"}], ",", 
             RowBox[{"ImageSize", "\[Rule]", 
              RowBox[{"Dynamic", "[", 
               RowBox[{"{", 
                RowBox[{"$DataWindowWidth", ",", "$DataWindowHeight"}], "}"}],
                "]"}]}], ",", 
             RowBox[{"ScrollPosition", "\[Rule]", 
              RowBox[{"Dynamic", "[", 
               RowBox[{"{", 
                RowBox[{"Sx", ",", "Sy"}], "}"}], "]"}]}], ",", 
             RowBox[{"ImageSizeAction", "\[Rule]", "\"\<Scrollable\>\""}], 
             ",", 
             RowBox[{"AppearanceElements", "\[Rule]", "All"}]}], "]"}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{"Dynamic", "[", "\[IndentingNewLine]", 
            RowBox[{"(*", 
             RowBox[{"tbl", "[", 
              RowBox[{
               RowBox[{
                RowBox[{"Ceiling", "[", 
                 RowBox[{
                  RowBox[{"Sy", "/", "500"}], "*", "20"}], "]"}], ";;"}], ",", 
               RowBox[{
                RowBox[{"Ceiling", "[", 
                 RowBox[{
                  RowBox[{"Sx", "/", 
                   RowBox[{"(", 
                    RowBox[{"950", "-", "20"}], ")"}]}], "*", "5"}], "]"}], 
                ";;"}]}], "]"}], "*)"}], "\[IndentingNewLine]", 
            RowBox[{"Grid", "[", 
             RowBox[{
              RowBox[{"Tbl", "[", 
               RowBox[{"[", "\[IndentingNewLine]", 
                RowBox[{
                 RowBox[{"Prepend", "[", 
                  RowBox[{
                   RowBox[{"Table", "[", 
                    RowBox[{"i", ",", 
                    RowBox[{"{", 
                    RowBox[{"i", ",", 
                    RowBox[{"2", "+", 
                    RowBox[{"Floor", "[", 
                    RowBox[{
                    RowBox[{"Sy", "/", 
                    RowBox[{"(", 
                    RowBox[{"$DataWindowHeight", "-", "30"}], ")"}]}], "*", 
                    "MaxRows"}], "]"}]}], ",", 
                    RowBox[{"Length", "[", "Tbl", "]"}]}], "}"}]}], "]"}], 
                   ",", "1"}], "]"}], ",", "\[IndentingNewLine]", 
                 RowBox[{"Prepend", "[", 
                  RowBox[{
                   RowBox[{"Table", "[", 
                    RowBox[{"i", ",", 
                    RowBox[{"{", 
                    RowBox[{"i", ",", 
                    RowBox[{"2", "+", 
                    RowBox[{"Floor", "[", 
                    RowBox[{
                    RowBox[{"Sx", "/", 
                    RowBox[{"(", 
                    RowBox[{"$DataWindowWidth", "-", "20"}], ")"}]}], "*", 
                    "5"}], "]"}]}], ",", 
                    RowBox[{"Length", "[", 
                    RowBox[{"Tbl", "//", "First"}], "]"}]}], "}"}]}], "]"}], 
                   ",", "1"}], "]"}]}], "\[IndentingNewLine]", "]"}], "]"}], 
              ",", "\[IndentingNewLine]", 
              RowBox[{"Dividers", "\[Rule]", 
               RowBox[{"{", 
                RowBox[{"(*", 
                 RowBox[{"Append", "[", 
                  RowBox[{
                   RowBox[{"Table", "[", 
                    RowBox[{"False", ",", 
                    RowBox[{"{", "IDN", "}"}]}], "]"}], ",", "True"}], "]"}], 
                 "*)"}], 
                RowBox[{
                 RowBox[{"{", 
                  RowBox[{"{", "True", "}"}], "}"}], ",", 
                 RowBox[{"{", 
                  RowBox[{"False", ",", "True", ",", "False"}], "}"}]}], 
                "}"}]}], ",", "\[IndentingNewLine]", 
              RowBox[{"Background", "\[Rule]", 
               RowBox[{"{", 
                RowBox[{"White", ",", 
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"RGBColor", "[", 
                    RowBox[{"0.9", ",", "0.9", ",", "1."}], "]"}], ",", 
                   RowBox[{"{", 
                    RowBox[{"White", ",", 
                    RowBox[{"GrayLevel", "[", "0.9", "]"}]}], "}"}]}], 
                  "}"}]}], "}"}]}], ",", "\[IndentingNewLine]", 
              RowBox[{"Alignment", "\[Rule]", 
               RowBox[{"{", 
                RowBox[{
                 RowBox[{"{", 
                  RowBox[{
                   RowBox[{"{", 
                    RowBox[{"2", ",", 
                    RowBox[{"-", "1"}]}], "}"}], ",", 
                   RowBox[{"{", 
                    RowBox[{"1", ",", "1"}], "}"}]}], "}"}], "\[Rule]", 
                 RowBox[{"{", 
                  RowBox[{"Right", ",", "Center"}], "}"}]}], "}"}]}], ",", 
              "\[IndentingNewLine]", 
              RowBox[{"ItemSize", "\[Rule]", 
               RowBox[{"{", 
                RowBox[{"Full", ",", "2"}], "}"}]}], ",", 
              "\[IndentingNewLine]", 
              RowBox[{"ItemStyle", "\[Rule]", 
               RowBox[{"{", 
                RowBox[{"FontFamily", "\[Rule]", "\"\<Sans Serif\>\""}], 
                "}"}]}]}], "\[IndentingNewLine]", "]"}], 
            "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", "}"}], ",",
          "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{"2", ",", "1"}], "}"}], ",", "\[IndentingNewLine]", "1"}], 
        "\[IndentingNewLine]", "]"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"DataWindowContent", "=", "Out"}], ";"}], "\[IndentingNewLine]",
      ")"}]}], "\[IndentingNewLine]", "]"}]}]}], "Input"]
}, Open  ]],

Cell[CellGroupData[{

Cell["More useful functions", "Subsection"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"KeyFind", "::", "usage"}], "=", 
   "\"\<KeyFind[str] represents an operator which can be used to select \
elements whose key is the provided string.\nKeyFind[patt] represents an \
operator which can be used to select elements whose key is the provided \
string pattern.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"KeyFind", "[", "str_", "]"}], ":=", 
   RowBox[{"KeySelect", "[", 
    RowBox[{
     RowBox[{"StringMatchQ", "[", 
      RowBox[{
       RowBox[{"ToString", "[", "#", "]"}], ",", "str"}], "]"}], "&"}], 
    "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"KeyFind", "[", "str_String", "]"}], ":=", 
   RowBox[{"Key", "[", "str", "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"KeyFind", "[", 
     RowBox[{"assoc_Association", ",", "str_"}], "]"}], ":=", 
    RowBox[{"KeySelect", "[", 
     RowBox[{"assoc", ",", 
      RowBox[{
       RowBox[{"StringMatchQ", "[", 
        RowBox[{
         RowBox[{"ToString", "[", "#", "]"}], ",", "str"}], "]"}], "&"}]}], 
     "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"KeyExcept", "::", "usage"}], "=", 
   "\"\<KeyExcept[str] represents an operator which can be used to select \
elements whose key is not the provided string.\nKeyExcept[patt] represents an \
operator which can be used to select elements whose key is not matched by the \
provided string pattern.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"KeyExcept", "[", "str_", "]"}], ":=", 
   RowBox[{"KeySelect", "[", 
    RowBox[{
     RowBox[{"StringFreeQ", "[", 
      RowBox[{
       RowBox[{"ToString", "[", "#", "]"}], ",", "str"}], "]"}], "&"}], 
    "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"KeyExcept", "[", "str_String", "]"}], ":=", 
   RowBox[{"KeyDrop", "[", "str", "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"KeyExcept", "[", 
     RowBox[{"assoc_Association", ",", "str_"}], "]"}], ":=", 
    RowBox[{"KeySelect", "[", 
     RowBox[{"assoc", ",", 
      RowBox[{
       RowBox[{"StringFreeQ", "[", 
        RowBox[{
         RowBox[{"ToString", "[", "#", "]"}], ",", "str"}], "]"}], "&"}]}], 
     "]"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"Unprotect", "[", "StringExpression", "]"}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"DataTable", "[", "ds_", "]"}], "[", 
    RowBox[{"op1_StringExpression", ",", "op2_StringExpression", ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], "^:=", 
   RowBox[{
    RowBox[{"DataTable", "[", "ds", "]"}], "[", 
    RowBox[{
     RowBox[{"KeyFind", "[", "op1", "]"}], ",", 
     RowBox[{"KeyFind", "[", "op2", "]"}], ",", "opts"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"DataTable", "[", "ds_", "]"}], "[", 
    RowBox[{"op1_StringExpression", ",", "op2_", ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], "^:=", 
   RowBox[{
    RowBox[{"DataTable", "[", "ds", "]"}], "[", 
    RowBox[{
     RowBox[{"KeyFind", "[", "op1", "]"}], ",", "op2", ",", "opts"}], "]"}]}],
   ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"DataTable", "[", "ds_", "]"}], "[", 
    RowBox[{"op1_", ",", "op2_StringExpression", ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], "^:=", 
   RowBox[{
    RowBox[{"DataTable", "[", "ds", "]"}], "[", 
    RowBox[{"op1", ",", 
     RowBox[{"KeyFind", "[", "op2", "]"}], ",", "opts"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"DataTable", "[", "ds_", "]"}], "[", 
    RowBox[{"op1_StringExpression", ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], "^:=", 
   RowBox[{
    RowBox[{"DataTable", "[", "ds", "]"}], "[", 
    RowBox[{
     RowBox[{"KeyFind", "[", "op1", "]"}], ",", "opts"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"Protect", "[", "StringExpression", "]"}], ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"b52a245f-f6f4-46cd-ad06-2867f6fa5b7f"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"Unprotect", "[", 
   RowBox[{"Not", ",", "StringExpression"}], "]"}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"DataTable", "[", "ds_", "]"}], "[", 
    RowBox[{"op1_Not", ",", "op2_StringExpression", ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], "^:=", 
   RowBox[{
    RowBox[{"DataTable", "[", "ds", "]"}], "[", 
    RowBox[{
     RowBox[{"KeyExcept", "[", 
      RowBox[{"op1", "//", "First"}], "]"}], ",", 
     RowBox[{"KeyFind", "[", "op2", "]"}], ",", "opts"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"DataTable", "[", "ds_", "]"}], "[", 
    RowBox[{"op1_Not", ",", "op2_", ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], "^:=", 
   RowBox[{
    RowBox[{"DataTable", "[", "ds", "]"}], "[", 
    RowBox[{
     RowBox[{"KeyExcept", "[", 
      RowBox[{"op1", "//", "First"}], "]"}], ",", "op2", ",", "opts"}], 
    "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"DataTable", "[", "ds_", "]"}], "[", 
    RowBox[{"op1_Not", ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], "^:=", 
   RowBox[{
    RowBox[{"DataTable", "[", "ds", "]"}], "[", 
    RowBox[{
     RowBox[{"KeyExcept", "[", 
      RowBox[{"op1", "//", "First"}], "]"}], ",", "opts"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"Protect", "[", 
   RowBox[{"Not", ",", "StringExpression"}], "]"}], ";"}]}], "Input",
 InitializationCell->True],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"NV", "::", "usage"}], "=", 
   "\"\<NV[datatable] returns the data (not the keys) in datatable, converted \
to a normal expression.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"NV", "[", "ds_Dataset", "]"}], ":=", 
   RowBox[{"Normal", "@", 
    RowBox[{"Values", "@", 
     RowBox[{"Map", "[", 
      RowBox[{
       RowBox[{
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"AssociationQ", "[", "#", "]"}], ",", 
          RowBox[{"Normal", "@", 
           RowBox[{"Values", "[", "#", "]"}]}], ",", "#"}], "]"}], "&"}], ",",
        "ds", ",", "Infinity"}], "]"}]}]}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"NV", "[", 
     RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], ":=", 
    RowBox[{"NV", "[", "ds", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"FV", "::", "usage"}], "=", 
   "\"\<FV[datatable] returns the first value in datatable.\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"FV", "[", "ds_Dataset", "]"}], ":=", 
   RowBox[{"First", "@", 
    RowBox[{"Map", "[", 
     RowBox[{
      RowBox[{
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"AssociationQ", "[", "#", "]"}], "||", 
          RowBox[{"ListQ", "[", "#", "]"}]}], ",", 
         RowBox[{"First", "[", "#", "]"}], ",", "#"}], "]"}], "&"}], ",", 
      "ds", ",", "Infinity"}], "]"}]}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"FV", "[", 
     RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], ":=", 
    RowBox[{"FV", "[", "ds", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"ColNames", "::", "usage"}], "=", 
   "\"\<ColNames[datatable] returns the list of the columns in the data \
table.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"ColNames", "[", "ds_Dataset", "]"}], ":=", 
   RowBox[{"If", "[", 
    RowBox[{
     RowBox[{
      RowBox[{"Depth", "[", 
       RowBox[{"DVMeans", "@", 
        RowBox[{"Normal", "@", "ds"}]}], "]"}], "<", "3"}], ",", 
     RowBox[{"{", "}"}], ",", 
     RowBox[{"DeleteDuplicates", "@", 
      RowBox[{"Flatten", "[", 
       RowBox[{"Values", "@", 
        RowBox[{"Normal", "@", 
         RowBox[{"(", 
          RowBox[{"Keys", "/@", 
           RowBox[{"Normal", "@", "ds"}]}], ")"}]}]}], "]"}]}]}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"ColNames", "[", 
     RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], ":=", 
    RowBox[{"ColNames", "[", "ds", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"NK", "::", "usage"}], "=", 
  "\"\<NK[datatable] returns the list of the row keys (IDs) in the data \
table.\>\""}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"NK", "[", "ds_Dataset", "]"}], ":=", 
   RowBox[{"Normal", "@", 
    RowBox[{"Keys", "@", "ds"}]}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"NK", "[", 
    RowBox[{"DataTable", "[", "ds_Dataset", "]"}], "]"}], ":=", 
   RowBox[{"NK", "[", "ds", "]"}]}], ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"6c2d856f-767f-4fba-b35a-7beae73fa2c8"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"MeanAndStandardError", "::", "usage"}], "=", 
   "\"\<MeanAndStandardError represents an an operator which can be applied \
to DataTable objects to calculate the means and standard errors, represented \
by an NDV object, e.g. of all rows.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"MeanAndStandardError", "=", 
    RowBox[{
     RowBox[{"Merge", "[", 
      RowBox[{
       RowBox[{"Values", "@", 
        RowBox[{"(", "#", ")"}]}], ",", 
       RowBox[{
        RowBox[{"NDV", "[", 
         RowBox[{
          RowBox[{"Mean", "[", "#", "]"}], ",", 
          RowBox[{
           RowBox[{
            RowBox[{"StandardDeviation", "[", "#", "]"}], "/", 
            RowBox[{"Sqrt", "[", 
             RowBox[{"Length", "[", "#", "]"}], "]"}]}], "//", "N"}]}], "]"}],
         "&"}]}], "]"}], "&"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"MeanAndStandardDeviation", "::", "usage"}], "=", 
   "\"\<MeanAndStandardDeviation represents an an operator which can be \
applied to DataTable objects to calculate the means and standard deviations, \
represented by an NDV object, e.g. of all rows.\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"MeanAndStandardDeviation", "=", 
   RowBox[{
    RowBox[{"Merge", "[", 
     RowBox[{
      RowBox[{"Values", "@", 
       RowBox[{"(", "#", ")"}]}], ",", 
      RowBox[{
       RowBox[{"NDV", "[", 
        RowBox[{
         RowBox[{"Mean", "[", "#", "]"}], ",", 
         RowBox[{
          RowBox[{"StandardDeviation", "[", "#", "]"}], "//", "N"}]}], "]"}], 
       "&"}]}], "]"}], "&"}]}], ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"2290214f-a902-4c38-8a5a-5388230aec33"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"FixedEffectMetaAnalysis", "::", "usage"}], "=", 
   "\"\<FixedEffectMetaAnalysis represents an an operator which can be \
applied to DataTable objects to carry out a fixed effect \
meta-analysis.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"FixedEffectMetaAnalysis", "=", 
   RowBox[{
    RowBox[{"Merge", "[", 
     RowBox[{
      RowBox[{"Values", "@", "#"}], ",", 
      RowBox[{
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", "WDat", "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"(", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"WDat", "=", 
            RowBox[{"WeightedData", "[", 
             RowBox[{
              RowBox[{"DVMeans", "@", "#"}], ",", 
              RowBox[{
               RowBox[{
                RowBox[{"1", "/", 
                 RowBox[{"#", "^", "2"}]}], "&"}], "/@", 
               RowBox[{"DVSEs", "[", "#", "]"}]}]}], "]"}]}], ";", 
           "\[IndentingNewLine]", 
           RowBox[{"NDV", "[", 
            RowBox[{
             RowBox[{"Mean", "[", "WDat", "]"}], ",", 
             RowBox[{
              RowBox[{"Sqrt", "[", 
               RowBox[{"1", "/", 
                RowBox[{"(", 
                 RowBox[{"Total", "[", 
                  RowBox[{
                   RowBox[{
                    RowBox[{"1", "/", 
                    RowBox[{"#", "^", "2"}]}], "&"}], "/@", 
                   RowBox[{"DVSEs", "[", "#", "]"}]}], "]"}], ")"}]}], "]"}], 
              "//", "N"}]}], "]"}]}], "\[IndentingNewLine]", ")"}]}], 
        "\[IndentingNewLine]", "]"}], "&"}]}], "]"}], "&"}]}], 
  ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"cc513e20-911a-46c4-ad39-cd226eb95062"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"RandomEffectsMetaAnalysis", "::", "usage"}], "=", 
   "\"\<RandomEffectsMetaAnalysis represents an an operator which can be \
applied to DataTable objects to carry out a random effect \
meta-analysis.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"RandomEffectsMetaAnalysis", "=", 
   RowBox[{
    RowBox[{"Merge", "[", 
     RowBox[{
      RowBox[{"Values", "@", "#"}], ",", 
      RowBox[{
       RowBox[{"Module", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{
          "WT", ",", "WTS", ",", "ESWT", ",", "ESSWT", ",", "Cv", ",", "Q", 
           ",", "TS", ",", "Wtot", ",", "ESWtot"}], "}"}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{"(", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"WT", "=", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{"1", "/", 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"DVSEs", "[", "#", "]"}], "^", "2"}], ")"}], "^", 
                 "2"}]}], ")"}], "&"}], "/@", "#"}]}], ";", 
           "\[IndentingNewLine]", 
           RowBox[{"WTS", "=", 
            RowBox[{
             RowBox[{
              RowBox[{
               RowBox[{"(", 
                RowBox[{"1", "/", 
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"DVSEs", "[", "#", "]"}], "^", "2"}], ")"}], "^", 
                  "2"}]}], ")"}], "^", "2"}], "&"}], "/@", "#"}]}], ";", 
           "\[IndentingNewLine]", 
           RowBox[{"ESWT", "=", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{"DVMeans", "[", "#", "]"}], "/", 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"DVSEs", "[", "#", "]"}], "^", "2"}], ")"}], "^", 
                 "2"}]}], ")"}], "&"}], "/@", "#"}]}], ";", 
           "\[IndentingNewLine]", 
           RowBox[{"ESSWT", "=", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{
                 RowBox[{"DVMeans", "[", "#", "]"}], "^", "2"}], "/", 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"DVSEs", "[", "#", "]"}], "^", "2"}], ")"}], "^", 
                 "2"}]}], ")"}], "&"}], "/@", "#"}]}], ";", 
           "\[IndentingNewLine]", 
           RowBox[{"Q", "=", 
            RowBox[{
             RowBox[{"Total", "[", "ESSWT", "]"}], "-", 
             RowBox[{
              RowBox[{
               RowBox[{"Total", "[", "ESWT", "]"}], "^", "2"}], "/", 
              RowBox[{"Total", "[", "WT", "]"}]}]}]}], ";", 
           "\[IndentingNewLine]", 
           RowBox[{"Cv", "=", 
            RowBox[{
             RowBox[{"Total", "[", "WT", "]"}], "-", 
             RowBox[{
              RowBox[{"Total", "[", "WTS", "]"}], "/", 
              RowBox[{"Total", "[", "WT", "]"}]}]}]}], ";", 
           "\[IndentingNewLine]", "\[IndentingNewLine]", 
           RowBox[{"TS", "=", 
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{"Q", ">", 
               RowBox[{
                RowBox[{"Length", "[", "#", "]"}], "-", "1"}]}], ",", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"Q", "-", 
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"Length", "[", "#", "]"}], "-", "1"}], ")"}]}], 
                ")"}], "/", "Cv"}], ",", "0"}], "]"}]}], ";", 
           "\[IndentingNewLine]", "\[IndentingNewLine]", 
           RowBox[{"Wtot", "=", 
            RowBox[{
             RowBox[{
              RowBox[{"1", "/", 
               RowBox[{"(", 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"DVSEs", "[", "#", "]"}], "^", "2"}], ")"}], "+", 
                 "TS"}], ")"}]}], "&"}], "/@", "#"}]}], ";", 
           "\[IndentingNewLine]", 
           RowBox[{"ESWtot", "=", 
            RowBox[{
             RowBox[{
              RowBox[{
               RowBox[{"DVMeans", "[", "#", "]"}], "/", 
               RowBox[{"(", 
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{"DVSEs", "[", "#", "]"}], "^", "2"}], ")"}], "+", 
                 "TS"}], ")"}]}], "&"}], "/@", "#"}]}], ";", 
           "\[IndentingNewLine]", "\[IndentingNewLine]", 
           RowBox[{"NDV", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"Total", "[", "ESWtot", "]"}], "/", 
              RowBox[{"Total", "[", "Wtot", "]"}]}], ",", 
             RowBox[{
              RowBox[{"Sqrt", "[", 
               RowBox[{"1", "/", 
                RowBox[{"Total", "[", "Wtot", "]"}]}], "]"}], "//", "N"}]}], 
            "]"}]}], "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", 
        "]"}], "&"}]}], "]"}], "&"}]}], ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"f81fba7e-6be4-47bc-aa66-8136fc7791de"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"MeanAndStandardErrorWithEV", "::", "usage"}], "=", 
   "\"\<MeanAndStandardErrorWithEV represents an an operator which can be \
applied to DataTable objects to calculate the means and standard errors of \
data which already contains uncertainties (in the form of EV objects), e.g. \
of all rows. The returned standard error is either calculated from the \
standard deviation of the means, or error propagation of the input \
uncertainties, whichever is larger.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"MeanAndStandardErrorWithEV", "=", 
    RowBox[{
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Print", "[", 
        RowBox[{"Values", "@", "#"}], "]"}], ";", 
       RowBox[{"Abort", "[", "]"}], ";", "\[IndentingNewLine]", 
       RowBox[{"Merge", "[", 
        RowBox[{
         RowBox[{"Values", "@", "#"}], ",", 
         RowBox[{
          RowBox[{"(", "\[IndentingNewLine]", 
           RowBox[{"If", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{"StandardDeviation", "[", 
                 RowBox[{"DVMeans", "@", "#"}], "]"}], "/", 
                RowBox[{"Sqrt", "[", 
                 RowBox[{"Length", "[", "#", "]"}], "]"}]}], ")"}], ">", 
              RowBox[{
               RowBox[{"DVE", "[", 
                RowBox[{"Mean", "[", "#", "]"}], "]"}], "[", 
               RowBox[{"[", "2", "]"}], "]"}]}], ",", "\[IndentingNewLine]", 
             RowBox[{"NDV", "[", 
              RowBox[{
               RowBox[{"Mean", "[", 
                RowBox[{"DVMeans", "@", "#"}], "]"}], ",", 
               RowBox[{
                RowBox[{"StandardDeviation", "[", 
                 RowBox[{"DVMeans", "@", "#"}], "]"}], "/", 
                RowBox[{"Sqrt", "[", 
                 RowBox[{"Length", "[", "#", "]"}], "]"}]}]}], "]"}], ",", 
             "\[IndentingNewLine]", 
             RowBox[{"DVE", "[", 
              RowBox[{"Mean", "[", "#", "]"}], "]"}]}], "\[IndentingNewLine]",
             "]"}], "\[IndentingNewLine]", ")"}], "&"}]}], "]"}]}], ")"}], 
     "&"}]}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"MeanAndStandardDeviationWithEV", "::", "usage"}], "=", 
   "\"\<MeanAndStandardDeviationWithEV represents an an operator which can be \
applied to DataTable objects to calculate the means and standard deviation of \
data which already contains uncertainties (in the form of EV objects), e.g. \
of all rows. The returned standard deviation is either calculated as the \
standard deviation of the input values, or error propagation of the input \
uncertainties, whichever is larger.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"MeanAndStandardDeviationWithEV", "=", 
   RowBox[{
    RowBox[{"Merge", "[", 
     RowBox[{
      RowBox[{"Values", "@", "#"}], ",", 
      RowBox[{
       RowBox[{"(", "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"(", 
            RowBox[{"StandardDeviation", "[", 
             RowBox[{"DVMeans", "@", "#"}], "]"}], ")"}], ">", 
           RowBox[{
            RowBox[{"DVE", "[", 
             RowBox[{"Mean", "[", "#", "]"}], "]"}], "[", 
            RowBox[{"[", "2", "]"}], "]"}]}], ",", "\[IndentingNewLine]", 
          RowBox[{"NDV", "[", 
           RowBox[{
            RowBox[{"Mean", "[", 
             RowBox[{"DVMeans", "@", "#"}], "]"}], ",", 
            RowBox[{"StandardDeviation", "[", 
             RowBox[{"DVMeans", "@", "#"}], "]"}]}], "]"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"DVE", "[", 
           RowBox[{"Mean", "[", "#", "]"}], "]"}]}], "\[IndentingNewLine]", 
         "]"}], "\[IndentingNewLine]", ")"}], "&"}]}], "]"}], "&"}]}], 
  ";"}]}], "Input"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"GroupByKey", "::", "usage"}], "=", 
   "\"\<GroupByKey[datatable,f] returns a DataTable in which the rows in in \
the input data table have been grouped into sublists with distinct f[row key \
(ID)].\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"GroupByKey", "[", 
    RowBox[{"data_DataTable", ",", "f_"}], "]"}], ":=", 
   RowBox[{"Module", "[", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", "Dat", "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Dat", "=", 
        RowBox[{"data", "[", 
         RowBox[{"MapIndexed", "[", 
          RowBox[{
           RowBox[{"Prepend", "[", 
            RowBox[{"#1", ",", 
             RowBox[{"\"\<GroupingKey\>\"", "\[Rule]", 
              RowBox[{"f", "[", 
               RowBox[{"#2", "[", 
                RowBox[{"[", 
                 RowBox[{"1", ",", "1"}], "]"}], "]"}], "]"}]}]}], "]"}], 
           "&"}], "]"}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"Dat", "[", 
         RowBox[{
          RowBox[{"GroupBy", "[", 
           RowBox[{"#", ",", 
            RowBox[{
             RowBox[{"\"\<GroupingKey\>\"", "/.", "#"}], "&"}]}], "]"}], 
          "&"}], "]"}], "[", 
        RowBox[{"All", ",", "All", ",", 
         RowBox[{"KeyDrop", "[", "\"\<GroupingKey\>\"", "]"}]}], "]"}]}], 
      "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"GroupByKey", "[", 
   RowBox[{"data_DataTable", ",", "f_", ",", "2"}], "]"}], ":=", 
  RowBox[{"Module", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"{", "Dat", "}"}], ",", "\[IndentingNewLine]", 
    RowBox[{"(", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"Dat", "=", 
       RowBox[{"data", "[", 
        RowBox[{"All", ",", 
         RowBox[{
          RowBox[{"MapIndexed", "[", 
           RowBox[{
            RowBox[{
             RowBox[{"Prepend", "[", 
              RowBox[{
               RowBox[{"{", 
                RowBox[{"\"\<Value\>\"", "\[Rule]", "#1"}], "}"}], ",", 
               RowBox[{"\"\<GroupingKey\>\"", "\[Rule]", 
                RowBox[{"f", "[", 
                 RowBox[{"#2", "[", 
                  RowBox[{"[", 
                   RowBox[{"1", ",", "1"}], "]"}], "]"}], "]"}]}]}], "]"}], 
             "&"}], ",", "#", ",", "1"}], "]"}], "&"}]}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Dat", "[", 
        RowBox[{"All", ",", 
         RowBox[{
          RowBox[{"GroupBy", "[", 
           RowBox[{"#", ",", 
            RowBox[{
             RowBox[{"\"\<GroupingKey\>\"", "/.", "#"}], "&"}]}], "]"}], 
          "&"}]}], "]"}], "[", 
       RowBox[{"All", ",", "All", ",", "All", ",", 
        RowBox[{
         RowBox[{"\"\<Value\>\"", "/.", "#"}], "&"}]}], "]"}]}], 
     "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}]}], "Input",\

 InitializationCell->True],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"PartitionAssociation", "::", "usage"}], "=", 
   "\"\<PartitionAssociation[assoc,n] partitions the association assoc into \
nonoverlapping subassociations of length n and returns a new association.\n\
PartitionAssociation[assoc,n,d] generates subassociations with offet d.\n\
PartitionAssociation[assoc,n,d,i] generates subassociations with offet d and \
the keys of the resulting association are generated from item number i of the \
partition group.\n\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"PartitionAssociation", "[", 
   RowBox[{"assoc_", ",", "n_", ",", "d_", ",", 
    RowBox[{"i_:", "1"}]}], "]"}], ":=", 
  RowBox[{"Association", "[", 
   RowBox[{
    RowBox[{
     RowBox[{"(", 
      RowBox[{
       RowBox[{"#", "[", 
        RowBox[{"[", 
         RowBox[{"i", ",", "1"}], "]"}], "]"}], "\[Rule]", 
       RowBox[{"Association", "@", "#"}]}], ")"}], "&"}], "/@", 
    RowBox[{"Partition", "[", 
     RowBox[{
      RowBox[{"Normal", "@", "assoc"}], ",", "n", ",", "d"}], "]"}]}], 
   "]"}]}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"PartitionAssociation", "[", 
   RowBox[{"assoc_", ",", "n_"}], "]"}], ":=", 
  RowBox[{"Association", "[", 
   RowBox[{
    RowBox[{
     RowBox[{"(", 
      RowBox[{
       RowBox[{"#", "[", 
        RowBox[{"[", 
         RowBox[{"1", ",", "1"}], "]"}], "]"}], "\[Rule]", 
       RowBox[{"Association", "@", "#"}]}], ")"}], "&"}], "/@", 
    RowBox[{"Partition", "[", 
     RowBox[{
      RowBox[{"Normal", "@", "assoc"}], ",", "n"}], "]"}]}], 
   "]"}]}]}], "Input",
 InitializationCell->True],

Cell[BoxData[{
 RowBox[{
  RowBox[{"SetAttributes", "[", 
   RowBox[{"QueryTo", ",", "HoldFirst"}], "]"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Options", "[", "QueryTo", "]"}], "=", 
   RowBox[{"Options", "[", "Query", "]"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"QueryTo", "::", "usage"}], "=", 
   "\"\<QueryTo[obj,\!\(\*SubscriptBox[\(operator\), \
\(1\)]\),\!\(\*SubscriptBox[\(operator\), \(2\)]\),...] applies the query \
with the given operators to the Dataset or Datatable obj.\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"QueryTo", "[", 
   RowBox[{"dt_", ",", "op___", ",", 
    RowBox[{"opts", ":", 
     RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
  RowBox[{"dt", "=", 
   RowBox[{
    RowBox[{"Query", "[", 
     RowBox[{"op", ",", "opts"}], "]"}], "[", "dt", "]"}]}]}]}], "Input",
 InitializationCell->True],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"ReplaceDatum", "::", "usage"}], "=", 
   "\"\<ReplaceDatum[obj,row,column,value] replaces the value of the datum in \
the row with a certain key (ID) and the column with a certain key with a new \
value.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"ReplaceDatum", "[", 
   RowBox[{"dt_", ",", "row_", ",", "column_", ",", "val_"}], "]"}], ":=", 
  RowBox[{"(", "\[IndentingNewLine]", 
   RowBox[{"dt", "[", 
    RowBox[{"{", 
     RowBox[{"row", "\[Rule]", 
      RowBox[{"(", 
       RowBox[{
        RowBox[{"<|", 
         RowBox[{"#", ",", 
          RowBox[{"column", "\[Rule]", "val"}]}], "|>"}], "&"}], ")"}]}], 
     "}"}], "]"}], "\[IndentingNewLine]", ")"}]}]}], "Input",
 InitializationCell->True],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"FoldValues", "::", "usage"}], "=", 
   "\"\<FoldValues[f,x,assoc] applies FoldList[f,x,list] to the values of \
items in an association and returns a new association using the keys from the \
second item in each operation. The arguments x is optional.\nFoldValues[f] \
represents the operator form of FoldValues.\>\""}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"FoldValues", "[", 
    RowBox[{"f_", ",", "x_", ",", "assoc_Association"}], "]"}], ":=", 
   RowBox[{"<|", 
    RowBox[{"FoldList", "[", 
     RowBox[{
      RowBox[{
       RowBox[{
        RowBox[{"#2", "[", 
         RowBox[{"[", "1", "]"}], "]"}], "\[Rule]", 
        RowBox[{"f", "[", 
         RowBox[{
          RowBox[{"#1", "[", 
           RowBox[{"[", "2", "]"}], "]"}], ",", 
          RowBox[{"#2", "[", 
           RowBox[{"[", "2", "]"}], "]"}]}], "]"}]}], "&"}], ",", 
      RowBox[{"If", "[", 
       RowBox[{
        RowBox[{
         RowBox[{"Head", "[", 
          RowBox[{"x", "[", 
           RowBox[{"First", "@", 
            RowBox[{"Values", "@", "assoc"}]}], "]"}], "]"}], "===", "Rule"}],
         ",", 
        RowBox[{"x", "[", 
         RowBox[{"First", "@", 
          RowBox[{"Values", "@", "assoc"}]}], "]"}], ",", 
        RowBox[{"\"\<Key0\>\"", "\[Rule]", 
         RowBox[{"x", "[", 
          RowBox[{"First", "@", 
           RowBox[{"Values", "@", "assoc"}]}], "]"}]}]}], "]"}], ",", 
      RowBox[{"Normal", "@", "assoc"}]}], "]"}], "|>"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"FoldValues", "[", 
    RowBox[{"f_", ",", "assoc_Association"}], "]"}], ":=", 
   RowBox[{"<|", 
    RowBox[{"FoldList", "[", 
     RowBox[{
      RowBox[{
       RowBox[{
        RowBox[{"#2", "[", 
         RowBox[{"[", "1", "]"}], "]"}], "\[Rule]", 
        RowBox[{"f", "[", 
         RowBox[{
          RowBox[{"#1", "[", 
           RowBox[{"[", "2", "]"}], "]"}], ",", 
          RowBox[{"#2", "[", 
           RowBox[{"[", "2", "]"}], "]"}]}], "]"}]}], "&"}], ",", 
      RowBox[{"Normal", "@", "assoc"}]}], "]"}], "|>"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"FoldValues", "[", "f_", "]"}], ":=", 
   RowBox[{
    RowBox[{"<|", 
     RowBox[{"FoldList", "[", 
      RowBox[{
       RowBox[{
        RowBox[{
         RowBox[{"#2", "[", 
          RowBox[{"[", "1", "]"}], "]"}], "\[Rule]", 
         RowBox[{"f", "[", 
          RowBox[{
           RowBox[{"#1", "[", 
            RowBox[{"[", "2", "]"}], "]"}], ",", 
           RowBox[{"#2", "[", 
            RowBox[{"[", "2", "]"}], "]"}]}], "]"}]}], "&"}], ",", 
       RowBox[{"Normal", "@", "#"}]}], "]"}], "|>"}], "&"}]}], 
  ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"89638fa0-7a58-450e-9221-bd234c2c80ed"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"AppendColumns", "[", 
    RowBox[{
     RowBox[{"DataTable", "[", "ds_", "]"}], ",", "columns_"}], "]"}], ":=", 
   RowBox[{"Module", "[", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"Cols", ",", "Fun", ",", "Spacer"}], "}"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Cols", "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"Head", "[", "columns", "]"}], "\[Equal]", "Function"}], 
          ",", "\[IndentingNewLine]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"AssociationQ", "[", 
             RowBox[{"columns", "//", "First"}], "]"}], ",", 
            "\[IndentingNewLine]", 
            RowBox[{"columns", "//", "First"}], ",", "\[IndentingNewLine]", 
            RowBox[{"Association", "[", 
             RowBox[{"columns", "//", "First"}], "]"}]}], 
           "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"AssociationQ", "[", "columns", "]"}], ",", 
            "\[IndentingNewLine]", "columns", ",", "\[IndentingNewLine]", 
            RowBox[{"Association", "@", "columns"}]}], "\[IndentingNewLine]", 
           "]"}]}], "\[IndentingNewLine]", "]"}]}], ";", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"Fun", "=", 
        RowBox[{
         RowBox[{"#", "~", "Join", "~", "Spacer"}], "&"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"Fun", "=", 
        RowBox[{"Fun", "/.", 
         RowBox[{"Spacer", "\[Rule]", "Cols"}]}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"Fun", "//", "FullForm"}], "//", "Print"}], ";", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"DataTable", "[", "ds", "]"}], "[", 
        RowBox[{"All", ",", "Fun"}], "]"}]}], "\[IndentingNewLine]", ")"}]}], 
    "\[IndentingNewLine]", "]"}]}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"AppendColumnsTo", "[", 
   RowBox[{
    RowBox[{"DataTable", "[", "ds_", "]"}], ",", "columns_"}], "]"}], ":=", 
  RowBox[{"Module", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", 
    RowBox[{"(", "\[IndentingNewLine]", "1", "\[IndentingNewLine]", ")"}]}], 
   "\[IndentingNewLine]", "]"}]}]}], "Input"]
}, Open  ]]
}, Open  ]],

Cell[CellGroupData[{

Cell["ListPlot integration", "Section"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"$DefaultPlotColors", "=", 
    RowBox[{"First", "/@", 
     RowBox[{"(", 
      RowBox[{"\"\<DefaultPlotStyle\>\"", "/.", 
       RowBox[{"(", 
        RowBox[{"Method", "/.", 
         RowBox[{"Charting`ResolvePlotTheme", "[", 
          RowBox[{"Automatic", ",", "ListPlot"}], "]"}]}], ")"}]}], ")"}]}]}],
    ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"$DefaultPlotMarkerG", "=", 
    RowBox[{"{", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"EdgeForm", "[", "Black", "]"}], ",", 
        RowBox[{"Disk", "[", "]"}]}], "}"}], ",", "\[IndentingNewLine]", 
      RowBox[{"{", 
       RowBox[{
        RowBox[{"EdgeForm", "[", "Black", "]"}], ",", 
        RowBox[{"Rectangle", "[", "]"}]}], "}"}], ",", "\[IndentingNewLine]", 
      
      RowBox[{"{", 
       RowBox[{
        RowBox[{"EdgeForm", "[", "Black", "]"}], ",", 
        RowBox[{"Polygon", "[", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{"1", ",", "0"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"0", ",", 
             RowBox[{"Sqrt", "[", "3", "]"}]}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"-", "1"}], ",", "0"}], "}"}]}], "}"}], "]"}]}], "}"}], 
      ",", "\[IndentingNewLine]", 
      RowBox[{"{", 
       RowBox[{
        RowBox[{"EdgeForm", "[", "Black", "]"}], ",", 
        RowBox[{"Polygon", "[", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{"0.", ",", "1."}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"-", "1."}], ",", "0."}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"0.", ",", 
             RowBox[{"-", "1."}]}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"1.", ",", "0."}], "}"}]}], "}"}], "]"}]}], "}"}], ",", 
      "\[IndentingNewLine]", 
      RowBox[{"{", 
       RowBox[{
        RowBox[{"EdgeForm", "[", "Black", "]"}], ",", 
        RowBox[{"Polygon", "[", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{"1", ",", "0"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"0", ",", 
             RowBox[{"-", 
              RowBox[{"Sqrt", "[", "3", "]"}]}]}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"-", "1"}], ",", "0"}], "}"}]}], "}"}], "]"}]}], "}"}], 
      ",", "\[IndentingNewLine]", 
      RowBox[{"{", 
       RowBox[{
        RowBox[{"EdgeForm", "[", "Black", "]"}], ",", 
        RowBox[{"Polygon", "[", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{"0", ",", "0"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"-", "1"}], ",", "1"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"0", ",", "0"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"-", "1"}], ",", 
             RowBox[{"-", "1"}]}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"0", ",", "0"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"1", ",", 
             RowBox[{"-", "1"}]}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"0", ",", "0"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"1", ",", "1"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"0", ",", "0"}], "}"}]}], "}"}], "]"}]}], "}"}], ",", 
      "\[IndentingNewLine]", 
      RowBox[{"{", 
       RowBox[{
        RowBox[{"EdgeForm", "[", "Black", "]"}], ",", 
        RowBox[{"Polygon", "[", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{"1", ",", "0"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"0", ",", 
             RowBox[{"Sqrt", "[", "3", "]"}]}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"-", "1"}], ",", "0"}], "}"}]}], "}"}], "]"}]}], "}"}], 
      ",", "\[IndentingNewLine]", 
      RowBox[{"{", 
       RowBox[{
        RowBox[{"EdgeForm", "[", "Black", "]"}], ",", 
        RowBox[{"Polygon", "[", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{"0", ",", "0"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"Sqrt", "[", "3", "]"}], ",", 
             RowBox[{"-", "1"}]}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"Sqrt", "[", "3", "]"}], ",", "1"}], "}"}]}], "}"}], 
         "]"}]}], "}"}], ",", "\[IndentingNewLine]", 
      RowBox[{"{", 
       RowBox[{
        RowBox[{"EdgeForm", "[", "Black", "]"}], ",", 
        RowBox[{"Polygon", "[", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{
             RowBox[{"Sqrt", "[", "3", "]"}], ",", "0"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"0", ",", 
             RowBox[{"-", "1"}]}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"0", ",", "1"}], "}"}]}], "}"}], "]"}]}], "}"}]}], 
     "\[IndentingNewLine]", "}"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"$DefaultPlotMarkers", "=", 
    RowBox[{"(", 
     RowBox[{
      RowBox[{
       RowBox[{"Graphics", "[", 
        RowBox[{"#", ",", 
         RowBox[{"ImageSize", "\[Rule]", "10"}]}], "]"}], "&"}], "/@", 
      RowBox[{"MapIndexed", "[", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{
         RowBox[{"Prepend", "[", 
          RowBox[{
           RowBox[{"$DefaultPlotMarkerG", "[", 
            RowBox[{"[", 
             RowBox[{"Mod", "[", 
              RowBox[{
               RowBox[{"#2", "[", 
                RowBox[{"[", "1", "]"}], "]"}], ",", 
               RowBox[{"Length", "[", "$DefaultPlotMarkerG", "]"}], ",", 
               "1"}], "]"}], "]"}], "]"}], ",", "#1"}], "]"}], "&"}], ",", 
        "$DefaultPlotColors"}], "]"}]}], ")"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Options", "[", "DTPlot", "]"}], "=", 
   RowBox[{"Options", "[", "ErrorListPlot", "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"SetOptions", "[", 
    RowBox[{"DTPlot", ",", 
     RowBox[{"PlotMarkers", "\[Rule]", "Automatic"}]}], "]"}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"DTPlot", "::", "usage"}], "=", 
   "\"\<DTPlot[datatable] returns a plots of the DataTable object.\n\
DTPlot[{\!\(\*SubscriptBox[\(datatable\), \
\(1\)]\),\!\(\*SubscriptBox[\(datatable\), \(2\)]\),...}] returns a plots of \
the DataTable objects.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"DTPlot", "[", 
   RowBox[{"data_", ",", 
    RowBox[{"opts", ":", 
     RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
  RowBox[{"Module", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"{", "DTs", "}"}], ",", "\[IndentingNewLine]", 
    RowBox[{"(", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"DTs", "=", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"Head", "[", "data", "]"}], "===", "DataTable"}], ",", 
         RowBox[{"{", "data", "}"}], ",", "data"}], "]"}]}], ";", 
      "\[IndentingNewLine]", 
      RowBox[{"DTs", "=", 
       RowBox[{
        RowBox[{
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{
            RowBox[{"Head", "[", "#", "]"}], "===", "DataTable"}], ",", 
           RowBox[{"DeleteMissing", "[", 
            RowBox[{"#", ",", "1", ",", "1"}], "]"}], ",", "#"}], "]"}], 
         "&"}], "/@", "DTs"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"ErrorListPlot", "[", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{
          RowBox[{
           RowBox[{"If", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"Head", "[", "#", "]"}], "===", "DataTable"}], ",", 
             RowBox[{
              RowBox[{
               RowBox[{"PrepareErrorList", "[", 
                RowBox[{"#", ",", 
                 RowBox[{"!", 
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"OptionValue", "[", "PlotMarkers", "]"}], "===", 
                    "None"}], ")"}]}]}], "]"}], "&"}], "@", "#"}], ",", "#"}],
             "]"}], "&"}], "/@", "DTs"}], ",", "\[IndentingNewLine]", 
         RowBox[{"Join", "[", 
          RowBox[{
           RowBox[{"{", "opts", "}"}], ",", 
           RowBox[{"{", "\[IndentingNewLine]", 
            RowBox[{
             RowBox[{"Frame", "\[Rule]", "True"}], ",", "\[IndentingNewLine]", 
             RowBox[{"FrameStyle", "\[Rule]", "Black"}], ",", 
             "\[IndentingNewLine]", 
             RowBox[{"FrameLabel", "\[Rule]", 
              RowBox[{
               RowBox[{"(", 
                RowBox[{"ColNames", "@", 
                 RowBox[{"First", "@", "DTs"}]}], ")"}], "[", 
               RowBox[{"[", 
                RowBox[{";;", "2"}], "]"}], "]"}]}], ",", 
             "\[IndentingNewLine]", 
             RowBox[{"PlotLegends", "\[Rule]", "Automatic"}], ",", 
             "\[IndentingNewLine]", 
             RowBox[{"PlotRangePadding", "\[Rule]", 
              RowBox[{"Scaled", "[", "0.1", "]"}]}], ",", 
             "\[IndentingNewLine]", 
             RowBox[{"PlotRange", "\[Rule]", "Full"}], ",", 
             "\[IndentingNewLine]", 
             RowBox[{"ImageSize", "\[Rule]", "400"}], ",", 
             "\[IndentingNewLine]", 
             RowBox[{"(*", 
              RowBox[{
               RowBox[{"PlotMarkers", "\[Rule]", "$DefaultPlotMarkers"}], ",",
                "\[IndentingNewLine]", 
               RowBox[{"Method", "\[Rule]", 
                RowBox[{"{", 
                 RowBox[{"\"\<OptimizePlotMarkers\>\"", "\[Rule]", "False"}], 
                 "}"}]}], ","}], "*)"}], "\[IndentingNewLine]", 
             RowBox[{"PlotStyle", "\[Rule]", "$DefaultPlotColors"}], ",", 
             "\[IndentingNewLine]", 
             RowBox[{"FrameTicksStyle", "\[Rule]", "12"}], ",", 
             "\[IndentingNewLine]", 
             RowBox[{"LabelStyle", "\[Rule]", "12"}], ",", 
             "\[IndentingNewLine]", 
             RowBox[{"Axes", "\[Rule]", "False"}], ",", "\[IndentingNewLine]", 
             RowBox[{"ErrorBarFunction", "\[Rule]", 
              RowBox[{"(", 
               RowBox[{
                RowBox[{
                 RowBox[{"ErrorBarPlots`Private`ebarfun", "[", "##", "]"}], "/.", 
                 RowBox[{"l_Line", "\[RuleDelayed]", 
                  RowBox[{"{", 
                   RowBox[{"Black", ",", "Thin", ",", 
                    RowBox[{"Dashing", "[", 
                    RowBox[{"{", "}"}], "]"}], ",", "l"}], "}"}]}]}], "&"}], 
               ")"}]}]}], "\[IndentingNewLine]", "}"}]}], "]"}]}], "]"}], "/.", 
       RowBox[{
        RowBox[{"GraphicsComplex", "[", 
         RowBox[{"x_", ",", "y_", ",", "z___"}], "]"}], "\[RuleDelayed]", 
        RowBox[{"(", 
         RowBox[{"GraphicsComplex", "[", 
          RowBox[{"x", ",", 
           RowBox[{"Replace", "[", 
            RowBox[{"y", ",", 
             RowBox[{"k_List", "\[RuleDelayed]", 
              RowBox[{"If", "[", 
               RowBox[{
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{"k", "//", "First"}], ")"}], "===", 
                 RowBox[{"Opacity", "[", "0.`", "]"}]}], ",", "k", ",", 
                RowBox[{"Reverse", "@", "k"}]}], "]"}]}], ",", 
             RowBox[{"{", "3", "}"}]}], "]"}], ",", "z"}], "]"}], ")"}]}]}]}],
      "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", 
   "]"}]}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"13ceb6bc-4f36-4ba6-94c6-5cc5f56bc24d"],

Cell[BoxData[
 RowBox[{
  RowBox[{"PrepareErrorList", "[", 
   RowBox[{"dt_DataTable", ",", "showErrors_"}], "]"}], ":=", 
  RowBox[{"Module", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"{", "}"}], ",", "\[IndentingNewLine]", 
    RowBox[{"(", "\[IndentingNewLine]", 
     RowBox[{"Prepend", "[", 
      RowBox[{
       RowBox[{"MapThread", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"Tooltip", "[", 
           RowBox[{
            RowBox[{"{", "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"DVMeans", "@", 
               RowBox[{"{", 
                RowBox[{
                 RowBox[{"#1", "[", 
                  RowBox[{"[", "1", "]"}], "]"}], ",", 
                 RowBox[{"#1", "[", 
                  RowBox[{"[", "2", "]"}], "]"}]}], "}"}]}], ",", 
              "\[IndentingNewLine]", 
              RowBox[{"ErrorBar", "[", "\[IndentingNewLine]", 
               RowBox[{
                RowBox[{"If", "[", 
                 RowBox[{"showErrors", ",", 
                  RowBox[{"Switch", "[", 
                   RowBox[{
                    RowBox[{"Head", "[", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], "]"}], ",", 
                    "\[IndentingNewLine]", "NDV", ",", 
                    RowBox[{
                    RowBox[{"IV", "[", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], "]"}], "[", 
                    RowBox[{"[", "2", "]"}], "]"}], ",", 
                    "\[IndentingNewLine]", "IV", ",", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "2"}], "]"}], "]"}], ",", 
                    "\[IndentingNewLine]", "DV", ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"#1", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "3"}], "]"}], "]"}], "===", "Null"}], 
                    ",", "0", ",", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "3"}], "]"}], "]"}]}], "]"}], ",", 
                    "\[IndentingNewLine]", "_", ",", "0"}], 
                   "\[IndentingNewLine]", "]"}], ",", "0"}], "]"}], ",", 
                "\[IndentingNewLine]", 
                RowBox[{"If", "[", 
                 RowBox[{"showErrors", ",", 
                  RowBox[{"If", "[", 
                   RowBox[{"showErrors", ",", 
                    RowBox[{"Switch", "[", 
                    RowBox[{
                    RowBox[{"Head", "[", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], "]"}], ",", 
                    "\[IndentingNewLine]", "NDV", ",", 
                    RowBox[{
                    RowBox[{"IV", "[", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], "]"}], "[", 
                    RowBox[{"[", "2", "]"}], "]"}], ",", 
                    "\[IndentingNewLine]", "IV", ",", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "2"}], "]"}], "]"}], ",", 
                    "\[IndentingNewLine]", "DV", ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"#1", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "3"}], "]"}], "]"}], "===", "Null"}], 
                    ",", "0", ",", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "3"}], "]"}], "]"}]}], "]"}], ",", 
                    "\[IndentingNewLine]", "_", ",", "0"}], 
                    "\[IndentingNewLine]", "]"}], ",", "0"}], "]"}], ",", 
                  "0"}], "]"}]}], "\[IndentingNewLine]", "]"}]}], 
             "\[IndentingNewLine]", "}"}], ",", 
            RowBox[{
             RowBox[{"ToString", "[", "#2", "]"}], "<>", "\"\< \>\"", "<>", 
             RowBox[{"ToString", "[", 
              RowBox[{"ToString", "/@", "#1"}], "]"}]}]}], "]"}], "&"}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"NV", "@", "dt"}], ",", 
           RowBox[{"NK", "@", "dt"}]}], "}"}]}], "\[IndentingNewLine]", "]"}],
        ",", 
       RowBox[{"{", 
        RowBox[{"Null", ",", "Null"}], "}"}]}], "]"}], "\[IndentingNewLine]", 
     ")"}]}], "\[IndentingNewLine]", "]"}]}]], "Input",
 InitializationCell->
  True,ExpressionUUID->"3ada0169-a8b1-469e-92c6-3bdc5c29d140"]
}, Open  ]],

Cell[CellGroupData[{

Cell["SciDraw integration", "Section",
 CellTags->"Null"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"DefineStyle", "[", 
    RowBox[{"\"\<DataAnalysis\>\"", ",", "\[IndentingNewLine]", 
     RowBox[{"{", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"FigObject", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"FontFamily", "\[Rule]", "\"\<Helvetica\>\""}], ",", 
          RowBox[{"FontSize", "\[Rule]", "12"}]}], "}"}]}], ",", 
       "\[IndentingNewLine]", 
       RowBox[{"Figure", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"CanvasMargin", "\[Rule]", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{"{", 
             RowBox[{"0.8", ",", "0.3"}], "}"}], ",", 
            RowBox[{"{", 
             RowBox[{"0.5", ",", "0.5"}], "}"}]}], "}"}]}], "}"}]}], ",", 
       "\[IndentingNewLine]", 
       RowBox[{"FigurePanel", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"TickFontSize", "\[Rule]", "11"}], ",", 
          RowBox[{"FrameFontSize", "\[Rule]", "12"}], ",", 
          RowBox[{"PanelLetterFontSize", "\[Rule]", "12"}], ",", 
          RowBox[{"ExtendRange", "\[Rule]", "0.07"}]}], "}"}]}], ",", 
       "\[IndentingNewLine]", 
       RowBox[{"Multipanel", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"TickFontSize", "\[Rule]", "11"}], ",", 
          RowBox[{"FrameFontSize", "\[Rule]", "12"}], ",", 
          RowBox[{"PanelLetterFontSize", "\[Rule]", "12"}], ",", 
          RowBox[{"ExtendRange", "\[Rule]", "0.07"}]}], "}"}]}], ",", 
       "\[IndentingNewLine]", 
       RowBox[{"DataLegend", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"FontSize", "\[Rule]", "12"}], "}"}]}], ",", 
       "\[IndentingNewLine]", 
       RowBox[{"FigLabel", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"FontSize", "\[Rule]", "12"}], "}"}]}]}], 
      "\[IndentingNewLine]", "}"}]}], "\[IndentingNewLine]", "]"}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"$SciDrawPlotMarkers", "=", 
   RowBox[{"{", 
    RowBox[{
    "\"\<Circle\>\"", ",", "\"\<Square\>\"", ",", "\"\<Diamond\>\"", ",", 
     "\"\<UpTriangle\>\"", ",", "\"\<DownTriangle\>\"", ",", 
     "\"\<LeftTriangle\>\"", ",", "\"\<RightTriangle\>\""}], "}"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"MapIndexed", "[", 
   RowBox[{
    RowBox[{
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"DefineStyle", "[", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{"\"\<DataAnalysisCurves\>\"", ",", 
           RowBox[{"#2", "[", 
            RowBox[{"[", "1", "]"}], "]"}]}], "}"}], ",", 
         RowBox[{"{", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"DataLine", "\[Rule]", 
            RowBox[{"{", "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"LineColor", "\[Rule]", "#1"}], ",", 
              "\[IndentingNewLine]", 
              RowBox[{"LineThickness", "\[Rule]", "Medium"}], ",", 
              "\[IndentingNewLine]", 
              RowBox[{"LineDashing", "\[Rule]", "None"}]}], 
             "\[IndentingNewLine]", "}"}]}], ",", "\[IndentingNewLine]", 
           RowBox[{"FigLine", "\[Rule]", 
            RowBox[{"{", "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"LineColor", "\[Rule]", "#1"}], ",", 
              "\[IndentingNewLine]", 
              RowBox[{"LineThickness", "\[Rule]", "Medium"}], ",", 
              "\[IndentingNewLine]", 
              RowBox[{"LineDashing", "\[Rule]", "None"}]}], 
             "\[IndentingNewLine]", "}"}]}], ",", "\[IndentingNewLine]", 
           RowBox[{"DataSymbol", "\[Rule]", 
            RowBox[{"{", "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"SymbolShape", "\[Rule]", 
               RowBox[{"$SciDrawPlotMarkers", "[", 
                RowBox[{"[", 
                 RowBox[{
                  RowBox[{"Mod", "[", 
                   RowBox[{
                    RowBox[{"#2", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"Length", "[", "$SciDrawPlotMarkers", "]"}]}], 
                   "]"}], "/.", 
                  RowBox[{"{", 
                   RowBox[{"0", "\[Rule]", 
                    RowBox[{"Length", "[", "$SciDrawPlotMarkers", "]"}]}], 
                   "}"}]}], "]"}], "]"}]}], ",", 
              RowBox[{"FillColor", "\[Rule]", "#1"}], ",", 
              RowBox[{"SymbolSize", "\[Rule]", "8"}]}], "\[IndentingNewLine]",
              "}"}]}]}], "\[IndentingNewLine]", "}"}]}], "]"}], ";"}], 
      "\[IndentingNewLine]", ")"}], "&"}], ",", "$DefaultPlotColors"}], "]"}],
   ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"92e202f9-fa3b-4d35-8028-c7373f216105"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"Options", "[", "SciDrawPlot", "]"}], "=", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{
      RowBox[{"XErrorBars", "\[Rule]", "True"}], ",", 
      RowBox[{"YErrorBars", "\[Rule]", "True"}], 
      RowBox[{"(*", 
       RowBox[{",", 
        RowBox[{"XLogScale", "\[Rule]", "False"}], ",", 
        RowBox[{"YLogScale", "\[Rule]", "False"}]}], "*)"}], ",", 
      RowBox[{"AnchorName", "\[Rule]", "None"}]}], "}"}], "~", "Join", "~", 
    RowBox[{"Options", "[", "DataPlot", "]"}]}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"XErrorBars", "::", "usage"}], "=", 
   "\"\<XErrorBars is an option that specifies if error bars should be drawn \
for the x-axis.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"YErrorBars", "::", "usage"}], "=", 
    "\"\<YErrorBars is an option that specifies if error bars should be drawn \
for the y-axis.\>\""}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"SciDrawPlot", "::", "usage"}], "=", 
   "\"\<SciDrawPlot[{{\!\(\*SubscriptBox[\(x\), \
\(1\)]\),\!\(\*SubscriptBox[\(y\), \(1\)]\)},{\!\(\*SubscriptBox[\(x\), \
\(2\)]\),\!\(\*SubscriptBox[\(y\), \(2\)]\)},...}] returns a DataPlot object \
which can be used to plot the data inside a SciDraw Figure. Error bars can be \
plotted if \!\(\*SubscriptBox[\(x\), \(i\)]\) and \!\(\*SubscriptBox[\(y\), \
\(i\)]\) are NDV-, DV-, or IV-type objects.\nSciDrawPlot[datatable] returns a \
DataPlot object with data in a DataTable, which can be used inside a SciDraw \
Figure.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"SciDrawPlot", "[", 
     RowBox[{"dt_List", ",", 
      RowBox[{"opts", ":", 
       RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
    RowBox[{"Module", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"Data", ",", 
        RowBox[{"XAsymErrors", "=", "False"}], ",", 
        RowBox[{"YAsymErrors", "=", "False"}]}], "}"}], ",", 
      "\[IndentingNewLine]", 
      RowBox[{"(", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"Data", "=", "dt"}], ";", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"OptionValue", "[", "XErrorBars", "]"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"(", "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"XAsymErrors", "=", 
             RowBox[{"TrueQ", "[", 
              RowBox[{"Or", "@@", 
               RowBox[{"(", 
                RowBox[{
                 RowBox[{
                  RowBox[{"MatchQ", "[", 
                   RowBox[{"#", ",", 
                    RowBox[{
                    RowBox[{"DV", "[", 
                    RowBox[{"_", ",", "_", ",", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"_", "?", "PosNumPatternQ"}], ",", 
                    RowBox[{"_", "?", "PosNumPatternQ"}]}], "}"}], ",", "_"}],
                     "]"}], "|", 
                    RowBox[{"IV", "[", 
                    RowBox[{"_", ",", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"_", "?", "PosNumPatternQ"}], ",", 
                    RowBox[{"_", "?", "PosNumPatternQ"}]}], "}"}]}], 
                    "]"}]}]}], "]"}], "&"}], "/@", 
                 RowBox[{"Data", "[", 
                  RowBox[{"[", 
                   RowBox[{"All", ",", "1"}], "]"}], "]"}]}], ")"}]}], 
              "]"}]}], ";", "\[IndentingNewLine]", 
            RowBox[{"Data", "=", 
             RowBox[{"If", "[", 
              RowBox[{"XAsymErrors", ",", "\[IndentingNewLine]", 
               RowBox[{
                RowBox[{
                 RowBox[{"Switch", "[", 
                  RowBox[{
                   RowBox[{"Head", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], "]"}], ",", 
                   "\[IndentingNewLine]", "NDV", ",", 
                   RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], ",", 
                    RowBox[{
                    RowBox[{"IV", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], "]"}], "[", 
                    RowBox[{"[", "2", "]"}], "]"}], ",", 
                    RowBox[{
                    RowBox[{"IV", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], "]"}], "[", 
                    RowBox[{"[", "2", "]"}], "]"}]}], "}"}], ",", 
                   "\[IndentingNewLine]", "DV", ",", 
                   RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "3"}], "]"}], "]"}], "===", "Null"}], 
                    ",", 
                    RowBox[{"{", 
                    RowBox[{"0", ",", "0"}], "}"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"ListQ", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "3"}], "]"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "3"}], "]"}], "]"}], ",", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "3"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "3"}], "]"}], "]"}]}], "}"}]}], "]"}]}],
                     "]"}]}], "}"}], ",", "\[IndentingNewLine]", "IV", ",", 
                   RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"ListQ", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "2"}], "]"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "2"}], "]"}], "]"}], ",", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "2"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "2"}], "]"}], "]"}]}], "}"}]}], "]"}]}],
                     "}"}], ",", "\[IndentingNewLine]", "_", ",", 
                   RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], ",", "0", ",", "0"}], 
                    "}"}]}], "\[IndentingNewLine]", "]"}], "&"}], "/@", 
                "Data"}], ",", "\[IndentingNewLine]", 
               RowBox[{
                RowBox[{
                 RowBox[{"Switch", "[", 
                  RowBox[{
                   RowBox[{"Head", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], "]"}], ",", 
                   "\[IndentingNewLine]", "NDV", ",", 
                   RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], ",", 
                    RowBox[{
                    RowBox[{"IV", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], "]"}], "[", 
                    RowBox[{"[", "2", "]"}], "]"}]}], "}"}], ",", 
                   "\[IndentingNewLine]", "DV", ",", 
                   RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "3"}], "]"}], "]"}], "===", "Null"}], 
                    ",", "0", ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "3"}], "]"}], "]"}]}], "]"}]}], "}"}], 
                   ",", "\[IndentingNewLine]", "IV", ",", 
                   RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "2"}], "]"}], "]"}]}], "}"}], ",", 
                   "\[IndentingNewLine]", "_", ",", 
                   RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], ",", "0"}], "}"}]}], 
                  "\[IndentingNewLine]", "]"}], "&"}], "/@", "Data"}]}], 
              "\[IndentingNewLine]", "]"}]}], ";", "\[IndentingNewLine]", 
            RowBox[{"Data", "=", 
             RowBox[{"Flatten", "/@", "Data"}]}], ";"}], 
           "\[IndentingNewLine]", ")"}], ",", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{
            RowBox[{"Data", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "1"}], "]"}], "]"}], "=", 
            RowBox[{
             RowBox[{"Data", "[", 
              RowBox[{"[", 
               RowBox[{"All", ",", "1"}], "]"}], "]"}], "//", "DVMeans"}]}], 
           ";"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"OptionValue", "[", "YErrorBars", "]"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"(", "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"YAsymErrors", "=", 
             RowBox[{"TrueQ", "[", 
              RowBox[{"Or", "@@", 
               RowBox[{"(", 
                RowBox[{
                 RowBox[{
                  RowBox[{"MatchQ", "[", 
                   RowBox[{"#", ",", 
                    RowBox[{
                    RowBox[{"DV", "[", 
                    RowBox[{"_", ",", "_", ",", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"_", "?", "PosNumPatternQ"}], ",", 
                    RowBox[{"_", "?", "PosNumPatternQ"}]}], "}"}], ",", "_"}],
                     "]"}], "|", 
                    RowBox[{"IV", "[", 
                    RowBox[{"_", ",", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"_", "?", "PosNumPatternQ"}], ",", 
                    RowBox[{"_", "?", "PosNumPatternQ"}]}], "}"}]}], 
                    "]"}]}]}], "]"}], "&"}], "/@", 
                 RowBox[{"Data", "[", 
                  RowBox[{"[", 
                   RowBox[{"All", ",", "2"}], "]"}], "]"}]}], ")"}]}], 
              "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
            RowBox[{"Data", "=", 
             RowBox[{"If", "[", 
              RowBox[{"YAsymErrors", ",", "\[IndentingNewLine]", 
               RowBox[{
                RowBox[{
                 RowBox[{"Switch", "[", 
                  RowBox[{
                   RowBox[{"Head", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], "]"}], ",", 
                   "\[IndentingNewLine]", "NDV", ",", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"Length", "[", "#", "]"}], ">", "2"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"3", ";;"}], "]"}], "]"}], ",", 
                    RowBox[{
                    RowBox[{"IV", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], "]"}], "[", 
                    RowBox[{"[", "2", "]"}], "]"}], ",", 
                    RowBox[{
                    RowBox[{"IV", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], "]"}], "[", 
                    RowBox[{"[", "2", "]"}], "]"}]}], "}"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{
                    RowBox[{"IV", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], "]"}], "[", 
                    RowBox[{"[", "2", "]"}], "]"}], ",", 
                    RowBox[{
                    RowBox[{"IV", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], "]"}], "[", 
                    RowBox[{"[", "2", "]"}], "]"}]}], "}"}]}], "]"}], ",", 
                   "\[IndentingNewLine]", "DV", ",", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"Length", "[", "#", "]"}], ">", "2"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"3", ";;"}], "]"}], "]"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "3"}], "]"}], "]"}], "===", "Null"}], 
                    ",", 
                    RowBox[{"{", 
                    RowBox[{"0", ",", "0"}], "}"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"ListQ", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "3"}], "]"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "3"}], "]"}], "]"}], ",", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "3"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "3"}], "]"}], "]"}]}], "}"}]}], "]"}]}],
                     "]"}]}], "}"}], ",", "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "3"}], "]"}], "]"}], "===", "Null"}], 
                    ",", 
                    RowBox[{"{", 
                    RowBox[{"0", ",", "0"}], "}"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"ListQ", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "3"}], "]"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "3"}], "]"}], "]"}], ",", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "3"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "3"}], "]"}], "]"}]}], "}"}]}], "]"}]}],
                     "]"}]}], "}"}]}], "\[IndentingNewLine]", "]"}], ",", 
                   "\[IndentingNewLine]", "IV", ",", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"Length", "[", "#", "]"}], ">", "2"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"3", ";;"}], "]"}], "]"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"ListQ", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "2"}], "]"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "2"}], "]"}], "]"}], ",", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "2"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "2"}], "]"}], "]"}]}], "}"}]}], "]"}]}],
                     "}"}], ",", "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"ListQ", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "2"}], "]"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "2"}], "]"}], "]"}], ",", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "2"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "2"}], "]"}], "]"}]}], "}"}]}], "]"}]}],
                     "}"}]}], "\[IndentingNewLine]", "]"}], ",", 
                   "\[IndentingNewLine]", "_", ",", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"Length", "[", "#", "]"}], ">", "2"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"3", ";;"}], "]"}], "]"}], ",", "0", ",", "0"}], 
                    "}"}], ",", "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], ",", "0", ",", "0"}], 
                    "}"}]}], "\[IndentingNewLine]", "]"}]}], 
                  "\[IndentingNewLine]", "]"}], "&"}], "/@", "Data"}], ",", 
               "\[IndentingNewLine]", 
               RowBox[{
                RowBox[{
                 RowBox[{"Switch", "[", 
                  RowBox[{
                   RowBox[{"Head", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], "]"}], ",", 
                   "\[IndentingNewLine]", "NDV", ",", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"Length", "[", "#", "]"}], ">", "2"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"3", ";;"}], "]"}], "]"}], ",", 
                    RowBox[{
                    RowBox[{"IV", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], "]"}], "[", 
                    RowBox[{"[", "2", "]"}], "]"}]}], "}"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{
                    RowBox[{"IV", "[", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], "]"}], "[", 
                    RowBox[{"[", "2", "]"}], "]"}]}], "}"}]}], "]"}], ",", 
                   "\[IndentingNewLine]", "DV", ",", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"Length", "[", "#", "]"}], ">", "2"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"3", ";;"}], "]"}], "]"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "3"}], "]"}], "]"}], "===", "Null"}], 
                    ",", "0", ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "3"}], "]"}], "]"}]}], "]"}]}], "}"}], 
                    ",", "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "3"}], "]"}], "]"}], "===", "Null"}], 
                    ",", "0", ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "3"}], "]"}], "]"}]}], "]"}]}], "}"}]}],
                     "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]",
                    "IV", ",", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"Length", "[", "#", "]"}], ">", "2"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"3", ";;"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "2"}], "]"}], "]"}]}], "}"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "2"}], "]"}], "]"}]}], "}"}]}], 
                    "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", 
                   "_", ",", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"Length", "[", "#", "]"}], ">", "2"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", 
                    RowBox[{"3", ";;"}], "]"}], "]"}], ",", "0"}], "}"}], ",",
                     "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], ",", "0"}], "}"}]}], 
                    "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", 
                  "]"}], "&"}], "/@", "Data"}]}], "\[IndentingNewLine]", 
              "]"}]}], ";", "\[IndentingNewLine]", 
            RowBox[{"Data", "=", 
             RowBox[{"Flatten", "/@", "Data"}]}], ";"}], 
           "\[IndentingNewLine]", ")"}], ",", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{
            RowBox[{"Data", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "2"}], "]"}], "]"}], "=", 
            RowBox[{
             RowBox[{"Data", "[", 
              RowBox[{"[", 
               RowBox[{"All", ",", "2"}], "]"}], "]"}], "//", "DVMeans"}]}], 
           ";"}]}], "\[IndentingNewLine]", "]"}], ";", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{
          RowBox[{"Data", "=", 
           RowBox[{"MapThread", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"Tooltip", "[", 
               RowBox[{"#1", ",", 
                RowBox[{"#2", "<>", "\"\< \>\"", "<>", 
                 RowBox[{"ToString", "[", 
                  RowBox[{"{", "\[IndentingNewLine]", 
                   RowBox[{
                    RowBox[{"ToString", "@", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"TrueQ", "[", 
                    RowBox[{"OptionValue", "[", "XLogScale", "]"}], "]"}], 
                    ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "3", "]"}], "]"}], ">", "0"}], ",", 
                    RowBox[{"EVE", "@", 
                    RowBox[{"(", 
                    RowBox[{"10", "^", 
                    RowBox[{"EV", "[", 
                    RowBox[{
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "3", "]"}], "]"}]}], "]"}]}], ")"}]}], ",", 
                    RowBox[{"10", "^", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}]}], "]"}], ",", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}], "]"}]}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"ToString", "@", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"TrueQ", "[", 
                    RowBox[{"OptionValue", "[", "YLogScale", "]"}], "]"}], 
                    ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"TrueQ", "[", "XErrorBars", "]"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "3", "]"}], "]"}], ">", "0"}], ",", 
                    RowBox[{"EVE", "@", 
                    RowBox[{"(", 
                    RowBox[{"10", "^", 
                    RowBox[{"EV", "[", 
                    RowBox[{
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "3", "]"}], "]"}]}], "]"}]}], ")"}]}], ",", 
                    RowBox[{"10", "^", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}]}], "]"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "4", "]"}], "]"}], ">", "0"}], ",", 
                    RowBox[{"EVE", "@", 
                    RowBox[{"(", 
                    RowBox[{"10", "^", 
                    RowBox[{"EV", "[", 
                    RowBox[{
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "4", "]"}], "]"}]}], "]"}]}], ")"}]}], ",", 
                    RowBox[{"10", "^", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}]}], "]"}]}], 
                    "\[IndentingNewLine]", "]"}], ",", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "2", "]"}], "]"}]}], "]"}]}]}], 
                   "\[IndentingNewLine]", "}"}], "]"}]}]}], "]"}], "&"}], ",", 
             RowBox[{"{", 
              RowBox[{"Data", ",", "\[IndentingNewLine]", "labels"}], "}"}]}],
             "]"}]}], ";"}], "*)"}], "\[IndentingNewLine]", 
        "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"TrueQ", "[", 
           RowBox[{
            RowBox[{"OptionValue", "[", "AnchorName", "]"}], "\[NotEqual]", 
            "None"}], "]"}], ",", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"DataPlot", "[", 
            RowBox[{"[", 
             RowBox[{"OptionValue", "[", "AnchorName", "]"}], "]"}], "]"}], 
           "[", 
           RowBox[{"Data", ",", 
            RowBox[{"Sequence", "@@", 
             RowBox[{"DeleteCases", "[", 
              RowBox[{
               RowBox[{"Join", "[", 
                RowBox[{
                 RowBox[{"{", "\[IndentingNewLine]", 
                  RowBox[{
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"OptionValue", "[", "XErrorBars", "]"}], ",", 
                    RowBox[{"XErrorColumn", "\[Rule]", 
                    RowBox[{"If", "[", 
                    RowBox[{"XAsymErrors", ",", 
                    RowBox[{"{", 
                    RowBox[{"3", ",", "4"}], "}"}], ",", "3"}], "]"}]}], ",", 
                    "Null"}], "]"}], ",", "\[IndentingNewLine]", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"OptionValue", "[", "YErrorBars", "]"}], ",", 
                    RowBox[{"YErrorColumn", "\[Rule]", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"OptionValue", "[", "XErrorBars", "]"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{"XAsymErrors", ",", 
                    RowBox[{"If", "[", 
                    RowBox[{"YAsymErrors", ",", 
                    RowBox[{"{", 
                    RowBox[{"5", ",", "6"}], "}"}], ",", "5"}], "]"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{"YAsymErrors", ",", 
                    RowBox[{"{", 
                    RowBox[{"4", ",", "5"}], "}"}], ",", "4"}], "]"}]}], 
                    "]"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{"YAsymErrors", ",", 
                    RowBox[{"{", 
                    RowBox[{"3", ",", "4"}], "}"}], ",", "3"}], "]"}]}], 
                    "]"}]}], ",", "Null"}], "]"}]}], "\[IndentingNewLine]", 
                  "}"}], ",", 
                 RowBox[{"FilterRules", "[", 
                  RowBox[{
                   RowBox[{"{", "opts", "}"}], ",", " ", 
                   RowBox[{"Options", "[", "DataPlot", "]"}]}], "]"}]}], 
                "]"}], ",", "Null"}], "]"}]}]}], "]"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"DataPlot", "[", 
           RowBox[{"Data", ",", 
            RowBox[{"Sequence", "@@", 
             RowBox[{"DeleteCases", "[", 
              RowBox[{
               RowBox[{"Join", "[", 
                RowBox[{
                 RowBox[{"{", "\[IndentingNewLine]", 
                  RowBox[{
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"OptionValue", "[", "XErrorBars", "]"}], ",", 
                    RowBox[{"XErrorColumn", "\[Rule]", 
                    RowBox[{"If", "[", 
                    RowBox[{"XAsymErrors", ",", 
                    RowBox[{"{", 
                    RowBox[{"3", ",", "4"}], "}"}], ",", "3"}], "]"}]}], ",", 
                    "Null"}], "]"}], ",", "\[IndentingNewLine]", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"OptionValue", "[", "YErrorBars", "]"}], ",", 
                    RowBox[{"YErrorColumn", "\[Rule]", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"OptionValue", "[", "XErrorBars", "]"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{"XAsymErrors", ",", 
                    RowBox[{"If", "[", 
                    RowBox[{"YAsymErrors", ",", 
                    RowBox[{"{", 
                    RowBox[{"5", ",", "6"}], "}"}], ",", "5"}], "]"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{"YAsymErrors", ",", 
                    RowBox[{"{", 
                    RowBox[{"4", ",", "5"}], "}"}], ",", "4"}], "]"}]}], 
                    "]"}], ",", 
                    RowBox[{"If", "[", 
                    RowBox[{"YAsymErrors", ",", 
                    RowBox[{"{", 
                    RowBox[{"3", ",", "4"}], "}"}], ",", "3"}], "]"}]}], 
                    "]"}]}], ",", "Null"}], "]"}]}], "\[IndentingNewLine]", 
                  "}"}], ",", 
                 RowBox[{"FilterRules", "[", 
                  RowBox[{
                   RowBox[{"{", "opts", "}"}], ",", " ", 
                   RowBox[{"Options", "[", "DataPlot", "]"}]}], "]"}]}], 
                "]"}], ",", "Null"}], "]"}]}]}], "]"}]}], 
         "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", ")"}]}], 
     "\[IndentingNewLine]", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"SciDrawPlot", "[", 
    RowBox[{"dt_DataTable", ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
   RowBox[{"Module", "[", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", "TrimmedData", "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"TrimmedData", "=", 
        RowBox[{"DeleteMissing", "[", 
         RowBox[{"dt", ",", "1", ",", "1"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"SciDrawPlot", "[", 
        RowBox[{
         RowBox[{"TrimmedData", "//", "NV"}], ",", 
         RowBox[{"(*", 
          RowBox[{
           RowBox[{"TrimmedData", "//", "NK"}], ","}], "*)"}], 
         RowBox[{"Join", "[", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{"AnchorName", "\[Rule]", 
             RowBox[{
              RowBox[{"ColNames", "[", "dt", "]"}], "[", 
              RowBox[{"[", "2", "]"}], "]"}]}], "}"}], ",", 
           RowBox[{"{", "opts", "}"}]}], "]"}]}], "]"}]}], 
      "\[IndentingNewLine]", ")"}]}], "]"}]}], ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"036262f9-b803-45e4-8261-924c054de0ac"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"SetAttributes", "[", 
   RowBox[{"Fig", ",", "HoldFirst"}], "]"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Options", "[", "Fig", "]"}], "=", 
   RowBox[{"Join", "[", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{
       RowBox[{"XLogScale", "\[Rule]", "False"}], ",", 
       RowBox[{"YLogScale", "\[Rule]", "False"}], ",", 
       RowBox[{"Joined", "\[Rule]", "False"}], ",", 
       RowBox[{"PlotMarkers", "\[Rule]", "True"}], ",", 
       RowBox[{"ShowLegend", "\[Rule]", "Automatic"}], ",", 
       RowBox[{"PlotLegends", "\[Rule]", "Automatic"}]}], "}"}], ",", 
     RowBox[{"Options", "[", "FigurePanel", "]"}], ",", 
     RowBox[{"Options", "[", "Figure", "]"}], ",", 
     RowBox[{"Options", "[", "SciDrawPlot", "]"}]}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"XLogScale", "::", "usage"}], "=", 
   "\"\<XLogScale is an option that specifies if Log10[x] should be applied \
to the x coordinates in the plot.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"YLogScale", "::", "usage"}], "=", 
   "\"\<YLogScale is an option that specifies if Log10[y] should be applied \
to the y coordinates in the plot.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"ShowLegend", "::", "usage"}], "=", 
    "\"\<ShowLegend is an option that specifies if a plot legend should be \
shown.\>\""}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Fig", "::", "usage"}], "=", 
   "\"\<Fig[{\!\(\*SubscriptBox[\(object\), \
\(1\)]\),\!\(\*SubscriptBox[\(object\), \(2\)]\),...}] returns a figure with \
plots of the objects using the SciDraw package. The objects can be of the \
type DataTable or Graphic.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Fig", "::", "nodatatable"}], "=", 
   "\"\<At least one DataTable must be displayed if no PlotRange option is \
not specified.\>\""}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Fig", "[", 
    RowBox[{"plots_", ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
   RowBox[{"Module", "[", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"TmpStyles", ",", "DTs", ",", "PR", ",", "ColLabels"}], "}"}], 
     ",", "\[IndentingNewLine]", 
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"DTs", "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"Head", "[", "plots", "]"}], "===", "DataTable"}], ",", 
          RowBox[{"{", "plots", "}"}], ",", 
          RowBox[{"Cases", "[", 
           RowBox[{"plots", ",", "_DataTable"}], "]"}]}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"DTs", "=", 
        RowBox[{
         RowBox[{
          RowBox[{"DeleteMissing", "[", 
           RowBox[{"#", ",", "1", ",", "1"}], "]"}], "&"}], "/@", "DTs"}]}], 
       ";", "\[IndentingNewLine]", 
       RowBox[{"PR", "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"ListQ", "[", 
           RowBox[{"OptionValue", "[", "PlotRange", "]"}], "]"}], ",", 
          RowBox[{"OptionValue", "[", "PlotRange", "]"}], ",", 
          RowBox[{"CalcPlotRange", "[", 
           RowBox[{"DTs", ",", 
            RowBox[{"FilterRules", "[", 
             RowBox[{
              RowBox[{"{", "opts", "}"}], ",", " ", 
              RowBox[{"Options", "[", "CalcPlotRange", "]"}]}], "]"}]}], 
           "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"ColLabels", "=", 
        RowBox[{"ColNames", "@", 
         RowBox[{"First", "@", "DTs"}]}]}], ";", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"TrueQ", "[", 
           RowBox[{"OptionValue", "[", "XLogScale", "]"}], "]"}], "||", 
          RowBox[{"TrueQ", "[", 
           RowBox[{"OptionValue", "[", "YLogScale", "]"}], "]"}]}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"DTs", "=", 
           RowBox[{
            RowBox[{
             RowBox[{"#", "[", 
              RowBox[{"All", ",", 
               RowBox[{
                RowBox[{"<|", "\[IndentingNewLine]", 
                 RowBox[{
                  RowBox[{"\"\<x\>\"", "\[Rule]", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"TrueQ", "[", 
                    RowBox[{"OptionValue", "[", "XLogScale", "]"}], "]"}], 
                    ",", 
                    RowBox[{"Log10", "@", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}], "]"}]}], ",", 
                  "\[IndentingNewLine]", 
                  RowBox[{"\"\<y\>\"", "\[Rule]", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"TrueQ", "[", 
                    RowBox[{"OptionValue", "[", "YLogScale", "]"}], "]"}], 
                    ",", 
                    RowBox[{"Log10", "@", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}]}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}]}], "]"}]}]}], 
                 "\[IndentingNewLine]", "|>"}], "&"}]}], "]"}], "&"}], "/@", 
            "DTs"}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"Figure", "[", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"FigurePanel", "[", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"{", "\[IndentingNewLine]", 
            RowBox[{
             RowBox[{"SetOptions", "[", 
              RowBox[{"DataPlot", ",", 
               RowBox[{"DataSymbol", "\[Rule]", 
                RowBox[{"{", 
                 RowBox[{"Show", "\[Rule]", 
                  RowBox[{"OptionValue", "[", "PlotMarkers", "]"}]}], 
                 "}"}]}]}], "]"}], ",", "\[IndentingNewLine]", 
             RowBox[{"SetOptions", "[", 
              RowBox[{"DataPlot", ",", 
               RowBox[{"DataLine", "\[Rule]", 
                RowBox[{"{", 
                 RowBox[{"Show", "\[Rule]", 
                  RowBox[{"OptionValue", "[", "Joined", "]"}]}], "}"}]}]}], 
              "]"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", 
             RowBox[{"(", 
              RowBox[{"FigGraphics", "/@", 
               RowBox[{"Cases", "[", 
                RowBox[{"plots", ",", "_Graphics"}], "]"}]}], ")"}], ",", 
             "\[IndentingNewLine]", 
             RowBox[{"(", 
              RowBox[{"ReleaseHold", "/@", 
               RowBox[{"Cases", "[", 
                RowBox[{"plots", ",", 
                 RowBox[{"Except", "[", 
                  RowBox[{"_DataTable", "|", "_Graphics"}], "]"}]}], "]"}]}], 
              ")"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{"MapIndexed", "[", 
               RowBox[{
                RowBox[{
                 RowBox[{"SciDrawPlot", "[", 
                  RowBox[{"#1", ",", 
                   RowBox[{"Append", "[", 
                    RowBox[{
                    RowBox[{"FilterRules", "[", 
                    RowBox[{
                    RowBox[{"{", "opts", "}"}], ",", " ", 
                    RowBox[{"Options", "[", "SciDrawPlot", "]"}]}], "]"}], 
                    ",", "\[IndentingNewLine]", 
                    RowBox[{"Style", "\[Rule]", 
                    RowBox[{"{", 
                    RowBox[{"\"\<DataAnalysisCurves\>\"", ",", 
                    RowBox[{"Mod", "[", 
                    RowBox[{
                    RowBox[{"#2", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"Length", "[", "$DefaultPlotColors", "]"}], ",", 
                    "1"}], "]"}]}], "}"}]}]}], "]"}]}], "]"}], "&"}], ",", 
                "DTs"}], "]"}], 
              RowBox[{"(*", ",", "*)"}], "\[IndentingNewLine]", 
              "\[IndentingNewLine]", 
              RowBox[{"If", "[", 
               RowBox[{
                RowBox[{
                 RowBox[{"(", 
                  RowBox[{
                   RowBox[{
                    RowBox[{"OptionValue", "[", "ShowLegend", "]"}], "===", 
                    "Automatic"}], "&&", 
                   RowBox[{
                    RowBox[{"Length", "[", "DTs", "]"}], ">", "1"}]}], ")"}], 
                 "||", 
                 RowBox[{"ListQ", "[", 
                  RowBox[{"OptionValue", "[", "ShowLegend", "]"}], "]"}]}], 
                ",", "\[IndentingNewLine]", 
                RowBox[{"DataLegend", "[", 
                 RowBox[{
                  RowBox[{"If", "[", 
                   RowBox[{
                    RowBox[{
                    RowBox[{"OptionValue", "[", "ShowLegend", "]"}], "===", 
                    "Automatic"}], ",", 
                    RowBox[{"Scaled", "[", 
                    RowBox[{"{", 
                    RowBox[{"0.8", ",", "0.2"}], "}"}], "]"}], ",", 
                    RowBox[{"Scaled", "[", 
                    RowBox[{"OptionValue", "[", "ShowLegend", "]"}], "]"}]}], 
                   "]"}], ",", "\[IndentingNewLine]", 
                  RowBox[{"If", "[", 
                   RowBox[{
                    RowBox[{
                    RowBox[{"OptionValue", "[", "PlotLegends", "]"}], "===", 
                    "Automatic"}], ",", "\[IndentingNewLine]", 
                    RowBox[{"Table", "[", 
                    RowBox[{
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"{", 
                    RowBox[{"\"\<DataAnalysisCurves\>\"", ",", 
                    RowBox[{"Mod", "[", 
                    RowBox[{"i", ",", 
                    RowBox[{"Length", "[", "$DefaultPlotColors", "]"}], ",", 
                    "1"}], "]"}]}], "}"}], ",", 
                    RowBox[{"ToString", "[", "i", "]"}]}], "}"}], ",", 
                    RowBox[{"{", 
                    RowBox[{"i", ",", "1", ",", 
                    RowBox[{"Length", "[", "DTs", "]"}]}], "}"}]}], "]"}], 
                    ",", "\[IndentingNewLine]", 
                    RowBox[{"Table", "[", 
                    RowBox[{
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"{", 
                    RowBox[{"\"\<DataAnalysisCurves\>\"", ",", 
                    RowBox[{"Mod", "[", 
                    RowBox[{"i", ",", 
                    RowBox[{"Length", "[", "$DefaultPlotColors", "]"}], ",", 
                    "1"}], "]"}]}], "}"}], ",", 
                    RowBox[{
                    RowBox[{"OptionValue", "[", "PlotLegends", "]"}], "[", 
                    RowBox[{"[", "i", "]"}], "]"}]}], "}"}], ",", 
                    RowBox[{"{", 
                    RowBox[{"i", ",", "1", ",", 
                    RowBox[{"Length", "[", "DTs", "]"}]}], "}"}]}], "]"}]}], 
                   "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", 
                  RowBox[{"FontFamily", "\[Rule]", "\"\<sans-serif\>\""}]}], 
                 "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", 
                "Null"}], "\[IndentingNewLine]", "]"}]}]}], 
            "\[IndentingNewLine]", "}"}], ",", "\[IndentingNewLine]", 
           RowBox[{"FilterRules", "[", 
            RowBox[{
             RowBox[{"{", "opts", "}"}], ",", " ", 
             RowBox[{"Options", "[", "FigurePanel", "]"}]}], "]"}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{"PlotRange", "\[Rule]", "PR"}], ",", "\[IndentingNewLine]", 
           RowBox[{"Frame", "\[Rule]", "True"}], ",", "\[IndentingNewLine]", 
           RowBox[{"XFrameLabel", "\[Rule]", 
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{"OptionValue", "[", "XLogScale", "]"}], ",", 
              RowBox[{"Log", "[", 
               RowBox[{"ColLabels", "[", 
                RowBox[{"[", "1", "]"}], "]"}], "]"}], ",", 
              RowBox[{"ColLabels", "[", 
               RowBox[{"[", "1", "]"}], "]"}]}], "]"}]}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{"YFrameLabel", "\[Rule]", 
            RowBox[{"If", "[", 
             RowBox[{
              RowBox[{"OptionValue", "[", "YLogScale", "]"}], ",", 
              RowBox[{"Log", "[", 
               RowBox[{"ColLabels", "[", 
                RowBox[{"[", "2", "]"}], "]"}], "]"}], ",", 
              RowBox[{"ColLabels", "[", 
               RowBox[{"[", "2", "]"}], "]"}]}], "]"}]}]}], 
          "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", 
         RowBox[{"FilterRules", "[", 
          RowBox[{
           RowBox[{"{", "opts", "}"}], ",", " ", 
           RowBox[{"Options", "[", "Figure", "]"}]}], "]"}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{"CanvasSize", "\[Rule]", 
          RowBox[{"1", "*", 
           RowBox[{"{", 
            RowBox[{"6", ",", "4"}], "}"}]}]}], ",", "\[IndentingNewLine]", 
         RowBox[{"Style", "\[Rule]", "\"\<DataAnalysis\>\""}]}], 
        "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", ")"}]}], 
    "\[IndentingNewLine]", "]"}]}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Options", "[", "CalcPlotRange", "]"}], "=", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"XLogScale", "\[Rule]", "False"}], ",", 
     RowBox[{"YLogScale", "\[Rule]", "False"}]}], 
    RowBox[{"(*", 
     RowBox[{",", 
      RowBox[{"PlotRangePadding", "\[Rule]", "0.05"}]}], "*)"}], "}"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"CalcPlotRange", "[", 
     RowBox[{"dt_DataTable", ",", 
      RowBox[{"opts", ":", 
       RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
    RowBox[{"Module", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"XMin", ",", "XMax", ",", "YMin", ",", "YMax", ",", "data"}], 
       "}"}], ",", "\[IndentingNewLine]", 
      RowBox[{"(", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"data", "=", 
         RowBox[{"DeleteMissing", "[", 
          RowBox[{"dt", ",", "1", ",", "1"}], "]"}]}], ";", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"XMin", "=", 
         RowBox[{"Min", "@", 
          RowBox[{"data", "[", 
           RowBox[{"All", ",", "1", ",", "DVMeans"}], "]"}]}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"TrueQ", "[", 
           RowBox[{"OptionValue", "[", "XLogScale", "]"}], "]"}], ",", 
          RowBox[{"XMin", "=", 
           RowBox[{"Log10", "[", "XMin", "]"}]}]}], "]"}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"XMax", "=", 
         RowBox[{"Max", "@", 
          RowBox[{"data", "[", 
           RowBox[{"All", ",", "1", ",", "DVMeans"}], "]"}]}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"TrueQ", "[", 
           RowBox[{"OptionValue", "[", "XLogScale", "]"}], "]"}], ",", 
          RowBox[{"XMax", "=", 
           RowBox[{"Log10", "[", "XMax", "]"}]}]}], "]"}], ";", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{
          RowBox[{"XMin", "=", 
           RowBox[{"XMin", "-", 
            RowBox[{
             RowBox[{"Abs", "[", 
              RowBox[{"XMax", "-", "XMin"}], "]"}], "*", 
             RowBox[{"If", "[", 
              RowBox[{
               RowBox[{"ListQ", "[", 
                RowBox[{"OptionValue", "[", "PlotRangePadding", "]"}], "]"}], 
               ",", 
               RowBox[{
                RowBox[{"OptionValue", "[", "PlotRangePadding", "]"}], "[", 
                RowBox[{"[", "1", "]"}], "]"}], ",", 
               RowBox[{"OptionValue", "[", "PlotRangePadding", "]"}]}], 
              "]"}]}]}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"XMin", "\[NotEqual]", "0"}], ",", 
            RowBox[{"XMin", "=", 
             RowBox[{"Floor", "[", 
              RowBox[{"XMin", ",", 
               RowBox[{"10", "^", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"Log10", "[", 
                    RowBox[{"Abs", "[", "XMin", "]"}], "]"}], "//", "Floor"}],
                    ")"}], "-", "1"}], ")"}]}]}], "]"}]}]}], "]"}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"XMax", "=", 
           RowBox[{"XMax", "+", 
            RowBox[{
             RowBox[{"Abs", "[", 
              RowBox[{"XMax", "-", "XMin"}], "]"}], "*", 
             RowBox[{"If", "[", 
              RowBox[{
               RowBox[{"ListQ", "[", 
                RowBox[{"OptionValue", "[", "PlotRangePadding", "]"}], "]"}], 
               ",", 
               RowBox[{
                RowBox[{"OptionValue", "[", "PlotRangePadding", "]"}], "[", 
                RowBox[{"[", "1", "]"}], "]"}], ",", 
               RowBox[{"OptionValue", "[", "PlotRangePadding", "]"}]}], 
              "]"}]}]}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"XMax", "\[NotEqual]", "0"}], ",", 
            RowBox[{"XMax", "=", 
             RowBox[{"Ceiling", "[", 
              RowBox[{"XMax", ",", 
               RowBox[{"10", "^", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"Log10", "[", 
                    RowBox[{"Abs", "[", "XMax", "]"}], "]"}], "//", "Floor"}],
                    ")"}], "-", "1"}], ")"}]}]}], "]"}]}]}], "]"}], ";"}], 
         "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"YMin", "=", 
         RowBox[{"Min", "@", 
          RowBox[{"data", "[", 
           RowBox[{"All", ",", "2", ",", "DVMeans"}], "]"}]}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"TrueQ", "[", 
           RowBox[{"OptionValue", "[", "YLogScale", "]"}], "]"}], ",", 
          RowBox[{"YMin", "=", 
           RowBox[{"Log10", "[", "YMin", "]"}]}]}], "]"}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"YMax", "=", 
         RowBox[{"Max", "@", 
          RowBox[{"data", "[", 
           RowBox[{"All", ",", "2", ",", "DVMeans"}], "]"}]}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"TrueQ", "[", 
           RowBox[{"OptionValue", "[", "YLogScale", "]"}], "]"}], ",", 
          RowBox[{"YMax", "=", 
           RowBox[{"Log10", "[", "YMax", "]"}]}]}], "]"}], ";", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{
          RowBox[{"YMin", "=", 
           RowBox[{"YMin", "-", 
            RowBox[{
             RowBox[{"Abs", "[", 
              RowBox[{"YMax", "-", "YMin"}], "]"}], "*", 
             RowBox[{"If", "[", 
              RowBox[{
               RowBox[{"ListQ", "[", 
                RowBox[{"OptionValue", "[", "PlotRangePadding", "]"}], "]"}], 
               ",", 
               RowBox[{
                RowBox[{"OptionValue", "[", "PlotRangePadding", "]"}], "[", 
                RowBox[{"[", "2", "]"}], "]"}], ",", 
               RowBox[{"OptionValue", "[", "PlotRangePadding", "]"}]}], 
              "]"}]}]}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"YMin", "\[NotEqual]", "0"}], ",", 
            RowBox[{"YMin", "=", 
             RowBox[{"Floor", "[", 
              RowBox[{"YMin", ",", 
               RowBox[{"10", "^", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"Log10", "[", 
                    RowBox[{"Abs", "[", "YMin", "]"}], "]"}], "//", "Floor"}],
                    ")"}], "-", "1"}], ")"}]}]}], "]"}]}]}], "]"}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"YMax", "=", 
           RowBox[{"YMax", "+", 
            RowBox[{
             RowBox[{"Abs", "[", 
              RowBox[{"YMax", "-", "YMin"}], "]"}], "*", 
             RowBox[{"If", "[", 
              RowBox[{
               RowBox[{"ListQ", "[", 
                RowBox[{"OptionValue", "[", "PlotRangePadding", "]"}], "]"}], 
               ",", 
               RowBox[{
                RowBox[{"OptionValue", "[", "PlotRangePadding", "]"}], "[", 
                RowBox[{"[", "2", "]"}], "]"}], ",", 
               RowBox[{"OptionValue", "[", "PlotRangePadding", "]"}]}], 
              "]"}]}]}]}], ";", "\[IndentingNewLine]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"YMax", "\[NotEqual]", "0"}], ",", 
            RowBox[{"YMax", "=", 
             RowBox[{"Ceiling", "[", 
              RowBox[{"YMax", ",", 
               RowBox[{"10", "^", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"(", 
                   RowBox[{
                    RowBox[{"Log10", "[", 
                    RowBox[{"Abs", "[", "YMax", "]"}], "]"}], "//", "Floor"}],
                    ")"}], "-", "1"}], ")"}]}]}], "]"}]}]}], "]"}], ";"}], 
         "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"TrueQ", "[", 
             RowBox[{"OptionValue", "[", "XLogScale", "]"}], "]"}], ",", 
            RowBox[{
             RowBox[{"XMin", "=", 
              RowBox[{
               RowBox[{
                RowBox[{"Floor", "[", 
                 RowBox[{"#", ",", "0.1"}], "]"}], "&"}], "@", 
               RowBox[{"Log10", "[", "XMin", "]"}]}]}], ";", 
             RowBox[{"XMax", "=", 
              RowBox[{
               RowBox[{
                RowBox[{"Ceiling", "[", 
                 RowBox[{"#", ",", "0.1"}], "]"}], "&"}], "@", 
               RowBox[{"Log10", "[", "XMax", "]"}]}]}], ";"}]}], "]"}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"TrueQ", "[", 
             RowBox[{"OptionValue", "[", "YLogScale", "]"}], "]"}], ",", 
            RowBox[{
             RowBox[{"YMin", "=", 
              RowBox[{"Floor", "@", 
               RowBox[{"Log10", "[", "YMin", "]"}]}]}], ";", 
             RowBox[{"YMax", "=", 
              RowBox[{"Ceiling", "@", 
               RowBox[{"Log10", "[", "YMax", "]"}]}]}], ";"}]}], "]"}], ";"}],
          "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"XMin", ",", "XMax"}], "}"}], ",", 
          RowBox[{"{", 
           RowBox[{"YMin", ",", "YMax"}], "}"}]}], "}"}]}], 
       "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"CalcPlotRange", "[", 
    RowBox[{"data_List", ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", "Ranges", "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Ranges", "=", 
        RowBox[{"(", 
         RowBox[{
          RowBox[{
           RowBox[{"CalcPlotRange", "[", 
            RowBox[{"#", ",", "opts"}], "]"}], "&"}], "/@", "data"}], ")"}]}],
        ";", "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"Length", "[", "Ranges", "]"}], "\[Equal]", "0"}], ",", 
         RowBox[{"ErrorMessage", "[", 
          RowBox[{"Fig", "::", "nodatatable"}], "]"}]}], "]"}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"{", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{
           RowBox[{"Min", "@@", 
            RowBox[{"Ranges", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "1", ",", "1"}], "]"}], "]"}]}], ",", 
           RowBox[{"Max", "@@", 
            RowBox[{"Ranges", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "1", ",", "2"}], "]"}], "]"}]}]}], "}"}], 
         ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"Min", "@@", 
            RowBox[{"Ranges", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "2", ",", "1"}], "]"}], "]"}]}], ",", 
           RowBox[{"Max", "@@", 
            RowBox[{"Ranges", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "2", ",", "2"}], "]"}], "]"}]}]}], "}"}]}], 
        "\[IndentingNewLine]", "}"}]}], "\[IndentingNewLine]", ")"}]}], 
    "\[IndentingNewLine]", "]"}]}], ";"}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"1442eba4-0c24-45da-b8fa-ff3b3a2b5bf0"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"FigColumn", "::", "usage"}], "=", 
    "\"\<FigColumn[datatable,x] returns a figure with vertically arranged \
panels plotting variable x vs. all other columns in the DataTable using the \
SciDraw package.\nFigColumn[datatable,x,{\!\(\*SubscriptBox[\(ycol\), \
\(1\)]\),\!\(\*SubscriptBox[\(ycol\), \(2\)]\),..}] returns a figure with \
vertically arranged panels plotting variable x vs. columns \
\!\(\*SubscriptBox[\(ycol\), \(i\)]\) in the DataTable using the SciDraw \
package.\nFigColumn[{\!\(\*SubscriptBox[\(dt\), \
\(1\)]\),\!\(\*SubscriptBox[\(dt\), \(2\)]\),..},x] plots the variables for \
DataTables \!\(\*SubscriptBox[\(dt\), \(i\)]\).\>\""}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"Options", "[", "FigColumn", "]"}], "=", 
    RowBox[{"Join", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"XLogScale", "\[Rule]", "False"}], ",", 
        RowBox[{"YLogScale", "\[Rule]", "False"}], ",", 
        RowBox[{"Joined", "\[Rule]", "False"}], ",", 
        RowBox[{"PlotMarkers", "\[Rule]", "True"}], ",", 
        RowBox[{"ShowLegend", "\[Rule]", "Automatic"}], ",", 
        RowBox[{"PlotLegends", "\[Rule]", "Automatic"}]}], "}"}], ",", 
      RowBox[{"Options", "[", "Multipanel", "]"}], ",", 
      RowBox[{"Options", "[", "Figure", "]"}], ",", 
      RowBox[{"Options", "[", "SciDrawPlot", "]"}]}], "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"FigColumn", "[", 
    RowBox[{"data_", ",", "x_", ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
   RowBox[{"FigColumn", "[", 
    RowBox[{"data", ",", "x", ",", "All", ",", "opts"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"FigColumn", "[", 
   RowBox[{"data_", ",", "x_", ",", 
    RowBox[{"y_:", "All"}], ",", 
    RowBox[{"opts", ":", 
     RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
  RowBox[{"Module", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"{", "YList", "}"}], ",", "\[IndentingNewLine]", 
    RowBox[{"(", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"YList", "=", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{"y", "===", "All"}], ",", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"ListQ", "[", "data", "]"}], ",", 
           RowBox[{"Rest", "@", 
            RowBox[{"ColNames", "@", 
             RowBox[{"data", "[", 
              RowBox[{"[", "1", "]"}], "]"}]}]}], ",", 
           RowBox[{"Rest", "@", 
            RowBox[{"ColNames", "@", "data"}]}]}], "]"}], ",", "y"}], "]"}]}],
       ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
      RowBox[{"Figure", "[", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"Multipanel", "[", "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"MapIndexed", "[", 
           RowBox[{
            RowBox[{
             RowBox[{"(", 
              RowBox[{"FigurePanel", "[", "\[IndentingNewLine]", 
               RowBox[{
                RowBox[{"{", "\[IndentingNewLine]", 
                 RowBox[{
                  RowBox[{"SetOptions", "[", 
                   RowBox[{"DataPlot", ",", 
                    RowBox[{"DataSymbol", "\[Rule]", 
                    RowBox[{"{", 
                    RowBox[{"Show", "\[Rule]", 
                    RowBox[{"OptionValue", "[", "PlotMarkers", "]"}]}], 
                    "}"}]}]}], "]"}], ",", "\[IndentingNewLine]", 
                  RowBox[{"SetOptions", "[", 
                   RowBox[{"DataPlot", ",", 
                    RowBox[{"DataLine", "\[Rule]", 
                    RowBox[{"{", 
                    RowBox[{"Show", "\[Rule]", 
                    RowBox[{"OptionValue", "[", "Joined", "]"}]}], "}"}]}]}], 
                   "]"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", 
                  RowBox[{"If", "[", 
                   RowBox[{
                    RowBox[{"ListQ", "[", "data", "]"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"Module", "[", 
                    RowBox[{
                    RowBox[{"{", 
                    RowBox[{"YVar", "=", "#1"}], "}"}], ",", 
                    RowBox[{"MapIndexed", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"SciDrawPlot", "[", 
                    RowBox[{
                    RowBox[{"#1", "[", 
                    RowBox[{"All", ",", 
                    RowBox[{"{", 
                    RowBox[{"x", ",", "YVar"}], "}"}]}], "]"}], ",", 
                    RowBox[{"Style", "\[Rule]", 
                    RowBox[{"{", 
                    RowBox[{"\"\<DataAnalysisCurves\>\"", ",", 
                    RowBox[{"Mod", "[", 
                    RowBox[{
                    RowBox[{"#2", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"Length", "[", "$DefaultPlotColors", "]"}], ",", 
                    "1"}], "]"}]}], "}"}]}], ",", 
                    RowBox[{"FilterRules", "[", 
                    RowBox[{
                    RowBox[{"{", "opts", "}"}], ",", " ", 
                    RowBox[{"Options", "[", "SciDrawPlot", "]"}]}], "]"}]}], 
                    "]"}], "&"}], ",", "data"}], "]"}]}], "]"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{"SciDrawPlot", "[", 
                    RowBox[{
                    RowBox[{"data", "[", 
                    RowBox[{"All", ",", 
                    RowBox[{"{", 
                    RowBox[{"x", ",", "#1"}], "}"}]}], "]"}], ",", 
                    RowBox[{"Style", "\[Rule]", 
                    RowBox[{"{", 
                    RowBox[{"\"\<DataAnalysisCurves\>\"", ",", "1"}], "}"}]}],
                     ",", 
                    RowBox[{"FilterRules", "[", 
                    RowBox[{
                    RowBox[{"{", "opts", "}"}], ",", " ", 
                    RowBox[{"Options", "[", "SciDrawPlot", "]"}]}], "]"}]}], 
                    "]"}], "}"}]}], "\[IndentingNewLine]", "]"}], ",", 
                  "\[IndentingNewLine]", 
                  RowBox[{"If", "[", 
                   RowBox[{
                    RowBox[{
                    RowBox[{"#2", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], "\[Equal]", "1"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"OptionValue", "[", "ShowLegend", "]"}], "===", 
                    "Automatic"}], "&&", 
                    RowBox[{"ListQ", "[", "data", "]"}], "&&", 
                    RowBox[{
                    RowBox[{"Length", "[", "data", "]"}], ">", "1"}]}], ")"}],
                     "||", 
                    RowBox[{"ListQ", "[", 
                    RowBox[{"OptionValue", "[", "ShowLegend", "]"}], "]"}]}], 
                    ",", "\[IndentingNewLine]", 
                    RowBox[{"DataLegend", "[", 
                    RowBox[{
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"OptionValue", "[", "ShowLegend", "]"}], "===", 
                    "Automatic"}], ",", 
                    RowBox[{"Scaled", "[", 
                    RowBox[{"{", 
                    RowBox[{"0.8", ",", "0.2"}], "}"}], "]"}], ",", 
                    RowBox[{"Scaled", "[", 
                    RowBox[{"OptionValue", "[", "ShowLegend", "]"}], "]"}]}], 
                    "]"}], ",", "\[IndentingNewLine]", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"OptionValue", "[", "PlotLegends", "]"}], "===", 
                    "Automatic"}], ",", "\[IndentingNewLine]", 
                    RowBox[{"Table", "[", 
                    RowBox[{
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"{", 
                    RowBox[{"\"\<DataAnalysisCurves\>\"", ",", 
                    RowBox[{"Mod", "[", 
                    RowBox[{"i", ",", 
                    RowBox[{"Length", "[", "$DefaultPlotColors", "]"}], ",", 
                    "1"}], "]"}]}], "}"}], ",", 
                    RowBox[{"ToString", "[", "i", "]"}]}], "}"}], ",", 
                    RowBox[{"{", 
                    RowBox[{"i", ",", "1", ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"ListQ", "[", "data", "]"}], ",", 
                    RowBox[{"Length", "[", "data", "]"}], ",", "1"}], "]"}]}],
                     "}"}]}], "]"}], ",", "\[IndentingNewLine]", 
                    RowBox[{"Table", "[", 
                    RowBox[{
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"{", 
                    RowBox[{"\"\<DataAnalysisCurves\>\"", ",", 
                    RowBox[{"Mod", "[", 
                    RowBox[{"i", ",", 
                    RowBox[{"Length", "[", "$DefaultPlotColors", "]"}], ",", 
                    "1"}], "]"}]}], "}"}], ",", 
                    RowBox[{
                    RowBox[{"OptionValue", "[", "PlotLegends", "]"}], "[", 
                    RowBox[{"[", "i", "]"}], "]"}]}], "}"}], ",", 
                    RowBox[{"{", 
                    RowBox[{"i", ",", "1", ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"ListQ", "[", "data", "]"}], ",", 
                    RowBox[{"Length", "[", "data", "]"}], ",", "1"}], "]"}]}],
                     "}"}]}], "]"}]}], "\[IndentingNewLine]", "]"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"FontFamily", "\[Rule]", "\"\<sans-serif\>\""}]}],
                     "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]",
                     "Null"}], "\[IndentingNewLine]", "]"}]}], 
                   "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", 
                 "}"}], ",", "\[IndentingNewLine]", 
                RowBox[{"{", 
                 RowBox[{
                  RowBox[{"#2", "[", 
                   RowBox[{"[", "1", "]"}], "]"}], ",", "1"}], "}"}]}], 
               "\[IndentingNewLine]", "]"}], ")"}], "&"}], ",", "YList"}], 
           "]"}], ",", "\[IndentingNewLine]", 
          RowBox[{"Dimensions", "->", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"Length", "[", "YList", "]"}], ",", "1"}], "}"}]}], ",", 
          "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{"FilterRules", "[", 
           RowBox[{
            RowBox[{"{", "opts", "}"}], ",", " ", 
            RowBox[{"Options", "[", "Multipanel", "]"}]}], "]"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"XPlotRange", "\[Rule]", 
           RowBox[{
            RowBox[{"CalcPlotRange", "[", 
             RowBox[{"If", "[", 
              RowBox[{
               RowBox[{"ListQ", "[", "data", "]"}], ",", 
               RowBox[{"Flatten", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"Module", "[", 
                   RowBox[{
                    RowBox[{"{", 
                    RowBox[{"YVar", "=", "#"}], "}"}], ",", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"All", ",", 
                    RowBox[{"{", 
                    RowBox[{"x", ",", "YVar"}], "}"}]}], "]"}], "&"}], "/@", 
                    "data"}]}], "]"}], "&"}], "/@", "YList"}], "]"}], ",", 
               RowBox[{
                RowBox[{
                 RowBox[{"data", "[", 
                  RowBox[{"All", ",", 
                   RowBox[{"{", 
                    RowBox[{"x", ",", "#"}], "}"}]}], "]"}], "&"}], "/@", 
                "YList"}]}], "]"}], "]"}], "[", 
            RowBox[{"[", "1", "]"}], "]"}]}], ",", "\[IndentingNewLine]", 
          RowBox[{"YPlotRange", "\[Rule]", 
           RowBox[{"If", "[", 
            RowBox[{
             RowBox[{"ListQ", "[", "data", "]"}], ",", 
             RowBox[{
              RowBox[{
               RowBox[{
                RowBox[{"CalcPlotRange", "[", 
                 RowBox[{"Module", "[", 
                  RowBox[{
                   RowBox[{"{", 
                    RowBox[{"YVar", "=", "#"}], "}"}], ",", 
                   RowBox[{
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"All", ",", 
                    RowBox[{"{", 
                    RowBox[{"x", ",", "YVar"}], "}"}]}], "]"}], "&"}], "/@", 
                    "data"}]}], "]"}], "]"}], "[", 
                RowBox[{"[", "2", "]"}], "]"}], "&"}], "/@", "YList"}], ",", 
             RowBox[{
              RowBox[{
               RowBox[{
                RowBox[{"CalcPlotRange", "[", 
                 RowBox[{"data", "[", 
                  RowBox[{"All", ",", 
                   RowBox[{"{", 
                    RowBox[{"x", ",", "#"}], "}"}]}], "]"}], "]"}], "[", 
                RowBox[{"[", "2", "]"}], "]"}], "&"}], "/@", "YList"}]}], 
            "]"}]}], ",", "\[IndentingNewLine]", 
          RowBox[{"Frame", "\[Rule]", "True"}], ",", "\[IndentingNewLine]", 
          RowBox[{"XFrameLabel", "\[Rule]", "x"}], ",", "\[IndentingNewLine]", 
          RowBox[{"YFrameLabel", "\[Rule]", "YList"}], ",", 
          "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{"PanelLetter", "\[Rule]", "None"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"YPanelGaps", "\[Rule]", "0.1"}]}], "\[IndentingNewLine]", 
         "]"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"FilterRules", "[", 
         RowBox[{
          RowBox[{"{", "opts", "}"}], ",", " ", 
          RowBox[{"Options", "[", "Figure", "]"}]}], "]"}], ",", 
        "\[IndentingNewLine]", 
        RowBox[{"CanvasSize", "\[Rule]", 
         RowBox[{"1", "*", 
          RowBox[{"{", 
           RowBox[{"6", ",", 
            RowBox[{"2", "*", 
             RowBox[{"Length", "[", "YList", "]"}]}]}], "}"}]}]}], ",", 
        "\[IndentingNewLine]", 
        RowBox[{"Style", "\[Rule]", "\"\<DataAnalysis\>\""}]}], 
       "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", ")"}]}], 
   "\[IndentingNewLine]", "]"}]}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"c7dbb690-fa95-49c6-9218-bf1c4efc4c7b"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"Options", "[", "FigGrid", "]"}], "=", 
    RowBox[{"Join", "[", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{
        RowBox[{"XLogScale", "\[Rule]", "False"}], ",", 
        RowBox[{"YLogScale", "\[Rule]", "False"}], ",", 
        RowBox[{"Joined", "\[Rule]", "False"}], ",", 
        RowBox[{"PlotMarkers", "\[Rule]", "True"}], ",", 
        RowBox[{"ShowLegend", "\[Rule]", "Automatic"}], ",", 
        RowBox[{"PlotLegends", "\[Rule]", "Automatic"}], ",", 
        RowBox[{"FigPanelExtras", "\[Rule]", 
         RowBox[{"<|", "|>"}]}]}], "}"}], ",", 
      RowBox[{"Options", "[", "Multipanel", "]"}], ",", 
      RowBox[{"Options", "[", "Figure", "]"}], ",", 
      RowBox[{"Options", "[", "SciDrawPlot", "]"}]}], "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"FigPanelExtras", "::", "usage"}], "=", 
    "\"\<FigPanelExtras is an option for FigGrid which specifies an \
association with \\\"extra\\\" graphic elements to plot in individual grid \
cells.\>\""}], ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"FigGrid", "::", "usage"}], "=", 
    "\"\<FigGrid[\!\(\*StyleBox[\"data\",FontSlant->\"Italic\"]\),\!\(\*\
StyleBox[\"x\",FontSlant->\"Italic\"]\)] returns a figure grid with plots of \
data in DataTable objects, where column \
\!\(\*StyleBox[\"x\",FontSlant->\"Italic\"]\) is plotted on the x-axis, using \
the SciDraw package.\n\
FigGrid[\!\(\*StyleBox[\"data\",FontSlant->\"Italic\"]\),\!\(\*StyleBox[\"x\",\
FontSlant->\"Italic\"]\)\!\(\*StyleBox[\",\",FontSlant->\"Italic\"]\)\!\(\*\
StyleBox[\"{\",FontSlant->\"Italic\"]\)\!\(\*StyleBox[SubscriptBox[\"ycol\", \
\"1\"],FontSlant->\"Italic\"]\)\!\(\*StyleBox[\",\",FontSlant->\"Italic\"]\)\!\
\(\*StyleBox[SubscriptBox[\"ycol\", \
\"2\"],FontSlant->\"Italic\"]\)\!\(\*StyleBox[\",\",FontSlant->\"Italic\"]\)\!\
\(\*StyleBox[\"..\",FontSlant->\"Italic\"]\)\!\(\*StyleBox[\"}\",FontSlant->\"\
Italic\"]\)] plots only columns specified by {\!\(\*SubscriptBox[\(ycol\), \
\(1\)]\),\!\(\*SubscriptBox[\(ycol\), \(2\)]\),..} in the figure grid.\>\""}],
    ";"}], "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"FigGrid", "[", 
    RowBox[{"data_", ",", "x_", ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
   RowBox[{"FigGrid", "[", 
    RowBox[{"data", ",", "x", ",", "All", ",", "opts"}], "]"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"FigGrid", "[", 
   RowBox[{"data_", ",", "x_", ",", 
    RowBox[{"y_:", "All"}], ",", 
    RowBox[{"opts", ":", 
     RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
  RowBox[{"Module", "[", "\[IndentingNewLine]", 
   RowBox[{
    RowBox[{"{", "YList", "}"}], ",", "\[IndentingNewLine]", 
    RowBox[{"(", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"YList", "=", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{"y", "===", "All"}], ",", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"ListQ", "[", 
            RowBox[{"data", "[", 
             RowBox[{"[", "1", "]"}], "]"}], "]"}], ",", 
           RowBox[{"DeleteCases", "[", 
            RowBox[{
             RowBox[{"ColNames", "@", 
              RowBox[{"data", "[", 
               RowBox[{"[", 
                RowBox[{"1", ",", "1"}], "]"}], "]"}]}], ",", "x"}], "]"}], 
           ",", 
           RowBox[{"DeleteCases", "[", 
            RowBox[{
             RowBox[{"ColNames", "@", 
              RowBox[{"data", "[", 
               RowBox[{"[", "1", "]"}], "]"}]}], ",", "x"}], "]"}]}], "]"}], 
         ",", "y"}], "]"}]}], ";", "\[IndentingNewLine]", 
      "\[IndentingNewLine]", 
      RowBox[{"Figure", "[", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"Multipanel", "[", "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"MapIndexed", "[", "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{
             RowBox[{"Module", "[", 
              RowBox[{
               RowBox[{"{", 
                RowBox[{
                 RowBox[{"ColData", "=", "#1"}], ",", 
                 RowBox[{"ColI", "=", 
                  RowBox[{"#2", "[", 
                   RowBox[{"[", "1", "]"}], "]"}]}]}], "}"}], ",", 
               "\[IndentingNewLine]", 
               RowBox[{"(", "\[IndentingNewLine]", 
                RowBox[{"MapIndexed", "[", 
                 RowBox[{
                  RowBox[{
                   RowBox[{"(", 
                    RowBox[{"FigurePanel", "[", "\[IndentingNewLine]", 
                    RowBox[{
                    RowBox[{"{", "\[IndentingNewLine]", 
                    RowBox[{
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"KeyExistsQ", "[", 
                    RowBox[{
                    RowBox[{"OptionValue", "[", "FigPanelExtras", "]"}], ",", 
                    
                    RowBox[{"{", 
                    RowBox[{"#1", ",", "ColI"}], "}"}]}], "]"}], ",", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"OptionValue", "[", "FigPanelExtras", "]"}], "[", 
                    
                    RowBox[{"{", 
                    RowBox[{"#1", ",", "ColI"}], "}"}], "]"}], "//", 
                    "ReleaseHold"}]}], "]"}], ",", "\[IndentingNewLine]", 
                    "\[IndentingNewLine]", 
                    RowBox[{"SetOptions", "[", 
                    RowBox[{"DataPlot", ",", 
                    RowBox[{"DataSymbol", "\[Rule]", 
                    RowBox[{"{", 
                    RowBox[{"Show", "\[Rule]", 
                    RowBox[{"OptionValue", "[", "PlotMarkers", "]"}]}], 
                    "}"}]}]}], "]"}], ",", "\[IndentingNewLine]", 
                    RowBox[{"SetOptions", "[", 
                    RowBox[{"DataPlot", ",", 
                    RowBox[{"DataLine", "\[Rule]", 
                    RowBox[{"{", 
                    RowBox[{"Show", "\[Rule]", 
                    RowBox[{"OptionValue", "[", "Joined", "]"}]}], "}"}]}]}], 
                    "]"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", 
                    
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"ListQ", "[", "ColData", "]"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"Module", "[", 
                    RowBox[{
                    RowBox[{"{", 
                    RowBox[{"YVar", "=", "#1"}], "}"}], ",", 
                    RowBox[{"MapIndexed", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"SciDrawPlot", "[", 
                    RowBox[{
                    RowBox[{"#1", "[", 
                    RowBox[{"All", ",", 
                    RowBox[{"{", 
                    RowBox[{"x", ",", "YVar"}], "}"}]}], "]"}], ",", 
                    RowBox[{"Style", "\[Rule]", 
                    RowBox[{"{", 
                    RowBox[{"\"\<DataAnalysisCurves\>\"", ",", 
                    RowBox[{"Mod", "[", 
                    RowBox[{
                    RowBox[{"#2", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", 
                    RowBox[{"Length", "[", "$DefaultPlotColors", "]"}], ",", 
                    "1"}], "]"}]}], "}"}]}], ",", 
                    RowBox[{"FilterRules", "[", 
                    RowBox[{
                    RowBox[{"{", "opts", "}"}], ",", " ", 
                    RowBox[{"Options", "[", "SciDrawPlot", "]"}]}], "]"}]}], 
                    "]"}], "&"}], ",", "ColData"}], "]"}]}], "]"}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{"SciDrawPlot", "[", 
                    RowBox[{
                    RowBox[{"ColData", "[", 
                    RowBox[{"All", ",", 
                    RowBox[{"{", 
                    RowBox[{"x", ",", "#1"}], "}"}]}], "]"}], ",", 
                    RowBox[{"Style", "\[Rule]", 
                    RowBox[{"{", 
                    RowBox[{"\"\<DataAnalysisCurves\>\"", ",", "1"}], "}"}]}],
                     ",", 
                    RowBox[{"FilterRules", "[", 
                    RowBox[{
                    RowBox[{"{", "opts", "}"}], ",", " ", 
                    RowBox[{"Options", "[", "SciDrawPlot", "]"}]}], "]"}]}], 
                    "]"}], "}"}]}], "\[IndentingNewLine]", "]"}], ",", 
                    "\[IndentingNewLine]", "\[IndentingNewLine]", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{
                    RowBox[{"#2", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], "\[Equal]", "1"}], "&&", 
                    RowBox[{"ColI", "\[Equal]", "1"}]}], ",", 
                    "\[IndentingNewLine]", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"(", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"OptionValue", "[", "ShowLegend", "]"}], "===", 
                    "Automatic"}], "&&", 
                    RowBox[{"ListQ", "[", "ColData", "]"}], "&&", 
                    RowBox[{
                    RowBox[{"Length", "[", "ColData", "]"}], ">", "1"}]}], 
                    ")"}], "||", 
                    RowBox[{"ListQ", "[", 
                    RowBox[{"OptionValue", "[", "ShowLegend", "]"}], "]"}]}], 
                    ",", "\[IndentingNewLine]", 
                    RowBox[{"DataLegend", "[", 
                    RowBox[{
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"OptionValue", "[", "ShowLegend", "]"}], "===", 
                    "Automatic"}], ",", 
                    RowBox[{"Scaled", "[", 
                    RowBox[{"{", 
                    RowBox[{"0.8", ",", "0.2"}], "}"}], "]"}], ",", 
                    RowBox[{"Scaled", "[", 
                    RowBox[{"OptionValue", "[", "ShowLegend", "]"}], "]"}]}], 
                    "]"}], ",", "\[IndentingNewLine]", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"OptionValue", "[", "PlotLegends", "]"}], "===", 
                    "Automatic"}], ",", "\[IndentingNewLine]", 
                    RowBox[{"Table", "[", 
                    RowBox[{
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"{", 
                    RowBox[{"\"\<DataAnalysisCurves\>\"", ",", 
                    RowBox[{"Mod", "[", 
                    RowBox[{"i", ",", 
                    RowBox[{"Length", "[", "$DefaultPlotColors", "]"}], ",", 
                    "1"}], "]"}]}], "}"}], ",", 
                    RowBox[{"ToString", "[", "i", "]"}]}], "}"}], ",", 
                    RowBox[{"{", 
                    RowBox[{"i", ",", "1", ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"ListQ", "[", "ColData", "]"}], ",", 
                    RowBox[{"Length", "[", "ColData", "]"}], ",", "1"}], 
                    "]"}]}], "}"}]}], "]"}], ",", "\[IndentingNewLine]", 
                    RowBox[{"Table", "[", 
                    RowBox[{
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"{", 
                    RowBox[{"\"\<DataAnalysisCurves\>\"", ",", 
                    RowBox[{"Mod", "[", 
                    RowBox[{"i", ",", 
                    RowBox[{"Length", "[", "$DefaultPlotColors", "]"}], ",", 
                    "1"}], "]"}]}], "}"}], ",", 
                    RowBox[{
                    RowBox[{"OptionValue", "[", "PlotLegends", "]"}], "[", 
                    RowBox[{"[", "i", "]"}], "]"}]}], "}"}], ",", 
                    RowBox[{"{", 
                    RowBox[{"i", ",", "1", ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"ListQ", "[", "ColData", "]"}], ",", 
                    RowBox[{"Length", "[", "ColData", "]"}], ",", "1"}], 
                    "]"}]}], "}"}]}], "]"}]}], "\[IndentingNewLine]", "]"}]}],
                     "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]",
                     "Null"}], "\[IndentingNewLine]", "]"}]}], 
                    "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", 
                    "}"}], ",", "\[IndentingNewLine]", 
                    RowBox[{"{", 
                    RowBox[{
                    RowBox[{"#2", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", "ColI"}], "}"}]}], 
                    "\[IndentingNewLine]", "]"}], ")"}], "&"}], ",", 
                  "YList"}], "]"}], "\[IndentingNewLine]", ")"}]}], 
              "\[IndentingNewLine]", "]"}], "&"}], ",", "\[IndentingNewLine]",
             "data"}], "\[IndentingNewLine]", "]"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"Dimensions", "->", 
           RowBox[{"{", 
            RowBox[{
             RowBox[{"Length", "[", "YList", "]"}], ",", 
             RowBox[{"Length", "[", "data", "]"}]}], "}"}]}], ",", 
          "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{"FilterRules", "[", 
           RowBox[{
            RowBox[{"{", "opts", "}"}], ",", " ", 
            RowBox[{"Options", "[", "Multipanel", "]"}]}], "]"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"XPlotRange", "\[Rule]", 
           RowBox[{"Map", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"Module", "[", 
               RowBox[{
                RowBox[{"{", 
                 RowBox[{"ColData", "=", "#"}], "}"}], ",", 
                RowBox[{"(", 
                 RowBox[{
                  RowBox[{"CalcPlotRange", "[", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"ListQ", "[", "ColData", "]"}], ",", 
                    RowBox[{"Flatten", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"Module", "[", 
                    RowBox[{
                    RowBox[{"{", 
                    RowBox[{"YVar", "=", "#"}], "}"}], ",", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"All", ",", 
                    RowBox[{"{", 
                    RowBox[{"x", ",", "YVar"}], "}"}]}], "]"}], "&"}], "/@", 
                    "ColData"}]}], "]"}], "&"}], "/@", "YList"}], "]"}], ",", 
                    
                    RowBox[{
                    RowBox[{
                    RowBox[{"ColData", "[", 
                    RowBox[{"All", ",", 
                    RowBox[{"{", 
                    RowBox[{"x", ",", "#"}], "}"}]}], "]"}], "&"}], "/@", 
                    "YList"}]}], "]"}], "]"}], "[", 
                  RowBox[{"[", "1", "]"}], "]"}], ")"}]}], "]"}], "&"}], ",", 
             "data"}], "]"}]}], ",", "\[IndentingNewLine]", 
          RowBox[{"YPlotRange", "\[Rule]", 
           RowBox[{"If", "[", 
            RowBox[{
             RowBox[{"ListQ", "[", 
              RowBox[{"data", "[", 
               RowBox[{"[", "1", "]"}], "]"}], "]"}], ",", 
             RowBox[{
              RowBox[{
               RowBox[{
                RowBox[{"CalcPlotRange", "[", 
                 RowBox[{"Flatten", "@", 
                  RowBox[{"Module", "[", 
                   RowBox[{
                    RowBox[{"{", 
                    RowBox[{"YVar", "=", "#"}], "}"}], ",", 
                    RowBox[{"Map", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"All", ",", 
                    RowBox[{"{", 
                    RowBox[{"x", ",", "YVar"}], "}"}]}], "]"}], "&"}], ",", 
                    "data", ",", 
                    RowBox[{"{", "2", "}"}]}], "]"}]}], "]"}]}], "]"}], "[", 
                RowBox[{"[", "2", "]"}], "]"}], "&"}], "/@", "YList"}], ",", 
             RowBox[{
              RowBox[{
               RowBox[{
                RowBox[{"CalcPlotRange", "[", 
                 RowBox[{"Module", "[", 
                  RowBox[{
                   RowBox[{"{", 
                    RowBox[{"YVar", "=", "#"}], "}"}], ",", 
                   RowBox[{
                    RowBox[{
                    RowBox[{"#", "[", 
                    RowBox[{"All", ",", 
                    RowBox[{"{", 
                    RowBox[{"x", ",", "YVar"}], "}"}]}], "]"}], "&"}], "/@", 
                    "data"}]}], "]"}], "]"}], "[", 
                RowBox[{"[", "2", "]"}], "]"}], "&"}], "/@", "YList"}]}], 
            "]"}]}], ",", "\[IndentingNewLine]", 
          RowBox[{"Frame", "\[Rule]", "True"}], ",", "\[IndentingNewLine]", 
          RowBox[{"XFrameLabel", "\[Rule]", "x"}], ",", "\[IndentingNewLine]", 
          RowBox[{"YFrameLabel", "\[Rule]", "YList"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"YYShowTickLabels", "\[Rule]", "Exterior"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"YYShowFrameLabel", "\[Rule]", "Exterior"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"XXShowFrameLabel", "\[Rule]", 
           RowBox[{"If", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"OptionValue", "[", "XXFrameLabel", "]"}], "===", 
              "Inherited"}], ",", "False", ",", "Exterior"}], "]"}]}], ",", 
          "\[IndentingNewLine]", "\[IndentingNewLine]", 
          RowBox[{"PanelLetter", "\[Rule]", "None"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"YPanelGaps", "\[Rule]", "0.1"}], ",", 
          "\[IndentingNewLine]", 
          RowBox[{"XPanelGaps", "\[Rule]", "0.1"}]}], "\[IndentingNewLine]", 
         "]"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"FilterRules", "[", 
         RowBox[{
          RowBox[{"{", "opts", "}"}], ",", " ", 
          RowBox[{"Options", "[", "Figure", "]"}]}], "]"}], ",", 
        "\[IndentingNewLine]", 
        RowBox[{"CanvasSize", "\[Rule]", 
         RowBox[{"1", "*", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{"6", "*", 
             RowBox[{"Length", "[", "data", "]"}]}], ",", 
            RowBox[{"2", "*", 
             RowBox[{"Length", "[", "YList", "]"}]}]}], "}"}]}]}], ",", 
        "\[IndentingNewLine]", 
        RowBox[{"CanvasMargin", "\[Rule]", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"{", 
            RowBox[{"0.8", ",", "0.8"}], "}"}], ",", 
           RowBox[{"{", 
            RowBox[{"0.6", ",", "0.6"}], "}"}]}], "}"}]}], ",", 
        "\[IndentingNewLine]", 
        RowBox[{"Style", "\[Rule]", "\"\<DataAnalysis\>\""}]}], 
       "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", ")"}]}], 
   "\[IndentingNewLine]", "]"}]}]}], "Input",
 InitializationCell->
  True,ExpressionUUID->"44fce864-39cf-49ac-a0ac-db3759ef3dee"]
}, Open  ]],

Cell[CellGroupData[{

Cell["LevelScheme integration (obsolete)", "Section",
 CellTags->"Null"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"LSDataStyles", ":=", 
   RowBox[{"{", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<1\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<Circle\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Red"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Color", "\[Rule]", "Red"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<1NoSymb\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Color", "\[Rule]", "Red"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<1NoLine\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<Circle\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Red"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<1d\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<Circle\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Red"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"Color", "\[Rule]", "Red"}], ",", 
          RowBox[{"Dashing", "\[Rule]", "10"}]}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<1dNoSymb\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"Color", "\[Rule]", "Red"}], ",", 
          RowBox[{"Dashing", "\[Rule]", "10"}]}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<2\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<Square\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Blue"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Color", "\[Rule]", "Blue"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<2NoSymb\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Color", "\[Rule]", "Blue"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<2d\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<Square\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Blue"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"Color", "\[Rule]", "Blue"}], ",", 
          RowBox[{"Dashing", "\[Rule]", "10"}]}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<2dNoSymb\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"Color", "\[Rule]", "Blue"}], ",", 
          RowBox[{"Dashing", "\[Rule]", "10"}]}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<2dNoSymb\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"Color", "\[Rule]", "Blue"}], ",", 
          RowBox[{"Dashing", "\[Rule]", "10"}]}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<2NoLine\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<Square\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Blue"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<3\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<Diamond\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Green"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Color", "\[Rule]", "Green"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<3NoLine\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<Diamond\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Green"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<3NoSymb\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Color", "\[Rule]", "Green"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<4\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<Cross\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Orange"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Color", "\[Rule]", "Orange"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<4NoSymb\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Color", "\[Rule]", "Orange"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<4NoLine\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<Cross\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Orange"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<4d\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<Cross\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Orange"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"Color", "\[Rule]", "Orange"}], ",", 
          RowBox[{"Dashing", "\[Rule]", "10"}]}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<4dNoSymb\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"Color", "\[Rule]", "Orange"}], ",", 
          RowBox[{"Dashing", "\[Rule]", "10"}]}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<5\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<UpTriangle\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Purple"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Color", "\[Rule]", "Purple"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<5NoSymb\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Color", "\[Rule]", "Purple"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<5NoLine\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<UpTriangle\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Purple"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<6\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<Circle\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Cyan"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"Color", "\[Rule]", "Cyan"}], ",", 
          RowBox[{"Dashing", "\[Rule]", "10"}]}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<6NoSymb\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"Color", "\[Rule]", "Cyan"}], ",", 
          RowBox[{"Dashing", "\[Rule]", "10"}]}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<6NoLine\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<Circle\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Cyan"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<7\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<Square\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Pink"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"Color", "\[Rule]", "Pink"}], ",", 
          RowBox[{"Dashing", "\[Rule]", "10"}]}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<7NoSymb\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"Color", "\[Rule]", "Pink"}], ",", 
          RowBox[{"Dashing", "\[Rule]", "10"}]}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<8\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<Diamond\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Brown"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"Color", "\[Rule]", "Brown"}], ",", 
          RowBox[{"Dashing", "\[Rule]", "10"}]}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<8NoSymb\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"Color", "\[Rule]", "Brown"}], ",", 
          RowBox[{"Dashing", "\[Rule]", "10"}]}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<8NoLine\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<Diamond\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "Brown"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Show", "\[Rule]", "False"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<9\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<Cross\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "NavyBlue"}], ",", 
          RowBox[{"Dashing", "\[Rule]", "10"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Color", "\[Rule]", "NavyBlue"}], "}"}]}]}], "]"}], ",", 
     "\[IndentingNewLine]", 
     RowBox[{"DefineDataStyle", "[", 
      RowBox[{"\"\<10\>\"", ",", 
       RowBox[{"DataSymbol", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"SymbolShape", "\[Rule]", "\"\<UpTriangle\>\""}], ",", 
          RowBox[{"FillColor", "\[Rule]", "LightBlue"}], ",", 
          RowBox[{"Dashing", "\[Rule]", "10"}]}], "}"}]}], ",", 
       RowBox[{"DataLine", "\[Rule]", 
        RowBox[{"{", 
         RowBox[{"Color", "\[Rule]", "LightBlue"}], "}"}]}]}], "]"}]}], 
    "\[IndentingNewLine]", "}"}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"NLSDS", "=", "10"}], ";"}]}], "Input",ExpressionUUID->"50a3cb8f-\
28b0-43c5-b872-eeb9bfe9d512"],

Cell[BoxData[{
 RowBox[{
  RowBox[{
   RowBox[{"Options", "[", "SciDrawPlot", "]"}], "=", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{
      RowBox[{"XErrorBars", "\[Rule]", "True"}], ",", 
      RowBox[{"YErrorBars", "\[Rule]", "True"}], ",", 
      RowBox[{"XLogScale", "\[Rule]", "False"}], ",", 
      RowBox[{"YLogScale", "\[Rule]", "False"}]}], "}"}], "~", "Join", "~", 
    RowBox[{"Options", "[", "DataPlot", "]"}]}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"SciDrawPlot", "[", 
     RowBox[{"dt_List", ",", "labels_List", ",", 
      RowBox[{"opts", ":", 
       RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
    RowBox[{"Module", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"{", "Data", "}"}], ",", "\[IndentingNewLine]", 
      RowBox[{"(", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"Data", "=", "dt"}], ";", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"Data", "[", 
          RowBox[{"[", 
           RowBox[{"All", ",", "1"}], "]"}], "]"}], "=", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"OptionValue", "[", "XErrorBars", "]"}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"Data", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "1"}], "]"}], "]"}], "/.", 
            RowBox[{
             RowBox[{"EV", "[", 
              RowBox[{"v_", ",", "e_", ",", "id_"}], "]"}], "\[RuleDelayed]", 
             
             RowBox[{"ErrorValue", "[", 
              RowBox[{"v", ",", "e"}], "]"}]}]}], ",", "\[IndentingNewLine]", 
           
           RowBox[{
            RowBox[{"Data", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "1"}], "]"}], "]"}], "/.", 
            RowBox[{
             RowBox[{"EV", "[", 
              RowBox[{"v_", ",", "e_", ",", "id_"}], "]"}], "\[RuleDelayed]", 
             "v"}]}]}], "]"}]}], ";", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"Data", "[", 
          RowBox[{"[", 
           RowBox[{"All", ",", "2"}], "]"}], "]"}], "=", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"OptionValue", "[", "YErrorBars", "]"}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"Data", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "2"}], "]"}], "]"}], "/.", 
            RowBox[{
             RowBox[{"EV", "[", 
              RowBox[{"v_", ",", "e_", ",", "id_"}], "]"}], "\[RuleDelayed]", 
             
             RowBox[{"ErrorValue", "[", 
              RowBox[{"v", ",", "e"}], "]"}]}]}], ",", "\[IndentingNewLine]", 
           
           RowBox[{
            RowBox[{"Data", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "2"}], "]"}], "]"}], "/.", 
            RowBox[{
             RowBox[{"EV", "[", 
              RowBox[{"v_", ",", "e_", ",", "id_"}], "]"}], "\[RuleDelayed]", 
             "v"}]}]}], "]"}]}], ";", "\[IndentingNewLine]", 
        "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{
          RowBox[{"Data", "=", 
           RowBox[{"Data", "/.", 
            RowBox[{"s_String", "\[RuleDelayed]", "0"}]}]}], ";"}], "*)"}], 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"Data", "=", 
         RowBox[{"MapThread", "[", 
          RowBox[{
           RowBox[{
            RowBox[{"Tooltip", "[", 
             RowBox[{"#1", ",", 
              RowBox[{"#2", "<>", "\"\< \>\"", "<>", 
               RowBox[{"ToString", "[", 
                RowBox[{"{", "\[IndentingNewLine]", 
                 RowBox[{
                  RowBox[{"ToString", "@", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"TrueQ", "[", 
                    RowBox[{"OptionValue", "[", "XLogScale", "]"}], "]"}], 
                    ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"Head", "[", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], "]"}], "===", 
                    "ErrorValue"}], ",", 
                    RowBox[{"EVE", "@", 
                    RowBox[{"(", 
                    RowBox[{"10", "^", 
                    RowBox[{"EV", "[", 
                    RowBox[{
                    RowBox[{"#1", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", 
                    RowBox[{"1", ",", "2"}], "]"}], "]"}]}], "]"}]}], ")"}]}],
                     ",", 
                    RowBox[{"10", "^", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}]}], "]"}], ",", 
                    RowBox[{
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], "/.", 
                    RowBox[{
                    RowBox[{"ErrorValue", "[", 
                    RowBox[{"a_", ",", "b_"}], "]"}], "\[RuleDelayed]", 
                    RowBox[{"EV", "[", 
                    RowBox[{"a", ",", "b"}], "]"}]}]}]}], "]"}]}], ",", 
                  "\[IndentingNewLine]", 
                  RowBox[{"ToString", "@", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"TrueQ", "[", 
                    RowBox[{"OptionValue", "[", "YLogScale", "]"}], "]"}], 
                    ",", 
                    RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{
                    RowBox[{"Head", "[", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], "]"}], "===", 
                    "ErrorValue"}], ",", 
                    RowBox[{"EVE", "@", 
                    RowBox[{"(", 
                    RowBox[{"10", "^", 
                    RowBox[{"EV", "[", 
                    RowBox[{
                    RowBox[{"#1", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "1"}], "]"}], "]"}], ",", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", 
                    RowBox[{"2", ",", "2"}], "]"}], "]"}]}], "]"}]}], ")"}]}],
                     ",", 
                    RowBox[{"10", "^", 
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "2", "]"}], "]"}]}]}], "]"}], ",", 
                    RowBox[{
                    RowBox[{"#1", "[", 
                    RowBox[{"[", "2", "]"}], "]"}], "/.", 
                    RowBox[{
                    RowBox[{"ErrorValue", "[", 
                    RowBox[{"a_", ",", "b_"}], "]"}], "\[RuleDelayed]", 
                    RowBox[{"EV", "[", 
                    RowBox[{"a", ",", "b"}], "]"}]}]}]}], "]"}]}]}], 
                 "\[IndentingNewLine]", "}"}], "]"}]}]}], "]"}], "&"}], ",", 
           RowBox[{"{", 
            RowBox[{"Data", ",", "\[IndentingNewLine]", "labels"}], "}"}]}], 
          "]"}]}], ";", "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"DataPlot", "[", 
         RowBox[{"Data", ",", 
          RowBox[{"FilterRules", "[", 
           RowBox[{
            RowBox[{"{", "opts", "}"}], ",", " ", 
            RowBox[{"Options", "[", "DataPlot", "]"}]}], "]"}]}], "]"}]}], 
       "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"SciDrawPlot", "[", 
    RowBox[{"dt_DataTable", ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
   RowBox[{"Module", "[", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", "TrimmedData", "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"TrimmedData", "=", 
        RowBox[{"DeleteMissing", "[", 
         RowBox[{"dt", ",", "1", ",", "1"}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"SciDrawPlot", "[", 
        RowBox[{
         RowBox[{"TrimmedData", "//", "NV"}], ",", 
         RowBox[{"TrimmedData", "//", "NK"}], ",", "opts"}], "]"}]}], 
      "\[IndentingNewLine]", ")"}]}], "]"}]}], ";"}]}], "Input"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"SetAttributes", "[", 
   RowBox[{"Fig", ",", "HoldFirst"}], "]"}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Options", "[", "Fig", "]"}], "=", 
   RowBox[{
    RowBox[{"{", 
     RowBox[{
      RowBox[{"FigPreamble", "\[Rule]", 
       RowBox[{"{", "}"}]}], ",", 
      RowBox[{"XLogScale", "\[Rule]", "False"}], ",", 
      RowBox[{"YLogScale", "\[Rule]", "False"}], ",", 
      RowBox[{"Joined", "\[Rule]", "False"}], ",", 
      RowBox[{"PlotMarkers", "\[Rule]", "True"}], ",", 
      RowBox[{"ShowLegend", "\[Rule]", "Automatic"}], ",", 
      RowBox[{"PlotLegends", "\[Rule]", "Automatic"}]}], "}"}], "~", "Join", 
    "~", 
    RowBox[{"Options", "[", "Figure", "]"}]}]}], ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Fig", "[", 
    RowBox[{"plots_", ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
   RowBox[{"Module", "[", "\[IndentingNewLine]", 
    RowBox[{
     RowBox[{"{", 
      RowBox[{"TmpStyles", ",", "DTs", ",", "PR", ",", "ColLabels"}], "}"}], 
     ",", "\[IndentingNewLine]", 
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"DTs", "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{
           RowBox[{"Head", "[", "plots", "]"}], "===", "DataTable"}], ",", 
          RowBox[{"{", "plots", "}"}], ",", 
          RowBox[{"Cases", "[", 
           RowBox[{"plots", ",", "_DataTable"}], "]"}]}], "]"}]}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"DTs", "=", 
        RowBox[{
         RowBox[{
          RowBox[{"DeleteMissing", "[", 
           RowBox[{"#", ",", "1", ",", "1"}], "]"}], "&"}], "/@", "DTs"}]}], 
       ";", "\[IndentingNewLine]", 
       RowBox[{"PR", "=", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"ListQ", "[", 
           RowBox[{"OptionValue", "[", "PlotRange", "]"}], "]"}], ",", 
          RowBox[{"OptionValue", "[", "PlotRange", "]"}], ",", 
          RowBox[{"CalcPlotRange", "[", 
           RowBox[{"DTs", ",", 
            RowBox[{"FilterRules", "[", 
             RowBox[{
              RowBox[{"{", "opts", "}"}], ",", " ", 
              RowBox[{"Options", "[", "CalcPlotRange", "]"}]}], "]"}]}], 
           "]"}]}], "]"}]}], ";", "\[IndentingNewLine]", 
       RowBox[{"ColLabels", "=", 
        RowBox[{"ColNames", "@", 
         RowBox[{"First", "@", "DTs"}]}]}], ";", "\[IndentingNewLine]", 
       "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"TrueQ", "[", 
           RowBox[{"OptionValue", "[", "XLogScale", "]"}], "]"}], "||", 
          RowBox[{"TrueQ", "[", 
           RowBox[{"OptionValue", "[", "YLogScale", "]"}], "]"}]}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{
          RowBox[{"DTs", "=", 
           RowBox[{
            RowBox[{
             RowBox[{"#", "[", 
              RowBox[{"All", ",", 
               RowBox[{
                RowBox[{"<|", "\[IndentingNewLine]", 
                 RowBox[{
                  RowBox[{"\"\<x\>\"", "\[Rule]", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"TrueQ", "[", 
                    RowBox[{"OptionValue", "[", "XLogScale", "]"}], "]"}], 
                    ",", 
                    RowBox[{"Log10", "@", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "1", "]"}], "]"}]}], "]"}]}], ",", 
                  "\[IndentingNewLine]", 
                  RowBox[{"\"\<y\>\"", "\[Rule]", 
                   RowBox[{"If", "[", 
                    RowBox[{
                    RowBox[{"TrueQ", "[", 
                    RowBox[{"OptionValue", "[", "YLogScale", "]"}], "]"}], 
                    ",", 
                    RowBox[{"Log10", "@", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}]}], ",", 
                    RowBox[{"#", "[", 
                    RowBox[{"[", "2", "]"}], "]"}]}], "]"}]}]}], 
                 "\[IndentingNewLine]", "|>"}], "&"}]}], "]"}], "&"}], "/@", 
            "DTs"}]}], ";"}]}], "\[IndentingNewLine]", "]"}], ";", 
       "\[IndentingNewLine]", "\[IndentingNewLine]", 
       RowBox[{"Figure", "[", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"{", "\[IndentingNewLine]", 
          RowBox[{
           RowBox[{"SetOptions", "[", 
            RowBox[{"DataSymbol", ",", 
             RowBox[{"SymbolSize", "\[Rule]", "8"}]}], "]"}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{
            RowBox[{"OptionValue", "[", "FigPreamble", "]"}], "//", 
            "ReleaseHold"}], ",", "\[IndentingNewLine]", 
           "\[IndentingNewLine]", 
           RowBox[{"Switch", "[", 
            RowBox[{
             RowBox[{"OptionValue", "[", "Joined", "]"}], ",", 
             "\[IndentingNewLine]", "True", ",", 
             RowBox[{"SetOptions", "[", 
              RowBox[{"DataLine", ",", 
               RowBox[{"{", 
                RowBox[{"Show", "\[Rule]", "True"}], "}"}]}], "]"}], ",", 
             "\[IndentingNewLine]", "False", ",", 
             RowBox[{"SetOptions", "[", 
              RowBox[{"DataLine", ",", 
               RowBox[{"{", 
                RowBox[{"Show", "\[Rule]", "False"}], "}"}]}], "]"}]}], 
            "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", 
           RowBox[{"Switch", "[", 
            RowBox[{
             RowBox[{"OptionValue", "[", "PlotMarkers", "]"}], ",", 
             "\[IndentingNewLine]", "True", ",", 
             RowBox[{"SetOptions", "[", 
              RowBox[{"DataSymbol", ",", 
               RowBox[{"{", 
                RowBox[{"Show", "\[Rule]", "True"}], "}"}]}], "]"}], ",", 
             "\[IndentingNewLine]", "False", ",", 
             RowBox[{"SetOptions", "[", 
              RowBox[{"DataSymbol", ",", 
               RowBox[{"{", 
                RowBox[{"Show", "\[Rule]", "False"}], "}"}]}], "]"}]}], 
            "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", 
           "LSDataStyles", ",", "\[IndentingNewLine]", "\[IndentingNewLine]", 
           
           RowBox[{"(", 
            RowBox[{"RawGraphics", "/@", 
             RowBox[{"Cases", "[", 
              RowBox[{"plots", ",", "_Graphics"}], "]"}]}], ")"}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{"(", 
            RowBox[{"ReleaseHold", "/@", 
             RowBox[{"Cases", "[", 
              RowBox[{"plots", ",", 
               RowBox[{"Except", "[", 
                RowBox[{"_DataTable", "|", "_Graphics"}], "]"}]}], "]"}]}], 
            ")"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", 
           RowBox[{"MapIndexed", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"SciDrawPlot", "[", 
               RowBox[{"#1", ",", 
                RowBox[{"Append", "[", 
                 RowBox[{
                  RowBox[{"FilterRules", "[", 
                   RowBox[{
                    RowBox[{"{", "opts", "}"}], ",", " ", 
                    RowBox[{"Options", "[", "CalcPlotRange", "]"}]}], "]"}], 
                  ",", 
                  RowBox[{"DataStyle", "\[Rule]", 
                   RowBox[{"ToString", "[", 
                    RowBox[{"Mod", "[", 
                    RowBox[{
                    RowBox[{"#2", "[", 
                    RowBox[{"[", "1", "]"}], "]"}], ",", "NLSDS", ",", "1"}], 
                    "]"}], "]"}]}]}], "]"}]}], "]"}], "&"}], ",", "DTs"}], 
            "]"}], ",", "\[IndentingNewLine]", "\[IndentingNewLine]", 
           RowBox[{"If", "[", 
            RowBox[{
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{
                 RowBox[{"OptionValue", "[", "ShowLegend", "]"}], "===", 
                 "Automatic"}], "&&", 
                RowBox[{
                 RowBox[{"Length", "[", "DTs", "]"}], ">", "1"}]}], ")"}], "||", 
              RowBox[{"ListQ", "[", 
               RowBox[{"OptionValue", "[", "ShowLegend", "]"}], "]"}]}], ",", 
             "\[IndentingNewLine]", 
             RowBox[{"DataLegend", "[", 
              RowBox[{
               RowBox[{"If", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"OptionValue", "[", "ShowLegend", "]"}], "===", 
                  "Automatic"}], ",", 
                 RowBox[{"{", 
                  RowBox[{"0.8", ",", "0.2"}], "}"}], ",", 
                 RowBox[{"OptionValue", "[", "ShowLegend", "]"}]}], "]"}], 
               ",", "\[IndentingNewLine]", 
               RowBox[{"If", "[", 
                RowBox[{
                 RowBox[{
                  RowBox[{"OptionValue", "[", "PlotLegends", "]"}], "===", 
                  "Automatic"}], ",", "\[IndentingNewLine]", 
                 RowBox[{"Table", "[", 
                  RowBox[{
                   RowBox[{"{", 
                    RowBox[{
                    RowBox[{"ToString", "[", 
                    RowBox[{"Mod", "[", 
                    RowBox[{"i", ",", "NLSDS", ",", "1"}], "]"}], "]"}], ",", 
                    
                    RowBox[{"ToString", "[", "i", "]"}]}], "}"}], ",", 
                   RowBox[{"{", 
                    RowBox[{"i", ",", "1", ",", 
                    RowBox[{"Length", "[", "DTs", "]"}]}], "}"}]}], "]"}], 
                 ",", "\[IndentingNewLine]", 
                 RowBox[{"Table", "[", 
                  RowBox[{
                   RowBox[{"{", 
                    RowBox[{
                    RowBox[{"ToString", "[", 
                    RowBox[{"Mod", "[", 
                    RowBox[{"i", ",", "NLSDS", ",", "1"}], "]"}], "]"}], ",", 
                    
                    RowBox[{
                    RowBox[{"OptionValue", "[", "PlotLegends", "]"}], "[", 
                    RowBox[{"[", "i", "]"}], "]"}]}], "}"}], ",", 
                   RowBox[{"{", 
                    RowBox[{"i", ",", "1", ",", 
                    RowBox[{"Length", "[", "DTs", "]"}]}], "}"}]}], "]"}]}], 
                "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", 
               RowBox[{"FontFamily", "\[Rule]", "\"\<sans-serif\>\""}]}], 
              "\[IndentingNewLine]", "]"}], ",", "\[IndentingNewLine]", 
             "Null"}], "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]", 
          "}"}], ",", "\[IndentingNewLine]", 
         RowBox[{"PlotRange", "\[Rule]", "PR"}], ",", "\[IndentingNewLine]", 
         RowBox[{"Frame", "\[Rule]", "True"}], ",", "\[IndentingNewLine]", 
         RowBox[{"FontFamily", "\[Rule]", "\"\<sans-serif\>\""}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{"FilterRules", "[", 
          RowBox[{
           RowBox[{"Join", "[", 
            RowBox[{
             RowBox[{"{", "opts", "}"}], ",", 
             RowBox[{"{", 
              RowBox[{"ImageSize", "\[Rule]", 
               RowBox[{"120", "*", 
                RowBox[{"{", 
                 RowBox[{"6", ",", "4"}], "}"}]}]}], "}"}]}], "]"}], ",", " ", 
           RowBox[{"Options", "[", "Figure", "]"}]}], "]"}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{"FrameTicks", "\[Rule]", 
          RowBox[{"{", 
           RowBox[{
            RowBox[{"LinTicks", "@@", 
             RowBox[{"PR", "[", 
              RowBox[{"[", "1", "]"}], "]"}]}], ",", 
            RowBox[{"LinTicks", "@@", 
             RowBox[{"PR", "[", 
              RowBox[{"[", "2", "]"}], "]"}]}]}], "}"}]}], ",", 
         "\[IndentingNewLine]", 
         RowBox[{"LabB", "\[Rule]", 
          RowBox[{"ColLabels", "[", 
           RowBox[{"[", "1", "]"}], "]"}]}], ",", "\[IndentingNewLine]", 
         RowBox[{"LabL", "\[Rule]", 
          RowBox[{"ColLabels", "[", 
           RowBox[{"[", "2", "]"}], "]"}]}]}], "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{"If", "[", 
          RowBox[{
           RowBox[{"OptionValue", "[", "YLogScale", "]"}], ",", 
           "\[IndentingNewLine]", 
           RowBox[{"{", "\[IndentingNewLine]", 
            RowBox[{
             RowBox[{"If", "[", 
              RowBox[{
               RowBox[{"OptionValue", "[", "XLogScale", "]"}], ",", 
               "\[IndentingNewLine]", 
               RowBox[{"LinTicks", "@@", 
                RowBox[{"PR", "[", 
                 RowBox[{"[", "1", "]"}], "]"}]}], 
               RowBox[{"(*", 
                RowBox[{"LogTicks", "[", 
                 RowBox[{
                  RowBox[{"PR", "[", 
                   RowBox[{"[", 
                    RowBox[{"1", ",", "1"}], "]"}], "]"}], ",", 
                  RowBox[{"PR", "[", 
                   RowBox[{"[", 
                    RowBox[{"1", ",", "2"}], "]"}], "]"}], ",", 
                  RowBox[{"TickLabelStep", "\[Rule]", "0.1"}]}], "]"}], 
                "*)"}], ",", "\[IndentingNewLine]", 
               RowBox[{"LinTicks", "@@", 
                RowBox[{"PR", "[", 
                 RowBox[{"[", "1", "]"}], "]"}]}]}], "\[IndentingNewLine]", 
              "]"}], ",", "\[IndentingNewLine]", 
             RowBox[{"LogTicks", "@@", 
              RowBox[{"PR", "[", 
               RowBox[{"[", "2", "]"}], "]"}]}]}], "\[IndentingNewLine]", 
            "}"}], ",", "\[IndentingNewLine]", 
           RowBox[{"If", "[", 
            RowBox[{
             RowBox[{"OptionValue", "[", "XLogScale", "]"}], ",", 
             "\[IndentingNewLine]", 
             RowBox[{"{", "\[IndentingNewLine]", 
              RowBox[{
               RowBox[{"LogTicks", "[", 
                RowBox[{
                 RowBox[{"PR", "[", 
                  RowBox[{"[", 
                   RowBox[{"1", ",", "1"}], "]"}], "]"}], ",", 
                 RowBox[{"PR", "[", 
                  RowBox[{"[", 
                   RowBox[{"1", ",", "2"}], "]"}], "]"}], ",", 
                 RowBox[{"TickLabelStep", "\[Rule]", "0.1"}]}], "]"}], ",", 
               "\[IndentingNewLine]", 
               RowBox[{"LinTicks", "@@", 
                RowBox[{"PR", "[", 
                 RowBox[{"[", "2", "]"}], "]"}]}]}], "\[IndentingNewLine]", 
              "}"}], ",", "\[IndentingNewLine]", 
             RowBox[{
              RowBox[{
               RowBox[{"LinTicks", "[", 
                RowBox[{
                 RowBox[{"#", "[", 
                  RowBox[{"[", "1", "]"}], "]"}], ",", 
                 RowBox[{"#", "[", 
                  RowBox[{"[", "2", "]"}], "]"}]}], "]"}], "&"}], "/@", 
              "PR"}]}], "\[IndentingNewLine]", "]"}]}], "\[IndentingNewLine]",
           "]"}], "*)"}], "\[IndentingNewLine]", "]"}]}], 
      "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"Options", "[", "CalcPlotRange", "]"}], "=", 
   RowBox[{"{", 
    RowBox[{
     RowBox[{"XLogScale", "\[Rule]", "False"}], ",", 
     RowBox[{"YLogScale", "\[Rule]", "False"}]}], "}"}]}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{
    RowBox[{"CalcPlotRange", "[", 
     RowBox[{"data_DataTable", ",", 
      RowBox[{"opts", ":", 
       RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
    RowBox[{"Module", "[", "\[IndentingNewLine]", 
     RowBox[{
      RowBox[{"{", 
       RowBox[{"XMin", ",", "XMax", ",", "YMin", ",", "YMax"}], "}"}], ",", 
      "\[IndentingNewLine]", 
      RowBox[{"(", "\[IndentingNewLine]", 
       RowBox[{
        RowBox[{"XMin", "=", 
         RowBox[{"Min", "@", 
          RowBox[{"data", "[", 
           RowBox[{"All", ",", "1", ",", "DVValues"}], "]"}]}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"TrueQ", "[", 
           RowBox[{"OptionValue", "[", "XLogScale", "]"}], "]"}], ",", 
          RowBox[{"XMin", "=", 
           RowBox[{"Log10", "[", "XMin", "]"}]}]}], "]"}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"XMin", "=", 
         RowBox[{"XMin", "-", 
          RowBox[{
           RowBox[{"Abs", "[", "XMin", "]"}], "*", "0.02"}]}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"XMin", "=", 
         RowBox[{"Floor", "[", 
          RowBox[{"XMin", ",", 
           RowBox[{"10", "^", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{"Log10", "[", 
                 RowBox[{"Abs", "[", "XMin", "]"}], "]"}], "//", "Floor"}], 
               ")"}], "-", "1"}], ")"}]}]}], "]"}]}], ";", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"XMax", "=", 
         RowBox[{"Max", "@", 
          RowBox[{"data", "[", 
           RowBox[{"All", ",", "1", ",", "DVValues"}], "]"}]}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"TrueQ", "[", 
           RowBox[{"OptionValue", "[", "XLogScale", "]"}], "]"}], ",", 
          RowBox[{"XMax", "=", 
           RowBox[{"Log10", "[", "XMax", "]"}]}]}], "]"}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"XMax", "=", 
         RowBox[{"XMax", "+", 
          RowBox[{
           RowBox[{"Abs", "[", "XMax", "]"}], "*", "0.02"}]}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"XMax", "=", 
         RowBox[{"Ceiling", "[", 
          RowBox[{"XMax", ",", 
           RowBox[{"10", "^", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{"Log10", "[", 
                 RowBox[{"Abs", "[", "XMax", "]"}], "]"}], "//", "Floor"}], 
               ")"}], "-", "1"}], ")"}]}]}], "]"}]}], ";", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"YMin", "=", 
         RowBox[{"Min", "@", 
          RowBox[{"data", "[", 
           RowBox[{"All", ",", "2", ",", "DVValues"}], "]"}]}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"TrueQ", "[", 
           RowBox[{"OptionValue", "[", "YLogScale", "]"}], "]"}], ",", 
          RowBox[{"YMin", "=", 
           RowBox[{"Log10", "[", "YMin", "]"}]}]}], "]"}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"YMin", "=", 
         RowBox[{"YMin", "-", 
          RowBox[{
           RowBox[{"Abs", "[", "YMin", "]"}], "*", "0.02"}]}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"YMin", "=", 
         RowBox[{"Floor", "[", 
          RowBox[{"YMin", ",", 
           RowBox[{"10", "^", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{"Log10", "[", 
                 RowBox[{"Abs", "[", "YMin", "]"}], "]"}], "//", "Floor"}], 
               ")"}], "-", "1"}], ")"}]}]}], "]"}]}], ";", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"YMax", "=", 
         RowBox[{"Max", "@", 
          RowBox[{"data", "[", 
           RowBox[{"All", ",", "2", ",", "DVValues"}], "]"}]}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"If", "[", 
         RowBox[{
          RowBox[{"TrueQ", "[", 
           RowBox[{"OptionValue", "[", "YLogScale", "]"}], "]"}], ",", 
          RowBox[{"YMax", "=", 
           RowBox[{"Log10", "[", "YMax", "]"}]}]}], "]"}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"YMax", "=", 
         RowBox[{"YMax", "+", 
          RowBox[{
           RowBox[{"Abs", "[", "YMax", "]"}], "*", "0.02"}]}]}], ";", 
        "\[IndentingNewLine]", 
        RowBox[{"YMax", "=", 
         RowBox[{"Ceiling", "[", 
          RowBox[{"YMax", ",", 
           RowBox[{"10", "^", 
            RowBox[{"(", 
             RowBox[{
              RowBox[{"(", 
               RowBox[{
                RowBox[{"Log10", "[", 
                 RowBox[{"Abs", "[", "YMax", "]"}], "]"}], "//", "Floor"}], 
               ")"}], "-", "1"}], ")"}]}]}], "]"}]}], ";", 
        "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"(*", 
         RowBox[{
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"TrueQ", "[", 
             RowBox[{"OptionValue", "[", "XLogScale", "]"}], "]"}], ",", 
            RowBox[{
             RowBox[{"XMin", "=", 
              RowBox[{
               RowBox[{
                RowBox[{"Floor", "[", 
                 RowBox[{"#", ",", "0.1"}], "]"}], "&"}], "@", 
               RowBox[{"Log10", "[", "XMin", "]"}]}]}], ";", 
             RowBox[{"XMax", "=", 
              RowBox[{
               RowBox[{
                RowBox[{"Ceiling", "[", 
                 RowBox[{"#", ",", "0.1"}], "]"}], "&"}], "@", 
               RowBox[{"Log10", "[", "XMax", "]"}]}]}], ";"}]}], "]"}], ";", 
          "\[IndentingNewLine]", 
          RowBox[{"If", "[", 
           RowBox[{
            RowBox[{"TrueQ", "[", 
             RowBox[{"OptionValue", "[", "YLogScale", "]"}], "]"}], ",", 
            RowBox[{
             RowBox[{"YMin", "=", 
              RowBox[{"Floor", "@", 
               RowBox[{"Log10", "[", "YMin", "]"}]}]}], ";", 
             RowBox[{"YMax", "=", 
              RowBox[{"Ceiling", "@", 
               RowBox[{"Log10", "[", "YMax", "]"}]}]}], ";"}]}], "]"}], ";"}],
          "*)"}], "\[IndentingNewLine]", "\[IndentingNewLine]", 
        RowBox[{"{", 
         RowBox[{
          RowBox[{"{", 
           RowBox[{"XMin", ",", "XMax"}], "}"}], ",", 
          RowBox[{"{", 
           RowBox[{"YMin", ",", "YMax"}], "}"}]}], "}"}]}], 
       "\[IndentingNewLine]", ")"}]}], "\[IndentingNewLine]", "]"}]}], ";"}], 
  "\[IndentingNewLine]"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{
   RowBox[{"CalcPlotRange", "[", 
    RowBox[{"data_List", ",", 
     RowBox[{"opts", ":", 
      RowBox[{"OptionsPattern", "[", "]"}]}]}], "]"}], ":=", 
   RowBox[{"Module", "[", 
    RowBox[{
     RowBox[{"{", "Ranges", "}"}], ",", "\[IndentingNewLine]", 
     RowBox[{"(", "\[IndentingNewLine]", 
      RowBox[{
       RowBox[{"Ranges", "=", 
        RowBox[{"(", 
         RowBox[{
          RowBox[{
           RowBox[{"CalcPlotRange", "[", 
            RowBox[{"#", ",", "opts"}], "]"}], "&"}], "/@", "data"}], ")"}]}],
        ";", "\[IndentingNewLine]", 
       RowBox[{"If", "[", 
        RowBox[{
         RowBox[{
          RowBox[{"Length", "[", "Ranges", "]"}], "\[Equal]", "0"}], ",", 
         RowBox[{"ErrorMessage", "[", 
          RowBox[{"Fig", "::", "nodatatable"}], "]"}]}], "]"}], ";", 
       "\[IndentingNewLine]", 
       RowBox[{"{", "\[IndentingNewLine]", 
        RowBox[{
         RowBox[{"{", 
          RowBox[{
           RowBox[{"Min", "@@", 
            RowBox[{"Ranges", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "1", ",", "1"}], "]"}], "]"}]}], ",", 
           RowBox[{"Max", "@@", 
            RowBox[{"Ranges", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "1", ",", "2"}], "]"}], "]"}]}]}], "}"}], 
         ",", "\[IndentingNewLine]", 
         RowBox[{"{", 
          RowBox[{
           RowBox[{"Min", "@@", 
            RowBox[{"Ranges", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "2", ",", "1"}], "]"}], "]"}]}], ",", 
           RowBox[{"Max", "@@", 
            RowBox[{"Ranges", "[", 
             RowBox[{"[", 
              RowBox[{"All", ",", "2", ",", "2"}], "]"}], "]"}]}]}], "}"}]}], 
        "\[IndentingNewLine]", "}"}]}], "\[IndentingNewLine]", ")"}]}], 
    "\[IndentingNewLine]", "]"}]}], ";"}]}], "Input",ExpressionUUID->\
"7d648e36-522c-4e6d-8de8-6cedc768b958"]
}, Open  ]],

Cell[CellGroupData[{

Cell["End private context", "Section"],

Cell[BoxData[
 RowBox[{
  RowBox[{"End", "[", "]"}], ";"}]], "Input",
 InitializationCell->True]
}, Closed]],

Cell[CellGroupData[{

Cell["End package", "Section"],

Cell[BoxData[{
 RowBox[{
  RowBox[{"Protect", "[", 
   RowBox[{"Evaluate", "[", 
    RowBox[{"$Context", "<>", "\"\<*\>\""}], "]"}], "]"}], 
  ";"}], "\[IndentingNewLine]", 
 RowBox[{
  RowBox[{"Unprotect", "[", "$UsePlusMinusForm", "]"}], ";"}], "\n", 
 RowBox[{
  RowBox[{"EndPackage", "[", "]"}], ";"}]}], "Input",
 InitializationCell->True]
}, Open  ]]
}, Open  ]]
},
AutoGeneratedPackage->Automatic,
WindowSize->{1920, 1007},
WindowMargins->{{-8, Automatic}, {Automatic, -8}},
DockedCells->FEPrivate`FrontEndResource["FEExpressions", "PackageToolbar"],
Magnification:>1.25 Inherited,
FrontEndVersion->"11.2 for Microsoft Windows (64-bit) (September 10, 2017)",
StyleDefinitions->"Default.nb"
]
(* End of Notebook Content *)

(* Internal cache information *)
(*CellTagsOutline
CellTagsIndex->{
 "Null"->{
  Cell[314572, 8148, 57, 1, 83, "Section",ExpressionUUID->"a06ba4f9-2260-44a5-b75f-47fe334ed8bf",
   CellTags->"Null"],
  Cell[417491, 10508, 72, 1, 160, "Section",ExpressionUUID->"4647ae39-b737-4aaa-b146-27914292bf69",
   CellTags->"Null"]}
 }
*)
(*CellTagsIndex
CellTagsIndex->{
 {"Null", 465405, 11693}
 }
*)
(*NotebookFileOutline
Notebook[{
Cell[CellGroupData[{
Cell[579, 22, 29, 0, 121, "Title",ExpressionUUID->"4bb493e9-fee0-4763-9cf3-fb711a708f39"],
Cell[CellGroupData[{
Cell[633, 26, 87, 0, 83, "Section",ExpressionUUID->"9d9e5efc-5729-48c9-b296-8e123767f5d5"],
Cell[723, 28, 551, 12, 200, "Input",ExpressionUUID->"3016a4ef-eca9-4385-877e-cf2ad253e825",
 InitializationCell->True],
Cell[1277, 42, 184, 5, 55, "Input",ExpressionUUID->"6f73b265-4b63-463d-8163-bd8dc3c61ba4",
 InitializationCell->True]
}, Open  ]],
Cell[CellGroupData[{
Cell[1498, 52, 88, 0, 83, "Section",ExpressionUUID->"1d83d6e5-66cb-44d4-87f9-e782c399f237"],
Cell[CellGroupData[{
Cell[1611, 56, 31, 0, 67, "Subsection",ExpressionUUID->"f32975d3-2a5d-42ca-80c7-0e8138f67122"],
Cell[1645, 58, 3196, 73, 1496, "Input",ExpressionUUID->"ae205faf-3b29-4a1c-90c5-941fdaa67198",
 InitializationCell->True]
}, Open  ]],
Cell[CellGroupData[{
Cell[4878, 136, 31, 0, 67, "Subsection",ExpressionUUID->"ff177c9a-adb7-4bc4-ba46-1753d697035e"],
Cell[4912, 138, 145, 3, 55, "Input",ExpressionUUID->"9935e195-a0b8-4785-8e55-afe9d69e84bd",
 InitializationCell->True]
}, Open  ]],
Cell[CellGroupData[{
Cell[5094, 146, 29, 0, 67, "Subsection",ExpressionUUID->"adb333de-de7c-4f94-a3c0-baaf134df863"],
Cell[5126, 148, 698, 16, 344, "Input",ExpressionUUID->"3ac7fdf1-b7ac-4cff-9829-ef21eee37f80",
 InitializationCell->True]
}, Open  ]]
}, Open  ]],
Cell[CellGroupData[{
Cell[5873, 170, 40, 0, 83, "Section",ExpressionUUID->"060f582a-6b73-4710-baa0-04444dc2dafa"],
Cell[5916, 172, 119, 3, 55, "Input",ExpressionUUID->"bbb99095-a848-4d27-a973-d4b3fe61888a",
 InitializationCell->True]
}, Open  ]],
Cell[CellGroupData[{
Cell[6072, 180, 33, 0, 83, "Section",ExpressionUUID->"6f4cc4c1-c62c-4e2c-88fe-c5da21dbea14"],
Cell[6108, 182, 552, 15, 176, "Input",ExpressionUUID->"0434ab53-18c8-4fab-aaae-343759f8ad05",
 InitializationCell->True],
Cell[6663, 199, 367, 12, 80, "Input",ExpressionUUID->"04a2fc6d-979d-4996-a6cd-4fdd3fa4c916",
 InitializationCell->True]
}, Open  ]],
Cell[CellGroupData[{
Cell[7067, 216, 28, 0, 128, "Section",ExpressionUUID->"f853fe52-b2d4-4be2-9415-123825a41db9"],
Cell[7098, 218, 619, 19, 498819165, "Input",ExpressionUUID->"634970fd-3f17-44de-97c2-e451d5883d6a",
 InitializationCell->True]
}, Closed]],
Cell[CellGroupData[{
Cell[7754, 242, 59, 0, 100, "Section",ExpressionUUID->"ba4c6084-a544-42be-a5f8-1c8834dbd69e"],
Cell[7816, 244, 908, 30, 163, "Input",ExpressionUUID->"fc15afd1-5f14-4149-9a36-df9887f9c030",
 InitializationCell->True],
Cell[8727, 276, 829, 22, 206, "Input",ExpressionUUID->"889557f4-e06c-44cd-bf3a-2f7c979216aa",
 InitializationCell->True],
Cell[9559, 300, 1112, 28, 275, "Input",ExpressionUUID->"0e77bc0f-00f9-4e7c-b110-6d1a422085c5",
 InitializationCell->True],
Cell[CellGroupData[{
Cell[10696, 332, 24, 0, 103, "Subsection",ExpressionUUID->"864bb0f8-76ba-4200-a9bb-f54459ad3814"],
Cell[10723, 334, 6575, 183, 950, "Input",ExpressionUUID->"6d257516-a69a-4ecc-80ef-f04cfd893179",
 InitializationCell->True],
Cell[17301, 519, 6633, 186, 837, "Input",ExpressionUUID->"921e3ce1-23a5-4f09-ae33-ec7f37e631e9",
 InitializationCell->True]
}, Open  ]],
Cell[CellGroupData[{
Cell[23971, 710, 25, 0, 103, "Subsection",ExpressionUUID->"93ae480d-dfb7-4331-a939-18e69291cdec"],
Cell[23999, 712, 922, 29, 200, "Input",ExpressionUUID->"1517b732-9d63-48c4-a60d-d01bb692be7d",
 InitializationCell->True],
Cell[24924, 743, 2422, 67, 275, "Input",ExpressionUUID->"e88723a7-8831-4785-923b-5a59fb2a23b3",
 InitializationCell->True]
}, Open  ]],
Cell[CellGroupData[{
Cell[27383, 815, 24, 0, 103, "Subsection",ExpressionUUID->"6febe5f0-3ea9-42e2-8062-0b3cc515ff2b"],
Cell[27410, 817, 710, 19, 200, "Input",ExpressionUUID->"6332177d-2434-4021-bfa0-9fea4b7eacdd",
 InitializationCell->True],
Cell[28123, 838, 2126, 60, 243, "Input",ExpressionUUID->"8f3496c4-d247-4688-b149-182d4c095bc0"],
Cell[30252, 900, 2523, 69, 243, "Input",ExpressionUUID->"85d7c7c5-25a9-42ff-8b60-72e5b3b378ad"]
}, Open  ]],
Cell[CellGroupData[{
Cell[32812, 974, 36, 0, 103, "Subsection",ExpressionUUID->"f3ff7000-36f7-413b-a547-ec5531b75ec6"],
Cell[32851, 976, 12862, 320, 2487, "Input",ExpressionUUID->"6307796d-d431-4617-b6a8-40dfab484714",
 InitializationCell->True],
Cell[45716, 1298, 14422, 358, 6252, "Input",ExpressionUUID->"b545aad2-3fa6-4948-bd08-f8cbe46390cc",
 InitializationCell->True],
Cell[60141, 1658, 6432, 163, 3050, "Input",ExpressionUUID->"b3ba71b5-cb92-4ff5-a85f-f7c47104f7da",
 InitializationCell->True]
}, Open  ]],
Cell[CellGroupData[{
Cell[66610, 1826, 47, 0, 250, "Subsection",ExpressionUUID->"d9adeef9-a811-42fd-972a-275b48245d3f"],
Cell[CellGroupData[{
Cell[66682, 1830, 51, 0, 56, "Subsubsection",ExpressionUUID->"affcda70-e0a9-4934-81db-9dd27e54326e"],
Cell[66736, 1832, 17256, 418, 2051, "Input",ExpressionUUID->"ea3c6c5d-c71e-4e70-8671-c799da7f4eb4",
 InitializationCell->True]
}, Open  ]],
Cell[CellGroupData[{
Cell[84029, 2255, 72, 0, 56, "Subsubsection",ExpressionUUID->"0825dede-4dc7-41ab-8a9a-51eb42e6566d"],
Cell[84104, 2257, 1059, 32, 104, "Input",ExpressionUUID->"eaac7248-4aa4-41e0-9d0e-4cf164be96df",
 InitializationCell->True],
Cell[85166, 2291, 953, 24, 176, "Input",ExpressionUUID->"b8311bd6-93bd-43b7-96bd-9eafc5751d2f",
 InitializationCell->True],
Cell[86122, 2317, 503, 13, 176, "Input",ExpressionUUID->"181f10f2-df9c-43d7-a316-0192861ef98b",
 InitializationCell->True],
Cell[86628, 2332, 1221, 36, 104, "Input",ExpressionUUID->"54e4cbde-7d46-4123-ae66-c33eb4778061",
 InitializationCell->True],
Cell[87852, 2370, 13576, 302, 1880, "Input",ExpressionUUID->"03d83ee6-6849-42d5-a40e-50be13234828",
 InitializationCell->True],
Cell[101431, 2674, 45, 0, 60, "Input",ExpressionUUID->"c73b1af1-447d-43a1-a01a-fc8a065fd499"],
Cell[101479, 2676, 34162, 838, 3899, "Input",ExpressionUUID->"f9fabc4a-7b46-4f2f-a35f-c7ec826895a0",
 InitializationCell->True],
Cell[135644, 3516, 1927, 54, 272, "Input",ExpressionUUID->"75d7004c-21a1-4651-9379-0d64be44fbc9",
 InitializationCell->True]
}, Open  ]]
}, Open  ]],
Cell[CellGroupData[{
Cell[137620, 3576, 70, 0, 67, "Subsection",ExpressionUUID->"bb6ab726-0e12-43da-8117-c51369594dfd"],
Cell[137693, 3578, 9468, 221, 1093, "Input",ExpressionUUID->"7f3b9870-4bb5-4c73-ad90-41f778a6fb67",
 InitializationCell->True]
}, Open  ]],
Cell[CellGroupData[{
Cell[147198, 3804, 64, 0, 103, "Subsection",ExpressionUUID->"faea0ab3-b452-49b4-879d-7bb0e6363645"],
Cell[CellGroupData[{
Cell[147287, 3808, 46, 0, 33338283, "Subsubsection",ExpressionUUID->"4d79916f-86f9-4f3f-8507-32fe96d47d9c"],
Cell[147336, 3810, 7487, 212, 1047536072, "Input",ExpressionUUID->"06224bef-65f8-45e4-8f87-f84ee5174aca",
 InitializationCell->True]
}, Open  ]],
Cell[CellGroupData[{
Cell[154860, 4027, 40, 0, 33338283, "Subsubsection",ExpressionUUID->"88cc1af8-3b99-4967-9c19-b13c9c741cce"],
Cell[154903, 4029, 14267, 344, 1612094276, "Input",ExpressionUUID->"c3c0b9a8-a4a4-4f38-a892-a7163a9a4ccb",
 InitializationCell->True],
Cell[169173, 4375, 3254, 86, 594629913, "Input",ExpressionUUID->"c564ee65-7f5a-43d4-ae6f-e777e86fe609",
 InitializationCell->True],
Cell[CellGroupData[{
Cell[172452, 4465, 212, 7, 28930132, "Input",ExpressionUUID->"a29ce988-97dc-49d6-b70f-ef5ab75e4777"],
Cell[172667, 4474, 40, 0, 28930132, "Output",ExpressionUUID->"0797e358-ab2f-44e3-be4d-f2eb4401c227"]
}, Open  ]],
Cell[172722, 4477, 1663, 47, 183559660, "Input",ExpressionUUID->"264d91d9-f9f6-4f08-9fd9-a86fa1205e9b",
 InitializationCell->True]
}, Open  ]]
}, Closed]]
}, Open  ]],
Cell[CellGroupData[{
Cell[174446, 4531, 28, 0, 128, "Section",ExpressionUUID->"ec5be3b0-ab42-4646-9df2-449544729ffa"],
Cell[CellGroupData[{
Cell[174499, 4535, 50, 0, 103, "Subsection",ExpressionUUID->"d9d7b3fa-d226-4a72-9cc8-3c3b1938bb4e"],
Cell[174552, 4537, 5721, 149, 1250, "Input",ExpressionUUID->"1a5c75c5-cd65-4484-b69c-ba45c2706050",
 InitializationCell->True]
}, Open  ]],
Cell[CellGroupData[{
Cell[180310, 4691, 46, 0, 103, "Subsection",ExpressionUUID->"cda24fbf-6363-41d6-b8e5-cf1be06f2c96"],
Cell[180359, 4693, 13671, 377, 2638, "Input",ExpressionUUID->"694c9784-a0cc-4a40-aa27-b4520f5b12b0",
 InitializationCell->True],
Cell[194033, 5072, 13095, 337, 2200, "Input",ExpressionUUID->"e181f1f6-dc6a-429a-8264-ef6338c7f8f6"]
}, Open  ]],
Cell[CellGroupData[{
Cell[207165, 5414, 42, 0, 200, "Subsection",ExpressionUUID->"7c66194c-8938-47d1-9546-6914de30f3f1"],
Cell[207210, 5416, 4111, 117, 1268, "Input",ExpressionUUID->"bfe1ef11-ddda-4fb7-a28e-c17182acd4a8",
 InitializationCell->True],
Cell[211324, 5535, 3441, 83, 1562, "Input",ExpressionUUID->"a5efba51-bf4c-473d-abd5-63c655a6be0d",
 InitializationCell->True],
Cell[214768, 5620, 1168, 29, 682, "Input",ExpressionUUID->"9195cd2d-1e43-4e7e-af40-bb5eb689d99c",
 InitializationCell->True]
}, Open  ]],
Cell[CellGroupData[{
Cell[215973, 5654, 29, 0, 200, "Subsection",ExpressionUUID->"f0b94b8f-837a-4f65-9c28-907f74213b58"],
Cell[216005, 5656, 8386, 191, 4783, "Input",ExpressionUUID->"b9251a51-ae21-4107-8583-93381c01c153",
 InitializationCell->True],
Cell[224394, 5849, 11610, 275, 2600, "Input",ExpressionUUID->"673244c1-5c14-4c7f-a240-fa4822493103",
 InitializationCell->True],
Cell[236007, 6126, 9632, 227, 2412, "Input",ExpressionUUID->"43daebab-6dc0-468c-bb78-3c253ee7ec6c",
 InitializationCell->True],
Cell[245642, 6355, 5299, 117, 1181, "Input",ExpressionUUID->"61ba6a64-4862-43aa-8b38-36f905d8025d"],
Cell[250944, 6474, 13450, 321, 2265, "Input",ExpressionUUID->"74927a27-6af1-4eff-a0e5-9c7056cc9913"]
}, Open  ]],
Cell[CellGroupData[{
Cell[264431, 6800, 43, 0, 103, "Subsection",ExpressionUUID->"2fb55640-0af7-409d-aa76-1a3127713531"],
Cell[264477, 6802, 4338, 120, 725, "Input",ExpressionUUID->"b52a245f-f6f4-46cd-ad06-2867f6fa5b7f",
 InitializationCell->True],
Cell[268818, 6924, 1611, 48, 462, "Input",ExpressionUUID->"fa49f365-04d8-4c2a-b1a5-e235f0781a9b",
 InitializationCell->True],
Cell[270432, 6974, 3347, 98, 1195, "Input",ExpressionUUID->"6c2d856f-767f-4fba-b35a-7beae73fa2c8",
 InitializationCell->True],
Cell[273782, 7074, 1779, 48, 608, "Input",ExpressionUUID->"2290214f-a902-4c38-8a5a-5388230aec33",
 InitializationCell->True],
Cell[275564, 7124, 1759, 46, 608, "Input",ExpressionUUID->"cc513e20-911a-46c4-ad39-cd226eb95062",
 InitializationCell->True],
Cell[277326, 7172, 5160, 135, 1415, "Input",ExpressionUUID->"f81fba7e-6be4-47bc-aa66-8136fc7791de",
 InitializationCell->True],
Cell[282489, 7309, 3881, 88, 1720, "Input",ExpressionUUID->"c0b54ca1-c0e6-4bc8-bb79-7e5ab7ca7dc2"],
Cell[286373, 7399, 3018, 80, 1493, "Input",ExpressionUUID->"a5c1031a-18cd-42ac-996a-78ea606ffa79",
 InitializationCell->True],
Cell[289394, 7481, 1615, 43, 668, "Input",ExpressionUUID->"302f1a07-1eab-4fb0-8c12-80923d6b4672",
 InitializationCell->True],
Cell[291012, 7526, 906, 24, 200, "Input",ExpressionUUID->"696b0e53-ec71-466a-8f37-ec04cb59a5c4",
 InitializationCell->True],
Cell[291921, 7552, 771, 20, 200, "Input",ExpressionUUID->"f0ee9d79-84c7-4925-8c6a-281ae2186b90",
 InitializationCell->True],
Cell[292695, 7574, 2814, 82, 350, "Input",ExpressionUUID->"89638fa0-7a58-450e-9221-bd234c2c80ed",
 InitializationCell->True],
Cell[295512, 7658, 2454, 59, 1068, "Input",ExpressionUUID->"3e9f337e-f11d-4bc6-b3e6-a3fb7c2ae8d5"]
}, Open  ]]
}, Open  ]],
Cell[CellGroupData[{
Cell[298015, 7723, 39, 0, 83, "Section",ExpressionUUID->"ea621ba9-24dd-4f51-b5b7-2d017576992b"],
Cell[298057, 7725, 11823, 310, 1184, "Input",ExpressionUUID->"13ceb6bc-4f36-4ba6-94c6-5cc5f56bc24d",
 InitializationCell->True],
Cell[309883, 8037, 4652, 106, 608, "Input",ExpressionUUID->"3ada0169-a8b1-469e-92c6-3bdc5c29d140",
 InitializationCell->True]
}, Open  ]],
Cell[CellGroupData[{
Cell[314572, 8148, 57, 1, 83, "Section",ExpressionUUID->"a06ba4f9-2260-44a5-b75f-47fe334ed8bf",
 CellTags->"Null"],
Cell[314632, 8151, 4718, 111, 728, "Input",ExpressionUUID->"92e202f9-fa3b-4d35-8028-c7373f216105",
 InitializationCell->True],
Cell[319353, 8264, 39239, 891, 2626, "Input",ExpressionUUID->"036262f9-b803-45e4-8261-924c054de0ac",
 InitializationCell->True],
Cell[358595, 9157, 25057, 594, 2505, "Input",ExpressionUUID->"1442eba4-0c24-45da-b8fa-ff3b3a2b5bf0",
 InitializationCell->True],
Cell[383655, 9753, 14647, 323, 2262, "Input",ExpressionUUID->"c7dbb690-fa95-49c6-9218-bf1c4efc4c7b",
 InitializationCell->True],
Cell[398305, 10078, 19149, 425, 3625, "Input",ExpressionUUID->"44fce864-39cf-49ac-a0ac-db3759ef3dee",
 InitializationCell->True]
}, Open  ]],
Cell[CellGroupData[{
Cell[417491, 10508, 72, 1, 160, "Section",ExpressionUUID->"4647ae39-b737-4aaa-b146-27914292bf69",
 CellTags->"Null"],
Cell[417566, 10511, 14982, 363, 1945, "Input",ExpressionUUID->"50a3cb8f-28b0-43c5-b872-eeb9bfe9d512"],
Cell[432551, 10876, 8305, 203, 4641, "Input",ExpressionUUID->"5ec96217-22a0-4fd2-a1ac-938c6f720b55"],
Cell[440859, 11081, 23495, 568, 16665, "Input",ExpressionUUID->"7d648e36-522c-4e6d-8de8-6cedc768b958"]
}, Open  ]],
Cell[CellGroupData[{
Cell[464391, 11654, 38, 0, 487, "Section",ExpressionUUID->"61d7714f-1e51-4123-9cb5-ca83cd358a3b"],
Cell[464432, 11656, 96, 3, 1605944846, "Input",ExpressionUUID->"abe064bb-0af9-4a5b-bdb5-ca0e9bfa44ba",
 InitializationCell->True]
}, Closed]],
Cell[CellGroupData[{
Cell[464565, 11664, 30, 0, 378, "Section",ExpressionUUID->"c97f4338-6793-48aa-a240-42dc71405e26"],
Cell[464598, 11666, 344, 10, 613, "Input",ExpressionUUID->"21bbf257-9d5b-4a99-b5a3-45d7acf3603e",
 InitializationCell->True]
}, Open  ]]
}, Open  ]]
}
]
*)

