Lucid explanation for "numerical stability of matrix inversion" in ridge regression and its role in reducing overfit

Question: I understand that we can employ regularization in a least squares regression problem as
$$\boldsymbol{w}^* = \operatorname*{argmin}_w \left[ (\mathbf y-\mathbf{Xw})^T(\boldsymbol{y}-\mathbf{Xw}) + \lambda\|\boldsymbol{w}\|^2 \right]$$
and that this problem has a closed-form solution as:
$$\hat{\boldsymbol{w}} = (\boldsymbol{X}^T\boldsymbol{X}+\lambda\boldsymbol{I})^{-1}\boldsymbol{X}^T\boldsymbol{y}.$$
We see that in the 2nd equation, regularization is simply adding $\lambda$ to the diagonal of $\boldsymbol{X}^T\boldsymbol{X}$, which is done to improve the numerical stability of matrix inversion.
My current 'crude' understanding of numerical stability is that if a function becomes more 'numerically stable' then its output will be less significantly affected by the noise in its inputs. I am having difficulties relating this concept of improved numerical stability to the bigger picture of how it avoids/reduces the problem of overfitting.
I have tried looking at Wikipedia and a few other university websites, but they don't go deep into explaining why this is so.
Comment: You may find some value in the (mostly descriptive/intuitive rather than algebraic) discussion at [*Why does ridge estimate become better than OLS by adding a constant to the diagonal?*](http://stats.stackexchange.com/questions/118712/why-does-ridge-estimate-become-better-than-ols-by-adding-a-constant-to-the-diago/)
Comment: Ridge regression comes to mind.  [link](https://en.wikipedia.org/wiki/Tikhonov_regularization)
Answer: In the linear model $Y=X\beta + \epsilon$, assuming uncorrelated errors with mean zero and $X$ having full column rank, the least squares estimator $(X^TX)^{-1}X^TY$ is an unbiased estimator for the parameter $\beta$. However, this estimator can have high variance. For example, when two of the columns of $X$ are highly correlated.
The penalty parameter $\lambda$ makes $\hat{w}$ a biased estimator of $\beta$, but it decreases its variance. Also, $\hat{w}$ is the posterior expectation of $\beta$ in a Bayesian regression with a $N(0,\frac{1}{\lambda}I)$ prior on $\beta$. In that sense, we include some information into the analysis that says the components of $\beta$ ought not be too far from zero. Again, this leads us to a biased point estimate of $\beta$ but reduces the variance of the estimate.
In a setting where $X$ high dimensional, say $N \approx p$, the least squares fit will match the data almost perfectly. Although unbiased, this estimate will be highly sensitive to fluctuations in the data because in such high dimensions, there will be many points with high leverage. In such situations the sign of some components of $\hat{\beta}$ can determined by a single observation. The penalty term has the effect of shrinking these estimates towards zero, which can reduce the MSE of the estimator by reducing the variance.
Edit: In my initial response I provided a link to a relevant paper and in my haste I removed it. Here it is:
http://www.jarad.me/stat615/papers/Ridge_Regression_in_Practice.pdf
Comment: In its current form this is really more of a comment; do you think you could flesh it out into a substantive answer?
Comment: The bottom of p. 5 right/top of p. 6 left, pertaining to Figure 3, contains the key discussion for the question asked in this post.
Comment: This is all correct, but I am not sure it answers the OP's question.
Comment: amoeba, see my comment above, which refers to the link which has been subsequently edited out from Eric Mittman's answer, http://www.jarad.me/stat615/papers/Ridge_Regression_in_Practice.pdf .
Answer: Numerical stability and overfitting are in some sense related but different issues.
The classic OLS problem:
Consider the classic least squares problem:
$$\operatorname*{minimize}(\text{over $\mathbf{b}$}) \quad(\mathbf y-X\mathbf{b})^T(\boldsymbol{y}-X\mathbf{b})  $$
The solution is the classic $\hat{\mathbf{b}} = (X'X)^{-1}(X'\mathbf{y})$. An idea is that by the law of large numbers:
$$ \lim_{n \rightarrow \infty} \frac{1}{n} X'X \rightarrow \mathrm{E}[\mathbf{x}\mathbf{x}'] \quad \quad \quad  \lim_{n \rightarrow \infty} \frac{1}{n} X'\mathbf{y} \rightarrow \mathrm{E}[\mathbf{x}y]$$
Hence the OLS estimate $\hat{\mathbf{b}}$ also converges to $\mathrm{E}[\mathbf{x}\mathbf{x}']^{-1}\mathrm{E}[\mathbf{x}y]$. (In linear algebra terms, this is the linear projection of random variable $y$ onto the linear span of random variables $x_1, x_2, \ldots, x_k$.)
Problems?
Mechanically, what can go wrong? What are possible problems?

For small samples, our sample estimates of $\mathrm{E}[\mathbf{x}\mathbf{x}']$ and $\mathrm{E}[\mathbf{x}y]$ may be poor.
If columns of $X$ are collinear (either due to inherent collinearity or small sample size), the problem will have a continuum of solutions! The solution may not be unique.

This occurs if $\mathrm{E}[\mathbf{x}\mathbf{x}']$ is rank deficient.
This also occurs if $X'X$ is rank deficient due to small sample size relative to the number of regressor issues.

Problem (1) can lead to overfitting as estimate $\hat{\mathbf{b}}$ starts reflecting patterns in the sample that aren't there in the underlying population. The estimate may reflect patterns in $\frac{1}{n}X'X$ and $\frac{1}{n}X'\mathbf{y}$ that don't actually exist in $\mathrm{E}[\mathbf{x}\mathbf{x}']$ and $\mathrm{E}[\mathbf{x}y]$
Problem (2) means a solution isn't unique. Imagine we're trying to estimate the price of individual shoes but pairs of shoes are always sold together. This is an ill-posed problem, but let's say we're doing it anyway. We may believe the left shoe price plus the right shoe price equals \$50, but how can we come up with individual prices? Is setting left shoe prices $p_l = 45$ and right shoe price $p_r = 5$ ok? How can we choose from all the possibilities?
Introducing $L_2$ penalty:
Now consider:
$$\operatorname*{minimize}(\text{over }\mathbf{b})\quad (\mathbf y-X\mathbf{b})^T(\boldsymbol{y}-X\mathbf{b}) + \lambda\|\boldsymbol{b}\|^2 $$
This may help us with both types of problems. The $L_2$ penalty pushes our estimate of $\mathbf{b}$ towards zero. This functions effectively as a Bayesian prior that the distribution over coefficient values are centered around $\mathbf{0}$. That helps with overfitting. Our estimate will reflect both the data and our initial beliefs that $\mathbf{b}$ is near zero.
$L_2$ regularization also always us to find a unique solution to ill-posed problems. If we know the price of left and right shoes total to $\$50$, the solution that also minimizes the $L_2$ norm is to choose $p_l = p_r = 25$.
Is this magic? No. Regularization isn't the same as adding data that would actually allow us to answer the question. $L_2$ regularization in some sense adopts the view that if you lack data, choose estimates closer to $0$.


Clarification of the intuition behind backpropagation

Question: I've been taking some time to try and understand the computations and mechanics of the machine learning algorithms I use in my day to day life.
Studying the backpropagation literature on the CS231n course, I want to make sure that I have understood the chain rule correctly before continuing my study.
Say I have the sigmoid function:
$$\sigma(x) = \frac{1}{1+e^{-x}}$$
in this case, $x=w0x0+w1x1+w2$
We can write this function as a computational graph (Ignoring the coloured values for now):

We can group the modularised nodes for computing the gradient of the sigmoid $w.r.t.$ its input into a single derivation:
$$\frac{d\sigma(x)}{d x}=(1 - \sigma(x))\sigma(x)$$
First, we perform forward propogation to obtain the outputs at each unit:
w = [2,-3,-3]
x = [-1, -2]

# Compute the forward pass
product = [w[0]*x[0]+w[1]*x[1]+w[2]]
activation = 1 / 1 + math.exp(-product)

To calculate the gradient of the activation, we can use the above formula:
grad_product = (1 - activation) * activation

Where I feel I may be getting confused, or, at least less intuitive, is calculating the gradient for x and w:
grad_x = [w[0] * activation + w[2] * activation]
grad_w = [x[0] * activation + x[1] * activation + 1 * activation]

More concretely, I'm confused as to why we apply 1 * activation when calculating the gradient $w.r.t.$ w.
It may help the reader spot my theoretical difficulty if I try to reason the calculations of both x and w's gradients...
The gradient of each $x_i$ is given by the corresponding $w_i$ under the rule of multiplication: if $f(x,y) = f(xy)$ then $\frac{\partial f}{\partial x}=y$. Then, using the chain rule, we multiply these local gradients by the gradient of the successive node (for each path of $x$) to obtain its gradient w.r.t. the function output. This explains the computation for computing $\partial x$.
The gradient of $w_i$ is given in the exact same (inverse) way as explained above with the additional 1 * activation. I believe this additional expression is coming from $w_2$? The local gradient of an addition unit is always 1 for all inputs and the multiplication with activation is a result of chaining the gradient to the function's output?
I'm partially confident with my current understanding but would appreciate if someone could clarify my current intuition on the computations involved in computing gradients.
Answer: The best way to understand backpropagation for a programmer is in terms of the chain rule as a recursion.
Here's the chain rule. You have a nested function expression $y=f(g(x))$. First you look at it as two different functions:
$$f(x)\\g(x)$$
When you do forward propagation it's nothing but this psudo code:
$$t=g(x)\\
y=f(t)$$
Now, if you want to take a derivative, you apply a chain rule:
$$y'=f(g(x))'=f'g'$$
where $$f'=df(t)/dt$$ and $$g'=dg(x)/dx$$
This is basically a recursion on a nested structure. If $g(x)=g(h(x))$, then you simply apply the chain rule again, and keep doing it until you reach the bottom, i.e. the input layer in case of NN.
Here's an example, a one neuron: $$a=sigmoid(Wx+b)$$
You have two functions here: $sigmoid(x)$ and $Wx+b$.
If you have two layers of neurons it's not much different:
$$sigmoid(W_1*sigmoid(Wx+b)+b_1)$$
so you go backwards:
$$z=Wx+b\\a_1=sigmoid(z)\\z_1=W_1*a_1+b_1\\a_2=sigmoid(z_1)$$
Answer: What you want to compute, is
$$\frac{\partial \sigma(\hat{x})}{\partial \vec{x}}=\left[\frac{\partial \sigma(\hat{x})}{\partial x_0},\frac{\partial \sigma(\hat{x})}{\partial x_1}\right]$$
and
$$\frac{\partial \sigma({\hat{x}})}{\partial \vec{w}}=\left[\frac{\partial \sigma(\hat{x})}{\partial w_0},\frac{\partial \sigma(\hat{x})}{\partial w_1},\frac{\partial \sigma(\hat{x})}{\partial w_2}\right]$$
knowing that $\hat{x}$ is in fact a function of those variables, as $\hat{x}=w_0x_0+w_1x_1+w_2$.
You can use the chain rule to compute this as:
$$\frac{\partial \sigma(\hat{x})}{\partial x_0}=\frac{\partial \sigma(\hat{x})}{\partial \hat{x}}\frac{\partial \hat{x}}{\partial x_0}$$
You already know $\frac{\partial \sigma(\hat{x})}{\partial \hat{x}}$
as its
$$\frac{\partial \sigma(\hat{x})}{\partial \hat{x}}=(1-\sigma(\hat{x}))\sigma(\hat{x})$$
and the second derivative is trivial (its just a polynomial! $\frac{\partial \hat{x}}{\partial x_0}=w_0$). You now only need to compute for the 5 partial derivatives. In short:
$$\frac{\partial \sigma(\hat{x})}{\partial \vec{x}}=\left[\frac{\partial \sigma(\hat{x})}{\partial \hat{x}}w_0,\frac{\partial \sigma(\hat{x})}{\partial \hat{x}}w_1\right]$$
$$\frac{\partial \sigma(\hat{\hat{x}})}{\partial \vec{w}}=\left[\frac{\partial \sigma(\hat{x})}{\partial \hat{x}}x_0,\frac{\partial \sigma(x)}{\partial \hat{x}}x_1,\frac{\partial \sigma(\hat{x})}{\partial \hat{x}}\right]$$


How to do back selector same as android market UI?

Question: How to do this kind of events
when I pressed the Preferences Button I need to change only the background color of the arrow.

what I did is when I put
 android:background="@null" for TextView is not working showing the whole view with blue color background.
<LinearLayout
                android:layout_width="wrap_content"
                android:layout_height="match_parent"
                android:layout_centerVertical="true"
                android:background="@drawable/btn_selector"
                android:clickable="true" >

                <ImageView
                    android:id="@+id/back_arrow"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:src="@drawable/ic_ab_back_holo_dark" />

                <TextView
                    android:id="@+id/settings_title"
                    android:layout_width="wrap_content"
                    android:layout_height="match_parent"
                    android:layout_marginLeft="10dp"
                    android:background="@null"
                    android:layout_toRightOf="@id/back_arrow"
                    android:gravity="center_vertical"
                    android:text="@string/settings_title"
                    android:textColor="@color/white"
                    android:textSize="22sp" />
            </LinearLayout>

Answer: Use the state list drawable for the background of the ImageView( or change to button if you like). then you can set the background of the button in different state ( for example, when pressed).
Reference
Answer: Just set the textview normally, black background (#000000) and have an imageButton set the src as a drawable selector:
    <ImageButton android:id="@+id/imageButton" android:layout_width="fill_parent"
         android:layout_height="wrap_content" android:background="@null" android:gravity="center_horizontal"
         android:paddingLeft="50dp" android:paddingTop="25dp" android:src="@drawable/button_selector"/>

selector:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
    <item android:state_pressed="true"
        android:drawable="@drawable/button_pressed"/>
    <item android:state_pressed="false"
            android:drawable="@drawable/button_rested"/>
    <item android:state_enabled="false"
            android:drawable="@drawable/button_disabled"/>
</selector>


How to create macro to split columns and rows?

Question: I have a long worksheet which include 3 columns:
Column A = Invoice number
Column B = Receive amounts
Column C - Pay amounts
Each number in column A need to split to two rows: Pay and Receive.
For Pay will take the associate number from column C
For receive will take associate number from column B
Comment: If you look into powerquery, you can set your data up as a table, then inside of this table go to  powerquery or data(2016) tab > query from table , then in the window that appears select the last 2 columns and right click unpivot columns
Comment: Thanks for the reply. Where is this powerquery? I have Office 2013
Comment: 2013 it is a free microsoft [add-in](https://www.microsoft.com/en-gb/download/details.aspx?id=39379) - if a work machine check that you are allowed to install.
Comment: Sorry cannot install addins. Firewall restrictions etc...It is forbidden by a company policy. So is there any way to create the result just like my example?
Comment: You could enquire with your IT dept whether they will allow as is a microsoft not third party add-in.
Answer: Suppose your data are in Sheet1, and we will let the splited data in Sheet2. Here is a simple solution:
Sub Split_Column()

Set st1 = ThisWorkbook.Sheets("Sheet1")
Set st2 = ThisWorkbook.Sheets("Sheet2")

j = 1
For i = 1 To st1.UsedRange.Rows.Count

    st2.Cells(j, 1) = st1.Cells(i, 1)
    st2.Cells(j, 2) = "Pay"
    st2.Cells(j, 3) = st1.Cells(i, 3)
    j = j + 1
    st2.Cells(j, 1) = st1.Cells(i, 1)
    st2.Cells(j, 2) = "Receive"
    st2.Cells(j, 3) = st1.Cells(i, 2)
    j = j + 1

Next

End Sub

Comment: Thank you both. This is what I was looking for. :)
Answer: I have created simple VBA code to split the rows into column from sheet1 to sheet2 of the Activeworkbook. you can modify the code as per need.
Dim sel As Range, b As Range
Dim rcount As Integer: rcount = 1
ActiveWorkbook.Sheets(2).Range("A:C").Delete Shift:=xlDown
With ActiveWorkbook.Sheets(1)
Set sel = .Range("A2:C" & .UsedRange.Rows.Count)
For Each b In sel.Rows
ActiveWorkbook.Sheets(2).Cells(rcount, 1).Value = b.Value2(1, 1)
ActiveWorkbook.Sheets(2).Cells(rcount, 2).Value = .Cells(1, 2).Value
ActiveWorkbook.Sheets(2).Cells(rcount, 3).Value = b.Value2(1, 2)
ActiveWorkbook.Sheets(2).Cells(rcount + 1, 1).Value = b.Value2(1, 1)
ActiveWorkbook.Sheets(2).Cells(rcount + 1, 2).Value = .Cells(1, 3).Value
ActiveWorkbook.Sheets(2).Cells(rcount + 1, 3).Value = b.Value2(1, 3)
rcount = rcount + 2
Next
End With


MySQL Delete Query

Question: I am having some trouble with a MySQL query. I have a field in a table called "ID", I want a query that deletes all rows in that table unless they have a certain ID, I want more to be able to define more than 1 ID in the query.
Any ideas?
Answer: DELETE FROM your_table
WHERE id NOT IN (1,2,3)

Answer: DELETE
FROM yourTable
WHERE yourID NOT IN (1,2,3,4) -- place your list here

Or of you do not want to list your ids, you can use a subquery which would contain the list of ids you want to keep:
DELETE
FROM yourTable
WHERE yourID NOT IN (SELECT * FROM yourTable WHERE ...)

Answer: delete from your_table where id not in (1, 2, 4)

Answer: You should try this query:
DELETE FROM tablename WHERE ID NOT IN ('1','2','3');

Answer: This should do the job
delete from TABLE_NAME where id not in (1,2,3,4,5,6)

of (1,2,3,4,5...) is a list of id's you want to save.
Answer: You can also use this with some extra conditions:
    delete from your_table_name where id not in (select id from your_table_name where necessary=false)

MySQL Delete Query


Conditional probability?

Question: Let's consider this hypothetical game, in which there are 10 cards, and one of the cards is marked as a winning card. We put the cards in a stack and pass them around in a circle, each person choosing one card at random and passing the remaining stack on, until none are left.
What is the probability that I pick the winning card? Initially, for the first person choosing, the probability is 1/10. Does the probability increase with successive turns, because the chances that the winning card is picked is smaller at the beginning? Or is the probability the same 1/10 throughout the whole game? Is it more beneficial to go later than to go first? I tried to think about this through an expected value lens and got all confused.
Comment: A bit confusing in the sense that it depends on how many friends are participating. For example if there are five friends, then each has 2 cards. Also, it depends on whether or not the cards are face up or face down. If the cards are face up, the odds must account for the additional information of not getting the winning card at each step. If the cards are hidden, for five friends, and are not looked at until all the cards are dealt, then the odds are one in five for each player. So, in effect, the conditional probability depends on the conditions of the game.
Answer: The probability that the first player wins is $1/10$.
The probability that the second player wins is the probability to have the winning card still in the stack (i.e. the probability that the first player did not win - $1-1/10=9/10$) times the probability that the second player will draw the winning card from the stack of 9 cards (i.e. $1/9$). Multiply those and you see that you end up with $9/10 \cdot 1/9 = 1/10$, same as the first player.
Similarly, the third player has a probability of $9/10 \cdot 8/9 = 8/10$ to get a stack with the winning card in it, but if they get it, they have a probability of $1/8$ to draw the winning card; again, it multiplies to $1/10$.
This holds on all the way until the 10th player (of course, the 11th player has no probability to draw the winning card).
For your intuition, consider this: The later players have a lower probability to have the winning card still in the stack (because more players drew from it), but if it's there - they have a higher probability to draw it (because the stack is smaller).
For another bit of intuition, consider that this process is no different than assigning cards at random... would you expect any other probability than $1/10$?
Answer: The probability is always 1/10 unless the players look at the card and then you know that it's not a winning card (or is).  This is not really a conditional probability problem because you don't condition on anything and no new information is made available until all 10 player, presumably reveal their cards after everyone has drawn.

Conditional probability?


postfix send double mail when mail is forwarded

Question: postfix will forward two mail to user when i configure autoreply, sender_bcc and always_bcc.
i have used postfix with dovecot and mysql for virtual user configuration. i dont found where is the problem is.
when i send mail from email@example.com to email@example.com and
in main.cf i have
always_bcc=pranav@sufalam. following are the log.
May 30 07:25:27 sufalammail postfix/smtpd[7827]: connect from unknown[192.168.0.201]
May 30 07:26:58 sufalammail postfix/smtpd[7827]: 69139222DE: client=unknown[192.168.0.201]
May 30 07:27:13 sufalammail postfix/cleanup[7839]: 69139222DE: message-id=<email@example.com>
May 30 07:27:13 sufalammail postfix/qmgr[7824]: 69139222DE: from=<email@example.com>, size=363, nrcpt=2 (queue active)
May 30 07:27:14 sufalammail postfix/pickup[7823]: 050C4222E0: uid=491 from=<firstname.lastname@example.com>
May 30 07:27:14 sufalammail postfix/cleanup[7839]: 050C4222E0: message-id=<email@example.com>
May 30 07:27:14 sufalammail postfix/qmgr[7824]: 050C4222E0: from=<email@example.com>, size=475, nrcpt=3 (queue active)
May 30 07:27:14 sufalammail postfix/pipe[7842]: 69139222DE: to=<firstname.lastname@example.com>, relay=dfilt, delay=93, delays=92/0.04/0/0.59, dsn=2.0.0, status=sent (delivered via dfilt service)
May 30 07:27:14 sufalammail postfix/pipe[7842]: 69139222DE: to=<firstname.lastname@example.com>, relay=dfilt, delay=93, delays=92/0.04/0/0.59, dsn=2.0.0, status=sent (delivered via dfilt service)
May 30 07:27:14 sufalammail postfix/qmgr[7824]: 69139222DE: removed
May 30 07:27:14 sufalammail postfix/virtual[7852]: 050C4222E0: to=<email@example.com>, relay=virtual, delay=0.16, delays=0.03/0.02/0/0.1, dsn=2.0.0, status=sent (delivered to mailbox)
May 30 07:27:14 sufalammail postfix/virtual[7852]: 050C4222E0: to=<email@example.com>, relay=virtual, delay=0.16, delays=0.03/0.02/0/0.11, dsn=2.0.0, status=sent (delivered to mailbox)
May 30 07:27:14 sufalammail postfix/virtual[7852]: 050C4222E0: to=<email@example.com>, relay=virtual, delay=0.16, delays=0.03/0.02/0/0.11, dsn=2.0.0, status=sent (delivered to mailbox)
May 30 07:27:14 sufalammail postfix/qmgr[7824]: 050C4222E0: removed
May 30 07:27:15 sufalammail postfix/smtpd[7827]: disconnect from unknown[192.168.0.201]

active entry of master.cf is show as below.
# ==========================================================================
# service type  private unpriv  chroot  wakeup  maxproc command + args
#               (yes)   (yes)   (yes)   (never) (100)
# ==========================================================================
smtp      inet  n       -        -       -       -       smtpd
#        -o content_filter=spamfilter:dummy
         -o content_filter=vacation:dummy
         -o content_filter=dfilt:dummy
#       -o cleanup_service_name= cleanupAF
vacation  unix  -       n        n       -       -       pipe
    flags=Rq user=vacation argv=/var/spool/vacation/vacation3.pl -f ${sender} -- ${recipient}
# flags=Rq user=vacation argv=/usr/bin/perl argv=/var/spool/vacation/vacation.pl -f ${sender} -- ${recipient}
#submission inet n       -       n       -       -       smtpd
#  -o smtpd_tls_security_level=encrypt
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
#  -o milter_macro_daemon_name=ORIGINATING
#smtps     inet  n       -       n       -       -       smtpd
#  -o smtpd_tls_wrappermode=yes
#  -o smtpd_sasl_auth_enable=yes
#  -o smtpd_client_restrictions=permit_sasl_authenticated,reject
relay     unix  -       -       n       -       -       smtp
        -o smtp_fallback_relay=
#       -o smtp_helo_timeout=5 -o smtp_connect_timeout=5
showq     unix  n       -       n       -       -       showq
error     unix  -       -       n       -       -       error
retry     unix  -       -       n       -       -       error
discard   unix  -       -       n       -       -       discard
local     unix  -       n       n       -       -       local
virtual   unix  -       n       n       -       -       virtual
lmtp      unix  -       -       n       -       -       lmtp
anvil     unix  -       -       n       -       1       anvil
scache    unix  -       -       n       -       1       scache
#
# ====================================================================
# Interfaces to non-Postfix software. Be sure to examine the manual
# pages of the non-Postfix software to find out what options it wants.
#
# Many of the following services use the Postfix pipe(8) delivery
# agent.  See the pipe(8) man page for information about ${recipient}
# and other message envelope options.
# ====================================================================
#
# maildrop. See the Postfix MAILDROP_README file for details.
#spamassassin unix -      n       n       -       -       pipe
#    flags=Rq user=spamd argv=/usr/bin/spamc -u ${user} -e /usr/sbin/sendmail -oi -f ${sender} ${recipient}
#dovecot    unix  -       n       n       -       -       pipe
#       flags=DRhu user=vmail:vmail argv=/usr/libexec/dovecot/deliver -d ${recipient}
#spamfilter unix         -       n       n       -       -       pipe
#   flags=Rq user=spamfilter argv=/usr/local/bin/spamfilter.sh -f ${sender} -- ${recipient}
#spamfilter unix -       n       n       -       -       pipe
#    flags=Rq user=vmail argv=/usr/bin/spamc -u ${user}@${domain} -e /usr/sbin/sendmail.postfix -oi -f ${sender} ${recipient}
dfilt     unix    -       n       n       -       -       pipe
    flags=Rq user=filterAlt argv=/etc/postfix/disclaimer -f ${sender} -- ${recipient}
#vacation  unix  -       n        n       -       -       pipe
#    flags=Rq user=vacation argv=/var/spool/vacation/vacation3.pl -f ${sender} -- ${recipient}
cleanupAF unix n - n - 0 cleanup
#-o email@example.com
#-o recipient_bcc_maps=mysql:/etc/postfix/mysql-virtual_always_bcc.cf

same way if i send mail to autoreply user then also sender get two mail.
Comment: Show us yer config, luv!
Comment: Oh, and relevant logs would be good, too.
Comment: Post the output of "postconf -n" in code tags so they're readable.
Answer: Most likely you have a content filter and the always_bcc is being called both before and after the content filter. Customise the smtpd either before or after the content filter to include
-o receive_override_options=no_address_mappings

(Note that options in master.cf can't contain spaces).
Answer: For me 'enable_original_recipient = No' in main.cf did the trick.:-)


Prove $V^+\oplus V^-=V \Longleftrightarrow f^2=1_V$

Question: Let $V$ be a $\mathbb{R}$ vector space, let $f\in \operatorname{End}(V)$. We define subsets of $V$ as follows:
$V^+=\{v\in V:f(v)=v\}$ and $V^-=\{v\in V:f(v)=-v\}$
We know that $V^+$ and $V^-$ are vector subspaces of V, and that their intersection is the zero vector.
Prove:
$V^+\oplus V^-=V \Longleftrightarrow f^2=1_V$

Proving $\Longrightarrow$
Hypothesis: $V^+\oplus V^-=V$
Then: $\forall v\in V:v=v^++v^- $ where $ v^+\in V^+ ,v^-\in V^-$
$f^2(v)=v\Rightarrow f(f(v))=f(f(v^++v^-))=f(f(v^+))+f(f(v^-))$ and because of the definition of the subsets (subspaces) $V^+$ and $V^-$ we get that:
$f(f(v^+))+f(f(v^-))=f(v^+)+f(-v^-)=v^++v^-=v$
$f^2(v)=v$ We have our proof.

Proving $\Longleftarrow$
Hypothesis: $f^2=1_V$
This means that $f^2(v)=f(f(v))=v$ ($f^2$ is bijective) therefore $f$ is bijective.

Well I don't know how to keep going, we are given a hint but I don't know how to apply it.
Hint we are given:
To prove $\Longleftarrow$, we must see if $\forall v\in V$ can be written as $v^++v^-$ where $ v^+\in V^+$ and $v^-\in V^-$. To get $v^+$ and $v^-$ we suppose that we have $v=v^++v^-$, then apply $f$ to the equality and we would get the second quation for $v^+$ and $v^-$
Not sure what to make out of this.
Answer: Note that the polynomial $X^2-1$ kills $f$, and this factors as $(X-1)(X+1)$. Now we can write $\frac 1 2 ((X+1)-(X-1)) = 1$, and we observe that for any $v$, this means we can then write
$v= v^+ + v^-$ where $v^+ = \frac 12 (f(v)+v)$ and $v^- = \frac 12 ((f(v)-v)$. Then check that this gives the desired decomposition.
Answer: Assume you have found the wanted $v^+$ and $v^-$; then
$$
f(v)=f(v^+)+f(v^-)=v^+-v^-
$$
Therefore
$$
v+f(v)=2v^+,\qquad v-f(v)=2v^-
$$
This gives necessary conditions: if $v^+$ and $v^-$ exist, then
$$
v^+=\frac{1}{2}(v+f(v)),\qquad v^-=\frac{1}{2}(v-f(v))
$$
Do these vectors satisfy the requirements under the assumption that $f^2$ is the identity?


Can we use OR with LIKE predicate in DB2 queries?

Question: I have a query to select names of employee start with 'y', then my query would be
SELECT EMP_NM FROM EMP
WHERE EMP_NM LIKE'Y%'

Say for example

I need to retrieve names of employee
  names start with both 'y' and 'z', do
  we have anything to suffice my
  requirement? It's something like using
  OR with LIKE, correct?

Your time and responses are highly appreciated.
Comment: So when you executed the query you know how to write but didn't know if worked, what result did you get?
Comment: Hi Ronnis, I tried and got an another question posted in the comment below. Ofcos, he responded back.. lemme try and get back. Thanks for checking on how did the query go!
Answer: WHERE EMP_NM LIKE 'Y%' OR EMP_NM LIKE 'Z%'

or, not sure if DB2 supports this (not even sure I have right link to documentation...)
WHERE EMP_NM LIKE '[YZ]%'

Comment: As you expected, DB2 doesn't support it seems. What happens when we have a multiple strings to be searched using LIKE. say LIKE 'RAJA%' OR 'LIKE 'GBN%''. Do we have a way to address it in DB2. Please let me know if its not clear. Thanks for your interest.
Comment: Change the WHERE to a JOIN with LIKE onto a table with all your string expressions?
Comment: I was out of city on a personal vacation. Ofcos, I'm late to respond... lemme try this... Thanks for your interest.
Comment: IBM added support for regular expression SQL functions in Db2 11.1 for Linux, UNIX, and Windows https://www.idug.org/p/bl/et/blogaid=605 The original question on this page (determining if EMP_NM begins with Y or Z) can be handled by calling `REGEXP_LIKE( EMP_NM, '^[YZ]' )`


Do I need to include the Install4J license text in my distribution?

Question: Do I need to include the Install4J license text (see here) in full or in parts when I distribute my commercial software whose installation is based on Install4J?
Neither could I find a LICENSE.txt file or something similar in the installation directory, nor did the installer GUI show any Install4J-related license texts.
The Install4J license does not seem to require an explicit listing of the license text but I'm wondering if I should still include some license info on Install4J in my attribution statement which comes with the software.
Answer: No, all generated installers and the runtime are freely redistributable, no attribution is required.
Source: https://www.ej-technologies.com/buy/install4j/licensing.html


What is the impact of overlooking learning scales?

Question: I've been playing guitar for about a month. I know that learning scales is so important, but I just hate learning them. My question is what is the impact of not learning scales from the beginning in the long term?
Answer: Scales teach your fingers where to find notes on the neck, and your brain how to think about intervals.
Without scales you will find it much harder to move around the fretboard, both on a single string, up and down the neck, but also across the neck. This will impact speed, clarity, and also your own composition processes.
I would say it is essential to learn scales, and then modes, in all positions and on all strings, so that you aren't limited when it comes to playing.
Put in the effort - it will benefit you in future!
Answer: Scales are absolutely vital, but only for their usefulness and their applicability. If you hate learning them, maybe your approach to learning them needs to be more musical. If you are just trying to learn the scale patterns all up and down the fretboard, you're missing the point. Granted, knowing your fretboard geometry is important too. However, if you can't apply a scale in one position, why learn all the other positions for that scale? If I gave you one position of a nonsense scale and it sounded terrible, unless you're into some avant-garde harmony or something, you won't see any reason to keep learning that scale.
So musical application is key. If you can, get a loop pedal or find some jam tracks on youtube. For a new scale, get just enough information to be able to play it and get a common position. Then jump right in. All the more in depth learning can wait for when you're interested in getting more info. Understand with your ears first. Everything else will fall into place. Find what notes fit on certain chords and learn how to navigate in a basic sense. For example, if you want to learn the Dorian scale, a common key is D. So learn the D Dorian scale in fifth position:

e|-----------------------5-7-8-7-5-----------------------|
b|-----------------5-6-8-----------8-6-5-----------------|
G|-----------4-5-7-----------------------7-5-4-----------|
D|-------5-7-----------------------------------7-5-------|
A|-5-7-8-------------------------------------------8-7-5-|
E|-------------------------------------------------------|

Then find a jam track for D Dorian or play Dm7 - G7 on your looper and with just that one position, you can do wonders. Then, when or if you're into it, learn more positions, find players who use the scale well, learn solo, transcribe solos, etc. Whatever you feel motivated to do to delve deeper into the scale.
The wonderful thing about music is that a lot of the ideas have been around for hundred of years, if not longer, but there's always more to learn and more to play and more to do. Learning scales is just one window into the musical minds of the greats that have come before us and just one way to develop our own musical understanding. Especially for guitar, learning scales is learning musical patterns and exploring scales is to explore these patterns. If you're not interested in learning scales, don't sweat it. You're not alone. They can be boring. But if you're serious about learning music and improving your playing, scales are essential.
Answer: It's not important to learn scales, if you can think of a better way to...

choose which notes to play when you're improvising
remember which notes to play in the songs you're playing
understand what people are talking about when they are talking about scales with commonly-used terminology.

So, can you?
Well, for the first two, it's certainly possible that you don't have to have your head in a scales mindset all that time. When it comes to choosing what notes to play, none of the common scales represent any kind of theoretical starting point from a physics / psychoacoustics point of view.
When it comes to memorising pieces too, I often remember pieces more by patterns and muscle memory. What note of the scale I'm playing is something I could also tell you straight away, and I might use that knowledge to help me improvise, but it's not what I'm really using to remember how to play the piece.
When it comes to communication with others, and understanding what people are talking about, you'll be up a creek without the terminology if you've not learned it, obviously.
Don't make too much of a big deal about it! As long as you find a smart way to learn scales, it won't take you a lot of time and you will be learning a lot of things that you will find helpful to navigate the fretboard however you're thinking about the notes you are playing. Just learn them at least to the point where you know what they are, then when you need them in the future, you'll know what it is that you need!
Answer: Generally speaking, a tune is played in one key. To learn that tune, one has to find each and every note by randomly looking for it, then on to the next, etc.Some of the notes played while trying to find the right ones won't ever be in that tune, as they don't feature in that key. Basically, in, say, a major key, there will be 7 notes that will probably feature, thus 5 more that rarely will. That's a lot of room for error, using hit-and-miss.
Knowing the notes that WILL feature saves a lot of time and effort. So, if you know that set of notes, often called a scale, it'll cut out a load of fuss.Most middle of the road tunes are based on full major or full minor scale notes, so once one knows some scale patterns, one can get to predict what the next note in a tune will be far better than randomly picking out possible notes. Working from the dots, one will 'lock in' to the set of notes used in a piece if one knows that scale.
When you come to compose your own pieces, knowing which notes work together will help. Use the notes from a particular scale, and you're there. Maybe start with the pentatonics, which bridge the gap between arpeggios and full scales, and tunes start to flow easily. Especially on guitar, which is tuned in such a way as to make pentatonics easy to find, use and play.


Participant non-compliance: How to include data in analysis

Question: I conducted a study in which participants were to do one of three treatment options and then write a test. The intention was to separate the participants based on the option they selected and using a one-way ANOVA, analyze whether these groups were statistically different from one another by comparing test grades.
The number of participants that did one of three treatment options were as follows:

Option 1, n = 27
Option 2, n = 98
Option 3, n = 69

The issue I ran into is that several participants misread the instructions and did all three options, or some combination of two of the three options.
The number of participants that did more than one treatment option:

Options 1, 2 and 3, n = 13
Options 1 and 2, n = 17
Options 1 and 3, n = 10
Options 2 and 3, n = 20

Is there a way to use the test data from this group of people (those that did more than one treatment option) in the statistical analysis? For example, can I somehow compare these groups' test grades to those of the single option groups? Or should they be excluded from the analysis (i.e. per-protocol analysis)?
I looked into complier-average causal effect (CACE) analysis, however in this case I don't have a control group and there's no way to determine which of the treatment options (for those that did more than one) had the effect, if any, on the test grade.
Any guidance you can provide is greatly appreciated. Thank you!
-Carmen
Comment: Is it possible that the instructions were misread as a result of your treatments?  If so, this would be important information to include in your questions as it will surely affect the answers you receive.
Answer: Create 3 dummy variables X1, X2, X3 to indicate which treatment option the participant took part in. For example, if the one took all of the three options, then X1=1, X2=1, X3=1. Then fit the model with X1, X2, X3 and their interactioins as covariates.
Comment: Since this is a reverse compliance problem where some subjects provided too much data rather than the usual case of too little, I like this approach, though perhaps without the interaction terms.  I don't think causal inference methods need to be brought in unless there is some kind of after-randomization bias.


Which git.exe should I reference?

Question: Git for Windows has installed four git.exe files.
They seem slightly different (comparing bytes).
Which should I use for other applications that want a reference to git.exe?

\Program Files\Git\bin\git.exe
\Program Files\Git\cmd\git.exe
\Program Files\Git\mingw64\bin\git.exe
\Program Files\Git\mingw64\libexec\git-core\git.exe
Answer: The different version are each one for a different purpose.

\Program Files\Git\bin\git.exe
This is the actual git binary which is added to your path if you run it form any script etc.
This entry found here in the git source script for windows:
https://github.com/git-for-windows/build-extra/blob/69c134c3c2c46bce1083d5bd4596d26543ca5f0f/portable/release.sh
\Program Files\Git\cmd\git.exe
This is the git which is run when you add installed and choose to add git to your cmd (windows path)
This entry can be found here in the source :  <File Id="GitExe" Source="cmd\\git.exe" />
https://github.com/git-for-windows/build-extra/blob/69c134c3c2c46bce1083d5bd4596d26543ca5f0f/msi/release.sh
\Program Files\Git\mingw64\bin\git.exe
This is the git-bash version which is used by the git-bash cygwin emulator
It defined here in the wxs (installer file)
https://github.com/git-for-windows/build-extra/blob/69c134c3c2c46bce1083d5bd4596d26543ca5f0f/msi/GitProduct.wxs
<?if $(var.SixtyFourBit)=64 ?>
    <Directory Id='MingwFolder' Name='mingw64' />
<?else?>

\Program Files\Git\mingw64\libexec\git-core\git.exe
Thisone is also for the emulator and is being defined here:
https://github.com/git-for-windows/build-extra/blob/69c134c3c2c46bce1083d5bd4596d26543ca5f0f/git-extra/git-prompt.sh
if test -z "$WINELOADERNOEXEC"
then
   GIT_EXEC_PATH="$(git --exec-path 2>/dev/null)"
   COMPLETION_PATH="${GIT_EXEC_PATH%/libexec/git-core}"
   ...

Comment: For the `\Program Files\Git\cmd\git.exe` what do you mean when you say "add installed and choose to add git to your `cmd` (windows path)" I'm sill not understanding.  Can you elaborate a bit more?
Comment: I have all those files in Windows. I don't use git bash, I use cmd.exe. If I type git --exec-path, it shows me the one in mingw64\libexec\git-core, Should I modify git to use the one in Program Files git/cmd/ or the one in git/bin/? And if so, how would I do that? And which one should I specify in PhpStorm?
Answer: When you are using from your windows command prompt you should be referring to the, \Program Files\Git\bin\git.exe
The ones under mingw64 are used with the Git bash interface.

Which git.exe should I reference?


Bayesian model: binomial(s) conditional on Poisson

Question: I am struggling a little with how to conceptualize and specify a particular Bayesian model. I suspect the solution is rather simple but for some reason I am having a hard time thinking about this.
My primary purpose is to model the incidence of a disease (let's denote this as $\lambda$), where the total number of cases of the disease in the population (let's denote this as $X$) is unobserved. What we DO observe is the number of cases of the disease as detected by some surveillance program, let's call this $Y$. Note that $Y$ is just a subset of $X$. We have made some assumptions based on a combination of previous data and our operative understanding of the structural context to relate $Y$ to $X$. Essentially, some subset of $X$ has a probability of seeking care (let's call this $C$); then, some subset of $C$ has a probability of being eligible for the surveillance program (let's call this $E$); finally, some subset of $E$ will have a positive test result that is a function of the sensitivity of the assay. This final step is what we observe ($Y$).
We can write this all out using simplified notation as:
$X|\lambda \sim Poisson(\lambda)$
$C|X,\pi_c \sim Binomial(X,\pi_c)$
$E|C,\pi_e \sim Binomial(C,\pi_e)$
$Y|E,\pi_y \sim Binomial(E, \pi_y)$
Therefore, through some simple algebra, we can show that:
$Y|\lambda,\pi_c,\pi_e,\pi_y \sim Poisson(\lambda\pi_c\pi_e\pi_y)$
Where I am struggling is then how to take the next step and evaluate the posterior, since the parameter is a product of multiple parameters. The simplest way of doing this would be to simply assume a conjugate prior on $\lambda$ and treat each of the $\pi$ parameters as fixed, but in practice we will have some amount of information on each of those parameters that we would want to incorporate into the model (e.g. we may reasonable expect those probabilities to be different among different subpopulations).
But I am struggling with how to move beyond that simplest case. If a different prior distribution (which may be functions of covariates) is assumed for each of the four parameters in that final equation, how do I derive the posterior (i.e. $P(\lambda|Y)$)? What if I am also interested in inference on the $\pi$ terms? Is that even possible within a single model? Or am I just thinking about this all wrong?
I suspect there is a very simple solution here, but for some reason I am feeling completely lost on how to go about doing this, and none of the examples I can find online are helping me.
EDIT: Here is my work trying to figure out the posterior. If by the definition of conditional probability we have:
$P(\lambda|Y,\pi_c,\pi_e,\pi_y)=\frac{P(Y,\pi_c,\pi_e,\pi_y,\lambda)}{P(Y,\pi_c,\pi_e,\pi_y)}$
The numerator can be decomposed using the chain rule as:
$P(\lambda|Y,\pi_c,\pi_e,\pi_y)=\frac{P(Y|\lambda,\pi_c,\pi_e,\pi_y)P(\pi_y|\lambda,\pi_e,\pi_c)P(\pi_e|\lambda,\pi_c)P(\pi_c|\lambda)P(\lambda)}{P(Y,\pi_c,\pi_e,\pi_y)}$
We can then perform a similar operation on the denominator:
$P(\lambda|Y,\pi_c,\pi_e,\pi_y)=\frac{P(Y|\lambda,\pi_c,\pi_e,\pi_y)P(\pi_y|\lambda,\pi_e,\pi_c)P(\pi_e|\lambda,\pi_c)P(\pi_c|\lambda)P(\lambda)}{P(Y|\pi_c,\pi_e,\pi_y)P(\pi_y|\pi_c,\pi_e)P(\pi_e|\pi_c)P(\pi_c)}$
Since we can (reasonably, I think) assume the parameters are independent, this all simplifies to:
$P(\lambda|Y)=\frac{P(Y|\lambda,\pi_c,\pi_e,\pi_y)P(\pi_y)P(\pi_e)P(\pi_c)P(\lambda)}{P(Y|\pi_c,\pi_e,\pi_y)P(\pi_y)P(\pi_e)P(\pi_c)}$
Which further simplifies as:
$P(\lambda|Y)=\frac{P(Y|\lambda,\pi_c,\pi_e,\pi_y)P(\lambda)}{P(Y|\pi_c,\pi_e,\pi_y)}$
But this doesn't look right to me. I don't quite understand what the quantity in the denominator would be (the conditional likelihood of $Y$ after marginalizing over $\lambda$?) or how I would calculate it. (Even the calculation of the likelihood for this model I am vague on, but that's more of an implementation question than a theoretical one).
Note that this would just be the posterior distribution of $\lambda$, if we were interested in a joint posterior so we could make inference over other parameters, we would have something like:
$P(\lambda,\pi_c,\pi_e,\pi_y|Y)=\frac{P(Y|\lambda,\pi_c,\pi_e,\pi_y)P(\pi_y)P(\pi_e)P(\pi_c)P(\lambda)}{P(Y)}$
Which looks a lot cleaner, but then I'm not sure how to draw marginal inference (e.g. on $\lambda$) from such a joint posterior (though I suppose that's where the assumption of independence comes in handy again?). I have a feeling that the answer is sitting right here in front of me, but something about the intuition hasn't yet "clicked" in my head and I'm feeling rather lost...
Answer: Looks like you answered most of your own questions already!

Where I am struggling is then how to take the next step and evaluate the posterior, since the parameter is a product of multiple parameters.

Bayes theorem still holds with joint distributions, all you would have to do is to specify a joint distribution for the set of parameters. Typically in a Bayesian model, this could be defined as a product of conditionals and marginals. In your scenario, it might be reasonable to define them as a product of marginals of $\pi_i$'s distributions.

The simplest way of doing this would be to simply assume a conjugate prior on λ and treat each of the π parameters as fixed, but in practice we will have some amount of information on each of those parameters ...

That's right, in that case you would probably use a beta prior for each of these $\pi_i$s.
However, your posterior $P_{all} = P(\lambda, \pi_c, \pi_e, \pi_y| Y)$  is not going to look pretty. This is where Markov chain Monte Carlo (MCMC) methods come in. If you're interested, I suggest studying the Metropolis algorithm (or Metropolis-Hastings, slightly different). In short: you sample from the posterior to approximate the distribution (e.g., you would have 10000 points of $(\lambda^{(t)}, \pi_c^{(t)}, \pi_e^{(t)},\pi_y^{(t)})$, for $t=1,2,...,10000$ whose distribution is approximately $P_{all}$.
To obtain the marginal posterior $P(\lambda | Y )$, you would have to integrate over $\pi_c,\pi_e,\pi_y$ from $P_{all}$. That is $P(\lambda | Y) = \int_{[0,1]^3}P(\lambda, \pi_c,\pi_e,\pi_y| Y)d\pi_cd\pi_ed\pi_y$. Suppose you have approximated the posterior $P_{all}$ via MCMC, then deriving the marginal distribution of $P(\lambda | Y)$ simply comes down to ignoring the $\pi_c,\pi_e,\pi_y$ samples (summing over discrete samples).
Here's how you would derive the posterior (and/or marginals)
$$P(\lambda, \pi_c,\pi_e,\pi_y | Y) = \frac{P(Y,\lambda,\pi_c,\pi_e,\pi_y)}{P(Y)}
\\  = \frac{ P(Y|\lambda, \pi_c, \pi_e,\pi_y) P(\lambda)P(\pi_c)P(\pi_e)P(\pi_y)}{\int_{\lambda,\pi_c,\pi_e,\pi_y} P(Y|\lambda, \pi_c, \pi_e,\pi_y) P(\lambda)P(\pi_c)P(\pi_e)P(\pi_y)d\lambda d\pi_c d\pi_e d\pi_y}$$
$$P(\lambda| Y) = \int_{\pi_c,\pi_e,\pi_y}P(\lambda, \pi_c, \pi_e,\pi_y | Y) d\pi_c d\pi_e d\pi_y $$
$$P(\pi_c| Y) = \int_{\lambda,\pi_e,\pi_y}P(\lambda, \pi_c, \pi_e,\pi_y | Y) d\lambda d\pi_e d\pi_y $$
Comment: Thank you! The math all makes sense to me, but for whatever reason it hasn't clicked with me on an intuitive level, so I never feel very confident with my results. Thanks for the explanation.
Comment: You're welcome :)! Are you able to point out a specific part that is not intuitive?
Comment: I think if I am able to implement it, the intuition will come to me. I may need to ask a separate question for this, but at the moment I can't figure out how to translate this into, say, R code based on the other examples I can find online.


Proof that when the conditional mean of Y does not depend on X, Y and X are uncorrelated

Question: I've been struggling to understand the proof that when E(Y|X) = $µ_y$, then cov(Y,X) = corr(Y,X) = 0, as provided in Stock and Watson's Introduction to Econometrics, 4th Edition. The book says the following:
First, assume Y and X have a mean 0, cov(Y,X)=E(YX). Second, the law of iterated expectations states that E(Y) = E[E(Y|X)]. Then, using this law, E(YX) = E[E(YX|X)] = E[E(Y|X)X] = 0, because E(Y|X) = 0, so cov(Y,X) = 0.
The specific parts in this sequence I struggle with are:

E[E(YX|X)] = E[E(Y|X)X]; I don't understand why the conditional mean of YX is equal to the conditional mean of Y, multiplied by X.
Why E[E(Y|X)X] = 0 means cov(Y,X) = 0.

I do understand on an intuitive level why the correlation should be 0 when the conditional mean of Y is equal to the mean of Y. I just don't understand this proof, probably due to the way it's denoted.
Comment: @kjetil b halvorson: Why did you edit my post? I can't say "Thanks in advance"? I'm honestly baffled by your action.
Comment: Because:  On this site there's no need to say "thank you" at the end
of your post - it might seem rude at first, but it's part
of
[the philosophy of this site](https://stats.stackexchange.com/help/behavior)
to "Ask questions, get answers, no distractions", and it
means future readers of your question don't need to read
through the pleasantries.
Answer:
I don't understand why the conditional mean of YX is equal to the conditional mean of Y, multiplied by X

Note that when $X = x$ we have that
$$E(YX | X = x) = E(Yx | X=x) = x E(Y | X=x).$$
We can say that when $X=x$ the random variable $E(YX | X)$ takes on the value $E(Yx | X=x)$. But, we can also say that when $X=x$ the random variable $E(YX | X)$ takes on the value $x E(Y | X=x)$. Consequently, the random variable $E(YX | X)$ must be the same as $X E(Y | X)$.
Suppose, for example, that the random variables $X$ and $Y$ are both continuous and that the conditional probability density function of $Y$ given $X=x$ is denoted by $p(y | x)$. Compare
$$
E(YX | X=x) = \int_{\mathbb R} yx \, p(y | x) \, dy \quad (*)
$$
and
$$
x E(Y | X=x) = x \int_{\mathbb R} y \, p(y | x) \, dy \quad (**).
$$
You should notice that they are equal.

Why E[E(Y|X)X] = 0 means cov(Y,X) = 0.

Given the assumptions you've made, it follows that $\text{cov}(Y,X) = E(YX)$. Since it's also true that $E(YX) = E[E(Y|X)X]$, if $E[E(Y|X)X] = 0$, then $\text{cov}(Y,X)=0$ because they are equal.


How to load a class which implements a interface from a jar file at runtime?

Question: I want to implement an application which could use users implemented classes. Each class should be implemented an interface that I define the interfaces and at last, all of classes which implemented by a user, archived in a jar file. Users copy the jar files in to class path and then only give the jar file name to my application. My application should be able to load jar file dynamically. To do this I found this post that is very useful, but it loads classes by class names. I want to load classes based on their parents.
public class A implements iA {
    @Override
    int getAValue() { ... }
}

public class B implements iB {
     @Override
     int getBValue() { ... }
}

Suppose loaded jar file has both A and B classes. I want to get an instance from class B by knowing the iB interface name.
What should I do?
Answer: Check this post out: Find Java classes implementing an interface
It talks about the solution to what you want.
I know what I am going to suggest is not the lightest way to do it, but you just described one of the fundamental use cases for a plugin architecture in Java and the success story of OSGi.
I would suggest using something light like Apache Felix, make the jar that the user provides implement a simple osgi.BundleActivator and register the implementation of your Interface as an OSGi service. (This is just a fancy hash map and nothing to do with REST services or the like).
Then you can just obtain all the implementations of a given interface. Its pretty straight forward. You can check out the Felix documentation here: http://felix.apache.org/site/apache-felix-framework-launching-and-embedding.html
Comment: love osgi too, it's quite painful when you start with osgi, but it's worth. I think you should mention auto-deploy option of felix too, it'll suit his case better.


Change location of maildir

Question: Standard Linux installation provide a maildir in /var/spool/mail/$user (that's actually a single file holding all emails, not a "mail directory"), soft-linked by /var/mail/.
I'm going to set up managed email on my installation, and I want to store mail in a separate partition that can be attached to the file system in case of server reimage (I already enforced this disaster-recovery measure for services such as mysql). The separate filesystem is /home.
So I would like system mail to be delivered to /home/$user/.mail[/] (final / in brackets because I'm not sure whether to include mail in a directory or not).
Currently, I run email for my own domain by redirecting all email to my ISP's email, which will not be forever (in case I change ISP I must migrate all email to the new ISP), so Postfix is instructed to redirect everyting directed to *@example.org to email@example.com.
I was thinking about using Dovecot as email server, as it fully supports SSL.
So first, before configuring Dovecot, how do I tell the system to deliver mail in a different directory than /var/spool? Please mind that cron regularly sends email to root when jobs don't write to /dev/null, so the configuration must be system-wide.
Comment: Possible solution: soft-linking /var/spool/mail to /home/mail will hold the mail queue under /home
Comment: @usr-local-ΕΨΗΕΛΩΝ I applied HBruijn's answer on my server and it works great. Can you please accept his answer if it answers your question?
Comment: Typically dovecot is the IMAP/POP3 daemon used by the recipients to read email and neither the incoming/outgoing SMTP server, nor the [local delivery agent](http://wiki2.dovecot.org/MDA). To change the location of the default mail dirctory you most likely need both to change where sendmail/postfix/exim or whatever you're using delivers email, as well as Dovecot's configuration.
Comment: Sorry that I involuntarily buried it
Answer: It is recommended to use the Maildir directory format to store email rather than the older mbox format. The Maildir format is well supported by Dovecot and has some advantages (no locking, allows for easy incremental back-ups and restoring of individual messages.) So you'll need to assign a directory.
It is convention to store mail in a ~/Maildir directory in a user's home directory, but nothing prevents you from using another (hidden) directory.
You configure both the Maildir format as well as its location with the Postfix home_mailbox setting:
sudo postconf -e "home_mailbox = Maildir/"

This is also the default location configured for most Dovecot packages.
The alternative is to configure Postfix to leave local mail delivery to the Dovecot LDA or LMTP.
Then configure Dovecot to look for mail in the correct location as well:
mail_location = maildir:~/Maildir

In case of mail users actually having local user accounts (instead of only existing as virtual mail users), you may want to populate /etc/skell with a Maildir and a welcome message for new users.

Change location of maildir


Proof of maximal principle on Laplace Equation involving Poisson integral formula

Question: This question appeared on a past PDE exam I found while studying for my finals:

Let $u(r,\theta)$ be  solution to the Laplace equation in polar coordinates:
  $$u_{rr}+\frac{1}{r}u_r+\frac{1}{r^2}u_{\theta\theta} = 0, \quad 0<r\le a$$
  which satisfies the boundary condition
  $$u(a,\theta)=f(\theta)$$
  where $u$ is given by Poisson's formula
  $$u(r,\theta)=\frac{a^2-r^2}{2\pi}\int_0^{2\pi} \frac{f(\xi)}{a^2-2ar\cos(\theta-\xi)+r^2 }\mathrm{d}\xi$$Prove that if $M=\max(|f(\theta)|)$, then $|u(r,\theta)| \le M$ for all $r \le a$ and all $\theta$.

This is obviously the maximal principle for harmonic functions and can be proved using analysis with balls and topological principles. However, none of this is covered in my class since its an undergraduate intro to PDE course.
The sample solution, given by the professor, is incorrect from what I can see and goes as follows:
\begin{align}
|u|&= \left|\frac{a^2-r^2}{2\pi}\int_0^{2\pi} \frac{f(\xi)}{a^2-2ar\cos(\theta-\xi)+r^2 }\mathrm{d}\xi\right|\\[1em]
 &= \frac{a^2-r^2}{2\pi} \left|\int_0^{2\pi} \frac{f(\xi)}{a^2-2ar\cos(\theta-\xi)+r^2 }\mathrm{d}\xi\right|\\[1em]
&\le \frac{a^2-r^2}{2\pi}\int_0^{2\pi} \left|\frac{f(\xi)}{a^2-2ar\cos(\theta-\xi)+r^2 }\right|\mathrm{d}\xi \\[1em]
&\le \frac{a^2-r^2}{2\pi}\int_0^{2\pi} \frac{|M|}{a^2-2ar+r^2 }\mathrm{d}\xi \\[1em]
&=\boxed{|M| \frac{a^2-r^2}{a^2-2ar+r^2}\frac{1}{2\pi} \int_0^{2\pi} \mathrm{d}\xi = |M| \frac{a-r}{a+r}} \le |M| \quad \blacksquare\\{}
\end{align}
The equality I have boxed is where the error arises since:
$$\frac{a^2-r^2}{a^2-2ar+r^2} = \frac{(a-r)(a+r)}{(a-r)^2} = \frac{a+r}{a-r} \ne \frac{a-r}{a+r}$$
by this logic the inequality is unbounded.
I have brought this up with the professor and he said that he would get back to me in a week as he agrees with me, but I honestly am too bugged by this to wait.
So what is the correct proof using the same method demonstrated by the professor?
Clearly the error must arise from some mistake in the logic followed by the inequalities of absolute values.
I tried to mend the solution by applying the triangle equality and/or reverse triangle inequality to the denominator of the integral but I can't arrive to the form
$$\frac{a^2-r^2}{a^2+2ar+r^2} = \frac{(a-r)(a+r)}{(a+r)^2} = \frac{a-r}{a+r}$$
whence the inequality would follow as was written in the solution.
Any help would be greatly appreciated.
Comment: I gather that your aim is (if feasible) to prove this simply using the Poisson kernel representation formula?
Answer: One approach might be to observe that
$$
\varphi(r,\theta) = \frac{a^2-r^2}{2\pi}\int_0^{2\pi} \frac{|M|}{a^2-2ar\cos(\xi - \theta)+r^2 }\mathrm{d}\xi
$$
solves the boundary value problem with the boundary condition of constant value $ | M | $. If you have already proven the uniqueness of solutions of the boundary value problem, then since the constant function $ \varphi(r,\theta) = |M| $ is a solution, you can conclude the value of the integral is $ |M| $.
Otherwise, you can just compute the integral. If you know some tools from complex analysis, then it's not a hard contour integral. Otherwise, I think there is some reasonable $ u $-substitution that works. For example, using the double angle formula for $ \cos $
$$
\int \frac{1}{a + b \cos(\theta)} d \theta = \int \frac{1}{a+b \; (2 \cos^2(\theta/2) - 1)} d \theta
$$
Then substituting $ u  = \tan(\theta/2) $ seems to go somewhere.
Note again that the value of the integral is $ |M| $, which suggests that any approach involving upper-bounding the kernel $ \frac{1}{a^2-2ar\cos(\theta-\xi)+r^2 } $ won't work.
Comment: Yes, sorry, I mean the whole value of $ u $, and not just at the boundary but at any value of $ r $ and $ \theta $. I am fairly certain that there is no way by basic inequalities: since exact answer is $|M|$, any upper bound (that isn't essentially identical to the kernel) will yield an estimate larger than $ |M| $.
Comment: Yes I do know the uniqueness proof for the BVP, but it doesn't look like that the professor has been expecting to arrive to the final conclusion that way. It seems he wanted to basic manipulation through inequalities, but from what I understand, its not that simple? I have experience computing the integral (check [this link](https://math.stackexchange.com/q/3162059/240398) for the previous part of this question). I'm just surprised that the professor had incorrectly assumed that it can be done by basic analysis of inequalities. Please see my comment on Gary's answer for more context.
Comment: And just for clarity, when you say the value of the integral is $|M|$, you mean the whole value of $u$ at the boundary is $|M|$ and not the integral alone without the factor $\frac{a^2-r^2}{2\pi}$, right?
Comment: solid reasoning, thank you for the insight. I will discuss this with my professor next week. its unfortunate for the students who had this question on the exam last year and were expected to do it in a way which is seemingly impossible.
Answer: I've played with this for a while to see if it could be done with some basic estimates on the integral. I haven't had any luck and, as user85055 said, given that
$$\frac{a^2-r^2}{2\pi}\int_0^{2\pi} \frac{M}{a^2-2ar\cos(\theta-\xi) + r^2} \ d\xi = M,$$
we won't be able to derive the result simply by obtaining upper bounds on the Poisson kernel.
Given this, I think that the best way to solve this problem would be to essentially rederive the maximum principle (at least in the special case where the domain is a disk). Fortunately, this is rather straightforward. I'd be happy to sketch the argument, but I imagine you could find it easily.
Edit: I'm going to sketch the argument which I'm suggesting. First, we'll prove a version of the maximum principle and then a maximum principle.
Pick some disk $D_\rho(p) \subset D_a(0)$. Choose polar coordinates centered at $p$ and use the Poisson kernel representation formula to get
$$u(p) = \frac{1}{2\pi}\int_0^{2\pi} u(\rho,\theta) \ d\theta.$$
That is, the value of $u$ at the center of any disk is equal to its average over the circle bounding the disk. Now we're ready to prove the result.
So, suppose that $u$ exceeds $M$ at some point in the interior. Then, $u$ must attain its max, call it $A>M$, at some point in the interior of the disk, say $q \in D_a(0)$. Then, pick $0<R<\mathrm{dist}(q,\partial D_a(0))$ and notice that
$$A = u(q) = \frac{1}{2\pi}\int_0^{2\pi} u(R,\theta) \ d\theta \leq A.$$
Notice that the inequality holds as the the average of $u$ over the circle can't exceed the maximum of $u$ over the whole disk. This implies that $u\equiv A$ on $\partial D_R(q)$. Repeating this argument and covering the disk with circles implies that $u\equiv A$ on $D_a(0)$. However, this is a problem as it is not consistent with the BCs; in particular, it implies that $u$ is not continuous on $\overline{D_a(0)}$.
Comment: I would like to mention that the PDE is indeed on the circular domain, this is the last part of a 3 part question so I stupidly left that out. Please look at [the second part](https://math.stackexchange.com/q/3162059/240398) if you wish to have some more context. If I understand what you both saying, its that the proof can not be simply done through basic inequality manipulation like the professor might had tried to show? I will just emphasize the fact this is an intro PDE course so proof of the maximum principle rigorously had not been shown before (although I know it alone).


Why is parsing "%Y-%m" using strptime in R giving an NA result, but "%Y-%m-%d" works?

Question: I'm getting a result I don't understand in R.
If I use strptime with a year and day formatted %Y-%m (like "2009-12"), I get an NA result. But if I add a day, like "2009-12-01", and change the format string accordingly, I do get a result. Example:
> strptime("2009-12",format="%Y-%m")
[1] NA
> strptime("2009-12-03",format="%Y-%m-%d")
[1] "2009-12-03"

Why is that?
Update: The thing I'm curious about is why strptime doesn't parse a year and a month, and the reason it seems weird that it wouldn't do so is because it does parse a year only, or a year-and-a-day:
> strptime("2009",format="%Y") # year only. Works. Uses current month and day as defaults.
[1] "2009-12-02"
> strptime("2009-03",format="%Y-%d") # year and day. Works. Uses current month as default.
[1] "2009-12-03"
> strptime("2009-03",format="%Y-%m") # year and month. Doesn't work. ?
[1] NA

Update to explain why this is not a duplicate
The possible duplicate was asked a few years after this question and it is concerned with a separate API in R: the asDate function. This question is about a quirk of the strptime function that as of R 3.1.3 still applies.
Comment: Because dates have days?  What do you expect it to output?
Comment: I was expecting it to use the current day as a default, the way it will do if you do strptime("2009", format="%Y"). This results in "2009-12-01".
Comment: Did you want that to be day of the year?  If so, try "%j".
Comment: Why not use Sys.Date() in that case?  "2009-12" isn't a valid date by itself.
Answer: That seems like sensible behavior to me.  As I see it, a better question would be "why does it allow you to do this: strptime("2009-03",format="%Y-%d")?"
Here's a workaround to get what I think you're trying to achieve (i.e. a POSIXlt object with a specified month and year, but today's day):
as.POSIXlt(paste("2009-12", days(Sys.Date()), sep="-"))

Comment: I know this question is really old but I found it when I had the same question myself.  According to the [documentation](http://stat.ethz.ch/R-manual/R-patched/library/base/html/strptime.html) on `strptime`: "For strptime the input string need not specify the date completely: it is assumed that unspecified seconds, minutes or hours are zero, and an unspecified year, month or day is the current one." So it should "seems like your workaround shouldn't be needed.
Comment: No, its a requirement as a 'date' designates a day in a month in a year, and just a giving a month and a year is not equivalent.
Comment: But then why does it work if you give it only a year, or only a year and a day?
Comment: So it's just a weird idiosyncrasy of the language?
Comment: My guess is that "that's just how it works" (in other words, there is no good reason). As everyone is saying, it doesn't make much sense for why you would actually want to do this at all. If you want today's date, use Sys.Date(). Otherwise just do what Shane suggested above...
Answer: I'm just guessing here.  But if it takes a year and a day, it's probably taking a year and a day in the range of 1-365 (or 366 for leap years).  What you could do is use paste() and add -01 at the end to get the standard YYYY-MM-DD format.
Here's the test I ran.
strptime("2009-123",format="%Y-%d")

returns "2009-05-12"


Maximum variance of random values

Question: Let us say we have $n$ random values $x_i$ chosen from an interval $[a,b]$. What would be the maximum possible variance $Var(X)=\frac{1}{n}\sum_{i=1}^n(x_i-\bar{x})^2$?
The number $(b-a)/2$ sounds plausible, can we prove this guess?
Comment: It is $(b-a)^2/4$. (Though if $n$ is odd, then the highest attainable value is $\frac{n-1}{n}\cdot\frac{(b-a)^2}{4}$.) Have a read of this page: https://stats.stackexchange.com/questions/350270/what-are-the-minimum-and-maximum-values-of-variance.
Answer: This is not a rigorous proof (for that have a look here) but can be useful anyhow.
Also it illustrates how handsome it can be to standardize.
Personally I dislike parameters and always seek for possibilities to get rid of them.

First let's solve this for $a=-1, b=1$ and $n$ is even.
Purely on intuition I state that the variance will take maximal value if the $x_i$ take the extreme values $1,-1$ with equal frequency.
So e.g. if $x_i=-1$ if $i$ is even and $x_i=1$ if $i$ is odd.
Then $\overline x=0$ and $\mathsf{Var}(X)=1$.
If $y_i$ is chosen from $[a,b]$ then we take $y_i=\frac12(b-a)x_i+\frac12(a+b)$ and find easily that $\mathsf{Var}(Y)=\frac14(b-a)^2$.
If $n$ is odd then (again purely on intuition) the same idea except that one of $x_i$ takes value $0$.

Maximum variance of random values


jQuery, window.width() nativo e window.on resize na mesma condição

Question: Gostaria de saber se é possível uma maneira melhor do que esta, pois poupava a repetição de codigo:
normalmente faço:
if($(window).width() > 800) {

// BLAH BLAH BLAH

}

$(window).resize(function(){

    if($(window).width() > 800) {

        // BLAH BLAH BLAH

    }

});

Isto não me parece uma viável/boa implementação de código pois estou a repetir codigo (BLAH BLAH BLAH), haverá alguma maneira de pôr as duas condições dentro da mesma?
Answer: Crie uma função e execute a função nos dois casos...
function blah() {
    // BLAH BLAH BLAH
}

if($(window).width() > 800) {

    blah();

}

$(window).resize(function(){

    if($(window).width() > 800) {

        blah();

    }

});

ou eliminando completamente a repetição:
function blah() {
    if($(window).width() > 800) {
        // BLAH BLAH BLAH
    }
}

blah();

$(window).resize(function(){
    blah();
});

Obs.: Sempre declare a função antes dela ser chamada...
Comment: Funciona sim, acabo de testar. Mas obviamente as funções declaradas dentro de outra função só estarão disponíveis depois que a função "mãe"  for chamada pelo menos uma vez... (É preciso verificar re declaração)
Comment: Mas eu tenho outras funções, dentro do BLAH BLAH BLAH
Comment: @Miguel não tem problema, execute tudo dentro da nova função normalmente...
Comment: Obgado, tinha pensado nisso mas pensei em 'php', que não dá para nested functions. Excelente
Comment: @Miguel Em php é possível até mesmo executar a própria função nela mesma...
Comment: Sim, mas não criar/declarar funções dentro de outras
Comment: Obgado, tem razão, dentro de uma classe/objeto dá também?
Answer: Você pode reduzir ainda mais o seu código.
$(window).on("resize", function(){
    if($(this).width() > 800) {

        // BLAH BLAH BLAH

    }
});
$(window).trigger('resize'); // Aqui você usa o 'trigger' para chamar o resize manualmente

Usando o trigger você consegue chamar o resize manualmente quando a tela carrega, fica bem mais limpo


Field with $125$ elements

Question: I want to construct a field with $125$ elements. My idea is to consider the polynomial ring $\Bbb F_5[x]$. It is enough to find an irreducible polynomial $f\in \Bbb F_5[x]$ of degree $3$ because then $\Bbb F_5[x]/(f)$ is a field with exactly $5^3=125$ elements.
How do I find an irreducible polynomial of degree $3$ in $\Bbb F_5[x]$?
Comment: The best idea is to do trial and error. It's easy to check whether a degree 3 polynomial is irreducible, because you only need to check whether it has a root.
Comment: My polynom isn't irreducible, but I thought you are also interested in how to get the finite fields and you can realize them as splitting fields.
Comment: You can get the field with $p^n$ elements as splitting field of $t^{p^n}-t\in \mathbb{F}_p[t]$.
Comment: Thanks. Why is that thing irreducible?
Answer: If a cubic polynomial of $\mathbb{F}_5[x]$ is reducible, then it splits into a linear factor and a quadratic factor or into the product of three linear factors. Linear factors are very easy to test for, as $(x-a)$ is a factor of $f$ if and only if $f(a) = 0$.
So you might choose a random degree $3$ polynomial and test for the five possible roots.
For instance, I'm tempted to try $f(x) = x^3 + 2x + 1$. Then
$$\begin{align}
&f(0) = 1, \\
&f(1) = 4, \\
&f(2) = 8 + 4 + 1 \equiv 3, \\
&f(3) = 27 + 6 + 1 \equiv 4, \\
&f(4) = 64 + 8 + 1 \equiv 3.
\end{align}$$
As none of these are zero, $f(x)$ is an irreducible cubic.

Note that testing for roots explicitly doesn't work for higher degree polynomials. It is possible that a reducible quartic factors into the product of two quadratics. So though there are no roots, it might still be reducible. However since we know that a reducible cubic has a linear factor, we can test just for the linear factor.
Comment: This is great, thank you!
Answer: The method given by mixedmath is correct. In the illustration the  random polynomial selected turned out to be irreducible. In general you may have to try many random ones before becoming lucky.
Instead of trying something wildly random restrict to those satisfying Eisenstein criterion. (because something that is reducible over integers is not going to help us).  As we are working mod 5 let us try prime coefficients less than 5.
Trial 1: $x^3+2x+2$. This polynomial evaluates to zero at 1.
Trial 2: Now let us try $g(x)=x^3+3x+3$.  Now $g(0) =1$
$$ g(1)=2$$  $$g(2)=2$$  $$g(3)=4$$  $$g(4)=1$$
So using the same reasoning of mixedmath we arrive at an irreducible polynomial.
Answer: @mixedmath @P Vanchinathan
One can generate a field with 125 elements by taking the powers $M^n$ of a certain $3 \times 3$ matrix $M$ with coefficients in $\mathbb{F}_5$ of order 124.
Edit: In order to be explicit, let us consider matrix
$$M = \begin{pmatrix}0&0&1\\2&0&0\\0&1&1 \end{pmatrix}$$
Cayley Hamilton theorem applied to $M$ gives: $M^3=2I_3+M^2 \ \ (1)$.
Let $R$ be the ring of $3 \times 3$ matrices with coefficients in $\mathbb{F}_5$ (with ordinary addition and multiplication of matrices).
The subset $S$ of matrices of the form $aI_3+bM+cM^2$ (for any $a,b,c \in \mathbb{F}_5$) is a subring of $R$ (by application of (1) for the stability by multiplication).
The represention of an element of $S$ under the form $aI+bM+cM^2$ is unique. Otherwise, an identity of the form $aI+bM+cM^2=a'I+b'M+c'M^2$ (where $(a,b,c) \neq (a',b',c')$) would infer the existence a polynomial of degree at most 2 that annihilates matrix $M$, and one can verify that no such "minimal" polynomial exist.
As a consequence $S$ is in bijective correspondance with $\mathbb{F}_5^3$, thus has $5 \times 5 \times 5 = 125 $ elements.
Let us now consider set $S'$ defined as the set of all powers $M^n$ which are clearly elements of $S$ by using iteratively (1)).
In fact $S=S'\cup \{0\}$ (where 0 is the null matrix).
Indeed, on one hand $S'$ is included in $S$ because, by successive applications of (1), one can lower any polynomial in $M$ into an at most degree 2 polynomial.
And, on the other hand, one can verify that $M$ has order 124 (it can certainly be be proved using the correspondence between matrices and - irreducible - polynomial through the concept of companion matrix).
Thus $S$=$S'$ minus ${0}$ is a (cyclic) group for multiplication.
Therefore $S$ is a field with 125 elements.
(all this in accordance with the fact that a finite field is commutative, and has a cyclic multiplicative group).
See this reference;
Comment: @JeanMarie: An extension field  $K$  of degree $n$ over a field $F$ can be realised as an $F$-subalgebra of $M_{n\times n}(F)$.  When $F$ is a  finite field, $K^*$ will be  a torsion subgroup of $GL_n(F)$. Is this what you mean by Wedderburn theorem?
Comment: @Morgan Rodgers 1) You are right, this matrix is of order 124. 2) I dont agree : I answer to the initial question "I want to construct a field with  125 elements" but using a different "idea". Moreover, I thought it was useful to speak about this construction process that is a little less publicized than the method using irreducible polynomials 3) I dont think it is more difficult (I could have taken a companion matrix which is completely equivalent to finding an irreducible polynomial).
Comment: @P Vanchinathan Thank you very much. In fact, I used the name "Wedderburn" without checking. And now, I see that it deals with commutativity of finite fields. What I needed is a different result (I have re-written it in my answer), i.e., that the mutiplicative group of a finite field is cyclic (there are broader results).
Comment: @Morgan Rodgers I think I am in the spirit of this site when I give another direction that maybe the OP didn't know, knowing that the mainsstream method has been well explained. Whe are between reasonable persons that try to show lateral views that by no means are orthogonal to what the OP is looking for. It is true that I have found this matrix by trial and error. I am aware of a method using companion matrix for that purpose but I need some more time to "excavate it". If somebody knows it...
Answer: Belatedly, there is a way to "be lucky" here, and not so computational, in an informative way. Namely, of all the polynomials known to humans, the best understood are cyclotomic ones. If a cyclotomic polynomial or a relative can resolve an issue, that's good fortune.
After a moment's fooling around, we observe that the smallest power of $5$ such that $5^n-1$ is divisible by $7$ is $5^6$. That is, $5$ happens to be a "primitive root" mod $7$. Thus, a seventh root of unity $\zeta$ is of degree $6$ over $\mathbb F_5$. That is, the seventh cyclotomic polynomial $x^6+x^5+...+x+1$ is irreducible over $\mathbb F_5$.
The irreducible of $\xi=\zeta+\zeta^{-1}$ over $\mathbb F_5$ is obtained by a standard algebraic manipulation:
$$
0\;=\;
\zeta^{-3}\Big(\zeta^6+\ldots+\zeta+1\Big)
\;=\;
\zeta^3+\zeta^2+\zeta+1+\zeta^{-1}+\zeta^{-2}+\zeta^{-3}
$$
$$
\;=\; (\xi^3 - 3\xi) + (\xi^2-2) + 1
\;=\; \xi^3 + \xi^2 - 3\xi - 1
$$
We can use $-3=2$ and $-1=4$ if we like.
So, then, basic Galois theory assures us that $x^3+x^2-3x-1$ is irreducible in $\mathbb F_5[x]$.

Field with $125$ elements