List of usage examples for java.lang Math ceil
public static double ceil(double a)
From source file:com.baifendian.swordfish.common.utils.DateUtils.java
/** * ?// w w w . ja v a 2 s . c om * * @param d1 * @param d2 * @return */ public static long diffMin(Date d1, Date d2) { return (long) Math.ceil(diffSec(d1, d2) / 60.0); }
From source file:Util.java
public static double fix(double x) { int sign = sign(x); double y = 0; if (sign == -1) { y = Math.ceil(x); } else if (sign == 1) { y = Math.floor(x);/* www .j ava2s. c o m*/ } return y; }
From source file:bb.mcmc.analysis.ConvergeStatUtils.java
protected static boolean[] thinWindow(boolean[] array, int kthin) { if (kthin == 1) { return array; } else {/*from w w w . j a v a 2s . c om*/ final int count = (int) Math.ceil(array.length / (double) kthin); final boolean[] newArray = new boolean[count]; for (int i = 0; i < newArray.length; i++) { newArray[i] = array[kthin * i]; } return newArray; } }
From source file:de.perdian.apps.dashboard.mvc.modules.jira.JiraController.java
@RequestMapping(value = "/jira/burndown/") @ResponseBody/*from w w w.j a va 2s. c om*/ JiraControllerResponse doBurndown(@ModelAttribute JiraControllerRequest controllerRequest) { BurndownDto burndownDto = this.getJiraService().loadBurndown(controllerRequest.getRapidViewId(), controllerRequest.getBurndownBasis(), controllerRequest.getStoryPointFieldName()); // We want to have twenty lines at maximum, so let's adjust the steps // accordingly double maxSteps = 20; double incrementPerStep = burndownDto.getStoryPointsTotal() / maxSteps; int increment = (int) Math.max(1, Math.ceil(incrementPerStep)); TickUnits rangeTickUnits = new TickUnits(); for (int i = 0; i < burndownDto.getStoryPointsTotal(); i += increment) { rangeTickUnits.add(new NumberTickUnit(i + 1)); } TickUnits domainTickUnits = new TickUnits(); domainTickUnits.add(new NumberTickUnit(burndownDto.getDays().size() + 1)); ChartCreator chartCreator = new ChartCreator(controllerRequest); chartCreator.setTitle(controllerRequest.getTitle()); chartCreator.setDomainTickUnits(domainTickUnits); chartCreator.setRangeTickUnits(rangeTickUnits); chartCreator .addStrokeDefinition(new ChartStrokeDefinition(new BasicStroke(7f), chartCreator.getColor(), null)); chartCreator.addStrokeDefinition(new ChartStrokeDefinition(null, null, false)); chartCreator.addStrokeDefinition(new ChartStrokeDefinition(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, new float[] { 2.0f, 6.0f }, 0.0f), chartCreator.getColor(), null)); chartCreator.setRangeAxisLabel( "worklog".equalsIgnoreCase(controllerRequest.getBurndownBasis()) ? "Worklog (Hours)" : "Storypoints"); JiraControllerResponse controllerResponse = new JiraControllerResponse(); controllerResponse.setBurndown(burndownDto); controllerResponse.setImageContent(chartCreator.createChartAsImageContent(burndownDto.toDataset())); return controllerResponse; }
From source file:edu.txstate.dmlab.clusteringwiki.cluster.KMeansClusterer.java
/** * Set number of clusters based on document collection to be clustered * Very simple approach - try to get an average of 10 results per cluster *//*from www . ja v a 2 s. c o m*/ public void setNumClusters() { if (documentsToCluster != null) { int n = documentsToCluster.length; numClusters = (int) Math.ceil(Math.sqrt(n)); } }
From source file:edu.asu.ca.kaushik.algorithms.twostage.TwoStageColoring.java
@Override protected int partialArraySize(int t, int k, int v) { double vpowt = Math.pow(v, t); double n1 = Math.ceil( Math.log(CombinatoricsUtils.binomialCoefficientDouble(k, t) * vpowt * Math.log(vpowt / (vpowt - 1))) / Math.log(vpowt / (vpowt - 1))); double denom = Math.log(1 - (1 / vpowt)); double n = (Math.log(this.times) + n1 * denom) / denom; return (int) Math.ceil(n); }
From source file:com.github.obiteaaron.common.data.FixPageImpl.java
@Override public int getTotalPages() { return getSize() == 0 ? 1 : (int) Math.ceil((double) total / (double) getSize()); }
From source file:com.linkedin.drelephant.math.Statistics.java
/** * The percentile method returns the least value from the given list which has at least given percentile. * @param values The list of values to find the percentile from * @param percentile The percentile/*from w w w. j ava 2 s.c o m*/ * @return The least value from the list with at least the given percentile */ public static long percentile(List<Long> values, int percentile) { if (values.size() == 0) { throw new IllegalArgumentException("Percentile of empty list is not defined."); } if (percentile > 100 || percentile < 0) { throw new IllegalArgumentException("Percentile has to be between 0-100"); } if (percentile == 0) { return 0; } Collections.sort(values); // Use Nearest Rank method. // https://en.wikipedia.org/wiki/Percentile#The_Nearest_Rank_method int position = (int) Math.ceil(values.size() * percentile / 100.0); // should never happen. if (position == 0) { return values.get(position); } // position is always one greater than index. Return value at the proper index return values.get(position - 1); }
From source file:gr.eap.LSHDB.HammingKey.java
public int getLc() { double p = 1 - (t * 1.0) / (this.size * 1.0); p = Math.pow(p, k);/*www .j a v a 2 s.c o m*/ double exp = (L * p); double std = Math.sqrt(exp * (1 - p)); int C = (int) Math.round(exp - std); double x = (Math.sqrt(Math.log(delta) * Math.log(delta) - 2 * C * Math.log(delta)) - Math.log(delta) + C) / p; int Lc = (int) Math.ceil(x); double b = Lc * p; if (C > b) System.out.println("does not apply C > np."); BinomialDistribution bd1 = new BinomialDistribution(L, p); for (int l = L; l < L * 2; l++) { bd1 = new BinomialDistribution(l, p); double result = bd1.cumulativeProbability(C - 1); if (result < delta) { Lc = l; break; } } System.out.println("Lc reduced to=" + Lc); return Lc; }
From source file:edu.asu.ca.kaushik.algorithms.twostage.TwoStageOnlineGreedy.java
@Override protected int partialArraySize(int t, int k, int v) { //Side effect; bad style this.second = new ListCA(t, k, v); this.t = t;// w ww .j a v a 2 s.co m this.k = k; this.v = v; // function proper double vpowt = Math.pow(v, t); double n1 = Math.ceil( Math.log(CombinatoricsUtils.binomialCoefficientDouble(k, t) * vpowt * Math.log(vpowt / (vpowt - 1))) / Math.log(vpowt / (vpowt - 1))); double denom = Math.log(1 - (1 / vpowt)); double n = (Math.log(this.times) + n1 * denom) / denom; return (int) Math.ceil(n); }