public ActionResult InputIntervalCalculation() { try { HttpFileCollectionBase files = Request.Files; HttpPostedFileBase file = files[0]; string filename = file.FileName; string savePath = Server.MapPath("/UploadExcel/") + filename; file.SaveAs(savePath); int s = filename.LastIndexOf("."); var list_excels = ExcelHelper.ExcelToDataTable(savePath); var eLower = list_excels.Select(x => x.Lower).ToArray(); var eProbability = list_excels.Select(x => x.Probability).ToArray(); var eStimulus = list_excels.Select(x => x.Stimulus).ToArray(); var eUpper = list_excels.Select(x => x.Upper).ToArray(); var econfidence = list_excels.Select(x => x.Confidence).ToArray(); LangleyPublic.aArray.Clear(); LangleyPublic.bArray.Clear(); LangleyPublic.cArray.Clear(); SideReturnData srd = new SideReturnData(); srd.responseProbability = eProbability; srd.Y_Ceilings = eUpper; srd.Y_LowerLimits = eLower; srd.responsePoints = eStimulus; double ceiling = srd.responsePoints.Min(); double lower = srd.responsePoints.Max(); for (int i = 0; i < srd.responseProbability.Length; i++) { LangleyPublic.aArray.Add("[" + srd.responsePoints[i] + "," + srd.responseProbability[i] + "]"); if (double.IsInfinity(srd.Y_Ceilings[i])) { LangleyPublic.bArray.Add("[" + lower + "," + srd.responseProbability[i] + "]"); } else { LangleyPublic.bArray.Add("[" + srd.Y_Ceilings[i] + "," + srd.responseProbability[i] + "]"); } if (double.IsInfinity(srd.Y_LowerLimits[i])) { LangleyPublic.cArray.Add("[" + ceiling + "," + srd.responseProbability[i] + "]"); } else { LangleyPublic.cArray.Add("[" + srd.Y_LowerLimits[i] + "," + srd.responseProbability[i] + "]"); } } LangleyPublic.incredibleIntervalType = filename.Substring(0, s); LangleyPublic.incredibleLevelName = econfidence[0].ToString(); } catch (Exception ex) { return(Json(false)); } return(Json(true)); }
public SideReturnData BatchIntervalCalculate(double Y_Ceiling, double Y_LowerLimit, int Y_PartitionNumber, double ConfidenceLevel, double favg, double fsigma, double[] xArray, int[] vArray, int intervalChoose) { SideReturnData sideReturnData = new SideReturnData(); double Y_ScaleLength = (DistributionSelection.QnormAndQlogisDistribution(Y_Ceiling) - DistributionSelection.QnormAndQlogisDistribution(Y_LowerLimit)) / Y_PartitionNumber; sideReturnData.responseProbability = new double[Y_PartitionNumber + 1]; for (int i = 0; i <= Y_PartitionNumber; i++) { if (i == 0) { sideReturnData.responseProbability[i] = Y_LowerLimit; } else { sideReturnData.responseProbability[i] = DistributionSelection.PointIntervalDistribution(DistributionSelection.QnormAndQlogisDistribution(Y_LowerLimit) + i * Y_ScaleLength, 0, 1); } } sideReturnData.Y_Ceilings = new double[sideReturnData.responseProbability.Length]; sideReturnData.Y_LowerLimits = new double[sideReturnData.responseProbability.Length]; sideReturnData.responsePoints = new double[sideReturnData.responseProbability.Length]; for (int i = 0; i < sideReturnData.responseProbability.Length; i++) { IntervalEstimation ie = new IntervalEstimation(); if (intervalChoose == 0) { ie = SingleSideEstimation(xArray, vArray, sideReturnData.responseProbability[i], ConfidenceLevel); } else { ie = DoubleSideEstimation(xArray, vArray, sideReturnData.responseProbability[i], ConfidenceLevel); } sideReturnData.Y_LowerLimits[i] = ie.Confidence.Down; sideReturnData.Y_Ceilings[i] = ie.Confidence.Up; double fq = sideReturnData.responseProbability[i]; sideReturnData.responsePoints[i] = StandardSelection.ProcessValue(StandardSelection.InverseProcessValue(favg) + (DistributionSelection.QnormAndQlogisDistribution(fq) * fsigma)); } return(sideReturnData); }
private SideReturnData GetSideReturnDataValue(double Y_Ceiling, double Y_LowerLimit, int Y_PartitionNumber) { SideReturnData sideReturnData = new SideReturnData(); double Y_ScaleLength = (LiftingDistributionSelection.QValue(Y_Ceiling) - LiftingDistributionSelection.QValue(Y_LowerLimit)) / Y_PartitionNumber; sideReturnData.responseProbability = new double[Y_PartitionNumber + 1]; for (int i = 0; i <= Y_PartitionNumber; i++) { if (i == 0) { sideReturnData.responseProbability[i] = Y_LowerLimit; } else { sideReturnData.responseProbability[i] = LiftingDistributionSelection.PValue(LiftingDistributionSelection.QValue(Y_LowerLimit) + i * Y_ScaleLength, 0, 1); } } sideReturnData.Y_Ceilings = new double[sideReturnData.responseProbability.Length]; sideReturnData.Y_LowerLimits = new double[sideReturnData.responseProbability.Length]; sideReturnData.responsePoints = new double[sideReturnData.responseProbability.Length]; return(sideReturnData); }