Tagged Questions

The tag has no wiki summary.

learn more… | top users | synonyms

0
votes
1answer
77 views

Inclusion-Exclusion Principle Implementation

I would like to know how I can write a Mathematica code for the Inclusion–exclusion principle. The formulas governing it are: $ P(\bigcup_{i=1}^n A_i)=\sum_{k=1}^n (-1)^{k-1} ...
-1
votes
1answer
42 views

Take the function f(x)=2x-x^2 and the open interval P=(0,2) why is f(P)=(0,1]? why is that 1 closed? [closed]

I would think it would be f(P)=(0,1). Why does it include the endpoint?
0
votes
0answers
40 views

Addition of all elements of two sets with each other [duplicate]

Let $S_1=\{a_1,a_2,\ldots,a_m\}$ and $S_2=\{b_1,b_2,\ldots,b_n\}$ be two sets. I want to list all $a_i+b_j$ for each $1\leq i\leq m$ and $1\leq j\leq n$ in a set. Is there a commend in mathematica for ...
4
votes
3answers
211 views

Counting number of inversions

Is there an inbuilt method to find the number of inversions in a set of numbers? I found Inversions in Combinatorica but when I ...
8
votes
4answers
301 views

Complement of multisets

Given lists $a$ and $b$, which represent multisets, how can I compute the complement $a\setminus b$? I'd like to construct a function xunion that returns the ...
0
votes
0answers
102 views

Putting set elements into venn diagram

My problem has two parts. Before that I have two Lists/Sets. It suppose to be created them by two initial strings. In the first part, I need to show sets' elements in venn diagram. I can create venn ...
2
votes
1answer
86 views

Intersection does not take list of lists

The function Intersection takes a number of lists (sets) and finds their intersection. However, the precise input is ...
10
votes
10answers
651 views

Finding neighbors from list

Say you are given the following list: list={{3, 2, 1}, {3, 4, 2}, {2, 4, 1}, {1, 4, 3}}; Two numbers $x,y$, not necessarily distinct, are neighbors if one of the ...
3
votes
5answers
401 views

How to plot a 2D region when there are 3 free parameters?

How could I obtain the region of payments, with the parameters a,b,c,d between 0 and 1 and the sum of all equals 1? After the comment/recommendation of belisarius... I edit the original question ...
4
votes
1answer
381 views

How to implement Kemeny-Young method? (rank aggregation problem)

Prehistory I am trying to make some statistical analysis of some experimental data, arises from measurements made ​​on an ordinal scale. I faced with the problem of rank aggregation: to get from ...
4
votes
2answers
117 views

How to constrain the generation of all possible orderings?

Here is code from Simon Woods' answer for getting all possible weak (equal ranks allowed) orderings for $N=3$ objects: ...
7
votes
1answer
224 views

How to get all possible orderings (equal ranks allowed) for given set of $N$ objects?

Hope there is a solution besides the tedious generation of nested loops. (Trying to avoid reinventing the wheel.) Here is an example with $N = 3$ objects. There are $13$ needed orderings (first ...
5
votes
1answer
105 views

Amount of k-sized not-duplicated subsets of subsets of pair with disitinct sorted integers

I have a list, L, of this kind ($n\in \mathbb{N}$): L=Sort[RandomSample[Subsets[Range[n],{2}],RandomInteger[{1,Binomial[n,2]}]]] S contains any k-sized subset ...
4
votes
1answer
152 views

List all possible elements of a set

I have this two sets: $A = \{\emptyset, \{\emptyset\}, \{\{\emptyset\}, \emptyset\}\}$ $B = \{\{x, \{x, y\}\} | x \in A, y \in A\}$ Now I want to list all possible elements that are in $B$. How do ...
0
votes
4answers
41 views

How to multy-Set a group of lists?

I have a group of lists, for example: lists = RandomInteger[10, {100, 2}] {{6, 7}, {7, 4}, {3, 3}, ....} Now, I want to ...
11
votes
1answer
183 views

How to find longest monotonic sequence?

I have a list, for example list = {2, 1, 3, 5, 4, 6} How to find longest ascending sequence of this list? There are two meanings of this question: Find the ...
3
votes
7answers
335 views

Concise way to generate multiset lists

I wrote the following to generate a multiset with the same number of items over a fixed range: ConstantArray[#, 3]& /@ Range[9] // Flatten ...
1
vote
3answers
142 views

How to write equal subset

I have a unique set S={1,1,3,3,3} but from this unique set I can create many combinations like {1,3,3,3,1}, {3,3,1,3,1}, ... I ...
24
votes
4answers
479 views

obtaining random element of a set given by multiple inequalities

I try to obtain random elements from a set given by multiple inequalities. This is of general interest to me, but let me present one example here: I have multiple inequalities specifying half spaces ...
3
votes
0answers
67 views

Listing all combinations produced by picking one element from each of several sets [duplicate]

I have a problem like this, I am given the following sets {a,b,c}, {d,e,f}, {h,i,j}. I want to pick one element from each set, and output a list of all the ...
9
votes
6answers
404 views

Performing Computations on Sets

I would like to find a permutation of $\quad S=\{\frac{1}{10}, \frac{1}{2}, \frac{4}{7}, \frac{3}{5}, \frac{2}{3} \}\quad$ that maximizes the sum of theses elements raised to unique powers: ...
1
vote
1answer
114 views

Set theoretic operations on sets of real numbers

I have two pieces of code that produce a bunch of real numbers, say $A$ and $B$ respectively. (It is not relevant to the question, but $A$ consists of eigenvalues of the Hamiltonian of some physical ...
1
vote
2answers
954 views

Plot 3D set (or a domain of three-variable function)

is there any way to plot a "3D set" of points subject to certain rules? For example, my task is to find maximum of some function of three variables which have to meet some conditions. Of course I ...
8
votes
3answers
311 views

Patternmatching sets

How to match set-patterns against sets? A set (in the mathematical sense) is a list of elements without repetition and order of elements does not matter. For example, we have a pattern set ...
11
votes
8answers
458 views

Any built-in function to generate successive sublists from a list?

Given lst = {a, b, c, d} I'd like to generate {{a}, {a, b}, {a, b, c}, {a, b, c, d}} but using built-in functions only, ...
4
votes
2answers
572 views

Exact cover solution

Is it possible to get a exact cover solution(s) and/or number of possible solutions in Mathematica?
1
vote
2answers
265 views

Combining lists with common elements efficiently [duplicate]

Possible Duplicate: Computing the equivalence classes of the symmetric transitive closure of a relation I am required to process sets consisting of 2-element subsets of integers by ...
7
votes
3answers
511 views

how to efficiently apply function to all pairs of a set (and collect the results)

To build a graph, I need to apply a function f[a_, b_] to all pairs of a list (3500 elements). The function itself returns a link ...
26
votes
6answers
2k views

How to select minimal subsets?

I am a newbie, so please point me in the right direction if you feel this question has been answered somewhere else before. Here goes: Suppose I have a list like this: ...
12
votes
5answers
2k views

Define a mathematical set

I have a terribly short question: Is there a way to define a pure mathematical set? I tried a bit of googling, but the word "set" has two meanings and the other one (as in setting) as by far more ...
6
votes
3answers
638 views

Subsets of a list

Consider the following demand of products for the next four months. data={1,20,3,40}; I could produce the whole demand in the first months, leading to the ...