Query to return maximum of one post per author

We are introducing a “featured author” area on our site and would like to display the most recent articles by a select group of authors. However, we only want a maximum of one post per author to display. So an author could potentially have posted 5 times since another author had posted, but regardless only one of their posts should appear. Currently this is the code I’ve got:

 5,
'author' => "6800,3845,1720,7045,4949"
);

$the_query = new WP_Query( $args );

while ( $the_query->have_posts() ) : $the_query->the_post(); 

?>

// DISPLAYING STUFF


One potential solution I have considered is querying more posts and setting up an array, then checking the array each time to see if an author is already in it. If they are, it would continue to the next row. But an obvious issue with this would be that I may potentially end up having to pull back 100’s of posts if a particular “featured author” hadn’t wrote for a while.

I’m still fairly new to PHP/MySQL and a solution is probably starring me in the face. Appreciate any assistance.

Fatal error: Maximum execution time of 120 seconds exceeded

O propósito do programa é organizar uma lista de professores em uma tabela 3 X 5, primeiro o programa distribuí os professores pelo dia que ele quer (sempre começando a distribuição pelo que possui maior pontuação), depois tenta distribui-lo sem ser em um dia que ele não queira. Se ele não conseguir ele apaga o registro do dia que ele quer do professor com menor pontuação e então tenta de novo, depois vai apagando em escala crescente. Finalmente começa a apagar o dia que ele não quer seguindo o estipulado acima. Daí ele dá um bug por que fica preso no looping e estoura o tempo de 2 minutos. Quero saber onde está a incoerência. Agradeço desde já.

Programa:


"; for($j=0; $j < 15; $j++){ for($i=0; $i < 9; $i++){ echo $array_docentes[$j][$i] . "  "; } echo "
"; } echo "

"; $array_semana = array(//Array que receberá os nomes dos docentes de acordo com o dia da semana array('0', '0', '0', '0', '0'), array('0', '0', '0', '0', '0'), array('0', '0', '0', '0', '0') ); $array_registro = array(//Registra aqueles que ja foram escalados no array_semana array('0', '0', '0', '0', '0'), array('0', '0', '0', '0', '0'), array('0', '0', '0', '0', '0') ); $array_semana1 = array('Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta');//Contém o nome dos dias da semana para comparar com as preferências $array_contro = array( array('0', '0', '0', '0', '0'), array('0', '0', '0', '0', '0'), array('0', '0', '0', '0', '0') ); $array_dias = array('0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'); for($j=0; $j < 15; $j++){ $array_dias[$j] = $array_docentes[$j][6]; } for($j=0; $j < 15; $j++){ for($i=0; $i < 15; $i++){ if($array_docentes[$j][1] > $array_docentes[$i][1]){ $aux = $array_docentes[$j][0]; $array_docentes[$j][0] = $array_docentes[$i][0]; $array_docentes[$i][0] = $aux; $aux = $array_docentes[$j][1]; $array_docentes[$j][1] = $array_docentes[$i][1]; $array_docentes[$i][1] = $aux; $aux = $array_docentes[$j][2]; $array_docentes[$j][2] = $array_docentes[$i][2]; $array_docentes[$i][2] = $aux; $aux = $array_docentes[$j][3]; $array_docentes[$j][3] = $array_docentes[$i][3]; $array_docentes[$i][3] = $aux; $aux = $array_docentes[$j][4]; $array_docentes[$j][4] = $array_docentes[$i][4]; $array_docentes[$i][4] = $aux; $aux = $array_docentes[$j][5]; $array_docentes[$j][5] = $array_docentes[$i][5]; $array_docentes[$i][5] = $aux; $aux = $array_docentes[$j][6]; $array_docentes[$j][6] = $array_docentes[$i][6]; $array_docentes[$i][6] = $aux; $aux = $array_dias[$j]; $array_dias[$j] = $array_dias[$i]; $array_dias[$i] = $aux; } } } echo "Nome   Pontuação   Dia não desejado   Dia não desejado   Dia não desejado   Dia não desejado   Dia desejado   Distribuído?   Distribuído?2

"; for($j=0; $j < 15; $j++){ for($i=0; $i < 9; $i++){ echo $array_docentes[$j][$i] . "  "; } echo "
"; } echo "

"; for($t=0; $t < 15;){ for($z=0; $z < 15;){ for($j=0; $j < 3; $j++){ for($i=0; $i < 5; $i++){ if($array_docentes[$z][8] == '0'){ if($array_semana[$j][$i] == '0'){ if($array_docentes[$z][6] == $array_semana1[$i]){ $array_semana[$j][$i] = $array_docentes[$z][0]; $i = 5; $j = 3; $array_docentes[$z][7] = '1'; $array_docentes[$z][8] = '1'; } } } } } } echo "   Semana

"; echo "Segunda   Terça   Quarta   Quinta   Sexta

"; for($j=0; $j < 3; $j++){ for($i=0; $i < 5; $i++){ echo $array_semana[$j][$i] . "  "; } echo "
"; } for($z=0; $z < 15;){ for($j=$b; $j < 3; $j++){ for($i=$c; $i < 5; $i++){ $f = 0; for($g=2; $g < 6; $g++){ if($array_docentes[$z][7] == '0'){ if($array_docentes[$z][8] == '0'){ if($array_registro[$j][$i] == '0'){ if($array_docentes[$z][$g] <> $array_semana1[$i]){ $f++; } if($f == 4){ $array_semana[$j][$i] = $array_docentes[$z][0]; $array_registro[$j][$i] = '1'; $array_docentes[$z][8] = '1'; $g = 6; $i = 5; $j = 3; $f = 0; $b = 0; $c = 0; $z++; } } } } } } } $contro1 = 0; if($array_docentes[$z][8] == '1'){ $contro1 = 0; } else{ $contro1 = 15; } if($contro1 == 15){ if($z != '0'){ $z--; if($array_docentes[$z][7] == '1'){ $pont = $his; $contro1 = 0; } else{ for($j=0; $j < 3; $j++){ for($i=0; $i < 5; $i++){ if($array_semana[$j][$i] == $array_docentes[$z][0]){ $b = $j; $c = $i; } } } $array_semana[$b][$c] = '0'; $array_registro[$b][$c] = '0'; $contro1 = 0; $array_docentes[$z][8] = '0'; $b++; $c++; } } else{ $pont = $his; $contro1 = 0; } } else{ $z++; $b = 0; $c = 0; $contro1 = 0; } $pont++; if($l >= 0){ if($pont >= $his){ echo "   Semana

"; echo "Segunda   Terça   Quarta   Quinta   Sexta

"; for($j=0; $j < 3; $j++){ for($i=0; $i < 5; $i++){ echo $array_semana[$j][$i] . "  "; } echo "
"; } for($j=0; $j < 3; $j++){ for($i=0; $i < 5; $i++){ $array_registro[$j][$i] = '0'; $array_semana[$j][$i] = '0'; } } $his = $his + 2000; $b = 0; $c = 0; $array_docentes[$l][6] = '0'; $z = 15; for($i=0;$i < 15; $i++){ $array_docentes[$i][7] = '0'; $array_docentes[$i][8] = '0'; } $l = $l - 1; echo "

"; echo "Nome   Pontuação   Dia não desejado   Dia não desejado   Dia não desejado   Dia não desejado   Dia desejado   Distribuído?

"; for($j=0; $j < 15; $j++){ for($i=0; $i < 9; $i++){ echo $array_docentes[$j][$i] . "  "; } echo "
"; } echo "

"; } } else if($y >= 0){ if($pont >= $his){ $array_docentes[$y][$k] = '0'; if($k == 2){ $k = 5; $y--; } $b = 0; $c = 0; $his = $his + 2000; $k--; for($j=0; $j < 3; $j++){ for($i=0; $i < 5; $i++){ $array_semana[$j][$i] = '0'; $array_registro[$j][$i] = '0'; } } } } } for($j=0; $j < 3; $j++){ for($i=0; $i < 5; $i++){ if($array_semana[$j][$i] <> '0'){ $ro++; } } } if($ro == 15){ $t = 15; } else{ $ro = 0; } } echo "         Semana
"; echo "Segunda         Terça         Quarta         Quinta         Sexta

"; for($j=0; $j < 3; $j++){ for($i=0; $i < 5; $i++){ echo $array_semana[$j][$i] . "&nbsp &nbsp &nbsp &nbsp "; } echo "
"; } echo "

"; print_r ($array_registro); echo "

"; echo "

"; echo "Nome         Pontuação         Dia não desejado         Dia não desejado         Dia não desejado         Dia não desejado         Dia desejado         Distribuído?

"; for($j=0; $j < 15; $j++){ for($i=0; $i < 8; $i++){ echo $array_docentes[$j][$i] . "&nbsp &nbsp &nbsp &nbsp "; } echo "
"; }

?>

Cumulative Probability Distribution of Maximum and 2nd from Maximum of 4 Variables

I understand that the cumulative probability distribution cum(x) of the maximum of 2 variables x1 and x2 with probability distribution p1(x1) and p2(x2) is the product of the two cumulative probability distributions.

So if the cumulative probability distribution of p1(x1) is cum1(x1), and the cumulative probability distribution of p2(x2) is cum2(x2), the cumulative distribution of the maximum of x1 and x2 is cum_max(x) = cum1(x) * cum2(x).

In my case I have 4 independent variables, with identical probability distribution p(x) and cumulative probability distribution cum(x). I want to determine the cumulative distribution function of the maximum of all 4, cum_max. and I also want to determine the cumulative distribution function of the 2nd from maximum, cum_2nd.

By iterating the property of the product of cumulative probability distribution I obtain:
cum_max(x) = [cum(x)]^4

I am stomped about what relationship applies to the 2nd from maximum.

Proving a sharp maximum identity for some relatively prime odd integers

Let $p, q$ and $r$ be relatively prime odd positive integers satisfying $$pq + pr – qr = 1.$$

Define $$f(a,n)= -(q + r)a^2 + 4aqn – 4(q – p)n^2 – 4n$$ where $-p leq a leq p+2$ and $0 leq n leq r-1$.

Under these conditions, can we prove that

$$mathrm max { f(a,n) } =f(1,1)$$

Or one can produce a counterexample?

For example, I proved the above idendity for triplets $$(p,q,r)=(2k+1,4k+1,4k+3)$$ and $$(p,q,r)=(4k+3,6k+5,12k+7)$$ by showing $$-f(a,n) + f(1,1) geq 0$$ with the help of basic number theoretic arguments.

Any contribution (proof suggestion or a counterexample) will make me extremely happy…

Maximum of beta-distributed random variables

Let $X_i sim operatorname{Beta}(alpha_i, beta_i)$ be beta-distributed random variables for $i = 1, ldots, k$. What can we say about $$X =max(X_1, ldots, X_k)?$$ In particular, can we estimate $alpha$ and $beta$ so that $X$ is approximately distributed like $operatorname{Beta}(alpha, beta)$? We may assume that $sum_i alpha_i + sum_i beta_i$ is large if it helps.

We can reduce the question to the case $k =2$, since $$max(X_1, ldots, X_k) = max(max(max(X_1, X_2),X_3, ldots))),$$ although some accuracy might be lost in making successive approximations. Note also that we have $$P(max(X_1, X_2) leq z) = P(X_1 leq z, X_2 leq z) = P(X_1 leq z) P(X_2 leq z),$$ giving the cumulative distribution function for $X$.

Using Sage I was able to take the case $alpha_1 = 10,beta_1 = 15,alpha_2 = 13,beta_2 = 12$ and approximate the density function of $X$ pretty well with $alpha = 16.796, beta = 14.830$. See image.

enter image description here

Context:

This would be useful for the bandit problem or Monte-Carlo tree search. Suppose you are playing $k$ games $Y_i$, and $Y_i$ is either a win, with probability $p_i$, or a loss. Then the game $Y$ which consists of a choice of one of the games $Y_i$ can be modeled by a Bernoulli random variable with parameter $p = max(p_1, ldots, p_k)$, since the best strategy is to always choose the game $Y_i$ that has the highest win rate. If we only have limited information about each $Y_i$ (some samples of each, for example), we can put a prior $p_i sim operatorname{Beta}(alpha_i, beta_i)$ on each parameter $p_i$ and try to infer information about $p$ from this.

Transformer maximum voltage rating specifications

I don’t know how to interpret the voltage values found in datasheets for transformers. For example, in the datasheet below:

where it says 15v, 50mA near the winding schematic. Is this a maximum or a test condition or nominal value? Is there generally a maximum output voltage for a transformer other than the dielectric breakdown voltage which is in this case specified at 1500V? Do i have to respect something like not go above 50mA*15V watts? If i want to use this transformer at an output of 75-100V for each of the 2 secondaries will i run into problems? How can i make sure the output of a flyback converter using this transformer is not too high, using the information provided in the datasheet?

Imgur

Maximum of beta distributions

Let $X_i sim operatorname{Beta}(alpha_i, beta_i)$ be beta-distributed random variables for $i = 1, ldots, k$. What can we say about $$X =max(X_1, ldots, X_k)?$$ In particular, can we estimate $alpha$ and $beta$ so that $X$ is approximately distributed like $operatorname{Beta}(alpha, beta)$? We may assume that $sum_i alpha_i + sum_i beta_i$ is large if it helps.

We can reduce the question to the case $k =2$, since $$max(X_1, ldots, X_k) = max(max(max(X_1, X_2),X_3, ldots))),$$ although some accuracy might be lost in making successive approximations. Note also that we have $$P(max(X_1, X_2) leq z) = P(X_1 leq z, X_2 leq z) = P(X_1 leq z) P(X_2 leq z),$$ giving the cumulative distribution function for $X$.

Using Sage I was able to take the case $alpha_1 = 10,beta_1 = 15,alpha_2 = 13,beta_2 = 12$ and approximate the density function of $X$ pretty well with $alpha = 16.796, beta = 14.830$. See image.

enter image description here

Context:

This would be useful for the bandit problem or Monte-Carlo tree search. Suppose you are playing $k$ games $Y_i$, and $Y_i$ is either a win,with probability $p_i$, or a loss. Then the game $Y$ which consists of a choice of one of the games $Y_i$ can be modeled by a Bernoulli random variable with parameter $p = max(p_1, ldots, p_k)$, since the best strategy is to always choose the game $Y_i$ that has the highest win rate. If we only have limited information about each $Y_i$ (some samples of each, for example), we can put a prior $p_i sim operatorname{Beta}(alpha_i, beta_i)$ on each parameter $p_i$ and try to infer information about $p$ from this.

Represent median between the minimum and maximum values in horizontal bar through percentage

I am using a progress bar to represent a median, showing the min, and the max, at the start, and end, of the horizontal bar (from 0% to 100%).

enter image description here

For a concrete example, let’s say, we have a range from €1k min, €3k max and a median of €1.2k.

My question is how to calc the percentage for the median value. I need to style the bar with a percentage to represent it.

It seems obvious that for:

  • € 1k median the percentage would be 0%,
  • € 1.5k median the percentage would be 50%
  • € 3k median the percentage would be 100%

However I am not sure how to calculate the percentage value for some random value like € 1.2k or € 2.6k. Please let me know if is clear what I am trying to do.

Exemple: demo

Maximum optimal transaction fees and max transactions per block after bulletproofs upgrade?

After the bulletproofs upgrade. Fees are in theory going to be cheaper as the blocks get full.

What is the optimal fee if we assume the blocks do get full? How much would fees be then?

And how many more transactions can we fit per block as compared to before bulletproofs?