static public IEnumerable <Pair <string, Dictionary <string, SufficientStatistics> > > LoadSparseFileEnumeration(string sparseFileName) //where T1:ISufficientStatistics
        {
            Set <string> variablesAlreadySeenSet = new Set <string>();

            Pair <string, Dictionary <string, SufficientStatistics> > variableAndCaseIdToNonMissingValue = null;

            foreach (Dictionary <string, string> row in SpecialFunctions.TabFileTable(sparseFileName, "var\tcid\tval", false))
            {
                string variable = row["var"];
                if (variableAndCaseIdToNonMissingValue != null && variableAndCaseIdToNonMissingValue.First != variable)
                {
                    yield return(variableAndCaseIdToNonMissingValue);

                    variableAndCaseIdToNonMissingValue = null;
                }
                if (variableAndCaseIdToNonMissingValue == null)
                {
                    SpecialFunctions.CheckCondition(!variablesAlreadySeenSet.Contains(variable), string.Format("Input file ({0}) is not grouped by variable. Variable {1} appears in multiple places", sparseFileName, variable));
                    variablesAlreadySeenSet.AddNew(variable);
                    variableAndCaseIdToNonMissingValue =
                        new Pair <string, Dictionary <string, SufficientStatistics> >(variable, new Dictionary <string, SufficientStatistics>());
                }
                string caseId            = row["cid"];
                SufficientStatistics val = SufficientStatistics.Parse(row["val"]);

                SpecialFunctions.CheckCondition(!variableAndCaseIdToNonMissingValue.Second.ContainsKey(caseId), string.Format("Input file ({0}) for var {1} contains multiple entries for caseId {2}", sparseFileName, variable, caseId));
                variableAndCaseIdToNonMissingValue.Second.Add(caseId, val);
            }

            if (variableAndCaseIdToNonMissingValue != null)
            {
                yield return(variableAndCaseIdToNonMissingValue);
            }
        }
        static public Dictionary <string, Dictionary <string, SufficientStatistics> > LoadSparseFileInMemory(string sparseFileName) //where TStat:ISufficientStatistics
        {
            Dictionary <string, Dictionary <string, SufficientStatistics> > variableToCaseIdToNonMissingValue =
                new Dictionary <string, Dictionary <string, SufficientStatistics> >();

            foreach (Dictionary <string, string> row in SpecialFunctions.TabFileTable(sparseFileName, "var\tcid\tval", false))
            {
                string variable          = row["var"];
                string caseId            = row["cid"];
                SufficientStatistics val = SufficientStatistics.Parse(row["val"]);

                Dictionary <string, SufficientStatistics> caseIdToNonMissingValue = SpecialFunctions.GetValueOrDefault(variableToCaseIdToNonMissingValue, variable);
                SpecialFunctions.CheckCondition(!caseIdToNonMissingValue.ContainsKey(caseId), string.Format("Input file ({0}) for var {1} contains multiple entries for caseId {2}", sparseFileName, variable, caseId));
                caseIdToNonMissingValue.Add(caseId, val);
            }
            return(variableToCaseIdToNonMissingValue);
        }