//attname and attvalue generally passed in from a reader public virtual void SetDemog3Properties(string attName, string attValue) { switch (attName) { case cHousing: this.Housing = attValue; break; case cWorkStatus: this.WorkStatus = attValue; break; case cMaritalStatus: this.MaritalStatus = attValue; break; case cLocationId: this.LocationId = attValue; break; case cFamilyIncomeCurrency: this.FamilyIncomeCurrency = attValue; break; case cFamilyIncomePerYear: this.FamilyIncomePerYear = CalculatorHelpers.ConvertStringToInt(attValue); break; default: break; } }
//takes '25_0', and outputs 25 as a double and 0 as an integer private bool GetValues(string obsMember, out string memberValue, out int filePosition) { bool bHasFileCount = false; memberValue = string.Empty; string sValue = obsMember; filePosition = 0; int iFileExtensionStart = obsMember.LastIndexOf(Constants.FILENAME_DELIMITER); if (iFileExtensionStart != -1) { bHasFileCount = true; sValue = obsMember.Substring(0, iFileExtensionStart); //get rid of the delimiter iFileExtensionStart += 1; string sFileNumber = obsMember.Substring(iFileExtensionStart, obsMember.Length - iFileExtensionStart); filePosition = CalculatorHelpers.ConvertStringToInt(sFileNumber); } memberValue = sValue; return(bHasFileCount); }
private void AddComparisonStatisticProperties(int filePosition, double attNumber) { if (this.CalcParams.AnalyzerParms.BaseCBStatistic.NameIsNotAStatistic( this.CalcParams.AnalyzerParms.ObservationAttributeName)) { //for standard deviation's running sum double dbStandardDeviation = 0; double dbMemberSquared = Math.Pow(attNumber, 2); double dbMemberSquaredTotal = 0; //for mean and sd running sum //double dbNewValue = attNumber; int iObservations = 1; double dbMean = attNumber; double dbTotal = attNumber; double dbMedian = 0; //could be another observation for same element within file //get the existing values from the collections, add the new //attnumber to the statistical collection, and set new //statistics (two tillage operations with same label //will have two observations, N=2, and need new mean, sd ... set) //note this attribute will never have a statistical suffix //in the attribute name (i.e. _MEAN) string sAttValue = this.GetStatisticalPropertyValue( filePosition, this.CalcParams.AnalyzerParms.NodePositionIndex, this.CalcParams.AnalyzerParms.ObservationAttributeName, this.CalcParams.AnalyzerParms.NodeName, string.Empty); dbTotal = CalculatorHelpers.ConvertStringToDouble(sAttValue) + attNumber; //get the new N and MEAN if (!string.IsNullOrEmpty(sAttValue)) { //set the number of observations string sNValue = this.GetStatisticalPropertyValue( filePosition, this.CalcParams.AnalyzerParms.NodePositionIndex, this.CalcParams.AnalyzerParms.ObservationAttributeName, this.CalcParams.AnalyzerParms.NodeName, CostBenefitStatistic01.N); iObservations = CalculatorHelpers.ConvertStringToInt(sNValue) + 1; //set the mean dbMean = dbTotal / iObservations; //set the new variance string sSumVariance = this.GetStatisticalPropertyValue( filePosition, this.CalcParams.AnalyzerParms.NodePositionIndex, this.CalcParams.AnalyzerParms.ObservationAttributeName, this.CalcParams.AnalyzerParms.NodeName, CostBenefitStatistic01.VAR2); dbMemberSquared = dbMemberSquared + CalculatorHelpers.ConvertStringToDouble(sSumVariance); } //get the new variance dbMemberSquaredTotal += dbMemberSquared; //get the new standard deviation dbStandardDeviation = GetStandardDeviation(dbTotal, iObservations, dbMemberSquaredTotal); //set the corresponding property values in the cb collections SetStatisticProperties(filePosition, iObservations, dbTotal, dbMean, dbMemberSquaredTotal, dbStandardDeviation, dbMedian); } }
//attname and attvalue generally passed in from a reader public void SetCEGeneralProperties(string attName, string attValue) { switch (attName) { case OUTPUTS: this.Outputs = CalculatorHelpers.ConvertStringToInt(attValue); break; case INPUTS: this.Inputs = CalculatorHelpers.ConvertStringToInt(attValue); break; default: break; } }
//attname and attvalue generally passed in from a reader public virtual void SetHealthBenefit1Properties(string attName, string attValue) { if (Demographics == null) { Demographics = new Demog1(); } Demographics.SetDemog1Properties(attName, attValue); switch (attName) { case cOutputCost: this.OutputCost = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cBenefitAdjustment: this.BenefitAdjustment = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cAdjustedBenefit: this.AdjustedBenefit = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cOutputEffect1Name: this.OutputEffect1Name = attValue; break; case cOutputEffect1Unit: this.OutputEffect1Unit = attValue; break; case cOutputEffect1Amount: this.OutputEffect1Amount = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cOutputEffect1Price: this.OutputEffect1Price = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cOutputEffect1Cost: this.OutputEffect1Cost = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cAverageBenefitRating: this.AverageBenefitRating = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cPhysicalHealthRating: this.PhysicalHealthRating = CalculatorHelpers.ConvertStringToInt(attValue); break; case cEmotionalHealthRating: this.EmotionalHealthRating = CalculatorHelpers.ConvertStringToInt(attValue); break; case cSocialHealthRating: this.SocialHealthRating = CalculatorHelpers.ConvertStringToInt(attValue); break; case cEconomicHealthRating: this.EconomicHealthRating = CalculatorHelpers.ConvertStringToInt(attValue); break; case cHealthCareDeliveryRating: this.HealthCareDeliveryRating = CalculatorHelpers.ConvertStringToInt(attValue); break; case cBeforeQOLRating: this.BeforeQOLRating = CalculatorHelpers.ConvertStringToInt(attValue); break; case cAfterQOLRating: this.AfterQOLRating = CalculatorHelpers.ConvertStringToInt(attValue); break; case cBeforeYears: this.BeforeYears = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cAfterYears: this.AfterYears = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cAfterYearsProb: this.AfterYearsProb = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cTimeTradeoffYears: this.TimeTradeoffYears = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cEquityMultiplier: this.EquityMultiplier = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cBenefitAssessment: this.BenefitAssessment = attValue; break; case cQALY: this.QALY = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cICERQALY: this.ICERQALY = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cTTOQALY: this.TTOQALY = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cWillDoSurvey: this.WillDoSurvey = CalculatorHelpers.ConvertStringToBool(attValue); break; default: break; } }
public double[] GetSampleData(string distType, double mostLikelyEstimate, double lowEstimate, double highEstimate) { if (Iterations > 10000) { Iterations = 10000; } if (Iterations <= 2) { Iterations = 1000; } if (this.CILevel < 10) { this.CILevel = 90; } if (this.CILevel > 99) { this.CILevel = 99; } Random rnd = new Random(Random); mostLikelyEstimate = Math.Round(mostLikelyEstimate, 4); lowEstimate = Math.Round(lowEstimate, 4); highEstimate = Math.Round(highEstimate, 4); var sampledata = new double[Iterations]; if (distType == Calculator1.RUC_TYPES.triangle.ToString()) { if (lowEstimate >= mostLikelyEstimate || lowEstimate == 0) { //arbitrary rules (25%) lowEstimate = mostLikelyEstimate * .75; //no errors: lowEstimate = 0 is often the case //sb.AppendLine(Errors.GetMessage("DATA_BADDISTRIBUTION")); } if (highEstimate <= mostLikelyEstimate || highEstimate == 0) { //arbitrary rules (25%) highEstimate = mostLikelyEstimate * 1.25; } if (Random != 0) { //generate samples of the Triangular(low, high, mode) distribution; Triangular.Samples(rnd, sampledata, lowEstimate, highEstimate, mostLikelyEstimate); } else { //generate samples of the Triangular(low, high, mode) distribution; Triangular.Samples(sampledata, lowEstimate, highEstimate, mostLikelyEstimate); } } else if (distType == Calculator1.RUC_TYPES.normal.ToString()) { //generate samples of the Normal(mean, sd) distribution; if (Random != 0) { Normal.Samples(rnd, sampledata, lowEstimate, highEstimate); } else { Normal.Samples(sampledata, lowEstimate, highEstimate); } } else if (distType == Calculator1.RUC_TYPES.lognormal.ToString()) { if (Random != 0) { LogNormal.Samples(rnd, sampledata, lowEstimate, highEstimate); } else { LogNormal.Samples(sampledata, lowEstimate, highEstimate); } } else if (distType == Calculator1.RUC_TYPES.weibull.ToString()) { if (Random != 0) { Weibull.Samples(rnd, sampledata, lowEstimate, highEstimate); } else { Weibull.Samples(sampledata, lowEstimate, highEstimate); } } else if (distType == Calculator1.RUC_TYPES.beta.ToString()) { if (Random != 0) { Beta.Samples(rnd, sampledata, lowEstimate, highEstimate); } else { Beta.Samples(sampledata, lowEstimate, highEstimate); } } else if (distType == Calculator1.RUC_TYPES.pareto.ToString()) { if (Random != 0) { Pareto.Samples(rnd, sampledata, lowEstimate, highEstimate); } else { Pareto.Samples(sampledata, lowEstimate, highEstimate); } } else if (distType == Calculator1.RUC_TYPES.uniform.ToString()) { var sampleints = new int[Iterations]; int iLower = CalculatorHelpers.ConvertStringToInt(lowEstimate.ToString()); int iUpper = CalculatorHelpers.ConvertStringToInt(highEstimate.ToString()); if (Random != 0) { DiscreteUniform.Samples(rnd, sampleints, iLower, iUpper); } else { DiscreteUniform.Samples(sampleints, iLower, iUpper); } for (int i = 0; i < sampleints.Count(); i++) { sampledata[i] = sampleints[i]; } } else if (distType == Calculator1.RUC_TYPES.bernoulli.ToString()) { var sampleints = new int[Iterations]; if (Random != 0) { Bernoulli.Samples(rnd, sampleints, lowEstimate); } else { Bernoulli.Samples(sampleints, lowEstimate); } for (int i = 0; i < sampleints.Count(); i++) { sampledata[i] = sampleints[i]; } } else if (distType == Calculator1.RUC_TYPES.poisson.ToString()) { var sampleints = new int[Iterations]; if (Random != 0) { Poisson.Samples(rnd, sampleints, lowEstimate); } else { Poisson.Samples(sampleints, lowEstimate); } for (int i = 0; i < sampleints.Count(); i++) { sampledata[i] = sampleints[i]; } } else if (distType == Calculator1.RUC_TYPES.binomial.ToString()) { var sampleints = new int[Iterations]; int iUpperEstimate = CalculatorHelpers.ConvertStringToInt(highEstimate.ToString()); if (Random != 0) { Binomial.Samples(rnd, sampleints, lowEstimate, iUpperEstimate); } else { Binomial.Samples(sampleints, lowEstimate, iUpperEstimate); } for (int i = 0; i < sampleints.Count(); i++) { sampledata[i] = sampleints[i]; } } else if (distType == Calculator1.RUC_TYPES.gamma.ToString()) { //generate samples of the Gamma(shape, scale) distribution; if (Random != 0) { Gamma.Samples(rnd, sampledata, lowEstimate, highEstimate); } else { Gamma.Samples(sampledata, lowEstimate, highEstimate); } } else { //don't force them to use distribution } //hold for possible infernet use //else if (distType == Calculator1.RUC_TYPES.dirichlet.ToString()) //{ // //generate samples of the Dirichlet(random, alpha) distribution; // Dirichlet.Sample(sampledata, lowEstimate); //} //else if (distType == Calculator1.RUC_TYPES.wishart.ToString()) //{ // //generate samples of the Wishart(random, degrees of freedom, scale) distribution; // Wishart.Sample(sampledata, lowEstimate, highEstimate); //} //the mathlibrary supports more than a dozen additional distributions return(sampledata); }
//this is asych for the calling Task.WhenAll //but does not necessarily need internal asych awaits public async Task <bool> RunAlgorithmAsync(List <List <double> > data) { bool bHasCalculations = false; try { //minimal data requirement is first five cols if (_colNames.Count() < 5 || _mathTerms.Count() == 0) { ErrorMessage = "Complete randomized anova requires at least 1 dependent variable and 1 independent variable. Randomized block and factorial anovas require at least 2 independent variables."; return(bHasCalculations); } if (data.Count() < 5) { //185 same as other analysis ErrorMessage = "Anova requires at least 2 rows of observed data and 3 rows of scoring data."; return(bHasCalculations); } //convert data to a Math.Net Matrix //last 3 rows are used to generate ci List <List <double> > dataci = data.Skip(data.Count - _scoreRows).ToList(); data.Reverse(); List <List <double> > dataobs = data.Skip(_scoreRows).ToList(); dataobs.Reverse(); //actual observed values Vector <double> y = Shared.GetYData(dataobs); //treatments or factor1 levels Matrix <double> treatments = Shared.GetDistinctMatrix(dataobs, 1); //206 condition added due to M and E dataset indexing _totalsNeeded = treatments.ColumnCount; double tDF = treatments.ColumnCount - 1; //step 1. get total of observed data double yTotal = y.Sum(); //step 2. get total of observed data squared double yTotal2 = y.PointwisePower(2).Sum(); //step 3. set CM double CM = Math.Pow(yTotal, 2) / y.Count(); //step 4. treatments and blocks double SSTotal = yTotal2 - CM; //add the data to a string builder StringBuilder sb = new StringBuilder(); sb.AppendLine("anova results"); //5 col array string[] cols = new string[] { "source", "df", "SS", "MS", "F" }; sb.AppendLine(Shared.GetLine(cols, true)); List <List <double> > totals = new List <List <double> >(_totalsNeeded); //min treatment block required bool bIsBlock = (_depColNames.Contains("treatment") && _depColNames.Contains("block")) ? true : false; //min 2 factors required bool bIsFactorial = (_depColNames.Contains("factor1") && _depColNames.Contains("factor2")) ? true : false; bool bIsComplete = (bIsBlock == false && bIsFactorial == false) ? true : false; if (bIsComplete) { double eDF = y.Count() - treatments.ColumnCount; //step 5.treatments (correct to divide by rows) double SST = ((treatments.ColumnSums().PointwisePower(2).Sum()) / treatments.RowCount) - CM; //step 6. error double SSE = SSTotal - SST; //step 7. mean treatment double MST = SST / tDF; //step 8. mean error double MSE = SSE / (y.Count() - treatments.ColumnCount); //step 9. F treatments double FT = MST / MSE; //tests double s = Math.Pow(MSE, 0.5); //correct 2 tailed t test int itDF = CalculatorHelpers.ConvertStringToInt(tDF.ToString()); int ieDF = CalculatorHelpers.ConvertStringToInt(eDF.ToString()); double dbCI = CalculatorHelpers.GetConfidenceIntervalProb(_confidenceInt); //TINV divides dbCI by 2 to get student t double tCriticalValue = ExcelFunctions.TInv(dbCI, ieDF); //prevents an error in Finv if (itDF == 0) { itDF = 1; } double FCriticalTValue = ExcelFunctions.FInv(dbCI, itDF, ieDF); string FTGreaterFCritical = (FT > FCriticalTValue) ? "true" : "false"; for (int i = 0; i < _totalsNeeded; i++) { //206 condition added due to M and E dataset indexing if (i < treatments.ColumnCount) { SetAnovaIntervals(i, totals, treatments, tCriticalValue, s, CalculatorHelpers.ConvertStringToDouble(treatments.RowCount.ToString()), FT, FCriticalTValue, bIsComplete); } } this.DataToAnalyze.Add(Label, totals); ////add the data to a string builder cols = new string[] { "treats", itDF.ToString("F0"), SST.ToString("F4"), MST.ToString("F4"), FT.ToString("F4") }; sb.AppendLine(Shared.GetLine(cols, false)); cols = new string[] { "error ", ieDF.ToString("F0"), SSE.ToString("F4"), MSE.ToString("F4") }; sb.AppendLine(Shared.GetLine(cols, false)); cols = new string[] { "total ", (y.Count() - 1).ToString("F0"), (SSTotal).ToString("F4") }; sb.AppendLine(Shared.GetLine(cols, false)); cols = new string[] { string.Concat("F Crit ", "treats"), FCriticalTValue.ToString("F5"), "F > F Critical", FTGreaterFCritical }; sb.AppendLine(Shared.GetLine(cols, true)); } else { //observations per cell for factorials (data[0] if first row of data) double r = Shared.GetObservationsPerCell(dataobs, 1, data[0].ElementAt(1), data[0].ElementAt(2)); //blocks or factor2 levels Matrix <double> blocks = Shared.GetDistinctMatrix(dataobs, 2); double bDF = blocks.ColumnCount - 1; double eDF = y.Count() - treatments.ColumnCount - blocks.ColumnCount + 1; if (bIsFactorial) { eDF = (treatments.ColumnCount * blocks.ColumnCount) * (r - 1); } //factorial interaction df double tbDF = tDF * bDF; //step 5.treatments (correct to divide by r) double SST = ((treatments.ColumnSums().PointwisePower(2).Sum()) / (blocks.ColumnCount * r)) - CM; //step 6. blocks double SSB = ((blocks.ColumnSums().PointwisePower(2).Sum()) / (treatments.ColumnCount * r)) - CM; //factor level interaction double SSFL = 0; //step 7. error double SSE = 0; if (bIsFactorial) { double totalinteraction = Shared.GetTotalInteraction(blocks, r); //watch block.colcount for 2 x 3 factorials SSFL = (totalinteraction / r) - SST - SSB - CM; //step 7. error SSE = SSTotal - SST - SSB - SSFL; } else { //step 7. error SSE = SSTotal - SST - SSB; } //step 8. mean treatment double MST = SST / tDF; //step 9. mean block double MSB = SSB / bDF; //step 10. mean error double MSE = SSE / eDF; double MSFL = SSFL / tbDF; //step 11. F treatments double FT = MST / MSE; //step 12. F blocks double FB = MSB / MSE; double FTB = MSFL / MSE; //tests double s = Math.Pow(MSE, 0.5); //correct 2 tailed t test int itDF = CalculatorHelpers.ConvertStringToInt(tDF.ToString()); int ibDF = CalculatorHelpers.ConvertStringToInt(bDF.ToString()); int itbDF = CalculatorHelpers.ConvertStringToInt(tbDF.ToString()); int ieDF = CalculatorHelpers.ConvertStringToInt(eDF.ToString()); double dbCI = CalculatorHelpers.GetConfidenceIntervalProb(_confidenceInt); //TINV divides dbCI by 2 to get student t double tCriticalValue = ExcelFunctions.TInv(dbCI, ieDF); //prevents an error in Finv if (itDF == 0) { itDF = 1; } double FCriticalTValue = ExcelFunctions.FInv(dbCI, itDF, ieDF); string FTGreaterFCritical = (FT > FCriticalTValue) ? "true" : "false"; //prevents an error in Finv if (ibDF == 0) { ibDF = 1; } double FCriticalBValue = ExcelFunctions.FInv(dbCI, ibDF, ieDF); string FBGreaterFCritical = (FB > FCriticalBValue) ? "true" : "false"; //prevents an error in Finv if (itbDF == 0) { itbDF = 1; } double FCriticalTBValue = ExcelFunctions.FInv(dbCI, itbDF, ieDF); string FTBGreaterFCritical = (FTB > FCriticalTBValue) ? "true" : "false"; //List<List<double>> totals = new List<List<double>>(_totalsNeeded); if (bIsFactorial) { //unless custom stylesheets are developed, can only display factor 1 - factor 2 diffs //build a matrix equivalent to treatments -1 row, variable cols Matrix <double> torbs = Matrix <double> .Build.Dense(1, _totalsNeeded); List <double> mrow = new List <double>(_totalsNeeded); for (int i = 0; i < _totalsNeeded; i++) { double cellMean = Shared.GetMeanPerCell(dataobs, 1, 2, i, i, r); mrow.Add(cellMean); } torbs.SetRow(0, mrow.ToArray()); for (int i = 0; i < _totalsNeeded; i++) { //206 condition added due to M and E dataset indexing if (i < treatments.ColumnCount) { //treatments SetAnovaIntervals(i, totals, torbs, tCriticalValue, s, CalculatorHelpers.ConvertStringToDouble(blocks.ColumnCount.ToString()), FT, FCriticalTValue, bIsComplete); } } //cell1Mean = Shared.GetMeanPerCell(dataobs, 1, 2, 0, 0, r); //cell2Mean = Shared.GetMeanPerCell(dataobs, 1, 2, 0, 1, r); //SetAnovaIntervals2(1, cell1Mean, cell2Mean, tCriticalValue, s, r); //cell1Mean = Shared.GetMeanPerCell(dataobs, 1, 2, 0, 0, r); //cell2Mean = Shared.GetMeanPerCell(dataobs, 1, 2, 2, 0, r); //SetAnovaIntervals2(2, cell1Mean, cell2Mean, tCriticalValue, s, r); //double cell1Mean = Shared.GetMeanPerCell(dataobs, 1, 2, 0, 0, r); //double cell2Mean = Shared.GetMeanPerCell(dataobs, 1, 2, 1, 0, r); //SetAnovaIntervals2(0, cell1Mean, cell2Mean, tCriticalValue, s, r); //cell1Mean = Shared.GetMeanPerCell(dataobs, 1, 2, 0, 0, r); //cell2Mean = Shared.GetMeanPerCell(dataobs, 1, 2, 0, 1, r); //SetAnovaIntervals2(1, cell1Mean, cell2Mean, tCriticalValue, s, r); //cell1Mean = Shared.GetMeanPerCell(dataobs, 1, 2, 0, 0, r); //cell2Mean = Shared.GetMeanPerCell(dataobs, 1, 2, 2, 0, r); //SetAnovaIntervals2(2, cell1Mean, cell2Mean, tCriticalValue, s, r); } else { //unless custom stylesheets are developed, need to only display treatment diffs for (int i = 0; i < _totalsNeeded; i++) { //206 condition added due to M and E dataset indexing if (i < treatments.ColumnCount) { //treatments SetAnovaIntervals(i, totals, treatments, tCriticalValue, s, CalculatorHelpers.ConvertStringToDouble(blocks.ColumnCount.ToString()), FT, FCriticalTValue, bIsComplete); ////blocks //SetAnovaIntervals(i, totals, blocks, tCriticalValue, s, // CalculatorHelpers.ConvertStringToDouble(treatments.ColumnCount.ToString()), // FB, FCriticalBValue, bIsComplete); //interactions } } } this.DataToAnalyze.Add(Label, totals); string sTreats = "treats "; string sBlocks = "blocks "; if (bIsFactorial) { sTreats = "factor1 "; sBlocks = "factor2 "; } ////add the data to a string builder //StringBuilder sb = new StringBuilder(); //sb.AppendLine("anova results"); cols = new string[] { sTreats, itDF.ToString("F0"), SST.ToString("F4"), MST.ToString("F4"), FT.ToString("F4") }; sb.AppendLine(Shared.GetLine(cols, false)); cols = new string[] { sBlocks, bDF.ToString("F0"), SSB.ToString("F4"), MSB.ToString("F4"), FB.ToString("F4") }; sb.AppendLine(Shared.GetLine(cols, false)); if (bIsFactorial) { cols = new string[] { "interacts ", tbDF.ToString("F0"), SSFL.ToString("F4"), MSFL.ToString("F4"), FTB.ToString("F4") }; sb.AppendLine(Shared.GetLine(cols, false)); } cols = new string[] { "error ", ieDF.ToString("F0"), SSE.ToString("F4"), MSE.ToString("F4") }; sb.AppendLine(Shared.GetLine(cols, false)); cols = new string[] { "total ", (y.Count() - 1).ToString("F0"), (SSTotal).ToString("F4") }; sb.AppendLine(Shared.GetLine(cols, false)); cols = new string[] { string.Concat("F Crit ", sTreats), FCriticalTValue.ToString("F5"), "F > F Critical", FTGreaterFCritical }; sb.AppendLine(Shared.GetLine(cols, true)); cols = new string[] { string.Concat("F Crit ", sBlocks), FCriticalBValue.ToString("F5"), "F > F Critical", FBGreaterFCritical }; sb.AppendLine(Shared.GetLine(cols, true)); if (bIsFactorial) { cols = new string[] { "F Crit Interacts", FCriticalTBValue.ToString("F5"), "F > F Critical", FTBGreaterFCritical }; sb.AppendLine(Shared.GetLine(cols, true)); } } cols = new string[] { "estimate", "mean diff", string.Concat("lower ", _confidenceInt.ToString(), "%"), string.Concat("upper ", _confidenceInt.ToString(), "%") }; sb.AppendLine(Shared.GetLine(cols, true)); //same report for calculator and analyzer for (int i = 0; i < _totalsNeeded; i++) { if (totals[i].Count >= 5) { if (i == 0) { QTPredicted = totals[i].ElementAt(0); QTL = QTPredicted - totals[i].ElementAt(4); QTU = QTPredicted + totals[i].ElementAt(4); cols = new string[] { "Treat 1 Mean ", QTPredicted.ToString("F4"), QTL.ToString("F4"), QTU.ToString("F4") }; sb.AppendLine(Shared.GetLine(cols, false)); } else { QTPredicted = totals[i].ElementAt(1); QTL = QTPredicted - totals[i].ElementAt(2); QTU = QTPredicted + totals[i].ElementAt(2); cols = new string[] { string.Concat("xminus1 ", i.ToString(), " "), QTPredicted.ToString("F4"), QTL.ToString("F4"), QTU.ToString("F4") }; sb.AppendLine(Shared.GetLine(cols, false)); QTPredicted = totals[i].ElementAt(3); QTL = QTPredicted - totals[i].ElementAt(4); QTU = QTPredicted + totals[i].ElementAt(4); cols = new string[] { string.Concat("base ", i.ToString(), " "), QTPredicted.ToString("F4"), QTL.ToString("F4"), QTU.ToString("F4") }; sb.AppendLine(Shared.GetLine(cols, false)); } } } if (this.MathResult.ToLower().StartsWith("http")) { bool bHasSaved = await CalculatorHelpers.SaveTextInURI( _params.ExtensionDocToCalcURI, sb.ToString(), this.MathResult); if (!string.IsNullOrEmpty(_params.ExtensionDocToCalcURI.ErrorMessage)) { this.MathResult += _params.ExtensionDocToCalcURI.ErrorMessage; //done with errormsg _params.ExtensionDocToCalcURI.ErrorMessage = string.Empty; } } else { this.MathResult = sb.ToString(); } bHasCalculations = true; } catch (Exception ex) { this.ErrorMessage = ex.Message; } return(bHasCalculations); }
public void SetTotalME2Stat1Property(ME2Stat1 ind, string attName, string attValue) { string sPropertyValue = string.Empty; switch (attName) { case cTME2N: ind.TME2N = CalculatorHelpers.ConvertStringToInt(attValue); break; case cTotalME2MMean: ind.TotalME2MMean = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cTotalME2MMedian: ind.TotalME2MMedian = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cTotalME2MVariance: ind.TotalME2MVariance = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cTotalME2MStandDev: ind.TotalME2MStandDev = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cTotalME2LMean: ind.TotalME2LMean = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cTotalME2LMedian: ind.TotalME2LMedian = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cTotalME2LVariance: ind.TotalME2LVariance = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cTotalME2LStandDev: ind.TotalME2LStandDev = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cTotalME2UMean: ind.TotalME2UMean = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cTotalME2UMedian: ind.TotalME2UMedian = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cTotalME2UVariance: ind.TotalME2UVariance = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cTotalME2UStandDev: ind.TotalME2UStandDev = CalculatorHelpers.ConvertStringToDouble(attValue); break; default: break; } }
public virtual void SetMachinery1InputProperty(string attName, string attValue) { switch (attName) { case cMarketValue: this.MarketValue = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cListPriceAdj: this.ListPriceAdj = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cSalvageValue: this.SalvageValue = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cFuelAmount: this.FuelAmount = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cFuelUnit: this.FuelUnit = attValue; break; case cFuelPrice: this.FuelPrice = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cFuelCost: this.FuelCost = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cLubeOilAmount: this.LubeOilAmount = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cLubeOilUnit: this.LubeOilUnit = attValue; break; case cLubeOilPrice: this.LubeOilPrice = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cLubeOilCost: this.LubeOilCost = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cRepairCost: this.RepairCost = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cLaborAmount: this.LaborAmount = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cLaborUnit: this.LaborUnit = attValue; break; case cLaborPrice: this.LaborPrice = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cLaborCost: this.LaborCost = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cServiceUnits: this.ServiceUnits = attValue; break; case cServiceCapacityUnits: this.ServiceCapacityUnits = attValue; break; case cCapitalRecoveryCost: this.CapitalRecoveryCost = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cTaxesHousingInsuranceCost: this.TaxesHousingInsuranceCost = CalculatorHelpers.ConvertStringToDouble(attValue); break; case cOptionForCapacity: this.OptionForCapacity = CalculatorHelpers.ConvertStringToInt(attValue); break; case cOptionForInflation: this.OptionForFuel = CalculatorHelpers.ConvertStringToInt(attValue); break; case cOptionForTime: this.OptionForTime = CalculatorHelpers.ConvertStringToInt(attValue); break; case cOptionForFuel: this.OptionForFuel = CalculatorHelpers.ConvertStringToInt(attValue); break; case cLaborAmountAdj: this.LaborAmountAdj = CalculatorHelpers.ConvertStringToDouble(attValue); break; default: break; } }