code
stringlengths
73
34.1k
label
stringclasses
1 value
public static double pdf(double x, double mu, double sigma, double k) { if(x == Double.POSITIVE_INFINITY || x == Double.NEGATIVE_INFINITY) { return 0.; } x = (x - mu) / sigma; if(k > 0 || k < 0) { if(k * x > 1) { return 0.; } double t = FastMath.log(1 - k * x); retu...
java
public static double cdf(double val, double mu, double sigma, double k) { final double x = (val - mu) / sigma; if(k > 0 || k < 0) { if(k * x > 1) { return k > 0 ? 1 : 0; } return FastMath.exp(-FastMath.exp(FastMath.log(1 - k * x) / k)); } else { // Gumbel case: return Fas...
java
public static double quantile(double val, double mu, double sigma, double k) { if(val < 0.0 || val > 1.0) { return Double.NaN; } if(k < 0) { return mu + sigma * Math.max((1. - FastMath.pow(-FastMath.log(val), k)) / k, 1. / k); } else if(k > 0) { return mu + sigma * Math.min((1. - F...
java
public static double cdf(double x, double sigma) { if(x <= 0.) { return 0.; } final double xs = x / sigma; return 1. - FastMath.exp(-.5 * xs * xs); }
java
public static double quantile(double val, double sigma) { if(!(val >= 0.) || !(val <= 1.)) { return Double.NaN; } if(val == 0.) { return 0.; } if(val == 1.) { return Double.POSITIVE_INFINITY; } return sigma * FastMath.sqrt(-2. * FastMath.log(1. - val)); }
java
public OutlierResult run(Database db, Relation<V> relation) { ArrayDBIDs ids = DBIDUtil.ensureArray(relation.getDBIDs()); // Build a kernel matrix, to make O(n^3) slightly less bad. SimilarityQuery<V> sq = db.getSimilarityQuery(relation, kernelFunction); KernelMatrix kernelMatrix = new KernelMatrix(sq, ...
java
protected double computeABOF(KernelMatrix kernelMatrix, DBIDRef pA, DBIDArrayIter pB, DBIDArrayIter pC, MeanVariance s) { s.reset(); // Reused double simAA = kernelMatrix.getSimilarity(pA, pA); for(pB.seek(0); pB.valid(); pB.advance()) { if(DBIDUtil.equal(pB, pA)) { continue; } do...
java
public OutlierResult run(Database database, Relation<O> relation) { DBIDs ids = relation.getDBIDs(); WritableDoubleDataStore store = DataStoreUtil.makeDoubleStorage(ids, DataStoreFactory.HINT_DB); DistanceQuery<O> distq = database.getDistanceQuery(relation, getDistanceFunction()); KNNQuery<O> knnq = dat...
java
public Clustering<?> run(final Database database, final Relation<DiscreteUncertainObject> relation) { if(relation.size() <= 0) { return new Clustering<>("Uk-Means Clustering", "ukmeans-clustering"); } // Choose initial means randomly DBIDs sampleids = DBIDUtil.randomSample(relation.getDBIDs(), k, ...
java
protected boolean updateAssignment(DBIDIter iditer, List<? extends ModifiableDBIDs> clusters, WritableIntegerDataStore assignment, int newA) { final int oldA = assignment.intValue(iditer); if(oldA == newA) { return false; } clusters.get(newA).add(iditer); assignment.putInt(iditer, newA); i...
java
protected double getExpectedRepDistance(NumberVector rep, DiscreteUncertainObject uo) { SquaredEuclideanDistanceFunction euclidean = SquaredEuclideanDistanceFunction.STATIC; int counter = 0; double sum = 0.0; for(int i = 0; i < uo.getNumberSamples(); i++) { sum += euclidean.distance(rep, uo.getSam...
java
protected void logVarstat(DoubleStatistic varstat, double[] varsum) { if(varstat != null) { double s = sum(varsum); getLogger().statistics(varstat.setDouble(s)); } }
java
public void save() throws FileNotFoundException { PrintStream p = new PrintStream(file); p.println(COMMENT_PREFIX + "Saved ELKI settings. First line is title, remaining lines are parameters."); for (Pair<String, ArrayList<String>> settings : store) { p.println(settings.first); for (String str : ...
java
public void load() throws FileNotFoundException, IOException { BufferedReader is = new BufferedReader(new InputStreamReader(new FileInputStream(file))); ArrayList<String> buf = new ArrayList<>(); while (is.ready()) { String line = is.readLine(); // skip comments if (line.startsWith(COMMENT...
java
public void remove(String key) { Iterator<Pair<String, ArrayList<String>>> it = store.iterator(); while (it.hasNext()) { String thisKey = it.next().first; if (key.equals(thisKey)) { it.remove(); break; } } }
java
public ArrayList<String> get(String key) { Iterator<Pair<String, ArrayList<String>>> it = store.iterator(); while (it.hasNext()) { Pair<String, ArrayList<String>> pair = it.next(); if (key.equals(pair.first)) { return pair.second; } } return null; }
java
public Clustering<Model> run(Database database, Relation<V> relation) { // current dimensionality associated with each seed int dim_c = RelationUtil.dimensionality(relation); if(dim_c < l) { throw new IllegalStateException("Dimensionality of data < parameter l! " + "(" + dim_c + " < " + l + ")"); ...
java
private List<ORCLUSCluster> initialSeeds(Relation<V> database, int k) { DBIDs randomSample = DBIDUtil.randomSample(database.getDBIDs(), k, rnd); List<ORCLUSCluster> seeds = new ArrayList<>(k); for(DBIDIter iter = randomSample.iter(); iter.valid(); iter.advance()) { seeds.add(new ORCLUSCluster(database...
java
private void assign(Relation<V> database, List<ORCLUSCluster> clusters) { NumberVectorDistanceFunction<? super V> distFunc = SquaredEuclideanDistanceFunction.STATIC; // clear the current clusters for(ORCLUSCluster cluster : clusters) { cluster.objectIDs.clear(); } // projected centroids of th...
java
private void merge(Relation<V> relation, List<ORCLUSCluster> clusters, int k_new, int d_new, IndefiniteProgress cprogress) { ArrayList<ProjectedEnergy> projectedEnergies = new ArrayList<>((clusters.size() * (clusters.size() - 1)) >>> 1); for(int i = 0; i < clusters.size(); i++) { for(int j = i + 1; j < cl...
java
private ProjectedEnergy projectedEnergy(Relation<V> relation, ORCLUSCluster c_i, ORCLUSCluster c_j, int i, int j, int dim) { NumberVectorDistanceFunction<? super V> distFunc = SquaredEuclideanDistanceFunction.STATIC; // union of cluster c_i and c_j ORCLUSCluster c_ij = union(relation, c_i, c_j, dim); d...
java
private ORCLUSCluster union(Relation<V> relation, ORCLUSCluster c1, ORCLUSCluster c2, int dim) { ORCLUSCluster c = new ORCLUSCluster(); c.objectIDs = DBIDUtil.newHashSet(c1.objectIDs); c.objectIDs.addDBIDs(c2.objectIDs); c.objectIDs = DBIDUtil.newArray(c.objectIDs); if(c.objectIDs.size() > 0) { ...
java
private static void initializeNNCache(double[] scratch, double[] bestd, int[] besti) { final int size = bestd.length; Arrays.fill(bestd, Double.POSITIVE_INFINITY); Arrays.fill(besti, -1); for(int x = 0, p = 0; x < size; x++) { assert (p == MatrixParadigm.triangleSize(x)); double bestdx = Dou...
java
protected int findMerge(int size, MatrixParadigm mat, double[] bestd, int[] besti, PointerHierarchyRepresentationBuilder builder) { double mindist = Double.POSITIVE_INFINITY; int x = -1, y = -1; // Find minimum: for(int cx = 0; cx < size; cx++) { // Skip if object has already joined a cluster: ...
java
protected void merge(int size, MatrixParadigm mat, double[] bestd, int[] besti, PointerHierarchyRepresentationBuilder builder, double mindist, int x, int y) { // Avoid allocating memory, by reusing existing iterators: final DBIDArrayIter ix = mat.ix.seek(x), iy = mat.iy.seek(y); if(LOG.isDebuggingFine()) { ...
java
private void updateCache(int size, double[] scratch, double[] bestd, int[] besti, int x, int y, int j, double d) { // New best if(d <= bestd[j]) { bestd[j] = d; besti[j] = y; return; } // Needs slow update. if(besti[j] == x || besti[j] == y) { findBest(size, scratch, bestd, b...
java
public VisualizerContext newContext(ResultHierarchy hier, Result start) { Collection<Relation<?>> rels = ResultUtil.filterResults(hier, Relation.class); for(Relation<?> rel : rels) { if(samplesize == 0) { continue; } if(!ResultUtil.filterResults(hier, rel, SamplingResult.class).isEmpty...
java
public static String getTitle(Database db, Result result) { List<TrackedParameter> settings = new ArrayList<>(); for(SettingsResult sr : SettingsResult.getSettingsResults(result)) { settings.addAll(sr.getSettings()); } String algorithm = null; String distance = null; String dataset = null;...
java
protected static String shortenClassname(String nam, char c) { final int lastdot = nam.lastIndexOf(c); if(lastdot >= 0) { nam = nam.substring(lastdot + 1); } return nam; }
java
private static Class<?> getRestrictionClass(OptionID oid, final Parameter<?> firstopt, Map<OptionID, List<Pair<Parameter<?>, Class<?>>>> byopt) { Class<?> superclass = getRestrictionClass(firstopt); // Also look for more general restrictions: for(Pair<Parameter<?>, Class<?>> clinst : byopt.get(oid)) { ...
java
private static <T> ArrayList<T> sorted(Collection<T> cls, Comparator<? super T> c) { ArrayList<T> sorted = new ArrayList<>(cls); sorted.sort(c); return sorted; }
java
protected void handleHoverEvent(Event evt) { if(evt.getTarget() instanceof Element) { Element e = (Element) evt.getTarget(); Node next = e.getNextSibling(); if(next instanceof Element) { toggleTooltip((Element) next, evt.getType()); } else { LoggingUtil.warning("Tooltip...
java
protected void toggleTooltip(Element elem, String type) { String csscls = elem.getAttribute(SVGConstants.SVG_CLASS_ATTRIBUTE); if(SVGConstants.SVG_MOUSEOVER_EVENT_TYPE.equals(type)) { if(TOOLTIP_HIDDEN.equals(csscls)) { SVGUtil.setAtt(elem, SVGConstants.SVG_CLASS_ATTRIBUTE, TOOLTIP_VISIBLE); ...
java
@Override public DoubleDBIDList reverseKNNQuery(DBIDRef id, int k) { ModifiableDoubleDBIDList result = DBIDUtil.newDistanceDBIDList(); final Heap<MTreeSearchCandidate> pq = new UpdatableHeap<>(); // push root pq.add(new MTreeSearchCandidate(0., getRootID(), null, Double.NaN)); // search in tree ...
java
private void leafEntryIDs(MkAppTreeNode<O> node, ModifiableDBIDs result) { if(node.isLeaf()) { for(int i = 0; i < node.getNumEntries(); i++) { MkAppEntry entry = node.getEntry(i); result.add(((LeafEntry) entry).getDBID()); } } else { for(int i = 0; i < node.getNumEntries();...
java
private PolynomialApproximation approximateKnnDistances(double[] knnDistances) { StringBuilder msg = new StringBuilder(); // count the zero distances (necessary of log-log space is used) int k_0 = 0; if(settings.log) { for(int i = 0; i < settings.kmax; i++) { double dist = knnDistances[i]...
java
protected final int isLeft(double[] a, double[] b, double[] o) { final double cross = getRX(a, o) * getRY(b, o) - getRY(a, o) * getRX(b, o); if(cross == 0) { // Compare manhattan distances - same angle! final double dista = Math.abs(getRX(a, o)) + Math.abs(getRY(a, o)); final double distb = Ma...
java
private double mdist(double[] a, double[] b) { return Math.abs(a[0] - b[0]) + Math.abs(a[1] - b[1]); }
java
private boolean isConvex(double[] a, double[] b, double[] c) { // We're using factor to improve numerical contrast for small polygons. double area = (b[0] - a[0]) * factor * (c[1] - a[1]) - (c[0] - a[0]) * factor * (b[1] - a[1]); return (-1e-13 < area && area < 1e-13) ? (mdist(b, c) > mdist(a, b) + mdist(a,...
java
private void grahamScan() { if(points.size() < 3) { return; } Iterator<double[]> iter = points.iterator(); Stack<double[]> stack = new Stack<>(); // Start with the first two points on the stack final double[] first = iter.next(); stack.add(first); while(iter.hasNext()) { doub...
java
public Polygon getHull() { if(!ok) { computeConvexHull(); } return new Polygon(points, minmaxX.getMin(), minmaxX.getMax(), minmaxY.getMin(), minmaxY.getMax()); }
java
private static double coverRadius(double[][] matrix, int[] idx, int i) { final int idx_i = idx[i]; final double[] row_i = matrix[i]; double m = 0; for(int j = 0; j < row_i.length; j++) { if(i != j && idx_i == idx[j]) { final double d = row_i[j]; m = d > m ? d : m; } } ...
java
private static int[] mstPartition(double[][] matrix) { final int n = matrix.length; int[] edges = PrimsMinimumSpanningTree.processDense(matrix); // Note: Prims does *not* yield edges sorted by edge length! double meanlength = thresholdLength(matrix, edges); int[] idx = new int[n], best = new int[n],...
java
private static double thresholdLength(double[][] matrix, int[] edges) { double[] lengths = new double[edges.length >> 1]; for(int i = 0, e = edges.length - 1; i < e; i += 2) { lengths[i >> 1] = matrix[edges[i]][edges[i + 1]]; } Arrays.sort(lengths); final int pos = (lengths.length >> 1); // 50...
java
private static double edgelength(double[][] matrix, int[] edges, int i) { i <<= 1; return matrix[edges[i]][edges[i + 1]]; }
java
private static void omitEdge(int[] edges, int[] idx, int[] sizes, int omit) { for(int i = 0; i < idx.length; i++) { idx[i] = i; } Arrays.fill(sizes, 1); for(int i = 0, j = 0, e = edges.length - 1; j < e; i++, j += 2) { if(i == omit) { continue; } int ea = edges[j + 1], eb...
java
private static int follow(int i, int[] partitions) { int next = partitions[i], tmp; while(i != next) { tmp = next; next = partitions[i] = partitions[next]; i = tmp; } return i; }
java
private static void computeCentroid(double[] centroid, Relation<? extends NumberVector> relation, DBIDs ids) { Arrays.fill(centroid, 0); int dim = centroid.length; for(DBIDIter it = ids.iter(); it.valid(); it.advance()) { NumberVector v = relation.get(it); for(int i = 0; i < dim; i++) { ...
java
public static <O> DistanceQuery<O> getDistanceQuery(Database database, DistanceFunction<? super O> distanceFunction, Object... hints) { final Relation<O> objectQuery = database.getRelation(distanceFunction.getInputTypeRestriction(), hints); return database.getDistanceQuery(objectQuery, distanceFunction, hints);...
java
public static <O> SimilarityQuery<O> getSimilarityQuery(Database database, SimilarityFunction<? super O> similarityFunction, Object... hints) { final Relation<O> objectQuery = database.getRelation(similarityFunction.getInputTypeRestriction(), hints); return database.getSimilarityQuery(objectQuery, similarityFun...
java
public static <O> RKNNQuery<O> getRKNNQuery(Relation<O> relation, DistanceFunction<? super O> distanceFunction, Object... hints) { final DistanceQuery<O> distanceQuery = relation.getDistanceQuery(distanceFunction, hints); return relation.getRKNNQuery(distanceQuery, hints); }
java
public static <O> RangeQuery<O> getLinearScanSimilarityRangeQuery(SimilarityQuery<O> simQuery) { // Slight optimizations of linear scans if(simQuery instanceof PrimitiveSimilarityQuery) { final PrimitiveSimilarityQuery<O> pdq = (PrimitiveSimilarityQuery<O>) simQuery; return new LinearScanPrimitiveSi...
java
protected static void register(Class<?> parent, String cname) { Entry e = data.get(parent); if(e == null) { data.put(parent, e = new Entry()); } e.addName(cname); }
java
protected static void register(Class<?> parent, Class<?> clazz) { Entry e = data.get(parent); if(e == null) { data.put(parent, e = new Entry()); } final String cname = clazz.getCanonicalName(); e.addHit(cname, clazz); if(clazz.isAnnotationPresent(Alias.class)) { Alias aliases = clazz...
java
protected static void registerAlias(Class<?> parent, String alias, String cname) { Entry e = data.get(parent); assert (e != null); e.addAlias(alias, cname); }
java
private static Class<?> tryLoadClass(String value) { try { return CLASSLOADER.loadClass(value); } catch(ClassNotFoundException e) { return null; } }
java
public static List<Class<?>> findAllImplementations(Class<?> restrictionClass) { if(restrictionClass == null) { return Collections.emptyList(); } if(!contains(restrictionClass)) { ELKIServiceLoader.load(restrictionClass); ELKIServiceScanner.load(restrictionClass); } Entry e = data....
java
public static List<Class<?>> findAllImplementations(Class<?> c, boolean everything, boolean parameterizable) { if(c == null) { return Collections.emptyList(); } // Default is served from the registry if(!everything && parameterizable) { return findAllImplementations(c); } // This cod...
java
private static <C> Class<?> tryAlternateNames(Class<? super C> restrictionClass, String value, Entry e) { StringBuilder buf = new StringBuilder(value.length() + 100); // Try with FACTORY_POSTFIX first: Class<?> clazz = tryLoadClass(buf.append(value).append(FACTORY_POSTFIX).toString()); if(clazz != null)...
java
protected Element setupCanvas() { final double margin = context.getStyleLibrary().getSize(StyleLibrary.MARGIN); this.layer = setupCanvas(svgp, this.proj, margin, getWidth(), getHeight()); return layer; }
java
protected SimpleTypeInformation<?> convertedType(SimpleTypeInformation<?> in, NumberVector.Factory<V> factory) { return new VectorFieldTypeInformation<>(factory, tdim); }
java
protected <O> Map<O, IntList> partition(List<? extends O> classcolumn) { Map<O, IntList> classes = new HashMap<>(); Iterator<? extends O> iter = classcolumn.iterator(); for(int i = 0; iter.hasNext(); i++) { O lbl = iter.next(); IntList ids = classes.get(lbl); if(ids == null) { ids ...
java
public Curve makeCurve() { Curve c = new Curve(curves.size()); curves.add(c); return c; }
java
public void publish(String message, Level level) { try { publish(new LogRecord(level, message)); } catch(BadLocationException e) { throw new RuntimeException("Error writing a log-like message.", e); } }
java
protected synchronized void publish(LogRecord record) throws BadLocationException { // choose an appropriate formatter final Formatter fmt; final Style style; // always format progress messages using the progress formatter. if(record.getLevel().intValue() >= Level.WARNING.intValue()) { // form...
java
protected void optimizeSNE(AffinityMatrix pij, double[][] sol) { final int size = pij.size(); if(size * 3L * dim > 0x7FFF_FFFAL) { throw new AbortException("Memory exceeds Java array size limit."); } // Meta information on each point; joined for memory locality. // Gradient, Momentum, and lear...
java
protected double computeQij(double[][] qij, double[][] solution) { double qij_sum = 0; for(int i = 1; i < qij.length; i++) { final double[] qij_i = qij[i], vi = solution[i]; for(int j = 0; j < i; j++) { qij_sum += qij_i[j] = qij[j][i] = MathUtil.exp(-sqDist(vi, solution[j])); } } ...
java
protected void computeGradient(AffinityMatrix pij, double[][] qij, double qij_isum, double[][] sol, double[] meta) { final int dim3 = dim * 3; int size = pij.size(); for(int i = 0, off = 0; i < size; i++, off += dim3) { final double[] sol_i = sol[i], qij_i = qij[i]; Arrays.fill(meta, off, off + ...
java
public OutlierResult run(Database database, Relation<O> relation) { DistanceFunction<? super O> df = clusterer.getDistanceFunction(); DistanceQuery<O> dq = database.getDistanceQuery(relation, df); // TODO: improve ELKI api to ensure we're using the same DBIDs! Clustering<?> c = clusterer.run(database, ...
java
@Override public FittingFunctionResult eval(double x, double[] params) { final int len = params.length; // We always need triples: (mean, stddev, scaling) assert (len % 3) == 0; double y = 0.0; double[] gradients = new double[len]; // Loosely based on the book: // Numerical Recipes in C:...
java
private void showVisualization(VisualizerContext context, SimilarityMatrixVisualizer factory, VisualizationTask task) { VisualizationPlot plot = new VisualizationPlot(); Visualization vis = factory.makeVisualization(context, task, plot, 1.0, 1.0, null); plot.getRoot().appendChild(vis.getLayer()); plot.g...
java
public void put(int[] data) { final int l = data.length; for(int i = 0; i < l; i++) { put(data[i]); } }
java
public OutlierResult run(Database database, Relation<O> rel) { final DBIDs ids = rel.getDBIDs(); LOG.verbose("Running kNN preprocessor."); KNNQuery<O> knnq = DatabaseUtil.precomputedKNNQuery(database, rel, getDistanceFunction(), kmax + 1); // Initialize store for densities WritableDataStore<double...
java
protected void estimateDensities(Relation<O> rel, KNNQuery<O> knnq, final DBIDs ids, WritableDataStore<double[]> densities) { final int dim = dimensionality(rel); final int knum = kmax + 1 - kmin; // Initialize storage: for(DBIDIter iter = ids.iter(); iter.valid(); iter.advance()) { densities.put(...
java
private int dimensionality(Relation<O> rel) { // Explicit: if(idim >= 0) { return idim; } // Cast to vector field relation. @SuppressWarnings("unchecked") final Relation<NumberVector> frel = (Relation<NumberVector>) rel; int dim = RelationUtil.dimensionality(frel); if(dim < 1) { ...
java
protected void computeOutlierScores(KNNQuery<O> knnq, final DBIDs ids, WritableDataStore<double[]> densities, WritableDoubleDataStore kdeos, DoubleMinMax minmax) { final int knum = kmax + 1 - kmin; FiniteProgress prog = LOG.isVerbose() ? new FiniteProgress("Computing KDEOS scores", ids.size(), LOG) : null; ...
java
public Clustering<Model> run(Relation<V> rel) { fulldatabase = preprocess(rel); processedIDs = DBIDUtil.newHashSet(fulldatabase.size()); noiseDim = dimensionality(fulldatabase); FiniteProgress progress = LOG.isVerbose() ? new FiniteProgress("CASH Clustering", fulldatabase.size(), LOG) : null; Clust...
java
private Relation<ParameterizationFunction> preprocess(Relation<V> vrel) { DBIDs ids = vrel.getDBIDs(); SimpleTypeInformation<ParameterizationFunction> type = new SimpleTypeInformation<>(ParameterizationFunction.class); WritableDataStore<ParameterizationFunction> prep = DataStoreUtil.makeStorage(ids, DataSto...
java
private void initHeap(ObjectHeap<CASHInterval> heap, Relation<ParameterizationFunction> relation, int dim, DBIDs ids) { CASHIntervalSplit split = new CASHIntervalSplit(relation, minPts); // determine minimum and maximum function value of all functions double[] minMax = determineMinMaxDistance(relation, dim...
java
private MaterializedRelation<ParameterizationFunction> buildDB(int dim, double[][] basis, DBIDs ids, Relation<ParameterizationFunction> relation) { ProxyDatabase proxy = new ProxyDatabase(ids); SimpleTypeInformation<ParameterizationFunction> type = new SimpleTypeInformation<>(ParameterizationFunction.class); ...
java
private ParameterizationFunction project(double[][] basis, ParameterizationFunction f) { // Matrix m = new Matrix(new // double[][]{f.getPointCoordinates()}).times(basis); double[] m = transposeTimes(basis, f.getColumnVector()); return new ParameterizationFunction(DoubleVector.wrap(m)); }
java
private double[][] determineBasis(double[] alpha) { final int dim = alpha.length; // Primary vector: double[] nn = new double[dim + 1]; for(int i = 0; i < nn.length; i++) { double alpha_i = i == alpha.length ? 0 : alpha[i]; nn[i] = ParameterizationFunction.sinusProduct(0, i, alpha) * FastMat...
java
private CASHInterval determineNextIntervalAtMaxLevel(ObjectHeap<CASHInterval> heap) { CASHInterval next = doDetermineNextIntervalAtMaxLevel(heap); // noise path was chosen while(next == null) { if(heap.isEmpty()) { return null; } next = doDetermineNextIntervalAtMaxLevel(heap); ...
java
private CASHInterval doDetermineNextIntervalAtMaxLevel(ObjectHeap<CASHInterval> heap) { CASHInterval interval = heap.poll(); int dim = interval.getDimensionality(); while(true) { // max level is reached if(interval.getLevel() >= maxLevel && interval.getMaxSplitDimension() == (dim - 1)) { ...
java
private double[] determineMinMaxDistance(Relation<ParameterizationFunction> relation, int dimensionality) { double[] min = new double[dimensionality - 1]; double[] max = new double[dimensionality - 1]; Arrays.fill(max, Math.PI); HyperBoundingBox box = new HyperBoundingBox(min, max); double d_min = ...
java
public HistogramResult run(Database database, Relation<O> relation) { final DistanceQuery<O> distanceQuery = database.getDistanceQuery(relation, getDistanceFunction()); final KNNQuery<O> knnQuery = database.getKNNQuery(distanceQuery, relation.size()); if(LOG.isVerbose()) { LOG.verbose("Preprocessing ...
java
public Clustering<M> run(Database database, Relation<V> relation) { if(relation.size() == 0) { throw new IllegalArgumentException("database empty: must contain elements"); } // initial models List<? extends EMClusterModel<M>> models = mfactory.buildInitialModels(database, relation, k, SquaredEucli...
java
public static void recomputeCovarianceMatrices(Relation<? extends NumberVector> relation, WritableDataStore<double[]> probClusterIGivenX, List<? extends EMClusterModel<?>> models, double prior) { final int k = models.size(); boolean needsTwoPass = false; for(EMClusterModel<?> m : models) { m.beginESte...
java
public static double assignProbabilitiesToInstances(Relation<? extends NumberVector> relation, List<? extends EMClusterModel<?>> models, WritableDataStore<double[]> probClusterIGivenX) { final int k = models.size(); double emSum = 0.; for(DBIDIter iditer = relation.iterDBIDs(); iditer.valid(); iditer.advan...
java
protected synchronized void updateVisualizerMenus() { Projection proj = null; if(svgCanvas.getPlot() instanceof DetailView) { PlotItem item = ((DetailView) svgCanvas.getPlot()).getPlotItem(); proj = item.proj; } menubar.removeAll(); menubar.add(filemenu); ResultHierar...
java
public OutlierResult run(Relation<V> relation) { final DBIDs ids = relation.getDBIDs(); ArrayList<ArrayDBIDs> subspaceIndex = buildOneDimIndexes(relation); Set<HiCSSubspace> subspaces = calculateSubspaces(relation, subspaceIndex, rnd.getSingleThreadedRandom()); if(LOG.isVerbose()) { LOG.verbose(...
java
private ArrayList<ArrayDBIDs> buildOneDimIndexes(Relation<? extends NumberVector> relation) { final int dim = RelationUtil.dimensionality(relation); ArrayList<ArrayDBIDs> subspaceIndex = new ArrayList<>(dim + 1); SortDBIDsBySingleDimension comp = new VectorUtil.SortDBIDsBySingleDimension(relation); for...
java
private double[] max(double[] distances1, double[] distances2) { if(distances1.length != distances2.length) { throw new RuntimeException("different lengths!"); } double[] result = new double[distances1.length]; for(int i = 0; i < distances1.length; i++) { result[i] = Math.max(distances1[i],...
java
public static int compileShader(Class<?> context, GL2 gl, int type, String name) throws ShaderCompilationException { int prog = -1; try (InputStream in = context.getResourceAsStream(name)) { int[] error = new int[1]; String shaderdata = FileUtil.slurp(in); prog = gl.glCreateShader(type); ...
java
protected int effectiveBandSize(final int dim1, final int dim2) { if(bandSize == Double.POSITIVE_INFINITY) { return (dim1 > dim2) ? dim1 : dim2; } if(bandSize >= 1.) { return (int) bandSize; } // Max * bandSize: return (int) Math.ceil((dim1 >= dim2 ? dim1 : dim2) * bandSize); }
java
@Override public final int addLeafEntry(E entry) { // entry is not a leaf entry if(!(entry instanceof LeafEntry)) { throw new UnsupportedOperationException("Entry is not a leaf entry!"); } // this is a not a leaf node if(!isLeaf()) { throw new UnsupportedOperationException("Node is not...
java
@Override public final int addDirectoryEntry(E entry) { // entry is not a directory entry if(entry instanceof LeafEntry) { throw new UnsupportedOperationException("Entry is not a directory entry!"); } // this is a not a directory node if(isLeaf()) { throw new UnsupportedOperationExcept...
java
public boolean deleteEntry(int index) { System.arraycopy(entries, index + 1, entries, index, numEntries - index - 1); entries[--numEntries] = null; return true; }
java
@SuppressWarnings("unchecked") @Deprecated public final List<E> getEntries() { List<E> result = new ArrayList<>(numEntries); for(Entry entry : entries) { if(entry != null) { result.add((E) entry); } } return result; }
java
public void removeMask(long[] mask) { int dest = BitsUtil.nextSetBit(mask, 0); if(dest < 0) { return; } int src = BitsUtil.nextSetBit(mask, dest); while(src < numEntries) { if(!BitsUtil.get(mask, src)) { entries[dest] = entries[src]; dest++; } src++; } ...
java