order statistics

Question: Suppose $X_1,..., X_n$ are i.i.d. continuous r.v. with distribution function $F(x)$, and density function $f(x)$.
$X_{(1)}<\cdots<X_{(n)}$ are the order statistics.
I've already showed that the distribution function of $X_{(k)}$ is
$G_k(x)=\sum^n_{j=k} {n \choose j}F(x)^j(1-F(x))^{n-j}$.
Now I'm asked to prove that the density function of $X_{(k)}$ is
$g_k(x)= \frac{n!}{(n-k)!(k-1)!}F(x)^{k-1}(1-F(x))^{n-k}f(x)$.
I'm supposed to do the derivative of $G_k$ w.r.t $x$ and obtain the density above.
However, I get to $g_k(x)=\sum^n_{j=k} {n \choose j}\cdot \left(jF(x)^{j-1}(1-F(x))^{n-j}f(x)-F(x)^{j}(n-j)(1-F(x))^{n-j-1}f(x) \right)=\sum^n_{j=k} {n \choose j} F(x)^{j-1}(1-F(x))^{n-j-1}f(x)(j-nF(x))$
where I remain stuck...
Any help would be appreciated.
Comment: could you show the steps you have gone through?
Comment: It would be helpful to go through your work to identify where you made mistake
Comment: @SA-255525 I've just edited the question. Thanks for the interest in this question
Answer: The distribution function is correct:
$$G_k(x)=\sum^n_{j=k} {n \choose j}F(x)^j(1-F(x))^{n-j}$$
The correct density function is (no sum)
$$g_k(x)=\frac{n!}{(n-k)!(k-1)!}F(x)^{k-1}(1-F(x))^{n-k}f(x).$$
Finding the density by directly differentiating the sum is difficult. Alternatively, the distribution function can be shown to have an integral representation in terms of the beta function
$$G_k(x) = \frac{n!}{(n-k)!(k-1)!}\int_{0}^{F(x)}t^{k-1}(1-t)^{n-k}\,dt,$$
and the density function is obtained directly by taking the derivative of the integral using Leibniz's rule.
We can derive the integral representation by induction.
Let
$$H(k,p) = \sum^n_{j=k} {n \choose j}p^j(1-p)^{n-j}$$
Then
$$H(0,p) = 1,\\H(1,p) = 1 - (1-p)^n= \frac{n!}{(n-1)!(1-1)!}\int_{0}^{p}t^{1-1}(1-t)^{n-1}\,dt$$
Assume
$$H(k-1,p) = \frac{n!}{(n-k+1)!(k-2)!}\int_{0}^{p}t^{k-2}(1-t)^{n-k+1}\,dt.$$
Integrate by parts to obtain
$$H(k-1,p) = {n \choose k-1}p^{k-1}(1-p)^{n-k+1}+\frac{n!}{(n-k)!(k-1)!}\int_{0}^{p}t^{k-1}(1-t)^{n-k}\,dt.$$
From the definition of $H$ as a sum we have,
$$H(k,p) = H(k-1,p) - {n \choose k-1}p^{k-1}(1-p)^{n-k+1}.$$
Hence,
$$H(k,p) = \frac{n!}{(n-k)!(k-1)!}\int_{0}^{p}t^{k-1}(1-t)^{n-k}\,dt.$$
Now substitute with $p = F(x)$ to obtain
$$G_k(x) =H(k,F(x))= \frac{n!}{(n-k)!(k-1)!}\int_{0}^{F(x)}t^{k-1}(1-t)^{n-k}\,dt.$$
Direct Derivation:
To get the density function directly, start with your formula
$$g_k(x)\\=\sum^n_{j=k} {n \choose j}\cdot \left(jF(x)^{j-1}(1-F(x))^{n-j}f(x)-F(x)^{j}(n-j)(1-F(x))^{n-j-1}f(x) \right)\\=f(x)\left[\sum^n_{j=k} j{n \choose j} F(x)^{j-1}(1-F(x))^{n-j}-\sum^{n-1}_{j=k} (n-j){n \choose j} F(x)^{j}(1-F(x))^{n-j-1}\right].$$
Note that
$$j{n \choose j}=n{n-1 \choose j-1},\\ (n-j){n \choose j}=n{n-1 \choose j}.$$
Then
$$g_k(x)\\=nf(x)\left[\sum^n_{j=k} {n-1 \choose j-1} F(x)^{j-1}(1-F(x))^{(n-1)-(j-1)}-\sum^{n-1}_{j=k} {n-1 \choose j} F(x)^{j}(1-F(x))^{(n-1)-j}\right].$$
The first sum is
$$\sum^n_{j=k} {n-1 \choose j-1} F(x)^{j-1}(1-F(x))^{(n-1)-(j-1)} \\={n-1 \choose k-1}F(x)^{k-1}(1-F(x))^{n-k} + \sum^n_{j=k+1} {n-1 \choose j-1} F(x)^{j-1}(1-F(x))^{(n-1)-(j-1)}$$
The second sum is
$$\sum^{n-1}_{j=k} {n-1 \choose j} F(x)^{j}(1-F(x))^{(n-1)-j)} \\=\sum^n_{j=k+1} {n-1 \choose j-1} F(x)^{j-1}(1-F(x))^{(n-1)-(j-1)}.$$
The remaining sums cancel leaving
$$g_k(x) = n{n-1 \choose k-1}F(x)^{k-1}(1-F(x))^{n-k}f(x)$$
Comment: Many thanks for your interest in this question. Your answer is really useful, even though it's not what I was asked to do... =) I upvoted your answer, but I think I cannot accept it, since I have to reach the density by derivation. I'm sorry. If solving it by derivation takes too much of your time, could you at least give me some hints on how to proceed by derivation? or send me a url?  Thanks
Comment: You're welcome - I found the derivative directly from the sum and added the derivation to the answer.
Comment: @RRL very clear explanation of combinatorics.i was stuck at this point.
Comment: @SA-255525: Thanks.  I knew the integral shortcut, but I decided to grind through the second derivation as requested.

order statistics


How do I "connect" one wireless network interface to anothet

Question: Basically I have two dd wrt routers(TP-LINK and ASUS) working in "LAN-WAN" infrastructure(so they both gateways, gateway-router infrastructure doesn't suit to me) and I want to somehow "connect" wireless network interface from one router to wireless interface of another router so that internet traffic and dhcp would go through the second router(I have traffic inspector there). Is there are any ways how I could setup this? I've tried WDS but it didn't work well since the routers have different chipsets.
Answer: If I understand correctly, you want one of them to be a gateway, but be able to create a single network. If so, set them up as a wireless bridge.
http://www.dd-wrt.com/wiki/index.php/Client_Bridged
Comment: Yes, you understood correctly(sorry for my English). I saw this manual but I can't afford to have one of them as a router, here in manual they say: "Go to setup/advanced routing and change the operating mode from "gateway" to router. Hit Apply."
Comment: I wish I could keep Firewall, Gateway mode and other settings enabled and somehow connect this virtual(yes, I forgot to mention that this wireless interface is virtual one, dd wrt allow to create virual AP's) AP's to second router.
Comment: If they are both a gateway I would recomend to make one a non gateway and the other gateway. That will allow you to disable the firewall on the wireless ethernet bridge. Which happens is what it is in this case.


If an arithmetic function has a strong logarithmic mean value, then it has an ordinary mean value.

Question: Say that an arithmetic function f has a strong logarithmic mean value
A, and write L(f) = A, if f satises an estimate of the form
\begin{align}
\sum\limits_{n=1}^{x}\frac{f(n)}{n} = Alog(x) + B + o(1)
\end{align}
It is clear to see that f has a logarithmic mean value. I am having trouble proving that f also has an actual mean value. Was hoping someone may be able to lead me in the correct direction for a proof.
Thanks.
Answer: I have found a solution to my own problem but I would like it to be critiqued by anyone willing to read it. We do the following.
\begin{equation}
\sum_{n=1}^{x}f(n)=\sum_{n=1}^{x}\frac{f(n)}{n}n =x\sum_{n=1}^{x}\frac{f(n)}{n} -\int_{1}^{x}\sum_{n=1}^{t}\frac{f(n)}{n}dt
\end{equation}
By summation by parts. From here we turn (1) into the following.
\begin{equation}
\sum_{n=1}^{x}f(n)=x(Alog(x)+B+o(1)) - \int_{1}^{x}Alog(t)+B+o(1)dt
\end{equation}
The integral above can be solved for easily and we get what is required to finish our proof.
\begin{equation}
Axlog(x)+B+o(1)-(A(x(log(x)-1))+B(x-1)+o(x))=Ax+B+o(x)
\end{equation}
Therefore,
\begin{equation}
\lim_{x->\infty}\frac{1}{x}\sum_{n=1}^{x}f(n)=\lim_{x->\infty}A+\frac{B}{x}+\frac{o(x)}{x}=A+0+0=A
\end{equation}
In conclusion, if f has a strong logarithmic mean value, it must also have a regular mean value. Moreover, the values are both A.
Comment: but you should be careful with small o since in genral you can't pull it out of the integral.


LINE-HEIGHT não está funcionando em minha tabela

Question:

* {
 font-family: arial;
}
body {
 padding: 0;
 margin: 0;
}
.escopo {
 width: 100%;
 height: 200px;
 background-color: yellow;
}
.margem_escopo {
 width: 1000px;
 height: 200px;
 margin: auto;
}
.tabela {
 border: 1px solid;
 width: 350px;
 height: 198px;
 background-color: red;
 margin: auto;
}
.style_tabela {
 margin: auto;
}
td {
 border: 1px solid;

}
tr {
 border: 1px solid;
}
td.verde:hover{

     background-color: green;
     /*display: block;*/
    }
table.style_tabela {
 border-collapse: collapse;
}
<!DOCTYPE html>

   <meta charset = "UTF-8"/>
   <title>Cabeçalho</title>
   <link rel="stylesheet" type="text/css" href="style.css">

        Gomo
        Tesla
        Riuta
        Ferna
        Romã
        Célula
        Atacado

        Gomo
        Tesão
        Riuta
        Ferna
        Romã
        Célula
        Atacado

Queria que ele ficasse assim...

Aguardo retorno de vocês!
Comment: Julio, teu código CSS não tem nenhum `line-height` sendo definido.
Comment: Exatamente. Quando eu coloco em qualquer DIV da tag TABLE ele fica estranho. Basta inserir que vc vai ver.
Comment: Eu aprendi que era para alinhar verticalmente textos. Como devo fazer com essa tabela?
Comment: Você já pensou em utilizar o display: flex;?
Comment: Posso inserir direto na CLASS DIV que comporta a tabela?
Comment: Veja a resposta que coloquei, creio que te ajude!
Comment: Você quer alinhar o que? A tabela no centro da `` verticalmente?
Sua pergunta tem apenas códigos e 1 imagem.
Answer: Para resolvermos esse tipo de problema, o método mais recomendado é o display: flex;
Tente alterar o css da sua .tabela para a seguinte forma:
.tabela {
    border: 1px solid;
    width: 350px;
    height: 198px;
    background-color: red;
    margin: auto;
    display: flex;
}

Creio que seja essa a resposta que você necessita.
Veja esse guia para lhe auxiliar melhor com o flex:
https://origamid.com/projetos/flexbox-guia-completo/
Comment: Cara você simplesmente resolveu o problema da forma mais objetiva e direta!
Comment: Que bom que te ajudou cara!
Answer: Você consegue centralizar usando translateY(-50%), mas é preciso usar também top: 50% e position: relative na tabela.

* {
 font-family: arial;
}
body {
 padding: 0;
 margin: 0;
}
.escopo {
 width: 100%;
 height: 200px;
 background-color: yellow;
}
.margem_escopo {
 width: 1000px;
 height: 200px;
 margin: auto;
}
.tabela {
 border: 1px solid;
 width: 350px;
 height: 198px;
 background-color: red;
 margin: auto;
}
.style_tabela {
 margin: auto;
}
td {
 border: 1px solid;

}
tr {
 border: 1px solid;
}
td.verde:hover{

     background-color: green;
     /*display: block;*/
    }
table.style_tabela {
 border-collapse: collapse;
  position: relative;
  top: 50%;
  transform: translateY(-50%);
}
<!DOCTYPE html>

   <meta charset = "UTF-8"/>
   <title>Cabeçalho</title>
   <link rel="stylesheet" type="text/css" href="style.css">

        Gomo
        Tesla
        Riuta
        Ferna
        Romã
        Célula
        Atacado

        Gomo
        Tesão
        Riuta
        Ferna
        Romã
        Célula
        Atacado

Ou então usando flexbox na div onde está a tabela com a propriedade justify-content: center:

* {
 font-family: arial;
}
body {
 padding: 0;
 margin: 0;
}
.escopo {
 width: 100%;
 height: 200px;
 background-color: yellow;
}
.margem_escopo {
 width: 1000px;
 height: 200px;
 margin: auto;
}
.tabela {
 border: 1px solid;
 width: 350px;
 height: 198px;
 background-color: red;
 margin: auto;
  display: flex;
  justify-content: center;
}
.style_tabela {
 margin: auto;
}
td {
 border: 1px solid;

}
tr {
 border: 1px solid;
}
td.verde:hover{

     background-color: green;
     /*display: block;*/
    }
table.style_tabela {
 border-collapse: collapse;
}
<!DOCTYPE html>

   <meta charset = "UTF-8"/>
   <title>Cabeçalho</title>
   <link rel="stylesheet" type="text/css" href="style.css">

        Gomo
        Tesla
        Riuta
        Ferna
        Romã
        Célula
        Atacado

        Gomo
        Tesão
        Riuta
        Ferna
        Romã
        Célula
        Atacado


Removing the effect of unknown independent variables

Question: I have 25 years of crop yield data (Y) and Minimum Temp, Max temp, and Rainfall as X1, X2, and X3. When I do regression analysis I get a result.
My question is that for the crop yield (Y), in addition to the X1, X2, and X3 independent variables, there are many other factors which can influence crop yield, such as good quality of soil, seed, fertilizers, etc. Since I have no data for all these variables, how can I remove the effects of these variables and look only at the effects of X1, X2, and X3 on crop yield (Y)?
Comment: If you don't have data for it you can't really remove their effect, since you don't know what effect they have.
Comment: Yes but the Value of Y is due to other IVs also including X1,X2 and X3. So how to deal that?
Answer: The errors from your model may reflect omitted variables. The omitted variables can either be stochastic or deterministic. The effect of the unknown/latent and waiting to be discovered deterministic variables (reflecting omitted deterministic  series) can be level/step shifts, local time trends, seasonal pulses, monthly effects and/or simply pulses. After adjusting for these effects by Intervention Detection / Model schemes http://docplayer.net/12080848-Outliers-level-shifts-and-variance-changes-in-time-series.html augmentation one can then study any remaining stochastic effects by examining the auto-correlation of the model residuals and the cross-correlation of model residuals with lags of the user-specified predictors to suggest appropriate model augmentation reflecting possible omitted stochastic series.
Find correlation between two time series. Theory and practice (R) is an interesting thread that might be of help to you.


Using the posterior probability from Bayes Theorem as the prior in another calculation

Question: I've got a dataset of medical diagnoses -for each encounter I have the list of conditions the patient has. I want to generate a list of diagnoses the patient DOESN'T have (or at least that aren't listed) that are most likely, given the list they DO have. I think I know how to do this for pairwise analysis, but I want to use information on all the diagnoses the patient has. I apologize in advance for my flagrant abuse of the maths.
Let's say A is the diagnosis we want to know about (they haven't been diagnosed with it, but we want to know how likely it is). Let's say B is the diagnosis they HAVE. (and please correct me if I'm wrong, but…)
p(A) = # cases of A / # of cases total
p(B) = # cases of B / # of cases total
p(B|A) = # cases of A AND B / # cases of A
p(A|B) = (p(A)* p(B|A))/p(B)
So that gives me the posterior probability of A given the diagnosis we have (B). Can I use that as the prior for another diagnosis (C)? -So they've been diagnosed with both B AND C, but I don't have data on p(A|BnC). Would it be:
p(A) = Posterior from above
p(C) = # cases of C / # of cases total
p(C|A) = # cases of C AND A / # cases of A
p(A|C) = (p(A)*p(C|A))/p(C)
I tried doing that, and either I'm doing it wrong or there is a flaw in this reasoning. The results quickly become impossible (>100%). Here's some real numbers to show the problem.
p(A) = 409/99239 = 0.41%
p(B) = 18006/99239 = 18.14%
p(B|A) = 228/409 = 55.75%
p(A|B) = (0.41%*55.75%)/18.14% = 1.27%
That much makes sense, the prevalence of B in the population that has A is much higher than in the general population, so the posterior is higher than the prior. Then using the posterior as the prior for the next step:
p(A) = 1.27%
p(C) = 1044/99239 = 1.05%
p(C|A) = 15/409 = 3.67%
p(A|C) = (1.27%*3.67%)/1.05% = 4.41%
Hopefully this is enough for someone to key in on my mistake but suffice it to say that by the time you get to p(D) = 0.15%, p(D|A) = 0.73%; and p(E) = 0.30%, p(E|A) = 2.20% the posterior for A goes up to 160%. I really hope there's a way to avoid having to do the conditional probability of (A|BnCnDnE), because I simply haven't got that data!
Answer: If I understood you correctly, you are asking whether the conditional probability P(A|B&C) can be calculated according to the following formula:
P(A|B&C) = P(A|B)P(C|A)/p(C)
In general case, this formula does not hold true. Let us derive when this equality is true. According to Bayes formula,
P(A|B&C) = p(B&C|A)P(A)/P(B&C)
We want this to be equal to
P(A|B)P(C|A)/P(C) = P(A)P(B|A)p(C|A)/(P(B)P(C))
So, your formula can only be applied under the following condition:
P(B|A)P(C|A)/(P(B)P(C)) = P(B&C|A)/P(B&C)
Here is an example where this is not true:
For a point (x,y) uniformly distributed in a unit square [0,1]x[0,1], let B = {x < 0.5}, C = {y < 0.5}, A = {x + y > 1}.
Then P(B|A) = 0.25, P(C|A) = 0.25, P(B&C|A) = 0, so the sides are not equal.
You may want to check out the https://www.coursera.org/learn/probabilistic-graphical-models/home/welcome course, where they describe how a bayesian network called Pathfinder was used for medical diagnosis.


how can I optimize jonswap spectrum in cython

Question: I am trying to improve the performance of calculating the Jonswap spectrum using cython. But it seems like much slower than the original code. How can I improve this?
cython code:
from libc.math cimport exp
from libc.stdlib cimport malloc
import numpy as np
cimport numpy as np

DTYPE_float = np.float64
ctypedef np.float64_t DTYPE_float_t

def jonswap(np.ndarray[DTYPE_float_t, ndim=1, mode ='c'] w, double Hs, double Tp, double gamma = 3.7):
    '''
    get Jonswap spectra
    :param w: np.ndarray Angular Frequency
    '''
    cdef:
        int n = w.shape[0]
        double *sigma = <double*>malloc(n * sizeof(double))
        double *a = <double*>malloc(n * sizeof(double))
        int i
    cdef double wp
    cdef np.ndarray[DTYPE_float_t, ndim=1, mode='c'] sj = np.ones(n, dtype=DTYPE_float)

    wp = 2 * np.pi / Tp
    for i in range(n):
        sigma[i] = 0.07 if w[i] < wp else 0.09
        a[i] = exp(-0.5 * pow((w[i] - wp) / (sigma[i] * w[i]), 2.0))
        sj[i] = 320 * pow(Hs, 2) * pow(w[i], -5.0) / pow(Tp, 4) * exp(-1950 * pow(w[i], -4) / pow(Tp, 4)) * pow(gamma, a[i])

    return sj

original code:
def jonswap(w: np.ndarray, Hs: float, Tp: float, gamma: float = 3.7) -> np.ndarray:
    '''
    get Jonswap spectra
    :param w: np.ndarray Angular Frequency
    '''
    omega = w
    wp = 2 * np.pi / Tp
    sigma = np.where(omega < wp, 0.07, 0.09)
    a = np.exp(-0.5 * np.power((omega - wp) / (sigma * omega), 2.0))
    sj = 320 * np.power(Hs, 2) * np.power(omega, -5.0) / np.power(Tp, 4) * \
          np.exp(-1950 * np.power(omega, -4) / np.power(Tp, 4)) * np.power(gamma, a)

    return sj

Answer: Your original code is all vectorized numpy ops, so the room for improvement is limited.  Running cython with the annotate flag (-a) points out the following possible improvements.

use the libc pow instead of the python builtin
elide boundschecking/wraparound semantics
use c division to turn off divide by 0 checking (if this is safe to do!)

New cython version
from libc.math cimport exp, pow
from libc.stdlib cimport malloc
import numpy as np
cimport numpy as np
cimport cython

DTYPE_float = np.float64
ctypedef np.float64_t DTYPE_float_t

@cython.boundscheck(False)
@cython.wraparound(False)
@cython.cdivision(True)
def cy_jonswap(np.ndarray[DTYPE_float_t, ndim=1, mode ='c'] w, double Hs, double Tp, double gamma = 3.7):
    '''
    get Jonswap spectra
    :param w: np.ndarray Angular Frequency
    '''
    cdef:
        int n = w.shape[0]
        double *sigma = <double*>malloc(n * sizeof(double))
        double *a = <double*>malloc(n * sizeof(double))
        int i
    cdef double wp
    cdef np.ndarray[DTYPE_float_t, ndim=1, mode='c'] sj = np.ones(n, dtype=DTYPE_float)

    wp = 2 * np.pi / Tp
    with nogil:
        for i in range(n):
            sigma[i] = 0.07 if w[i] < wp else 0.09
            a[i] = exp(-0.5 * pow((w[i] - wp) / (sigma[i] * w[i]), 2.0))
            sj[i] = 320 * pow(Hs, 2) * pow(w[i], -5.0) / pow(Tp, 4) * exp(-1950 * pow(w[i], -4) / pow(Tp, 4)) * pow(gamma, a[i])

    return sj

Timings
w = np.random.randn(1_000_000)

%timeit cy_jonswap(w, .5, .5)
289 ms ± 7.34 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

%timeit jonswap(w, .5, .5)
411 ms ± 26.3 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

Also, note that in your cython version you are leaking memory for sigma and a
Comment: Most of the slow pow calls are not necessary. eg Hs*Hs is much faster than pow(Hs,2). https://stackoverflow.com/a/53172561/4045774 It should also make quite some difference if you have pow(w[i], -5) instead of pow(w[i], -5.0) or even 1./(w[i]*w[i]*w[i]*w[i]*w[i])


Receiving emails on postfix returns relay access denied

Question: When I send an email from a Gmail to an email on my postfix server I get 454 4.7.1 relay access denied.
This is my main.cf:
alias_database = hash:/etc/aliases
alias_maps = hash:/etc/aliases
append_dot_mydomain = no
biff = no
compatibility_level = 2
home_mailbox = Maildir/
inet_interfaces = all
inet_protocols = all
mailbox_size_limit = 0
milter_default_action = accept
mydestination = $myhostname, $mydomain, mail.domain.com, localhost.$mydomain, localhost
mydomain = domain.com
myhostname = mail.domain.com
mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
myorigin = $mydomain
non_smtpd_milters = inet:127.0.0.1:8892
readme_directory = no
recipient_delimiter = +
relayhost =
smtp_tls_security_level = may
smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache
smtpd_banner = $myhostname ESMTP $mail_name (Debian/GNU)
smtpd_milters = inet:127.0.0.1:8892
smtpd_recipient_restrictions = permit_mynetworks,permit_auth_destination,permit_sasl_authenticated,reject
smtpd_relay_restrictions = permit_mynetworks permit_sasl_authenticated defer_unauth_destination
smtpd_sasl_auth_enable = yes
smtpd_sasl_local_domain = $myhostname
smtpd_sasl_path = private/auth
smtpd_sasl_security_options = noanonymous
smtpd_sasl_type = dovecot
smtpd_tls_cert_file = /root/mail.crt
smtpd_tls_key_file = /root/mail.key
smtpd_tls_security_level = may
smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
smtpd_use_tls = yes

This is the maillog
Mar  5 06:05:02 mail postfix/smtpd[2163]: connect from mail-ed1-f46.google.com[22.214.171.124]
Mar  5 06:05:02 mail postfix/smtpd[2158]: disconnect from mail-ed1-f53.google.com[188.8.131.52] ehlo=2 starttls=1 mail=1 rcpt=0/1 data=0/1 quit=1 commands=5/7
Mar  5 06:05:03 mail postfix/smtpd[2163]: NOQUEUE: reject: RCPT from mail-ed1-f46.google.com[184.108.40.206]: 454 4.7.1 <firstname.lastname@example.com>: Relay access denied; from=<email@example.com> to=<firstname.lastname@example.com> proto=ESMTP helo=<mail-ed1-f46.google.com>
Mar  5 06:05:03 mail postfix/smtpd[2163]: disconnect from mail-ed1-f46.google.com[188.8.131.52] ehlo=2 starttls=1 mail=1 rcpt=0/1 data=0/1 quit=1 commands=5/7

Answer: Same with all domains, no mail anymore on reception.
But since 2 min, i got mail come again.
I have just add all my domain to postfix/main.cf
Before it was :
mydestination = $myhostname, serveur.pulsart-games.com, localhost.pulsart-games.com, localhost

I add my domain that dont received mail anymore like this :
mydestination = $myhostname, serveur.pulsart-games.com, localhost.pulsart-games.com, localhost, amns.fr, pulsart-games.com, agence-brunel.com

And now its seem to work.
Try it


Issues in working with comparison operators

Question: I have a SQL statement which looks like:
SELECT `scaleble` FROM `property_requirement` WHERE (`scaleble` > '850' AND `scaleble` < '1200' )

and is not producing any results, whereas another SQL statement which looks like:
SELECT `scaleble` FROM `property_requirement` WHERE (`scaleble` > 850 AND `scaleble` < 1200 )

gives required results.
However, the individual comparisons like:
SELECT `scaleble` FROM `property_requirement` WHERE (`scaleble` > '850')

AND
SELECT `scaleble` FROM `property_requirement` WHERE (`scaleble` < '1200')

do produce the required results.
I am a bit confused with the working of these queries. Can anyone help me with this?
Comment: What is the type of `scaleble` ?
Comment: I think you should not put quotes around your integers in a SQL Query.
Comment: It is of type varchar(255)
Comment: @Tushki check my posted answer which will return different records for each query
Answer: Presumably, scalable is being stored as a string.  The comparisons with single quotes convert the values to strings, so they are not numerically ordered.  As string '850' > '1200' so nothing satisfies the condition.
You can fix this by dropping the single quotes.  I would also encourage you to convert the value to a number explicitly.  I often just add 0 for this purpose:
SELECT `scaleble`
FROM `property_requirement`
WHERE (`scaleble` + 0 > 850 AND `scaleble` + 0 < 1200 );

Comment: But why are the individual queries working then? And that too in the expected fashion..
Answer: You are wrong to test please check SQL Fiddle
SELECT `scaleble` FROM `property_requirement` WHERE (`scaleble` > '850')

This above query will return only next higher value record. Where following query will return all higer record
SELECT `scaleble` FROM `property_requirement` WHERE (`scaleble` > 850)

Compare these two queries in fiddle
Comment: But in my case I am getting multiple values from the former query as well but yes, the count is different.


RatingBar stars shows weird effect

Question: I am using rating bar to show movie rating in my app. Placed rating bar like this in my layout file:
               <RatingBar
                android:id="@+id/RatingBar"
                style="@style/MicRatingBar"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginBottom="10dp"
                android:layout_marginTop="2dp"
                android:layout_toRightOf="@+id/movie_img"
                android:isIndicator="true"
                android:numStars="5"
                android:rating="3.0"
                android:stepSize="1"
                android:textColor="@drawable/button_text" />

In the style part, I've assigned it minHeight and maxHeight 9dp which reduce the weird but not completely gone. My rating bar look like this. what is these lines. please help. thanks in advance.

The style part is this:

Comment: This isn't the emulator, so it's not an accurate representation of how the rating bar looks in effect. Please show us that, and also - show us the style/MicRatingBar
Comment: same effect on emulator. style xml is updated
Answer: Please have a look into minHeight for a View class and maxHeight of ProgressBar (no maxHeight attribute in View class). When you set android:layout_height="wrap_content", it tries to measure itself to the minimum height you have provided. You could get wider idea if you see onMeasure(...) of AbsSeekBar (RatingBar extends AbsSeekBar)

RatingBar stars shows weird effect


hook_menu() doesn't work as expected. How can I fix that?

Question: hook_menu() contains the following code.
//案件 > インポート設定 > GMC_Subaccountの追加
$items[FEED_MANAGER_MENU_PATH.'/import/%import_id/gmc_subaccount/add'] = array(
    'title' => 'GMCサブアカウントの追加',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('feed_manager_import_gmc_subaccount_edit', 2),
    'access arguments' => array('feed import gmc_subaccount edit'),
    'type' => MENU_LOCAL_ACTION,
    'file' => 'feed_manager.import_gmc_subaccount.inc',
);
//案件 > インポート設定 > GMC_Subaccountの編集
$items[FEED_MANAGER_MENU_PATH.'/import/%import_id/gmc_subaccount/%store_id'] = array(
    'title' => 'GMCサブアカウントの編集',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('feed_manager_import_gmc_subaccount_edit', 2, 4),
    'access arguments' => array('feed import gmc_subaccount edit'),
    'type' => MENU_CALLBACK,
    'file' => 'feed_manager.import_gmc_subaccount.inc',
);

When I visit /import/%import_id/gmc_subaccount/%store_id, it does't show the edit page, but the list page, which is defined from the following code.
//案件 > インポート設定 > GMC_Subaccount_設定
$items[FEED_MANAGER_MENU_PATH.'/import/%import_id/gmc_subaccount'] = array(
    'title' => 'GMCサブアカウント',
    'page callback' => 'drupal_get_form',
    'page arguments' => array('feed_manager_import_gmc_subaccount_list', 2),
    'access arguments' => array('feed import gmc_subaccount edit'),
    'type' => MENU_CALLBACK,
    'file' => 'feed_manager.import_gmc_subaccount.inc',
);

The code I use to create the link to the edit page is the  following.
$row['data'][] = l(t('Edit'), FEED_MANAGER_MENU_PATH.'/import/'.$data->import_id.'/gmc_subaccount/'.$data->store_id.'/edit');

How can I fix the fact that link shows the wrong page?
Comment: Can you update your second menu item to following and let me know how you go.
$items[FEED_MANAGER_MENU_PATH.'/import/%import_id/gmc_subaccount/%store_id/edit'] = array( 'title' => 'GMCサブアカウントの編集', 'page callback' => 'drupal_get_form', 'page arguments' => array('feed_manager_import_gmc_subaccount_edit', 2, 4), 'access arguments' => array('feed import gmc_subaccount edit'), 'type' => MENU_LOCAL_ACTION, 'file' => 'feed_manager.import_gmc_subaccount.inc',
);
Answer: It was very simple problem-
I just added following line to my .module file-
function store_id_to_arg($args){
if(empty($args)){ drupal_goto('<front>'); }
return $args;
}

Thanks for your help.


Clearfix not working with a fixed width column

Question: I am new to Bootstrap and I am having a problem with clearfix. I am trying to design a website with 3 content columns (of variable height) and a 4th column with a fixed width for advertising.

The class col-fixed looks like this:
.col-fixed {
    width: 318px;
    float: right;
}

Everything else is standard bootstrap. Because the height of my advertising column is much larger than the height of the content elements there is a large gap between the first and second row. How do I solve this? Can I either:

Ignore specific divs in regard to the use of clearfix?
use a different grid layout?

Thanks in advance for any help or hint!
Comment: Please create a snippet with the full css :) after doing that your problem is much better to understand and to solve.
Comment: A fiddle to a question is like a bible to a priest. They both don't make sense without their counterparts. ;)
Comment: Ok, I am sorry. Here is the fiddle https://jsfiddle.net/eosvk7nm/1/ Please see the HTML comments for any further description of my problem.
Comment: Is there really no solution to my problem? Anyone? I can't get it to work by myself...
Answer: Ok, I solved my problem. This did the trick:
.col-fixed {
  width: 160px;
  float: right;
}

.contentrow {
  width:calc(100% - 160px);
  float: left;
}

.contentcol {
  padding-left: 2px;
  padding-right: 2px;
}

I still have an advertising column with a fixed width. But I added float: left; to my content column.
See: https://jsfiddle.net/tprarmjc/1/
However I cannot explain why it solved the problem? Maybe someone can explain it to me.


How many irreducible representations does SO(2) have?

Question: SO(2) is a continuous abelian group describing proper rotations in 2d space. Because all elements commute, each conjugacy class contains only one element. Thus, there are uncountably many classes that can be parameterized by the angle $0\le\phi<2\pi$. According to the group theory, the number of classes is equal to the number of irreducible representations (irreps). Thus, there should be uncountably many irreps. However, the irreps are known. They can be parametrized by integer (or half-integer) $J$, which has the meaning of the angular momentum in quantum mechanics. There are countably many of them.  What are the remaining uncountably many representations? Am I missing something in these considerations?
Comment: I think you are confusing ${\rm SO}\left(2\right)$ and ${\rm SU}\left(2\right)$ in the comment about quantum mechanics.
Comment: @eranreches No, SO(2) is a subgroup of SO(3).
Answer: The statement "the number of classes is equal to the number of irreducible representations" holds for finite groups, but not in general. And $SO(2,\mathbb R)$ is infinite.
Comment: Right, it is the Peter-Weyl theorem. What would be an intuitive explanation why this is the case?
Comment: I'm not sure I understand your question. The Peter-Weyl theorem, in the case of $SO(2,\mathbb R)$, simply asserts that the linear combinations of functions of the type$$\begin{bmatrix}\cos\theta&-\sin\theta\\\sin\theta&\cos\theta\end{bmatrix}\mapsto e^{in\theta}$$($n\in\mathbb N$) are dense in the space of continuous functions from $SO(2,\mathbb R)$ into $\mathbb C$, with respect to the $\sup$ norm.
Comment: I wanted to intuitively understand why "the number of classes is equal to the number of irreducible representations" fails for infinite compact groups?
Comment: That is another question. Please post it as such. Concerning the question that you posted here, I believe that I provided an answer.
Comment: Fair enough, accepted, upvoted.
Comment: Thank you. ${}$
Comment: $n\in\mathbb{Z}$, not $n\in\mathbb{N}$.
Comment: @AbdelmalekAbdesselam Sure. Thank you.


Identify included libraries/modules from Manifest

Question: TL;DR
Given an .apk file and its Manifest.xml decoded, is it possible to tell which libraries/(ad-)modules it ships bundled with – and if so, how?
Detailed question
I've checked with the Manifest specifications and saw the <uses-library /> element – but that's for shared libraries the app expects to be present on the device it shall be installed onto, and thus (AFAICT) not of relevance in this context. I've also checked several "example Manifest.xml files" to see what I would find (and yes, if one knows what to look for, one can e.g. identify AdMob by its declared <activity />). But except from "guess-work", I was unable to figure an "structured approach" valid for (mostly) all cases one might encounter in the real-world.
So what I'm looking for is to write a script which I can pass an .apk file to, and which then spits out a list of libraries and ad-modules used. I'm not asking you to provide me with that script (though I definitely wouldn't reject if offered that; I wouldn't be surprised to hear someone has done that already) – but rather for the core point of what the "identifiers" would be. General approaches are of course welcome as well. If that includes other calls to e.g. aapt, that's of course OK. And if I'm on the completely wrong track, and that information has to be looked for at another place, I'd definitely like to hear those details, too :)
In case it's relevant (e.g. for other "external tools" needed), I'm working on Linux – so Windows tools wouldn't do.
Comment: Related: [How to find all the packages included in an apk](http://stackoverflow.com/q/18717248/2533433). The *question* describes quite well what *details* I'm looking for. The [self-answer](http://stackoverflow.com/a/23874023/2533433) unfortunately takes a different approach (plus seems to be GUI only). // PS: Just found [LibRadar](https://github.com/pkumza/LibRadar) which (from its description) seems capable of what I need. Still investigating.
Answer: AndroidManifest file has nothing to do with libraries which used in app. And I don't think that there is a way to get list of used libraries, except to check decompiled code and try to match it by package name. But in case if that code obfuscated with Proguard, I think your goal is almost unreachable.
Comment: Thanks for clarifying this, Divers. I'm sure there must be a way to reach my goal – as otherwise, how can e.g. [AppBrain](http://www.apprain.com/) list which libraries and ad modules an app contains, or how do the corresponding [ad-module checker apps](https://android.izzysoft.de/applists/category/named/network_admodules#group_443) work? The latter are scanning the device too fast to do some on-device decompiling (they might be checking some online references by package name and version, though).
Comment: You gave a link on apprain, so I was very confused ). According to Appbrain, you should use their library in order to use it, correct? If yes, they can just parse your build.gradle file and get here all dependency. As per ad-module, don't they just check permission of app?
Comment: I doubt all apps they list those components for have their library integrated (if you check some examples, they seem to list them for almost all the apps, though it takes some time for those details to "turn up" when a new app/APK is added to the site). Also, if that were a requirement, that library would be listed as well, which it not always is (compare e.g. [their ad detector](http://www.appbrain.com/app/com.appspot.swisscodemonkeys.detector) with [denper's](http://www.appbrain.com/app/com.denper.addonsdetector) in the resp. "Libraries" section). No idea how they do it.
Comment: Ah: looks like they [maintain their own list](http://www.appbrain.com/stats/libraries) where the library developers can send the specifications for. Still I doubt all ad networks did so :) For that, they require some "Identifying features" – e.g. classes, but also "activities or services need to be added to the manifest" as my question asks for. Unfortunately, that list doesn't seem available for download, nor do I see those "Identifying features" published with the resp. descriptions.


Change ng-include with controller

Question: I have a tab structure made of ng-reapet which shows the content of each tab in a panel (the same one but diff content). I have added

in each tab-panel to display the content according to selected tab and its fine, but when i click on submit within the html(after filling the fields there) I want the ng-include to be replaced with another html (the submit results) template and his controller.
Now i am doing $state.go("url") and its taking me to another page and using route refresh the page.
Answer: Try this out,
<!DOCTYPE html>

  <link rel="stylesheet" href="style.css" />

  <input type='button' ng-value='buttonText' ng-click="doEdit()" />

Controller.js
var app = angular.module('myApp', []);

app.controller('switchCtrl', function($scope) {

  $scope.templates = [{
    name: 'template-one.html',
    url: 'template-one.html'
  }, {
    name: 'template-two.html',
    url: 'template-two.html'
  }];

  $scope.hasPermissionToEdit = true;
  $scope.buttonText = 'Edit';
  $scope.isEditing = false;
  $scope.shared = 'shared value between templates.';
  $scope.template = $scope.templates[0];

  $scope.doEdit = function() {
    if ($scope.isEditing) {
      $scope.template = $scope.templates[0];
      $scope.isEditing = false;
      $scope.buttonText = 'Edit';
    } else {
      if ($scope.hasPermissionToEdit) {
        $scope.template = $scope.templates[1];
        $scope.isEditing = true;
        $scope.buttonText = 'Go back';
      } else {
        alert('you don\'t have permission to edit');
      }
    }
  }
});

Hope this helps !!

Change ng-include with controller


What does this symbol of $\Longleftrightarrow$ mean?

Question: What does it mean, is it an implication or does mean something else?
Comment: it means "if and only if"
Answer: The symbol $\iff$ in this context means "if and only if". If you have two statements $p$ and $q$, then $p\iff q$ means $p\Rightarrow q$ and $q\Rightarrow p$, and consequently that $p$ and $q$ have the same truth values. $$\begin{array}{|c|c|}
\hline p & q & p\Rightarrow q & q\Rightarrow p & p\iff q \\ \hline
\color{green}1 & \color{#C00}0 & \color{#C00}0 & \color{green}1 & \color{#C00}0 \\
\hline \color{green}1 & \color{green}1 & \color{green}1 & \color{green}1 & \color{green}1 \\
\hline \color{#C00}0 & \color{green}1 & \color{green}1 & \color{#C00}0 & \color{#C00}0 \\
\hline \color{#C00}0 & \color{#C00}0 & \color{green}1 &\color{green}1 &\color{green}1 \\ \hline
\end{array}$$
Answer: It means "if and only if". Sometimes this is shortened to "iff".
You can translate $P \iff Q$ by ($P \implies Q \text{ and } Q \implies P$).


Run a crontab for django management command with an argument

Question: I wish to ping_google for the sitemap every 10 minutes using crontab and django manage.py
I need to run the following on server-
python manage.py ping_google /sitemap.xml
I am not sure how to give the parameter '/sitemap.xml' in the crontab. Here is what I have
*/10 * * * * /home/project/.virtualenvs/app/bin/python /home/project/workspace/app-backend/django-app/manage.py ping_google /sitemap.xml
Am I passing the argument correctly? How am I supposed to pass the argument?
Comment: @WillemVanOnsem I fixed the mistake. Here, `/sitemap.xml` represents the address of the sitemap on the website
Comment: What is the backslash doing here?
Answer: I think it might be better here to write a small shell script here that sets the current working directory correctly, and activates the virtual environment. For example a file command.sh in the directory /home/project/workspace/app-backend/django-app/:
#!/bin/bash

# cd to the correct directory
cd "/home/project/workspace/app-backend/django-app/"

# source the virtual environment
. /home/project/.virtualenvs/app/bin/activate

# call the command
python manage.py ping_google /sitemap.xml

Then you can run this with:
*/10 * * * * bash /home/project/workspace/app-backend/django-app/command.sh


Difference in Difference analysis via emmeans in R

Question: Using emmeans, I have already coded for the difference and significance in means between: White Christian (WC) Men and Black Christian (BC) men, and then White Muslim (WM) men and Black Muslim (BM) men, for certain stereotype Dimensions. Here is my code for it:
pairwise_emm2 <- emmeans(fitdata3, pairwise ~ Religion * Race | Dimension, type = "response") pairwise_emm2$contrasts
I now want to code for the differences between these differences. Meaning I want to know if the WC-BC difference is greater than the WM-BM difference, and if it is significant. Can someone please help me figure out the code for that? Thank you!
Answer: This is an interaction contrast. Try
contrast(pairwise_emm2[[1]], interaction = "consec")

This calculates the difference of consecutive differences for each level of Dimension.
See vignette("interactions", "emmeans") for more discussion and examples
Or, you could compare the existing differences directly:
pairs(pairwise_emm2[[2]], simple = "contrast")

Comment: Thank you @RussLenth for your help so far! This is basically what I want, but in both options, it is not showing me all the possible difference - difference contrasts. For example with option 2 at the end of each Dimension it reads: [ reached getOption("max.print") -- omitted 212 rows ] . Is their a way to specify a specific difference - difference contrast I want?
Comment: Your question suggests that you have 2 genders and 2 religions. That's one interaction contrast per dimension. If you have a lot more than that, then the numbers will grow quickly. I suggest not going overboard and testing too many things. You can use `at` in the emmeans call to use a smaller number of levels, and you can use a contrast family that gives only the comparisons you want.


AVD Manager ajuste no display

Question:
Olá pessoal, eu estou utilizando o processador intel x86 com uma Device padrão android 4.1.2. Apenas fiz a instalação alone do SDK e startei o Device. Como pode ver o display fica todo desconfigurado.
Comment: sei que não responde a sua pergunta, mas tenta usar o Genymotion pra teste do Android. Eu uso somente ele e garanto que é muito bom. Sem falar que é mais leve que os outros virtual devices padrões. https://www.genymotion.com/
Answer: Pude notar que você utiliza o windows

Baixe o Xamarin Android Player na Versão 0.5.6(ou mais recente)
clicando aqui
Instale o Xamarin Android Player (que vai instalar o Oracle VM Virtual Box)
Se estiver utilizando o Windows 8.1 ou 10 baixe a ultima versão do VM Virtual Box clicando aqui
Atualize o VM Virtual Box
Crie o seu novo dispositivo com a API ou versão Android desejada

AVD Manager ajuste no display


Android Koin DI can't get instance with named

Question: Here is my code...
class MainActivity : AppCompatActivity() {
val myService: MyService by inject(named("MyService"))
val yourService: YourService by inject(named("YourService"))

override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_main)

    myService.myServiceDo()
    yourService.yourServiceDo()
}

MyApp :
class MyApp : Application() {

override fun onCreate() {
    super.onCreate()

    startKoin {
        androidContext(this@MyApp)

        module { myModule }
    }

}

IService Interface :
interface IService {
fun foo()}

MyService :
class MyService : IService {
override fun foo() {
    TODO("Not yet implemented")
}
fun myServiceDo(){
    Log.d("MyService", "myServiceDo...")
}

YourService :
class YourService : IService {
override fun foo() {
    TODO("Not yet implemented")
}

fun yourServiceDo() {
    Log.d("YourService", "yourServiceDo...")
}

myModule :
val myModule = module {
single<IService>(named("MyService")) { MyService() }

single<IService>(named("YourService")) { YourService() }

The error is like org.koin.core.error.NoBeanDefFoundException: No definition found for class:'se.jun.koinex.IService' & qualifier:'MyService'. Check your definitions!
I can't understand why it happens even if I did think I followed Koin Offical Documents.
Could you please help me? thanks.
Answer: Oooops... there was a mistake in startKoin function.
For specify module, I should use modules function but there was a module...
And also,here
val myService: MyService by inject(named("MyService"))
val yourService: YourService by inject(named("YourService"))

the type of services should be IService.
If I wanna use MyService's or YourService's own functions, then should cast to applicable type.


How should one call the complement of the critical / rejection region?

Question: In null hypothesis statistical testing, the critical region (also known as the rejection region) is

A set of values for the test statistic for which the null hypothesis is rejected. i.e. if the observed test statistic is in the critical region then we reject the null hypothesis and accept the alternative hypothesis. [1]

For a Stats 101-like course, they might be illustrated as follow (omitting most of the details):

The question is: How do you call the complement of the critical region / rejection region (the interval where the distribution is not shaded)? Is there a specific term for this interval?
I have heard of the interval being referred to as "non-rejection region" and "acceptance region" (which IMO is misleading as it implies acceptance of the null), though I am looking for answers with reference(s) that have defined / discussed on such terminology.

Note: I have seen this question but the question deals with the Bayesian version.
[1] Newcastle University (2018) Critical Region and Confidence Interval. https://internal.ncl.ac.uk/ask/numeracy-maths-statistics/statistics/hypothesis-testing/critical-region-and-confidence-interval.html
Comment: @whuber - Nope, I want to know a concise name of the complement for the critical region / rejection region (instead of referring it as e.g. "the set complement of the interval referred as critical region") - will take suggestion on how to improve the question!
Comment: Thank you clarifying and emphasizing this is a terminological question.  (Some of us read questions too hastily ;-).)
Comment: Are you inquiring what a [set complement](https://en.wikipedia.org/wiki/Complement_(set_theory)) means?
Answer: Acceptance region. There's plenty more references in the web.
Comment: That's an awful name, since failing to reject $\text{H}_{0}$ may result **either** because the null is true, **or** because $\text{H}_{\text{A}}$ is true, but there is not enough power to reject. Also, this is why combining tests for difference with tests for equivalence is dope. :)
Comment: Since we don't accept the null, but we need a word that is the opposite of *critical*, I propose we call it the 'insincere flattery region', @Alexis ;-P.
Comment: I am fine with calling it the acceptance region when statisticians are talking, since probably all of us read Casella and had the professor say, "Isn't that name awful? But it is what it is." However, when you have to explain in a meeting why we don't accept the null hypothesis when the value falls in the acceptance region...
Comment: While this is what Casella calls it, we all agreed that this terminology is poor, as we do not accept null hypotheses.
Comment: @Dave, we do not, that's true, but we say that a lot, because it's shorter. I guess names and labels are like models: never really right, but still useful
Comment: onestly if you are talking acceptance regions, you can put it like your professor did, that's its name anyway. And I don't even think it's that bad as a term, "acceptance" is a quite mild word after all.
Comment: @gung-ReinstateMonica my hero! (Heads off to edit lecture slides)
Comment: While I have some misgivings to the name itself and what it may imply, I have accepted the answer as it provides what the original question asked for.


redis cluster in Kubernetes doesn't write nodes.conf file

Question: I'm trying to set up a Redis cluster and I followed this guide here: https://rancher.com/blog/2019/deploying-redis-cluster/
Basically I'm creating a StatefulSet with a replica 6, so that I can have 3 master nodes and 3 slave nodes.
After all the nodes are up, I create the cluster, and it all works fine... but if I look into the file "nodes.conf" (where the configuration of all the nodes should be saved) of each redis node, I can see it's empty.
This is a problem, because whenever a redis node gets restarted, it searches into that file for the configuration of the node to update the IP address of itself and MEET the other nodes, but he finds nothing, so it basically starts a new cluster on his own, with a new ID.
My storage is an NFS connected shared folder. The YAML responsible for the storage access is this one:
kind: Deployment
apiVersion: extensions/v1beta1
metadata:
  name: nfs-provisioner-raid5
spec:
  replicas: 1
  strategy:
    type: Recreate
  template:
    metadata:
      labels:
        app: nfs-provisioner-raid5
    spec:
      serviceAccountName: nfs-provisioner-raid5
      containers:
        - name: nfs-provisioner-raid5
          image: quay.io/external_storage/nfs-client-provisioner:latest
          volumeMounts:
            - name: nfs-raid5-root
              mountPath: /persistentvolumes
          env:
            - name: PROVISIONER_NAME
              value: 'nfs.raid5'
            - name: NFS_SERVER
              value: 10.29.10.100
            - name: NFS_PATH
              value: /raid5
      volumes:
        - name: nfs-raid5-root
          nfs:
            server: 10.29.10.100
            path: /raid5
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: nfs-provisioner-raid5
---
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
  name: nfs.raid5
provisioner: nfs.raid5
parameters:
  archiveOnDelete: "false"

This is the YAML of the redis cluster StatefulSet:
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: redis-cluster
  labels:
    app: redis-cluster
spec:
  serviceName: redis-cluster
  replicas: 6
  selector:
    matchLabels:
      app: redis-cluster
  template:
    metadata:
      labels:
        app: redis-cluster
    spec:
      containers:
      - name: redis
        image: redis:5-alpine
        ports:
        - containerPort: 6379
          name: client
        - containerPort: 16379
          name: gossip
        command: ["/conf/fix-ip.sh", "redis-server", "/conf/redis.conf"]
        readinessProbe:
          exec:
            command:
            - sh
            - -c
            - "redis-cli -h $(hostname) ping"
          initialDelaySeconds: 15
          timeoutSeconds: 5
        livenessProbe:
          exec:
            command:
            - sh
            - -c
            - "redis-cli -h $(hostname) ping"
          initialDelaySeconds: 20
          periodSeconds: 3
        env:
        - name: POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP
        volumeMounts:
        - name: conf
          mountPath: /conf
          readOnly: false
        - name: data
          mountPath: /data
          readOnly: false
      volumes:
      - name: conf
        configMap:
          name: redis-cluster
          defaultMode: 0755
  volumeClaimTemplates:
  - metadata:
      name: data
      labels:
        name: redis-cluster
    spec:
      accessModes: [ "ReadWriteOnce" ]
      storageClassName: nfs.raid5
      resources:
        requests:
          storage: 1Gi

This is the configMap:
apiVersion: v1
kind: ConfigMap
metadata:
  name: redis-cluster
  labels:
    app: redis-cluster
data:
  fix-ip.sh: |
    #!/bin/sh
    CLUSTER_CONFIG="/data/nodes.conf"
    echo "creating nodes"
    if [ -f ${CLUSTER_CONFIG} ]; then
      if [ -z "${POD_IP}" ]; then
        echo "Unable to determine Pod IP address!"
        exit 1
      fi
      echo "Updating my IP to ${POD_IP} in ${CLUSTER_CONFIG}"
      sed -i.bak -e "/myself/ s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/${POD_IP}/" ${CLUSTER_CONFIG}
      echo "done"
    fi
    exec "$@"
  redis.conf: |+
    cluster-enabled yes
    cluster-require-full-coverage no
    cluster-node-timeout 15000
    cluster-config-file /data/nodes.conf
    cluster-migration-barrier 1
    appendonly yes
    protected-mode no

and I created the cluster using the command:
kubectl exec -it redis-cluster-0 -- redis-cli --cluster create --cluster-replicas 1 $(kubectl get pods -l app=redis-cluster -o jsonpath='{range.items[*]}{.status.podIP}:6379 ')

what am I doing wrong?
this is what I see into the /data folder:

the nodes.conf file shows 0 bytes.
Lastly, this is the log from the redis-cluster-0 pod:
creating nodes
1:C 07 Nov 2019 13:01:31.166 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
1:C 07 Nov 2019 13:01:31.166 # Redis version=5.0.4, bits=64, commit=00000000, modified=0, pid=1, just started
1:C 07 Nov 2019 13:01:31.166 # Configuration loaded
1:M 07 Nov 2019 13:01:31.179 * No cluster configuration found, I'm e55801f9b5d52f4e599fe9dba5a0a1e8dde2cdcb
1:M 07 Nov 2019 13:01:31.182 * Running mode=cluster, port=6379.
1:M 07 Nov 2019 13:01:31.182 # WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.
1:M 07 Nov 2019 13:01:31.182 # Server initialized
1:M 07 Nov 2019 13:01:31.182 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
1:M 07 Nov 2019 13:01:31.185 * Ready to accept connections
1:M 07 Nov 2019 13:08:04.264 # configEpoch set to 1 via CLUSTER SET-CONFIG-EPOCH
1:M 07 Nov 2019 13:08:04.306 # IP address for this node updated to 10.40.0.27
1:M 07 Nov 2019 13:08:09.216 # Cluster state changed: ok
1:M 07 Nov 2019 13:08:10.144 * Replica 10.44.0.14:6379 asks for synchronization
1:M 07 Nov 2019 13:08:10.144 * Partial resynchronization not accepted: Replication ID mismatch (Replica asked for '27972faeb07fe922f1ab581cac0fe467c85c3efd', my replication IDs are '31944091ef93e3f7c004908e3ff3114fd733ea6a' and '0000000000000000000000000000000000000000')
1:M 07 Nov 2019 13:08:10.144 * Starting BGSAVE for SYNC with target: disk
1:M 07 Nov 2019 13:08:10.144 * Background saving started by pid 1041
1041:C 07 Nov 2019 13:08:10.161 * DB saved on disk
1041:C 07 Nov 2019 13:08:10.161 * RDB: 0 MB of memory used by copy-on-write
1:M 07 Nov 2019 13:08:10.233 * Background saving terminated with success
1:M 07 Nov 2019 13:08:10.243 * Synchronization with replica 10.44.0.14:6379 succeeded

thank you for the help.
Comment: I find it strange that you are updating the conf this way.
A good feature of stateful set is  [POD identity](https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#pod-identity).
You could use it to setup config once with pod domain names, it won't matter if pods go up or down.
Comment: shouldn't all the redis nodes have a shared node.conf? Since you are using a volumetemplate, you are getting a new volume for each pod. Since it is NFS and likely has the same data for each pod, you can create a normal volume and volume mount instead of the template
Comment: what is your environment? minikube? GKE?
Comment: It's actually a Kubernetes cluster with 4 nodes, one of them is the master. It's a cluster we setup internally, starting from this guide: https://github.com/hobby-kube/guide.
For the storage though we use a shared folder in NFS.
Comment: Can you add to your answer part of your stetefulset yaml that is responsible for mounting nfs volume? And preferably every other information that may be helpful while replicating your issue?
Comment: ok done. If you need anything else, I'll be glad to post it :)
Comment: I need the content of `fix-ip.sh`. Can you add  *redis-cluster* configmap ?
Comment: I replicated your issue on GKE using Filestore as NFS server and everything works fine. `nodes.conf` file contains list of all nodes. Can you try manually creating any file with any content in `/data` dir? maybe there is problem with storing data on your nfs.
Comment: but I can see in that folder other files, like the appendonly.aof file that is changing in time... in fact also if I try to create and edit a file via VI, it works.
Comment: Try deleting statefulset (`kubectl delete sts redis-cluster`)  and pvc (`kubectl delete pvc -l app=redis-cluster`) and then recreate it. Also look into redis logs, maybe it shows something, maybe redis has some problem with opening `nodes.conf` file (also change *loglevel* to *debug*)
Comment: @HelloWorld I already did it, and the logs show NO error in opening the file... in the logs all is going ok.
Comment: My files are very similar to yours except that my redis.conf states `cluster-config-file nodes.conf` (the /data/ does not appear)
I also use the fix-ip.sh and the path is the same `CLUSTER_CONFIG="/data/nodes.conf"`
Comment: can you share the logs from redis-cluster-0 pod
Comment: @jbl I did the same now, but the file is still empty.
Comment: @PEkambaram done, you can now see the logs in the question.
Comment: @Deboroh88, can you please post also the security context and serviceAccount of one of your redis' Pods (just to be sure that nothing mutates Kubernetes resources on your cluster before they are actually created). One more thing, check files/directory permissions of your NFS folder '/raid5' directly on NFS Server.
Comment: Idid you try with the updated script
Comment: can you use fix-ip.sh script from my answer below and confirm. it should work
Comment: @Nepomucen the serviceAccount is the default one, that is an ADMIN (has full access to everything). The permission on the shared disk is "Everyone -> full control".
Comment: @Deboroh88, I think we reached sort of deadpoint trying to help you out with your unique case. Lot of users, including me (Kubernetes v1.15.2 GCE, with in-cluster NFS server) cannot reproduce your case = works w/o problem. At this place I would recommend you in the route of elimination to try to find a culprit. For me the main suspect is NFS based storage. Please replace it with [in-cluster solution](https://github.com/kubernetes/examples/tree/master/staging/volumes/nfs), and recreate your Redis cluster setup. BTW. you put to few info about your Kubernetes cluster.
Answer: Looks to be an issue with the shell script that is mounted from configmap. can you update as below
  fix-ip.sh: |
    #!/bin/sh
    CLUSTER_CONFIG="/data/nodes.conf"
    echo "creating nodes"
    if [ -f ${CLUSTER_CONFIG} ]; then
      echo "[ INFO ]File:${CLUSTER_CONFIG} is Found"
    else
      touch $CLUSTER_CONFIG
    fi
    if [ -z "${POD_IP}" ]; then
      echo "Unable to determine Pod IP address!"
      exit 1
    fi
    echo "Updating my IP to ${POD_IP} in ${CLUSTER_CONFIG}"
    sed -i.bak -e "/myself/ s/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/${POD_IP}/" ${CLUSTER_CONFIG}
    echo "done"
    exec "$@"

I just deployed with the updated script and it worked. see below the output
master $ kubectl get po
NAME              READY   STATUS    RESTARTS   AGE
redis-cluster-0   1/1     Running   0          83s
redis-cluster-1   1/1     Running   0          54s
redis-cluster-2   1/1     Running   0          45s
redis-cluster-3   1/1     Running   0          38s
redis-cluster-4   1/1     Running   0          31s
redis-cluster-5   1/1     Running   0          25s
master $ kubectl exec -it redis-cluster-0 -- redis-cli --cluster create --cluster-replicas 1 $(kubectl getpods -l app=redis-cluster -o jsonpath='{range.items[*]}{.status.podIP}:6379 ')
>>> Performing hash slots allocation on 6 nodes...
Master[0] -> Slots 0 - 5460
Master[1] -> Slots 5461 - 10922
Master[2] -> Slots 10923 - 16383
Adding replica 10.40.0.4:6379 to 10.40.0.1:6379
Adding replica 10.40.0.5:6379 to 10.40.0.2:6379
Adding replica 10.40.0.6:6379 to 10.40.0.3:6379
M: 9984141f922bed94bfa3532ea5cce43682fa524c 10.40.0.1:6379
   slots:[0-5460] (5461 slots) master
M: 76ebee0dd19692c2b6d95f0a492d002cef1c6c17 10.40.0.2:6379
   slots:[5461-10922] (5462 slots) master
M: 045b27c73069bff9ca9a4a1a3a2454e9ff640d1a 10.40.0.3:6379
   slots:[10923-16383] (5461 slots) master
S: 1bc8d1b8e2d05b870b902ccdf597c3eece7705df 10.40.0.4:6379
   replicates 9984141f922bed94bfa3532ea5cce43682fa524c
S: 5b2b019ba8401d3a8c93a8133db0766b99aac850 10.40.0.5:6379
   replicates 76ebee0dd19692c2b6d95f0a492d002cef1c6c17
S: d4b91700b2bb1a3f7327395c58b32bb4d3521887 10.40.0.6:6379
   replicates 045b27c73069bff9ca9a4a1a3a2454e9ff640d1a
Can I set the above configuration? (type 'yes' to accept): yes
>>> Nodes configuration updated
>>> Assign a different config epoch to each node
>>> Sending CLUSTER MEET messages to join the cluster
Waiting for the cluster to join
....
>>> Performing Cluster Check (using node 10.40.0.1:6379)
M: 9984141f922bed94bfa3532ea5cce43682fa524c 10.40.0.1:6379
   slots:[0-5460] (5461 slots) master
   1 additional replica(s)
M: 045b27c73069bff9ca9a4a1a3a2454e9ff640d1a 10.40.0.3:6379
   slots:[10923-16383] (5461 slots) master
   1 additional replica(s)
S: 1bc8d1b8e2d05b870b902ccdf597c3eece7705df 10.40.0.4:6379
   slots: (0 slots) slave
   replicates 9984141f922bed94bfa3532ea5cce43682fa524c
S: d4b91700b2bb1a3f7327395c58b32bb4d3521887 10.40.0.6:6379
   slots: (0 slots) slave
   replicates 045b27c73069bff9ca9a4a1a3a2454e9ff640d1a
M: 76ebee0dd19692c2b6d95f0a492d002cef1c6c17 10.40.0.2:6379
   slots:[5461-10922] (5462 slots) master
   1 additional replica(s)
S: 5b2b019ba8401d3a8c93a8133db0766b99aac850 10.40.0.5:6379
   slots: (0 slots) slave
   replicates 76ebee0dd19692c2b6d95f0a492d002cef1c6c17
[OK] All nodes agree about slots configuration.
>>> Check for open slots...
>>> Check slots coverage...
[OK] All 16384 slots covered.

master $ kubectl exec -it redis-cluster-0 -- redis-cli cluster info
cluster_state:ok
cluster_slots_assigned:16384
cluster_slots_ok:16384
cluster_slots_pfail:0
cluster_slots_fail:0
cluster_known_nodes:6
cluster_size:3
cluster_current_epoch:6
cluster_my_epoch:1
cluster_stats_messages_ping_sent:61
cluster_stats_messages_pong_sent:76
cluster_stats_messages_sent:137
cluster_stats_messages_ping_received:71
cluster_stats_messages_pong_received:61
cluster_stats_messages_meet_received:5
cluster_stats_messages_received:137

master $ for x in $(seq 0 5); do echo "redis-cluster-$x"; kubectl exec redis-cluster-$x -- redis-cli role;echo; done
redis-cluster-0
master
588
10.40.0.4
6379
588

redis-cluster-1
master
602
10.40.0.5
6379
602

redis-cluster-2
master
588
10.40.0.6
6379
588

redis-cluster-3
slave
10.40.0.1
6379
connected
602

redis-cluster-4
slave
10.40.0.2
6379
connected
602

redis-cluster-5
slave
10.40.0.3
6379
connected
588

Comment: unfortunately, it still doesn't work. I mean, if I run the commands that you do here, I can see the same log, because the cluster gets created normally, but the file is still empty. I guess it's a problem with the file writing on disk at this point... that is weird because on that folder I still see that the "appendonly.aof" and "dump.rdb" files have data on them.
Comment: You might be right, the container might not have permission to write to the mount. In that case write the file to different location In the container and use that location  for starting up redis server
Comment: ok, it seems a good test, but to make a node able to re-meet the cluster once it gets restarted I need the file to be permanently stored, right?
Comment: Give it a try and check
Comment: Another way is to use init container to update permissions on data folder to 777. Then redis container should be able to write. You need to share the data folder between init container and redis container. I tried this way few years ago when I run into silimilar issue
Comment: indeed putting the file in another folder have worked. What do you mean by "init container"? Should I modify the "fix-ip" script to change permissions on the folder? Would it work, if I'm inside the container itself?
Comment: good that it is worked with different location. if you want to try another way try with init container to update the permissions on the data volume. refer the link for init container https://kubernetes.io/docs/concepts/workloads/pods/init-containers/
Comment: mmm that doesn't work too... there is something strange, but maybe it's normal: if I get up the redis-cluster with the nodes.conf file on another folder, it gets written... and in the /data folder I can write manually all the files I need (from within the container). But when I start the container with the nodes.conf inside the /data folder, even if I try to edit the file manually, the data inside continues to vanish. I guess it's the redis process that erases the data...?
Comment: But when I tested yday I didn't face any problem. Redis cluster came up fine
Comment: Something to do with your nfs volume. Instead of nfs test with emptyDir and see if it works. I used emptyDir and it worked fine


Does a strongly convex cone have a unique set of minimal generators?

Question: I am studying toric varieties from the book "Toric Varieties" by Cox, Little and Schenck. They define rays as the edges of a strongly convex cone, $\sigma$. Each ray, $\rho$ has a unique ray generator $u_\rho$ which generates the semigroup $\rho\cap N$ where $N$ is the underlying lattice.
Lemma 1.2.15 says that $\sigma$ is generated by it's ray generators but I am wondering if the converse is true.

If $\sigma$ has a set of minimal generators (over $\mathbb{R}$), $x_1,...,x_n$, do the $x_i$ have to lie in the rays of $\sigma$?.

I am having trouble proving this because the definition of an edge is a 1 -dimensional intersection $H_m\cap \sigma$ where $H_m$ is a halfplane. This seems very different from being a generator to me.
I have tried showing that if some $u_\rho$ can be generated (over $\mathbb{R}$) by another sets of point in the cone, then the cone is not strongly convex, but I am not sure if this is actually true.
Comment: Hint: First show that if $v$ is a vertex of a convex polytope $P$, then $v$ cannot lie in the interior of a segment contained in $P$.
Answer: I spoke to my supervisor who helped me find an answer to this question, so I will share for any future readers who have the same question.
Assume for the sake of contradiction that there are two minimal generating sets for the cone: $x_1,...,x_n$ and $v_1,...,v_m$, and that $x_1$ does not lie in the same line as any $v_j$.
Since each $x_i$ is in the cone, it can be generated by $v_1,...,v_n$. Therefore we can write $x_i=\sum a_{ij}vj$ for some $a_{ij}\in \mathbb{R}_{\ge 0}$. Similarly each $v_j$ can be written as $\sum b_{ij} x_i$ for some $b_{ij}\in \mathbb{R}_{\ge 0}$.
Combining these we get $x_i=\sum_{i=1}^n a_{ij}b_{ij}x_i$.
Therefore, renaming our constants and collecting like terms,  there exists $c_i\in \mathbb{R}$ such that $c_1x_1=\sum_{i=2}^n c_ix_i$. Here $c_1=1-a_{11}b_{11}\in \mathbb{R}$ and $c_i=a_{1i}b_{1i}\in \mathbb{R}_{\ge 0}$. We can assume that $c_2,...,c_n$ are not all zero as this would only be possible if $x_1$ was in the same line as some $v_j$.
There are three cases: $c_i>0$, $c_i=0$ and $c_i<0$.
If $c_i>0$, then $x_1=\sum_{i=2}^n\frac{c_i}{c_1}x_i$. Since $\frac{c_i}{c_1}\in \mathbb{R}_{\ge 0}$, this implies $x_1\in \text{Cone}(x_2,...,x_n)$ which contradicts the fact that $x_1,...,x_n$ is a minimal generating set.
If $c_i=0$, then $0=\sum_{i=2}^nc_ix_i$. Not all of the $c_i$ are zero, so without loss of generality we can assume $c_2\ne 0$. Then $-c_2=\sum_{i=3}^n\frac{c_i}{c_2}x_i\in \text{Cone}(x_1,...,x_n)$, which contradicts the strong convexity of the cone.
Finally if $c_i<0$ then $x_1=\sum_{i=2}^n\frac{c_i}{c_1}x_i$, which again contradicts the strong convexity of the cone.
Therefore, up to scalar multiples, $v_1,...,v_n$ is the only minimal generating set.
Comment: Isn't the final case impossible, since each $a_{ij}$ and $b_{ij}$ are non-negative?
Comment: You are very right. Especially considering that I literally wrote that the c_i were in the positive reals in the previous paragraph, and then promtly forgot. Silly me from 2017!


Why two new balls in One Day Internationals?

Question: Why two new balls in One Day Internationals? Ground is getting smaller [true]. Bats are becoming powerful [true]. I don't seem to get the argument of two new balls helping the bowlers. Ideally, new balls are used by fast bowlers to good effect. Spinners can use the old ball to good effect too. Spinners can bowl with new ball [a different argument]. I want to know technically how will it help the bowlers?
Answer: White balls discolour more quickly, and so the ball was frequently being changed around 35 overs to allow the batsman to see it more clearly.
A new ball from either end (which is what happens) means each ball is only in play for 25 overs and so should remain in shape and white for the duration of the innings.
Technically it will help seamers and swing bowlers as a better ball is more useful to them. It will be of less assistance to spinners, especially those who need to grip the ball, but the slippery coating will normally wear off anyway, and most spinners playing ODI cricket are now used to bowling with balls that don't provide much assistance.


Find the distributional derivative of a piecewise continuous function $f(x)=x^2$, when $x <3$ and $f(x)=x^3,$ when $x\geq 3$.

Question: Find the distributional derivative of a piecewise continuous function $f(x)=x^2$, when $x <3$ and $f(x)=x^3,$ when $x\geq 3$.
I know that I want to set this up as $$f(\phi)=-\int_{-\infty}^\infty f(x)\phi'(x)=-\int_{-\infty}^3x^2\phi'(x)dx - \int_{3}^\infty x^3\phi'(x)dx.$$
Using integration by parts, I can express the integrals as $$\int_{-\infty}^3x^2\phi'(x)dx = x^2\phi(x)\bigg|_{-\infty}^3-2\int_{-\infty}^3x\phi(x)dx = 9\phi(3)-2\int_{3}^\infty x\phi(x)dx$$ $$\int_{3}^\infty x^3\phi'(x)dx = x^3\phi(x)\bigg|_{3}^\infty-3\int_{3}^\infty x^2\phi(x)dx=27\phi(3)-3\int_{3}^\infty x^2\phi(x)dx.$$
but I'm unsure how to proceed from here. There isn't an obvious way for me to evaluate the remaining integrals, or to reduce them into the form of something else known.
Any thoughts would be greatly appreciated.
Thanks in advance.
Answer: You have made errors: $\left. x^2 \phi(x) \right|_{-\infty}^{3} = 9 \phi(3)$, not just $9$. Likewise for the $x^3\phi(x)$ part. And how did you go from $\int_{-\infty}^{3}$ to $\int_3^\infty$?
What you should get is
$$
\langle f', \phi \rangle
= -\langle f, \phi' \rangle
= -\int_{-\infty}^3x^2\phi'(x)\,dx - \int_{3}^\infty x^3\phi'(x)\,dx
\\= -9\,\phi(3) + 27\,\phi(3) + \int_{-\infty}^3 2x\,\phi(x)\,dx + \int_3^\infty 3x^2\,\phi(x)\,dx
\\= \langle 18\,\delta(x-3),\phi(x)\rangle + \langle g(x), \phi(x) \rangle,
$$
where
$$
g(x) = \begin{cases}
2x & (x<3) \\
3x^2 & (x>3)
\end{cases}
$$
Thus,
$$
f'(x) = 18\,\delta(x-3) + g(x).
$$
Answer: You wrote $9$ for $9\phi (3)$ and $27$ for $-27\phi (3)$ So you get $-9\phi (3)+2 \begin {align} \int\limits_3^{\infty} x\phi(x)dx \end {align}+27\phi (3)$ $+3\begin {align} \int\limits_3^{\infty} x^{2}\phi (x)dx \end {align}$. Hence the derivative is $=18\delta_3+2x\chi_{(-\infty, 3)}+3x^{2}\chi_{(3,\
\infty)}$.
Notation: $\delta_3(\phi)=\phi(3)$ for any test function $\phi$.
Comment: Yeah, you're right about the $\phi(3); $ I've edited my post.

I think I'm overlooking something simple, but how did you get $\int_3^\infty x\phi(x)=x\chi(3,\infty)$ and $\int_3^\infty x^2\phi(x)=x^2\chi(3,\infty)$?

Since we don't know anything about $\phi$, except that it's a test function, how do we know those integrals?
Comment: @Bears An intergal of the form $\int g(x) \phi(x)$ corresponds the function $g$ treated as a generalized function.
Comment: Yeah, that much makes sense.
Maybe I'm just understanding your notation incorrectly. Are you using $\chi$ as a characteristic/indicator function?
Comment: Yes, $\chi_A(x)=1$ for $x \in A$ and $0$ for $x \notin A$.


Problems uploading lambda function code on Amazon Web Services console

Question: I'm trying to build an Alexa prototype for a client using this tutorial : https://developer.amazon.com/public/community/post/Tx3DVGG0K0TPUGQ/New-Alexa-Skills-Kit-Template:-Step-by-Step-Guide-to-Build-a-Fact-Skill
I am getting errors when I upload the zip file with the Alexskill.js and index.js files in it. I believe these are in the system itself and nothing to do with my code. Here is a screen grab of my browser console:
https://developer.amazon.com/public/community/post/Tx3DVGG0K0TPUGQ/New-Alexa-Skills-Kit-Template:-Step-by-Step-Guide-to-Build-a-Fact-Skill
There's no way to see if the zip file you upload has been successful (frustrating) - but this looks bad right?
Obviously, when I try and test the lambda function I get this error:
<code>{
  "errorMessage": "Cannot find module 'index'",
  "errorType": "Error",
  "stackTrace": [
    "Function.Module._load (module.js:276:25)",
    "Module.require (module.js:353:17)",
    "require (internal/module.js:12:17)"
  ]
}
</code>
I desperately need to get this working. Has anyone got the code in one file that I can use to do this using the inline code editor? I am using the FactSkill demo which is very basic.
Answer: This is one of those 'I want to kick myself around the room' moments. In this article it tells you to download the ZIP archive from GIT and then upload it to the lambda control panel. When you do that on a mac it unzips it into a folder for you. I then zipped that folder back up and uploaded it. That was my problem ...
You need to zip the two files inside the folder and not the folder itself!
Then it can see the module from the archive.
DOH!!!
But, still ... Amazon, wtf is going on with all those errors?
Comment: Yep. That's what I figured it was, but you worked it out yourself. There is the same problem with Java Lambda functions that people run into all the time as well. It is very particular about the zip file format.


How to show difference between views page and views block

Question: I have created a view page, to this same page I will add a block by clicking on add button. So whatever changes I will do in the block is affecting the view page also. So how can I configure this, so that my block changes should apply only to block and not to page.
Answer: Using This page override  option in view field configuration instead of All display
Comment: Thank you Vamsi.. Is this work for adding an attachment to that same view instead of block?
Comment: I think it will work. @Suraj


ChromeOptions not working for me in selenium

Question: new to selenium. For some reason ChromeOptions are not working. What am I doing wrong here?
I've tried a few different things I've found here on stackoverflow but nothing is working. It doesn't load the proper profile. Thanks in advance.
import undetected_chromedriver as uc
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.support.wait import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC

if __name__ == '__main__':
    email = "#"
    password = "#"

    options = webdriver.ChromeOptions()
    options.add_argument(r'--users-data-dir=C:\Users\dsfgdfs\AppData\Local\Google\Chrome\User Data\Profile 65')

    browser = uc.Chrome(options=options,
    )
    browser.get('https://accounts.google.com/signin/v2/identifier?continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&service=mail&sacu=1&rip=1&hl=en&flowName=GlifWebSignIn&flowEntry=ServiceLogin')

    browser.find_element(By.ID, 'identifierId').send_keys(email)

    browser.find_element(
        By.CSS_SELECTOR, '#identifierNext > div > button > span').click()

    password_selector = "#password > div.aCsJod.oJeWuf > div > div.Xb9hP > input"

    WebDriverWait(browser, 10).until(
        EC.visibility_of_element_located((By.CSS_SELECTOR, password_selector)))

    browser.find_element(

        By.CSS_SELECTOR, password_selector).send_keys(password)

    browser.find_element(
        By.CSS_SELECTOR, '#passwordNext > div > button > span').click()

Answer: You have missing import
from selenium.webdriver.chrome.options import Options

Comment: Hello, I've added this to my import but still the options are not being imported.
Comment: checkout this [https://stackoverflow.com/questions/63681266/selenium-configuration-chromedriver-works-but-chromeoptions-not-found]


Divs filhas extrapolam Div pai

Question: Estou tentando fazer a DIV pai ser preenchida por todas as DIVS filhas, porém já tentei várias coisas e não funciona. Acaba sempre a DIV pai sendo extrapolada pelas filhas.
EDIT: Testei meu código exemplo e fica assim:
DIV pai = #corpo;
DIVs filhas = todas as DIVS dentro de #corpo

* {
    margin: 0;
    padding: 0;
}

nav {
    background: blue;
    width: 100%;
    height: 34px;
    display: flex;
    justify-content: space-between;
}

#corpo {
    width: 100%;
    height: 100%;
    background: red;
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: visible;
}

#corpo div {
    clear:both;
    border: 1px solid gray;
    border-radius: 8px;
    margin-top: 5px;
    margin-bottom: 5px;
    text-align: center;
    width: 200px;
    height: 200px;
}

#destaques {
    background: yellow;
    width: 200px;
    height: 30px;
}

.post {
    background: lightgray;
}

.post h1 {
    margin-bottom: 30px;
    font-size: 14px;
}

.post img {
    width: 200px;
    height: 100px;
    border-top-left-radius: 8px;
    border-top-right-radius: 8px;
}

#footer {
    background: lightgreen;
    clear: both;
}

Logo

Search

Neutralidade da rede: planos com whatsapp gratuito são ou nao ilegais?

11 MAR 17

Neutralidade da rede: planos com whatsapp gratuito são ou nao ilegais?

11 MAR 17

Neutralidade da rede: planos com whatsapp gratuito são ou nao ilegais?

11 MAR 17

Neutralidade da rede: planos com whatsapp gratuito são ou nao ilegais?

11 MAR 17

Neutralidade da rede: planos com whatsapp gratuito são ou nao ilegais?

11 MAR 17

 Footer

Comment: Não entendi. Reproduzi aqui e não notei nada de estranho.
Comment: Não ficou claro o que você deseja. Você quer o header/footer fixos? agrupar os pontos no body? tornar a pagina responsiva?
Comment: Parece estar funcionando corretamente. O que você quer dizer com extrapolar?
Comment: Não entendi muito bem o erro que você esta tendo, testei o código e parece estar certo!
Comment: @WillianTártaro testei meu codigo de exemplo e tirei um foto mostrando o problema.
Comment: @LeonFreire O que eu queria era que o #corpo crescesse junto com as divs internas.
Comment: @TobiasMesquita O que eu queria era que o #corpo crescesse junto com as divs internas.
Comment: @TheBiro  testei meu codigo de exemplo e tirei um foto mostrando o problema.
Comment: @Amzero, tente aplicar um `clearflix` no `#corpo`, como por exemplo.: `.clearfix:after {
    content:"";
    display:block;
    clear:both;
}`
Comment: @Amzero da uma olhada aqui https://jsfiddle.net/WillianTartaro/mg9rv9c1/, eu adicionei varios posts e o corpo esta crescendo junto, mas tenta colocar aquele overflow: auto que o cara falou ali na resposta!
Comment: Aqui cresceu a #corpo. Experimentou limpar o cache? (=
Comment: @WillianTártaro de acordo com o seu link está normal. Porém eu conferi o codigo no firefox e chrome e estão da mesma maneira daquela foto do post. Vou reconferir tudo denovo.
Comment: @Aline Não. Vou tentar.
Answer: Aqui aparece tudo normal, mas tenta aplicar um overflow: auto no #corpo.
EDIT:
Retire o height: 100%;.
Comment: @Amzero Como você pode ver, já estava funcionando para o de todo mundo, menos o seu. Não vou saber te explicar direito o porque disso, mas só me lembrei de já ter acontecido de forma similar comigo. Se eu tivesse que forçar uma explicação, eu diria que o `height: 100%;` estava fixando a sua div em uma altura que não corresponde ao total. O `overflow: auto;` força ele a se adaptar aos filhos. É mais prático assim.
Comment: @Amzero Tenta o `overflow: auto;` mas tirando o `height: 100%;`
Comment: O overflow de #corpo já estava em visible. Isso obriga os browser a mostrarem. O auto deixa o browser escolher mostrar ou não. Por duvidas testei o auto e não funcionou.
Comment: Tirei o overflow e o height: 100%. Funcionou! Não entendi nada. O problema era o height: 100%. Sabe o por que?
Comment: Saquei. Muito Obrigado pela ajuda.
Answer: Complementando a resposta do @LeonFreire
A causa do problema é o overflow: visible junto ao `height: 100%, mas...
Por quê?
O height: 100% pega 100% da tela de acordo com seu elemento pai, e digamos...
Qual o tamanho do seu div #corpo? 100%.
Ok, não muito claro, o 100% foi definido de acordo com o tamanho da viewport(área visível da tela), pois o body tem esse tamanho (100% da tela) no carregamento, que é fixo(lê-se absoluto).
O overflow: visible, obriga o conteúdo a aparecer, mesmo que o pai não tenha tamanho para isso, por isso o conteúdo "extrapolava", pois o conteúdo tinha um tamanho maior que a div, que era do tamanho da tela visível.
Mas sabe o real motivo desse "bug"?
Nosso navegador não está utilizando as especificações corretas do HTML(5), pela falta do <!DOCTYPE html>, ele chutou um com base no seu html[1].
Em alguma versão a tag  tem inicialmente o tamanho da viewport e não o tamanho do seu conteúdo, fazendo com que ele dê esse problema, o 100% no #corpo seria o tamanho do  travando ele nesse tamanho, não sendo um valor relativo (no body, na minha tela o body tinha um valor fixo de ~700px, logo #corpo tem o tamanho de 700px), pois por padrão, um valor relativo (%) dentro de outro é ignorado pois não é possível fazer os cálculos.
Então se o valor ficava travado na tamanho da viewport, você tem o problema de o contéudo da div ultrapassar o tamanho da div, sendo necessário o overflow pra mostrar, mas aí tá o problema, o overflow:visible deixa as coisas "extrapolarem" e foi resolvido o problema removendo o height:100% porque você volta o valor da div #corpo para relativo ao conteúdo, e não ao tamanho fixo do .
Talvez tenha ficado confuso, mas é só pra dizer que faltava o <!DOCTYPE html> porque ele faz com que o  também tenha tamanho relativo ao conteúdo hehe
[1] Não sei exatamente qual o comportamento dos browsers quanto a omissão do DOCTYPE, e qual versão do DTD(Definição de Tipo de Documento) é utilizada.
Comment: Deu pra dar uma entendida aqui. E realmente eu peco em não colocar o  em meus arquivos html. Era justamente uma prática que eu já tinha em mente em corrigir, justamente pelo bootstrap que se não me engano, não funciona corretamente sem ele. Obrigado pela ajuda.

Divs filhas extrapolam Div pai


MySQL Query Optimization to get montly report

Question: I need to optimize a query.
Script return a simple table result like this below.
I'm like to speed up results, maybe one solution is consolidating montly query into only one.
What is the best and correct way to get the listing with good speed?
TABLE
YAER 2018
ID     NAME    JAN   FEV   MAR   APR   MAY   JUN   JUL   AUG   SEP   OCT   NOV   DEC
00001  PAUL    OK    OK    OK    OK    -     OK    -     -     -     -     -     -
00002  MARK    OK    OK    OK   -     -    - OK    -     -     -     -     -     -
00003  JACK    OK    -     -    -     -    - OK    -     -     -     -     -     -
more 50K lines

My Database is simple
 USERS
  user_id
  user_name

 DOCUMENTS
  document_id
  document_user_id
  document_date
  document_file

First, I get a a users, in this way
$query_users = " SELECT user_id, user_name FROM users ";
$res_users = mysqli_query($mysqli,$query_users) or die(mysqli_error($mysqli));

And create a table with a while

        ID
            NAME
            JAN
            FEB
            MAR
            APR
            MAY
            JUN
            JUL
            AUO
            SEP
            OCT
            NOV
            DEC

<?php
 while($row = mysqli_fetch_assoc($res_users)) {
 $user_id = $row['user_id'];
 $user_name = $row['user_name'];
?>

      <?php echo $user_name; ?>

// For each month I run this query to check if user have document on year
            <?
            // --------------------------------------------------------------------------------------------
            // GET JAN DOCS
            // --------------------------------------------------------------------------------------------
            $query_doc_month_01 = "
                SELECT document_id, document_date,
                SUM(documento_date) AS total_documents
                FROM documents
                WHERE document_user_id = '$user_id'
                AND document_date = '$year-01-00'
           LIMIT 1
            ";

            $res_doc_month_01 = mysqli_query($mysqli,$query_doc_month_01) or die(mysqli_error($mysqli));

            while($row_month_01 = mysqli_fetch_assoc($res_doc_month_01)) {
                $document_month_01_id = $row_month_01['document_id'];

            ?>
            <td <? if ($document_month_01 == '') { echo 'bgcolor="#f1f1c1"'; } ?>>
            <? if ($document_month_id == '') { echo '- - -'; } else { echo $document_month_01_id; } ?>

            <?php
                }
            ?>

    <?
            // --------------------------------------------------------------------------------------------
            // SAME ABOVE TO GET FEB DOCS
            // SAME ABOVE TO GET MAR DOCS
            // ETC ETC
            // --------------------------------------------------------------------------------------------
        ?>

        <?php
            }
            mysqli_close($mysqli);
            ?>

Comment: Where is `$year` initialized?
Comment: Previous page $year= '2018'; I edit and add
Answer: Looks like you could use a JOIN on your first query and get all the data at once. This way you wouldn't be doing another query in the loop.
Select user_id, user_name, document_id, document_date, document_file from users u INNER JOIN documents on d.document_user_id = u.user_id order by u.user_id

If you still want to show users with no documents use a left JOIN instead of inner.
By only using one query it should be a lot faster. You the  set a var for the user I'd and create a new row when it changes.
Can I also suggest you don't prefix your columns with the table name. It's redundant in my opinion. Just document.file would be enough to know other than document.document_file.
Typing on a phone, sorry if any typos.
Answer: Currently you're doing this:
Query with N results
for each N results you're performing another query, times twelve.
Which means you're flooding the database with a significant amount of query requests. Use an inner-join.
This isn't the complete query but it'll help you get started:
 SELECT u.user_id, u.user_name
 FROM users U INNER JOIN documents D
 ON D.document_user_id = u.user_ID

Do this with either one, or at most 12 queries if you must.
Avoid making an insane amount of requests.
Answer: Try this:
SELECT user_id, user_name, YEAR(document_date) as year, MONTH(document_date) as month, COUNT(*)
FROM users
LEFT JOIN documents ON (document_user_id = user_id)
GROUP BY user_id, year, month

This should return one row for each user having documents on a specific month of a year, if no documents found nothing will be returned, you can check and display empty data for the non-returned rows


Non-existence claims making use of the axiom of regularity

Question: We have that an intersection with the empty set is empty,
$$\forall x.\, \varnothing \cap x = \varnothing$$
and so with the witness $\varnothing$ for $y$, we get
$$\forall x.\, \varnothing\in x \rightarrow \exists y.\, (y\in x \land y \cap x = \varnothing)$$
and so in particular
$$\forall x.\, \varnothing\in x \rightarrow \left(x \neq \varnothing \rightarrow \exists y.\, (y\in x \land y \cap x = \varnothing)\right)$$
So every set holding the empty set is regular in the sense given by the axiom of regularity.
Now if we have a theory allowing us to form what would naturally be denoted as
$$x=\{x, \varnothing\},$$
(e.g. via allowing for comprehensions over a predicate $z=\varnothing\ \lor z \in x$, in which however the definiendum $x$ would notably depend on $x$ itself, calling for the appropriate axioms)
then we got an infinite descending chain, $x\in x$.
As such, is the active non-existence claim I saw occasionally here on SE as well as in the third sentence of the axiom of regularity  Wikipedia article wrong?

The axiom implies that no set is an element of itself (...)
Comment: Related (and also you can probably answer your question on your own from reading the answers there): https://math.stackexchange.com/questions/2537526/axiom-of-regularity-allows-for-this-set-be-an-element-of-itself
Answer: No, the set $x=\{x,\varnothing\}$ will still violate the Axiom of Regularity. Consider the set $X=\{x\}$ with $x=\{x,\varnothing\}$, then $X$ is nonempty, yet its only element $x$ does not have the property that $x\cap X$ is empty, since $x\cap X=\{x\}$.
Comment: @Nikolaj-K: When people talk about implications of the axiom of regularity, they normally are also assuming all of the other axioms of ZFC (and talking about what the axiom of regularity allows you to prove that you couldn't with just the other axioms).  The axiom of regularity on its own (with no other axioms) proves very little.
Comment: Okay, so the axiom of pairing is missing in the description?


How to show a text field upon hovering a button with just pure CSS?

Question: Is there a way to only use pure CSS code to show a text field when you hover a button?
<form id="demo">
    <input type="text" id="search-field" name="s" placeholder="Search">
    <input type="submit" id="search-icon">

</form>

The text field should be hidden and only shows up when you hover the button. I'm not sure it can be done through CSS only. :/
Comment: This looks like a usability nightmare. In the provided answers, you can't even click on the text field (though you can tab to it). Where are all these upvotes coming from?
Comment: which field would you like to show on hover?
Answer: Try this code:

#search-field {
    display: none;
}
#btn:hover + #search-field {
    display: inline-block;
}
<form id="demo">
    <input type="button" value="Hover" id="btn" />
    <input type="text" id="search-field" name="s" placeholder="Search" />
    <input type="submit" id="search-icon" />

</form>

Updated
Swap your inputs in the HTML and rearrange your elements using the order property and apply display:flex; to your container in CSS. That would solve it.

#search-field {
    visibility: hidden;
}
#search-icon:hover + #search-field {
    visibility: visible;
}
#demo {
    display: flex;
}
input:nth-child(2) {
    order: -1;
}
<form id="demo">
    <input type="submit" id="search-icon" />
    <input type="text" id="search-field" name="s" placeholder="Search" />

</form>

Check: https://stackoverflow.com/a/36118012/5336321
Comment: Just gave up on my codepen... about 30 lines of code and getting there... you do it in like 8... haha nice job
Comment: Nice, but why you used `input:nth-child(2)` instead of just `#search-field`. I didn't understand that part.
Comment: It works given with that new input. But can this work, #btn:hover + #search-field{ visibility:visible;} using the "submit" input type?
Comment: There are no selectors to do that in css but you can do this using flex and reversing the order https://jsfiddle.net/b7snbomk/ or use JS or jQuery
Comment: @user12109321358 you can place `submit` button before `input`
Comment: check my updated answer if that could help you get after this!
Comment: you can do as suggested by @Muhammad Usman if you're not bothered about the positions
Comment: Glad you value it @Ricky :)
Comment: Hitesh, thank you!! That worked!! And now I know how flex and order really works. :P Thanks!! :)
Comment: The input fields have 2 different ids so i triggered with the element selector `input`. instead you can use a class with same name `.class_name:nth-child(2)`
Comment: By the way, do the inputs need to be swapped?
Answer: You can swap the order of input[type="text"] and input[type="submit"] and then you can style input[type="text"] on hover of button as shown below.

#demo {
  position: relative;
  padding-top: 30px;
}
#search-field {
  transition: opacity 0.25s linear;
  position: absolute;
  opacity: 0;
  left: 0;
  top: 0;
}

#search-icon:hover + #search-field {
  opacity: 1;
}
<form id="demo">
  <input type="submit" id="search-icon" />
  <input type="text" id="search-field" name="s" placeholder="Search" />

</form>


Dart - Creating new objects changes old objects

Question: Running this in DartPad, why does object a get updated by succeeding declarations and instantiations of the same object type? How do I prevent the first objects from being updated?
void main() {
  SampleClass a = SampleClass(publicParam: 'A');
  print('1. a: ${a.getPrivateProperty}');

  SampleClass b = SampleClass(publicParam: 'B');
  print('2. a: ${a.getPrivateProperty}');
  print('3. b: ${b.getPrivateProperty}');

  SampleClass(publicParam: 'C');
  print('4. a: ${a.getPrivateProperty}');
  print('5. b: ${b.getPrivateProperty}');
}

class SampleClass {
  final String publicParam;
  static late String _privateProperty;

  SampleClass({
    required this.publicParam,
  }) {
    _privateProperty = publicParam;
  }

  // Getter
  String get getPrivateProperty => _privateProperty;
}

Output:
1. a: A
2. a: B
3. b: B
4. a: C
5. b: C

Can someone please help me as detailed as possible? Thank you so much. I think it's got to do with the constructor but I'm not really sure.
Answer: The cause is that your _privateProperty property is static, which means it is shared across all instances of the class.
I do not know your motivation of having another private property, but assuming you need it I would rewrite your class like this:
class SampleClass {
  final String publicParam;

  final String _privateProperty;

  SampleClass({
    required this.publicParam,
  }) : _privateProperty = publicParam;

  // Getter
  String get getPrivateProperty => _privateProperty;
}

Comment: Thank you so much. I needed a private property so that I can implement listeners to the changes to that property.