All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.jessemull.microflex.doubleflex.stat.EqualBinsDouble Maven / Gradle / Ivy

There is a newer version: 1.0.4
Show newest version
/**
 * Licensed to the Apache Software Foundation (ASF) under one
 * or more contributor license agreements.  See the NOTICE file
 * distributed with this work for additional information
 * regarding copyright ownership.  The ASF licenses this file
 * to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance
 * with the License.  You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing,
 * software distributed under the License is distributed on an
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the
 * specific language governing permissions and limitations
 * under the License.
 */

/* -------------------------------- Package -------------------------------- */

package com.github.jessemull.microflex.doubleflex.stat;

/* ----------------------------- Dependencies ------------------------------ */

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * This splits up double plate stacks, plates, wells and well sets into sublists
 * into bins spaced evenly between the maximum and minimum values.
 * 
 * 
* * Statistical operations can be performed on stacks, plates, sets and wells using * standard or aggregated functions. Standard functions calculate the desired * statistic for each well in the stack, plate or set. Aggregated functions aggregate * the values from all the wells in the stack, plate or set and perform the statistical * operation on the aggregated values. Both standard and aggregated functions can * be performed on a subset of data within the stack, plate, set or well. * *

* * The methods within the MicroFlex library are meant to be flexible and the * descriptive statistic object supports operations using a single stack, plate, * set or well as well as collections and arrays of stacks, plates, sets or wells. * * * * * * * * * * * * * * * * * * *
Operation
Beginning
Index
Length of
Subset
Input/Output
* * * * *
Standard
*
* * * * *
+/-
*
* * * * *
+/-
*
* * * * * * * *
Accepts a single well, set, plate or stack as input
Calculates the statistic for each well in a well, set, plate or stack
*
* * * * *
Aggregated
*
* * * * *
+/-
*
* * * * *
+/-
*
* * * * * * * *
Accepts a single well/set/plate/stack or a collection/array of wells/sets/plates/stacks as input
Aggregates the data from all the wells in a well/set/plate/stack and calculates the statistic using the aggregated data
*
* * @author Jesse L. Mull * @update Updated Oct 18, 2016 * @address http://www.jessemull.com * @email [email protected] */ public class EqualBinsDouble extends QuantileStatisticListDouble { /* ---------------- Methods for splitting lists into bins --------------- */ /** * Splits the list into equal bins. * @param List the list * @param int the number of bins * @return the result */ public List> calculate(List list, int p) { if(p < 1) { return null; } Collections.sort(list); double binLength = (list.get(list.size() - 1) - list.get(0)) / p; List> bins = new ArrayList>(); for(int i = 0; i < p; i++) { bins.add(new ArrayList()); } bins.get(p - 1).add(list.get(list.size() - 1)); for(int i = 0; i < list.size() - 1; i++) { int index = (int) Math.floor(list.get(i) / binLength); if(index > bins.size() - 1) { bins.get(p - 1).add(list.get(i)); } else { bins.get(index).add(list.get(i)); } } for(List next : bins) { Collections.sort(next); } return bins; }; /** * Splits the values between the beginning and ending indices into equal bins. * @param List the list * @param int beginning index of subset * @param int length of subset * @param int the number of bins * @return the result */ public List> calculate(List list, int begin, int length, int p) { return this.calculate(list.subList(begin, begin + length), p); }; }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy