private int step2FindE(IMemFunc memFunc, double yQuote) { int yeCount = 1; foreach (double step in memFunc.getElements(n)) { double currentNumber = memFunc.getElements(n)[yeCount]; if (yQuote < step && yQuote < currentNumber) { break; } yeCount++; } return(yeCount); }
private double step1ToAvr(IMemFunc memFunc) { double num = 0.0; double den = 0.0; foreach (double step in memFunc.getElements(n)) { double avrBetvenLandU = (memFunc.lowerMemFunction(step) + memFunc.upperMemFunction(step)) / 2; num = num + step * avrBetvenLandU; den += avrBetvenLandU; } return(num / den); }
private double step3ForClOrCr(IMemFunc memFunc, int e, bool ifCr = false) { double num = 0.0; double den = 0.0; int z = 1; foreach (double step in memFunc.getElements(n)) { double avrBetvenLandU = (memFunc.lowerMemFunction(step) + memFunc.upperMemFunction(step)) / 2; double deltaBetvenLandU = (memFunc.lowerMemFunction(step) - memFunc.upperMemFunction(step)) / 2; if (ifCr) { int local = e; e = z; z = local; } double numberDipendOnClOrCr = 0; if (z <= e) { numberDipendOnClOrCr = avrBetvenLandU + deltaBetvenLandU; } else { numberDipendOnClOrCr = avrBetvenLandU - deltaBetvenLandU; } num += step * avrBetvenLandU; den += avrBetvenLandU; z++; } return(num / den); }