V
V
valis2019-07-11 06:35:27
Mathematics
valis, 2019-07-11 06:35:27

How to generate a set covering the maximum number of results?

There is the following task
We have a condition for forming a set of sets (or a table):
- The number of rows (elements of the set)
- For each column, the percentage of the Null value is set (for example (10,20,50) - the first column is 10% zeros, the second is 20 and the third is 50 )
It is necessary to generate such a set of a given length that it optimally covers all possible combinations of zeros and non-zeros

Answer the question

In order to leave comments, you need to log in

3 answer(s)
X
xmoonlight, 2019-07-21
@xmoonlight

1. Calculate the total number of combinations ("masks" of zeros/non-zeros: from "all zeros" to "all non-zeros" on a given set: the number of rows). This will be 100% of the entire range.
2. 10%, 20%, 50% - every 10th, every 5th, every 2nd, respectively.
3. Let's start with the most frequent (50%) and after 1 (every 2nd) we will make a list.
4. Take the next one (20%) and apply it to the remaining half (also evenly, considering half - for 100%) and add it to the list.
5. Take the remaining percentage (10%) and apply to the remaining 30% - this will be every 3rd element and also add to the list.
The resulting list will be what was required.

R
Rsa97, 2019-07-11
@Rsa97

And what's the problem then?

$nullPercents = [10, 20, 50];
$totalRows = 11;
$result = [];
for ($i = 1; $i <= $totalRows; $i++) {
  $row = [];
  foreach ($nullPercents as $percent) {
    if ($i <= $totalRows*$percent/100) {
      $row[] = null;
    } else {
      $row[] = $i;
    }
  }
  $result[] = $row;
}

D
Dmitry Entelis, 2017-10-05
@DmitriyEntelis

1. Make sure that there is an index in the table etsy_order_detailsby order_id.
2. In the order of delirium, make sure that the tables usershave billing_statementsan index on id.
3. If it doesn't help, post the results of the show create tableused tables and explainyour query.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question