I have a set of objects in a Vector from which I'd like to select a random subset (e.g. 100 items coming back; pick 5 randomly). In my first (very hasty) pass I did an extremely simple and perhaps overly clever solution:
Vector itemsVector = getItems();
Collections.shuffle(itemsVector);
itemsVector.setSize(5);
While this has the adva...
Hi all,
I'm using oracle(10).
I've got two tables as follows:
Table1 (uniq rows):
ID AMOUNT DATE
Table2:
ID AMOUNT1 AMOUNT2 ...AMOUNTN DATE
Table2 is connected many to one to Table1 connected via ID.
What I need is update-ing Table1.DATE with: the last (earliest) date from Table2 where Table1.AMOUNT - SUM(Table2.AMOUNT1...
I have a single NSDictionary object which contains a large number of custom objects. The objects will either be of class B or of class C, both of which inherit from class A. If the objects are of type B, they will have an internal flag (kindOfCIsh) which will be used for future grouping.
How can I, at different times in my program, get ...
Hi,
I'm looking for an algorithm which can take two sets of integers (both positive and negative) and find subsets within each that have the same sum.
The problem is similar to the subset sum problem:
http://en.wikipedia.org/wiki/Subset-sum_problem
except that I'm looking for subsets on both sides.
Here's an example:
List A {4, 5, 9,...
I am a graduate student of physics and I am working on writing some code to sort several hundred gigabytes of data and return slices of that data when I ask for it. Here is the trick, I know of no good method for sorting and searching data of this kind.
My data essentially consists of a large number of sets of numbers. These sets can co...
Hi all,
1st of all: I'm not a programmer, never learnt programming/algorithms.
Actually I have to program, mostly in awk, or ruby, some bash.
In today's task, I have a huge data set (float numbers) in a plain text file, one record/line, and a sum of all numbers of the set, but the sum is wrong, because some of the numbers (can be only...
The problem is the following:
You are given a set of positive integers { a1 , a2 , a3 , ... , an } in which there are no same numbers ( a1 exists only once ,a2 exists only once,...) eg A = {12 , 5 ,7 ,91 }.
Question: Are there two disjoint subsets of A , A1 = { b1,b2,...,bm } and A2 = { c1,c2,...,ck} so that b1+b2+...+bm = c1+c2+.....
I'm looking for a pattern for this general case:
"I need to get a subset of data based on directly related criteria and indirectly related data."
...
How can I easily check to see if one ArrayList object is contained as a subset of another?
...
Is there a good way to enumerate through only a subset of a Collection in C#? That is, I have a collection of a large number of objects (say, 1000), but I'd like to enumerate through only elements 250 - 340. Is there a good way to get an Enumerator for a subset of the collection, without using another Collection?
Edit: should have men...
Hi,
I have the following table
Id Value
1 3
1 12
1 67
2 7
2 99
5 30
5 33
5 4
5 87
5 12
5 1
I'd like to update it to have this table.
Id UniqueIdBySubSet Value
1 1 3
1 2 12
1 3 67
2 1 7
2 ...
Suppose I am given a sorted list of elements and I want to generate all subsets satisfying some condition, so that if a given set does not satisfy the condition, then a larger subset will also not satisfy it, and all sets of one element do satisfy it.
For example, given a list of all positive integers smaller than 100, determine subsets...
I have a mathematical set in a Perl array: (1, 2, 3). I'd like to find all the subsets of that set: (1), (2), (3), (1,2), (1,3), (2,3).
With 3 elements this isn't too difficult but if set has 10 elements this gets tricky.
Thoughts?
...
I am trying to think of an elegant way of getting a random subset from a set in F#
Any thoughts on this?
Perhaps this would work: say we have a set of 2x elements and we need to pick a subset of y elements. Then if we could generate an x sized bit random number that contains exactly y 2n powers we effectively have a random mask with y...
Hi, I need to populate a DataGridView conditionally. The data comes from one XML file, e.g.
<?xml version="1.0" standalone="yes"?>
<people>
<person>
<name>Bob</name>
<dogs>
<dog><name>Rover</name></dog>
<dog><name>Rex</name></dog>
</dogs>
</person>
<person>
<name>Jim</name>
<dogs>
<dog><name>D...
Hi. First time user.
The reason I place this post is that I am looking to reconcile customer accounts receivable accounts where "payments" are posted to accounts instead of matched with the open invoices and cleared. So here is my issue:
Have a single number (payment) that should equal a subset of a given set of numbers (invoice am...
Background: I've inherited some MATLAB code to analyze data for my Ph.D. research. To help me better understand the code, I've pared the code down to the minimum subset of files required to run the code for a sample test case.
Question: I would like to commit this code to a version control system as two branches, a master branch contai...
I would like to incorporate variable names that imply what I should do with them. I imagine a dataframe "survey".
library(Rlab) # Needed for rbern() function.
survey <- data.frame(cbind(
id = seq(1:10),
likert_this = sample(seq(1:7),10, replace=T),
likert_that = sample(seq(1:7), 10, replace=T),
dim_bern_varx = rbern(10, 0.6),
...
Are the following queries effective in MySQL:
SELECT * FROM table WHERE field & number = number;
# to find values with superset of number's bits
SELECT * FROM table WHERE field | number = number;
# to find values with subset of number's bits
...if an index for the field has been created?
If not, is there a way to make it run faste...
I have a large dataset (202k points). I know that there are 8 values over 0.5. I want to subset on those rows.
How do I find/return a list the row numbers where the values are > 0.5?
probably pretty basic, sorry.
thx.
...