public void executeNeymanMethod(int i, Random random) { double value = 0.0; if (dataInput.intervalBegin < 0 && dataInput.intervalEnd <= 0) { value = dataInput.intervalEnd + random.NextDouble() * dataInput.intervalBegin - dataInput.intervalEnd; } else if (dataInput.intervalBegin >= 0 && dataInput.intervalEnd > 0) { value = dataInput.intervalBegin + random.NextDouble() * dataInput.intervalEnd - dataInput.intervalBegin; } else { if (i % 2 == 0) { value = dataInput.intervalEnd + random.NextDouble() * dataInput.intervalBegin - dataInput.intervalEnd; } else { value = dataInput.intervalBegin + random.NextDouble() * dataInput.intervalEnd - dataInput.intervalBegin; } } double maxValue = neymanMethodObj.getMaxValue() * random.NextDouble(); double analyticValue = analyticMethodObj.getPDF(value); if (analyticValue > maxValue) { neymanMethodObj.insertNewValue(value); } }
public double getMaxValue() { AnalyticMethod analytic = new AnalyticMethod(this.gamma, this.intervalBegin, this.intervalEnd, this.x0); double max = analytic.getPDF(0); for (double i = this.intervalBegin; i < this.intervalEnd; i += 0.005) { double value = analytic.getPDF(i); if (value > max) { max = value; } } return(max); }