Lapply não retorna o resultado desejado para algumas funções

Question: Minha lista:
structure(list(col1 = structure(list(a = 1:5, b = 1:5, c = 1:5), .Names = c("a",
"b", "c"), row.names = c(NA, -5L), class = "data.frame"), col2 = structure(list(
    a = 6:10, c = 6:10), .Names = c("a", "c"), row.names = c(NA,
-5L), class = "data.frame"), col3 = structure(list(a = 11:15,
    c = 11:15), .Names = c("a", "c"), row.names = c(NA, -5L), class = "data.frame"),
    col4 = structure(list(a = 16:20, b = 16:20), .Names = c("a",
    "b"), row.names = c(NA, -5L), class = "data.frame"), col5 = structure(list(
        a = 21:25, c = 21:25), .Names = c("a", "c"), row.names = c(NA,
    -5L), class = "data.frame")), .Names = c("col1", "col2",
"col3", "col4", "col5"))

Tentei:
res<-lapply(list,function(x)colSums(subset(x,select=c('a'))))

e
res<-lapply(list,function(x)colMeans(subset(x,select=c(1,2))))

e o resultado foi ok.
Mas, quando executo:
res<-lapply(list,function(x)shapiro.test(subset(x,select=c(1,2))))

não tenho sucesso (Error: is.numeric(x) is not TRUE).
O que fazer?
Comment: Esse erro surge simplesmente porque o teste de Shapiro só é aplicável a vetores numéricos, não a data.frames. Da página de help, *"x  a numeric vector of data values."* O teste de normalidade só faz sentido para vetores, cada *vetor* da df pode ou pode não seguir uma distribuição normal. Tal como diz, para os outros casos, `colSums` e `colMeans` está tudo bem.
Answer: Como muito bem apontado pelo comentário do Rui, a função shapiro.test só está definida para vetores. Mas nada nos impede de criarmos uma versão para ela que pode ser aplicada em colunas de data frames:
shapiro.test.df <- function(df){
  apply(df, 2, shapiro.test)
}

A função shapiro.test.df foi criada simplesmente aplicando-se a própria função shapiro.test nas colunas de um data frame qualquer. Agora basta usar lapply para aplicá-la nos elementos de uma lista, desde que estes elementos sejam data frames:
lapply(dados, shapiro.test.df)

$col1
$col1$a

    Shapiro-Wilk normality test

data:  newX[, i]
W = 0.98676, p-value = 0.9672

$col1$b

    Shapiro-Wilk normality test

data:  newX[, i]
W = 0.98676, p-value = 0.9672

$col1$c

    Shapiro-Wilk normality test

data:  newX[, i]
W = 0.98676, p-value = 0.9672

$col2
$col2$a

    Shapiro-Wilk normality test

data:  newX[, i]
W = 0.98676, p-value = 0.9672

$col2$c

    Shapiro-Wilk normality test

data:  newX[, i]
W = 0.98676, p-value = 0.9672

$col3
$col3$a

    Shapiro-Wilk normality test

data:  newX[, i]
W = 0.98676, p-value = 0.9672

$col3$c

    Shapiro-Wilk normality test

data:  newX[, i]
W = 0.98676, p-value = 0.9672

$col4
$col4$a

    Shapiro-Wilk normality test

data:  newX[, i]
W = 0.98676, p-value = 0.9672

$col4$b

    Shapiro-Wilk normality test

data:  newX[, i]
W = 0.98676, p-value = 0.9672

$col5
$col5$a

    Shapiro-Wilk normality test

data:  newX[, i]
W = 0.98676, p-value = 0.9672

$col5$c

    Shapiro-Wilk normality test

data:  newX[, i]
W = 0.98676, p-value = 0.9672


Help with Inequality

Question: Given that $x, y, z$ are nonnegative real numbers such that :
$$x^2 + y^2 + z^2 + xyz = 4$$
Prove that
$0 ≤ xy + yz + zx − xyz ≤ 2$
Answer: Here's a straight-forward way, which is not very elegant, but is on the other hand very general, and does not require problem-specific tricks.
We want to calculate bounds for the function $$f=x y + y z+ z x - x y z\ ,$$ under the constraint $$g=x^2 + y^2 + z^2 + x y z-4=0\ .$$
For this, we introduce the Lagrange multiplier $\lambda$, and look for points for which
$$\nabla(f-(\lambda-1) g)=\left(
\begin{array}{c}
 y+z-2 x (\lambda -1)-y z \lambda  \\
 x+z-2 y (\lambda -1)-x z \lambda  \\
 x+y-2 z (\lambda -1)-x y \lambda  \\
\end{array}
\right)=0$$
The choice $\lambda-1$ rather than $\lambda$ is arbitrary and will be convenient in the following. Solving the above equation for $x,y,z$ requires some work, and the result gives 2 families of solutions:

$x=y=z=\frac{4}{\lambda }-2$
$x =y=2-\frac{1}{\lambda } ,\  z= \frac{3-8 \lambda +4 \lambda ^2}{2 \lambda -2 \lambda ^2}$ (and cyclic permutations of this).

Solving for $\lambda$, the first solution satisfies $g$ only when $\lambda=\frac{3}{4}$, and then $x=y=z=1$ and $f=2$. Doing the same trick for the second one, one gets only negative results for $x,y$ or $z$, so we can forget about that (for example, the point $x=y=\frac{2}{3},\ z=-2$ satisfies $g$ but not the non-negativity constraint).
We see that for $x,y,z>0$, there is only one critical point of $f$ under the constraint $g$, at the point $x=y=z=1$. A simple check shows that this is a global maximum, since the point $x=y=0, z=2$ satisfies $g$ and has $f=0<2$. You now just have to check the boundaries, i.e. WLOG $x=0$, but this gives immediately $f=yz$ which is non-negative by assumption. therefore $0\le f\le 2$.
Comment: Don`t you need to justify the use of lagrangian mulitplicators? I mean that your constraint does not define a closed smooth submanifold.
Comment: I did, in way. There are  actually four constraints: $x>0, \ y>0, \ z>0$, and $g$. Each of them is smooth, and for the first three the check is easy.
Answer: For the left part of the inequality:
By the AGM-inequality, we have:
$$3(xyz)^{2/3}=3((xy)(xz)(yz))^{1/3}\leq xy+xz+yz$$
Suppose that $xy+xz+yx<xyz$, therefore we get $3(xyz)^{2/3}<xyz$, hence $3^3<xyz$. This contradicts the fact that $x^2+y^2+z^2+xyz=4$
Comment: where did $3^3$ come from?
Comment: If $(xyz)^{1/3}<xyz$, then $xyz\not=0$. Now divide both sides by $(xyz)^{2/3}$. Now we get $3<(xyz)^{1/3}$
Answer: use this $$\cos^2{A}+\cos^2{B}+\cos^2{C}+2\cos{A}\cos{B}\cos{C}=1$$
and $$x^2+y^2+z^2+xyz=4$$
then we set
$$x=2\cos{A},y=2\cos{B},z=2\cos{C}$$
$$\Longleftrightarrow 0\le 4(\cos{A}\cos{B}+\cos{B}\cos{C}+\cos{A}\cos{C})-8\cos{A}\cos{B}\cos{C}\le 2$$
and since
$$\cos{A}\cos{B}\cos{C}=\dfrac{s^2-(2R+r)^2}{4R^2},\cos{A}\cos{B}+\cos{B}\cos{C}+\cos{C}\cos{A}=\dfrac{s^2+r^2-4R^2}{4R^2}$$
then
$$\Longleftrightarrow 0\le\dfrac{s^2+r^2-4R^2}{R^2}-\dfrac{2}{R^2}\left(s^2-(2R+r)^2\right)\le 2$$
and left hand it suffices that
$$s^2+r^2-4R^2-2s^2+2(2R+r)^2\ge 0$$
$$\Longleftrightarrow 3r^2+8Rr+4R^2\ge s^2$$
use the Gerrseten inequality:
$$r(16R-5r)\le s^2\le 4R^2+4Rr+3r^2$$
then
$$\Longleftrightarrow 4R^2+4Rr+3r^2\le 3r^2+4R^2+8Rr$$
$$\Longleftrightarrow 4Rr\ge 0$$is obvious.
and the Right Hand,
$$\Longleftrightarrow s^2+r^2-4R^2-2(s^2-(2R+r)^2)\le 2R^2 $$
$$\Longleftrightarrow 2R^2+8Rr+3r^2\le s^2$$
since
$$s^2\ge r(16R-5r)$$,
it follow that
$$r(16R-5r)\ge 2R^2+8Rr+3r^2$$
$$\Longleftrightarrow (R-2r)^2\ge 0$$
is obivous.
Answer: Let $x=\frac{2a}{\sqrt{(a+b)(a+c)}}$ and $y=\frac{2b}{\sqrt{(a+b)(b+c)}}$, where $a$, $b$ and $c$ be positives.
Hence, $z=\frac{2c}{\sqrt{(a+c)(b+c)}}$ and the left inequality it's
$$4\sum_{cyc}\frac{ab}{(a+b)\sqrt{(a+c)(b+c)}}\geq\frac{8abc}{(a+b)(a+c)(b+c)}$$ or
$$\sum_{cyc}ab\sqrt{(a+c)(b+c)}\geq2abc,$$
which is true because
$$\sum_{cyc}ab\sqrt{(a+c)(b+c)}\geq\sum_{cyc}abc\geq2abc.$$
The right inequality.
We need to prove that
$$4\sum_{cyc}\frac{ab}{(a+b)\sqrt{(a+c)(b+c)}}-\frac{8abc}{(a+b)(a+c)(b+c)}\leq2$$ or
$$2\sum_{cyc}ab\sqrt{(a+c)(b+c)}\leq(a+b)(a+c)(b+c)+4abc,$$
which is AM-GM:
$$2\sum_{cyc}ab\sqrt{(a+c)(b+c)}\leq\sum_{cyc}ab(a+c+b+c)=$$
$$=\sum_{cyc}(a^2b+a^2c+2abc)=(a+b)(a+c)(b+c)+4abc.$$
Done!

Help with Inequality


Can't display a list into panel although that it have a layout

Question: Hi StackOverFlow Community,
Well, maybe is theory that I forget read, but I don't stand why this code below don't show me anything. (I already try with another answers in the forum like config height manual and layout fit work but with these layout I can't do what I want).
Code:
<code>Ext.define('myMoney.view.Settings',{
    extend: 'Ext.Panel', //--> Ext.Container don't work either
    fullscreen: true,
    xtype: 'configuracion',

    config: {
        title: 'Configuracion',
        iconCls: 'settings',
        scrollable: true,
        styleHtmlContent: true,
        layout: {
            type: 'vbox',
            align: 'middle'
        },
        defaults: {
            width: '50%',
            height: '50%',
            flex:1,
        },

        items: [
            {
                xtype: 'list',
                itemTpl: '{item}',

                data: [
                    {item: 'Cuentas Actuales'},
                    {item: 'Agregar nueva Cuenta'},
                ]
            },
        ]
    }
});
</code>
The real code have two 'fieldset' before the list but I don't want show you guys a code too long. so, anyone knows what happens?
Answer: Usually it is fixed by  layout: 'fit' setting. You could add it to the outer fieldset config.
Comment: well, like I do is make a overlay panel, in the controller I do this: showAccount: function(button, id){
  showAccount = Ext.Viewport.add({
   xtype: 'panel',
   layout: 'fit',
   scrollable: true,
   hideOnMaskTap: true,
   modal: true,
   centered: true,
   width: '20%',
   height: '80%',
   styleHtmlCls: true,
    items:[
     {
      xtype: 'list',
      store: 'Clasificacion',
      itemTpl: '{name}'
     }
    ]
  });
 },


Is $P(\bigcup_{k=1}^\infty A_k)=\lim_{n\rightarrow\infty}P(\bigcup_{k=1}^n A_k)$ equivalent to countable additivity?

Question: The third axiom of probability theory, known as countable additivity, states that $$P(\bigcup_{k=1}^\infty A_k)=\sum_{k=1}^\infty P(A_k)$$ holds for any countable sequence of disjoint events $A_1,A_2,\dots$.
How about the following one? Are they inequivalent? Why? $$P(\bigcup_{k=1}^\infty A_k)=\lim_{n\rightarrow\infty}P(\bigcup_{k=1}^n A_k)$$
Comment: They are equivalent, **if** you assume finite additivity. Otherwise, most likely not. To elaborate: You mention the "third axiom", but there are more than one way to write up the axioms. I am used to having just the one you gave together with $P(\emptyset)=0$ and $P(\Omega)=1$.
Comment: Do you have any thoughts? Do you know the definition of an infinite sum? How can you rewrite $P$ of a finite union of disjoint events?
Comment: … I forgot to mention $P(A)\ge0$ …
Comment: Are the $A_k$ supposed to be disjoint in the second equality? Otherwise it reminds me more of the continuity of $P$ from below (I hope that is the right term) meaning that if $(A_k)$ isa sequence of increasing sets, i.e. $A_k \subseteq A_{k+1}$, then $P(\bigcup_{k=1}^{\infty} A_k) = \lim_{n\to \infty} P(\bigcup_{k=1}^n A_k) = \lim_{n \to \infty} P(A_n)$.
Comment: @GenericNickname: isn't it continuity from below regardless of whether $A_k$ are assumed to be disjoint or not?
Comment: @ilya only if $A_n$ are increasing.
Comment: @GenericNickname: well, their unions are increasing for sure.
Comment: @ilya that's right :)
Answer: Not in general: the property that you've described is called the continuity from below. That is, if a set function $\mu:\Sigma \to \Bbb R$ is such that $\mu(\bigcup E_n) = \lim_n \mu(E_n)$ where $E_n\subseteq E_{n+1}$, then we say that it is continuous from below. In your case $E_n = \bigcup_{k=1}^n A_k$.
As much as with usual functions, continuity does not imply additivity. For example, on a finite set any finite set function is continuous (since all infinite unions are finite unions), but of course there are set functions that are not measures, even on finite sets.


Fastest way to compute a column of a dataframe

Question: I'm getting a pandas issue that I need help with.
On the one hand, I have a DataFrame that looks like the following:
   contributor_id     timestamp     edits    upper_month   lower_month
0      8             2018-01-01       1      2018-04-01    2018-02-01
1      26424341      2018-01-01       11     2018-04-01    2018-02-01
10     26870381      2018-01-01       465    2018-04-01    2018-02-01
22     28109145      2018-03-01       17     2018-06-01    2018-04-01
23     32769624      2018-01-01       84     2018-04-01    2018-02-01
25     32794352      2018-01-01       4      2018-04-01    2018-02-01

On the other hand, I have (available in another DF), a given index of dates:
2018-01-01, 2018-02-01, 2018-03-01, 2018-04-01, 2018-05-01, 2018-06-01, 2018-07-01, 2018-08-01, 2018-09-01, 2018-10-01, 2018-11-01, 2018-12-01.

I need to create a pd.Series that has as an index the previously shown index. The data of the pd.Series must be, for each date in the index:
if date >= lower_month and date <= upper_month, then I add a 1.
The objective is to count, per each date, the number of times that the date is between the upper and lower month values in the previous DataFrame.
The sample output pd.Series for this case would be:
2018-01-01    0
2018-02-01    5
2018-03-01    5
2018-04-01    6
2018-05-01    1
2018-06-01    1
2018-07-01    0
2018-08-01    0
2018-09-01    0
2018-10-01    0
2018-11-01    0
2018-12-01    0

Is there a fast way of doing this calculation, avoiding to traverse the first dataframe a huge amount of times?
Thank you all.
Comment: What size are your dataframes?
Answer: Use list comprehension with flattening for test membership between zipped columns converted to tuples and values in range, create DataFrame and sum in generator:
rng = pd.date_range('2018-01-01', freq='MS', periods=12)
vals = list(zip(df['lower_month'], df['upper_month']))

s = pd.Series({y: sum(y >= x1 and y <= x2 for x1, x2 in vals) for y in rng})

EDIT:
For better performance use count method, thank you @Stef:
s = pd.Series({y: [y >= x1 and y <= x2 for x1, x2 in vals].count(True) for y in rng})

print (s)
2018-01-01    0
2018-02-01    5
2018-03-01    5
2018-04-01    6
2018-05-01    1
2018-06-01    1
2018-07-01    0
2018-08-01    0
2018-09-01    0
2018-10-01    0
2018-11-01    0
2018-12-01    0
dtype: int64

Performace:
np.random.seed(123)

def random_dates(start, end, n=10000):

    start_u = start.value//10**9
    end_u = end.value//10**9

    return pd.to_datetime(np.random.randint(start_u, end_u, n), unit='s').floor('d')

d1 = random_dates(pd.to_datetime('2015-01-01'), pd.to_datetime('2018-01-01')) + pd.offsets.MonthBegin(0)
d2 = random_dates(pd.to_datetime('2018-01-01'), pd.to_datetime('2020-01-01')) + pd.offsets.MonthBegin(0)

df = pd.DataFrame({'lower_month':d1, 'upper_month':d2})
rng = pd.date_range('2015-01-01', freq='MS', periods=6 * 12)
vals = list(zip(df['lower_month'], df['upper_month']))

In [238]: %timeit pd.Series({y: [y >= x1 and y <= x2 for x1, x2 in vals].count(True) for y in rng})
158 ms ± 2.55 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

In [239]: %timeit pd.Series({y: sum(y >= x1 and y <= x2 for x1, x2 in vals) for y in rng})
221 ms ± 17 ms per loop (mean ± std. dev. of 7 runs, 10 loops each)

#first solution is slow
In [240]: %timeit pd.DataFrame([(y, y >= x1 and y <= x2) for x1, x2 in vals for y in rng],                  columns=['d','test']).groupby('d')['test'].sum().astype(int)
4.52 s ± 396 ms per loop (mean ± std. dev. of 7 runs, 1 loop each)

Comment: This definitely worked. Could you provide an explanation of what exactly is the line s = pd.DataFrame([(y, y >= x1 and y <= x2) for x1, x2 in vals for y in rng],
                  columns=['d','test']).groupby('d')['test'].sum().astype(int)  doing?
Comment: @HRDSL - Added another better solution.
Comment: wouldn't `pd.Series({y: [y >= x1 and y <= x2 for x1, x2 in vals].count(True) for y in rng})` be more efficient and straightforward than abusing `sum`?
Comment: @Stef - I can test it.
Answer: I have used itertools to repeat the upper_month and lower month for each index_date
Then compare the index_date for each lower and upper_month and set temporary column
check = 1
Then sum check after group by index_date
import pandas as pd
from pandas.compat import StringIO, BytesIO
import itertools

#sample data
data = ('contributor_id,timestamp,edits,upper_month,lower_month\n'
'8,2018-01-01,1,2018-04-01,2018-02-01\n'
'26424341,2018-01-01,11,2018-04-01,2018-02-01\n'
'26870381,2018-02-01,465,2018-04-01,2018-02-01\n'
'28109145,2018-03-01,17,2018-06-01,2018-04-01\n')

orig_df = pd.read_csv(StringIO(data))

# sample index_dates
index_df = list(pd.Series(["2018-01-01", "2018-02-01"]))

# repeat upper_month and lower_month using itertools.product
abc = list(orig_df[['upper_month','lower_month']].values)
combine_list = [index_df,abc]
res = list(itertools.product(*combine_list))
df = pd.DataFrame(res,columns=["timestamp","range"])

#separate lower_month and upper_month from  range
df['lower_month'] = df['range'].apply(lambda x : x[1])
df['upper_month'] = df['range'].apply(lambda x : x[0])
df.drop(['range'],axis=1,inplace=True)

# convert all dates column to make them consistent
orig_df['timestamp'] = pd.to_datetime(orig_df['timestamp']).dt.date.astype(str)
orig_df['upper_month'] = pd.to_datetime(orig_df['upper_month']).dt.date.astype(str)
orig_df['lower_month'] = pd.to_datetime(orig_df['lower_month']).dt.date.astype(str)

#apply condition to set check 1
df.loc[(df["timestamp"]>=df['lower_month']) & (df["timestamp"]<=df['upper_month']),"check"] = 1

#simply groupby to count check
res = df.groupby(['timestamp'])['check'].sum()

print(res)

timestamp
2018-01-01    0.0
2018-02-01    3.0


DataTables - RowReorder not printing the updated row order

Question: After a row has been reordered, I would like to get the updated row order, but after all solutions tried, the original row order prints every time. How can I get the updated row order?
The docs suggest using dataTable.rows({ order: 'updated' }).data(), but it's not working.
Refer: DataTables
Answer: Try applied instead of updated
table.rows({ order: 'applied' }).data()
Possible values - 'current', 'applied', 'index',  'original'
More info on selector-modifier
Comment: Thanks for the suggestion, but I also tried all those options when worked through the documentation.
Comment: @deanwilliammills check which version are you using?


How exactly does a Galois group behave?

Question: Suppose that $L:K$ is a Galois extension, so that $L$ is the splitting field for a minimal polynomial $f$ over $K$. We can write $f$ as $$(t-\alpha _1)\ldots (t-\alpha _r)$$
so that any $K$-automorphism of $L$ can be thought of as a permutation of the zeroes of $f$. I'm wondering if all such permutations would lead to a $K$-automorphism of $L$, yet I haven't been able to (dis)prove it.

More generally, for a Galois extension $L:K$, in which $L$ is the splitting field of the polynomial $f$, which can be factored into irreducibles as $$m_1\ldots m_n,$$
if we let $\tau _i$ be an arbitrary permutation of the zeroes of $m_i$, would the product $\tau _1\ldots \tau_n$ be a $K$-automorphism of $L$?

I would appreciate any help/thoughts!
Answer: No, not every permutation need lead to an automorphism.
A cyclotomic field for example, is a field of the form $\mathbb{Q}(\zeta_n)$, where $\zeta_n$ is a primitive $n$th root of unity. It is the splitting field of $x^n-1$, and hence Galois. It is known that the Galois group $\mathrm{Gal}(\mathbb{Q}(\zeta_n)/\mathbb{Q})$ is always abelian, and so cannot be the full symmetric group if $n>3$ (the degree is $\phi(n)$, Euler's phi function at $n$).
Now, $x^n-1$ is not irreducible for $n>1$. $\mathbb{Q}(\zeta_n)$ is the splitting field of $\Phi_n(x)$, the $n$th cyclotomic polynomial. For arbitrary $n$ it may not be obvious what the value is, but when $n$ is prime, we have that
$$\Phi_p(x) = x^{p-1}+x^{p-2}+\cdots + x + 1$$
(which is $(x^p-1)/(x-1)$). This can be shown to be irreducible over $\mathbb{Q}$ by substituting $x=y+1$ and applying Eisenstein's Criterion at $p$.
So $[\mathbb{Q}(\zeta_p):\mathbb{Q}] = p-1$, and the Galois group is abelian. If $p>3$, this cannot be the symmetric group on $p-1$ letters.
(In fact, the Galois group of $\mathbb{Q}(\zeta_n)$ over $\mathbb{Q}$ is isomorphic to the group of units of $\mathbb{Z}/n\mathbb{Z}$, and so for $n$ a prime it will be cyclic of order $p-1$.)
In general, if $f$ is irreducible of degree $n$, then the Galois group is a transitive subgroup of $S_n$; thus, given any two roots $u$ and $v$ of $f$ you can always find an element of the Galois group that sends $u$ to $v$; but in general, you may not even have double transitivity. There may exist two pairs of distinct roots $u_1,u_2$ and $v_1,v_2$ for which no element of the Galois group sends $u_1$ to $v_1$ and $u_2$ to $v_2$.
Answer: Let $f \in F[x]$ and $K/F$ a splitting field of $f$. Suppose $f$ is separable so $K/F$ is Galois. Let the roots of $f$ in $K$ be $Z = \{\alpha_1, \dots, \alpha_n\}$. Let $G = Gal(K/F)$. We can define an injective map $G \longrightarrow \Sigma(Z) = S_n$ via $\sigma \mapsto \sigma|_Z$. This is well defined because any element of the Galois group permutes the roots of $f$ (indeed, $\sigma$ fixes $F$ - where the coefficients of $f$ live). It is injective as $K$ is generated over $F$ by the roots of $f$, as it is the splitting field.  We can therefore view $G \subseteq S_n$. Your question is whether or not $G = S_n$, and the answer is no.
First of all, if we furthermore assume $f$ to be irreducible, we have that $G$ acts transitively on the roots of $f$. This is a basic fact about Galois theory that I won't prove here. This is the same as saying that $G$ is a transitive subgroup of $S_n$ under this identification, but there are often many of these. For a concrete example, $\langle(1234)\rangle \subseteq S_4$ is a transitive subgroup. To witness this in Galois theory, take $\mathbb F_{p^4}/\mathbb F_p$. Letting $\alpha$ be a generator of $\mathbb F_{p^4}^\times$, $\mathbb F_{p^4} = \mathbb F_p(\alpha)$. Then of course, if $f$ is the minimal polynomial of $\alpha$, $\mathbb F_{p^4}$ is a splitting field. Its Galois group is $\mathbb Z/4$ and cyclically permutes the roots of $f$. Hence, there are permutations in $S_4$ (viewed as permutations of the roots of $f$) which do not induce field automorphisms.
More generally, let $f = \prod f_i^{e_i} \in F[x]$ be an irreducible factorization. Let the set of roots of each $f_i$ (assumed to be distinct) be $Z_i$. Let $G$ be the Galois group of $f$ and $Z = \bigcup Z_i$ the roots of $f$. Then certainly $G$ acts on $Z$, inducing an embedding $G \subseteq \Sigma(Z)$. However, this won't be a transitive subgroup of $\Sigma(Z)$ unless there is only one $f_i$ (so $f$ is a prime power). Hence, $G < \Sigma(Z)$. $G$ will, however, act transitively on each $Z_i$, so indeed these will end up being the orbits of this action.
Comment: Yup, let $\zeta_n$ be a primitive $n^{th}$ root of unity. Then $\mathbb Q(\zeta_n)$ is a Galois extension. It's a general fact that its Galois group is $(\mathbb Z/n)^\times$. This is often cyclic. Indeed, take $n = 5$ to get a cyclic Galois group of order 4.
Comment: Do you happen to know if counterexamples exist for fields of characteristic $0$?
Comment: Even when it is not cyclic, it is always abelian, so it cannot be all of $S_{\phi(n)}$ if $\phi(n)]\gt 2$.

How exactly does a Galois group behave?


Select element by its content and remove the first and last character of its content

Question: I have a dynamic page which fetches data from Google App Script and makes a visualization with them.
This is the code which I use as HTMLService
Index.html

So, I want to select the values of the last column of the visualization and remove the first and last character of them with CSS, JS, JQuery...no matter.
The values always contain <a href so the selector can be defined via contents of the element or its row number. I will try to explain with code what I'm trying to do but it is incorrect, because I am mixing the languages.

Or

Answer: $('some_selector') returns an object, so you cannot use slice on an object, it should be a string, like this after you get your tds :

var toBeSliced = "Hello world"; // string
    toBeSliced = toBeSliced.slice(1,toBeSliced.length -1 ); // cut off first and last chars
    console.log(toBeSliced);
after you get your html tags using which contain data you can use element.textContent.slice( _ , _ ) ;
String.prototype.slice()
Comment: so you may do the following :
1. get you html elements which contain your targeted data.
2. iterate over the result of your query.
3. get the text ( string ) content of each element you get.
4. do slicing
Answer: You need to loop each row to remove the first and last character of the last column. Replace the drawTable function with the below
function drawTable(response) {
        var data = response.getDataTable();
        var table = new google.visualization.Table(document.getElementById('table_div'));
        table.draw(data, {showRowNumber: false, width: '100%', height:'100%'});
        $(".google-visualization-table-table tr td:nth-child(11)").each(function() { // Assuming 11 is the last column number
           var data = $(this).text();
           $(this).text(data.slice(1, data.length - 1));
       });
    }


How can I run a query passing information from a form?

Question: I guess this is a silly question, but I'm having problems figuring this out.
I have two tables with loads of information used to make reports.
I have a query that joins these two tables.
The same query adds two simple filters: A date range and an ID checker.
The reports are supposed to be printed withing a date range with a specific ID.
Every time I need to change the query data range I need to manually edit it and change the parameters.
How can I make a form and pass this information to the query so I won't have to manually update the query every week?
I made a new form with two date fields and I would need some code to pass this information to the query before opening it, but DoCmd.OpenQuery Method doesn't permit I pass any information.
Ideally I'd prefer to use a SQL command to set the query and then open it, is this even possible?
Answer: Actually, I am using this method often:
Declare variables in a Module and write a function for each one that simply returns the value. You can then use the function call within the Query-Designer (e. g. criteria = Between getMyValue1() AND getMyValue2())
You can then set the global variables before opening the query.
(This has worked better for me than Query-Parameters or direct references to form fields within queries.)
Comment: Honestly, I'm not sure if this was the most elegant way to solve my problem but I really loved the fact that I can use functions within queries, this makes so many things so much easier - and I realized that I can actually call SQL commands using functions. Anyways, this solved my problems and blew my mind.
Comment: I have to agree that this is a really nice idea and an elegant solution!
Comment: I would even agree that this is _not_ really elegant on first sight, but to my mind the QueryDefs.Parameters should really be there just for this, but they don't work (I know only that they work when you set them and then directly work with QueryDef.OpenRecordSet inside vba code.) So I'm used to going this way now...
Answer: Open the report with a filter:
Dim sWhere as String
sWhere = "Tbl_Swift.Data >= #10/01/2012# AND Tbl_Swift.Data <= #10/10/2012#"
DoCmd.OpenReport "rptMyReportName", acViewPreview, ,sWhere

(I'm not sure if "BETWEEN" will work or not, although I think it should if you'd write it properly.)
Comment: +1 Use your form to collect the date range values, then create your OpenReport WhereCondition parameter (sWhere) string based on those dates.
Comment: It can't be this easy... I'm trying this now.
Comment: And it wasn't. I tried using the filter ´"Tbl_Swift.Data = "Tbl_Swift.Data = Between #01/01/2012# And #10/10/2012#"´ and I get a runtime 3075 error.
Comment: So you're saying you have a field named Data that holds date information? I'd recommend naming your fields more appropriately.
Comment: @JohnnyBigoode Try this: `sWhere = "Tbl_Swift.Data Between #2012-01-01# AND #2012-10-10#"`
Answer: You could also put a condition in your query that refers to a field in your form:
SELECT ... WHERE ID = [Forms]![FormName]![TextField]

Comment: Will this alter the code of the query? Should I run the SQL command and then simply DoCmd.OpenQuery?
Comment: You have to alter the code of the query just once, then you can just call DoCmd.OpenQuery. You don't have to use a query with parameters.
Answer: You have two options.

Do not put values of parameters in the query. Access will always ask for these values on every execution of query.
use DATE() function to get the current date and calculate the week start and end accordingly. This way, you will never have to provide the date.
Comment: Ok... But I don't want to manually type the values, I want Access to grab the information typed on the form.


How do I add a favicon to my custom theme?

Question: This seems like a simple question, but I couldn't find a clear answer when I googled so going to create one.
Comment: any update for D9/D10 ?
Answer: You can add a favicon by just adding a favicon.ico (or .png or .gif or other valid  favicon file type) to the root of your custom theme folder.
If you'd like to have your favicon stored in a custom location, see the method described here: (Change default favicon programmatically)
Edit:
If you simply want to give your theme the ability to change the favicon, without providing one yourself, you can add the setting to your theme settings folder by adding a /config/install/THEMENAME.settings.yml file to your theme, with the following settings:
<code>features:
  favicon: true
favicon:
  use_default: false
</code>
Comment: has this been tested on drupal9/10? does not work for me


Why use precision instead of variance in a prior?

Question: I am a newcomer in the field of statistic. I am wondering about using precision instead of variance in a prior.
Comment: Can you make your question more precise? As given, it is too vague.
Comment: I provided an answer that assumed that you ask about Normal distribution but please correct me if I am wrong. If the question is about parametrization of Normal distribution please edit your question so ti is more precise.
Answer: I guess that you ask about parametrization of Normal distribution, as some statistical software such as BUGS, or JAGS use precision rather than variance. First, notice that it is not true for every statistical package, e.g. R or Stan use "traditional" standard deviation (square root of variance), so this is not always true. Why precision is used? It is mostly for some historical, obsolete, reasons. The general rationale, as I heard about it, was that we are rather interested in how "precise", i.e. focused around the mean, is our variable, rather then how "unprecise" or diffuse it is, since we often think of it in terms of mean.
There is also another reason given by Kruschke (Doing Bayesian Data Analysis: A Tutorial with R, JAGS, and Stan, p. 454):

Because of its role in conjugate priors for normal likelihood
  function, the gamma distribution is routinely used as a prior for
  precision. But there is no logical necessity to do so, and modern MCMC
  methods permit more flexible specification of priors. Indeed, because
  precision is less intuitive than standard deviation, it can be more
  useful to give standard deviation a uniform prior that spans a wide
  range.

The problem with precision is also that in most cases people are interested in knowing the variance, so you end up with inverting precision.
Comment: In WinBUGS or BUGS $precision=\frac{1}{Variance}$
Comment: hehe, I did not read your last sentence before.
Comment: @DeepNorth yes, that is true - what you want to say..?


Make email validation message in drupal 7 webform come out in spanish

Question: I have a webform in spanish and I have manually put in all of the validation error messages in spanish, however I cannot find where I can make the "Please enter an email address" message which comes out if you put an invalid email into an email type field come out in spanish instead.
Thank you
Answer: Try with String Overrides module.
When you go to module settings choose 'Spanish' tab (if you have more than one language enabled), on the left side put "Please enter an email address" (without quotes of course) and on the right side write Spanish translation. (clear cache)
Let me know if this is working.
Comment: no didnt work for me.
Answer: another way I found to do it:
Go to configuration, translate interface, do a search for the error message in english and then add the spanish translation.
Answer: I just changed it to a text field instead of an email field and validated it with regex so I could put the error message in spanish.


Understanding signal-flow of Neutrik NYS-SPP-L1 Patch-Panel

Question: I purchased a patch-panel for my home studio, coming with the following diagrams:

My question is about the signal direction. Where are inputs and where are outputs on the first images in the row? Does it merge, or does it split signal?
Answer: A patch panel like this doesn't have any particular direction of signal flow. It's just connections. A patch panel like this can split a signal, but you generally can't merge signals with a patch panel.
There are some often used conventions for a patch panel. Especially when there are normals like this one.
The assumption made by Neutrik in the top row configuration is that the top rear plug is connected to an output, say the output from a mic preamp. Then the bottom rear plug is connected to an input, like the input on an audio interface. For the top row, those two jacks will be normalled together, which means they are connected if that is all you plug in. That means if you plug a mic into the mic preamp, you can record into your computer without making any other connections, because the mic pre out and the interface input are connected via the normal on the patch panel.
But if you want to put a compressor inline between the preamp and the interface, you don't have to unplug the preamp from the interface, you can just run a patch cable from the top front jack (connected to the preamp output) to the compressor input. Then run a patch cable from the compressor output to the bottom front jack (connected to the interface input) and your signal chain will be pre -> comp -> interface. When you plug into the bottom front jack, you break the normal between the top rear and bottom rear jacks, which means they are no longer directly connected.
Set up like that, a patch panel usually has outputs all along the top row and inputs on the bottom that are normalled together. You might have 24 mixer direct outs on top and 24 interface inputs on the bottom so you can record direct from the mixer or break the normal and insert something in between.

The bottom configuration is different. Those are really two different setups, because normally you are not changing connections on the rear jacks. You set them up once and leave them. The front jacks help you change the connections. So if the normal gets broken on the rear jack, that means you aren't really using it as a normal.
The lower left configuration is a splitter. You might plug an output into the bottom rear jack and that gives you two copies of that output on the top and bottom front jacks.
The lower right configuration is just a pass through. That means you are taking connections in the back of your rack and connecting them to those rear jacks to make then available at the front of your rack. Remember the compressor we talked about above? Maybe you have this lower right configuration for the compressor. The compressor is in the rack, so you can't easily get to it's inputs and outputs. So you plug the compressor input to the top rear jack and the compressor output to the bottom rear jack. Now when you want to interrupt the normal between your preamp and interface like in the example above, you run a patch cable from the front top where the preamp is connected to the front top jack of the compressor, and then another patch cable from the front bottom jack where the compressor is plugged in back over to the front bottom jack where the interface is normalled to the preamp.
Now if I wrote that clearly enough, you might be thinking "why can't I just leave the patch panel configured like in the top row and hook up the compressor that way? It will be normalled to itself but that doesn't matter". The answer is, you can totally do that and that's an easier way to run the patch panel because you don't have to flip over the cards in some places and not in others.

Probably (hopefully), you're seeing now that the most important thing about setting up a patch panel is planning it and labeling it. Otherwise, it's going to be more annoying than it is helpful.
Comment: Awesome, just awesome! THX. I have one more question about connecting the compressor like in the top row: Wouldn't that create some kind of feedback loop inside this circuit, having the inputs of the compressor connected to its own outputs?
Comment: @nath Well yes. If you want to be able to leave the compressor on and not have to worry about that, better to flip the patch panel card. Other options would be to leave the compressor off when not in use or make sure the output gain is all the way down when it's not patched in. Or leave a patch cable plugged into the bottom front to break the normal.
Comment: @nath Short answer: no signal loss. Medium answer: Assuming you are using properly built line level inputs and outputs, there should be bridging impedances at both inputs. That means that if you split the signal using the patch bay, the inputs will look like they are wired in parallel and the power transfer will be high impedance - mostly voltage. Loads in parallel see the same voltage and each take a share of the current, so if you are sending a mostly voltage signal, parallel loads will get essentially the full signal. Long answer: ask on electronics.SE.
Comment: @ToddWilcox Yes label it label it label it. I was fortunate enough to work at a studio that had a very well labeled patch bay. i was also unfortunate enough to work at a studio that didn't have a well labeled patch bay and i can tell you, please please please for the love all that is good in the world....label your patch bay.
Comment: and uhh, sorry another one: assuming I would route the signal from my mic like in the top row to a complete different input without returning it, wouldn't I then get a dB loss because the signal would get fed to both, the original input and the new? (as it would probably be the case on the splitter on the first image of row two)


Proper way to query in Hugo using goTemplates with multiple nested arguments, is it possible?

Question: I'm working with Hugo and have a question regarding where clause. Currently I am doing the following and it works fine. I attempted to add one more where argument and I got the error below:
Question: How do I add multiple nested arguments to Hugo where clause. I will continue to test it out in the meantime.
Error calling where: can't evaluate the array by no match argument or more than or equal to two arg:uments
Works:
{{ range where (where site.Pages "Type" "post") "Params.type" "featured"  }}

                    {{ .Render "li" }}

            {{ end }}

Fails:
{{ range where (where site.Pages "Type" "post") "Params.type" "featured" "Params.location" "nashville" }}

                        {{ .Render "li" }}

                {{ end }}

Per Hugo:
Nest where Clauses
You can also nest where clauses to drill down on lists of content by more than one parameter. The following first grabs all pages in the "blog" section and then ranges through the result of the first where clause and finds all pages that are not featured:
Answer: I was able to resolve this, after reading some additional information at https://pkg.go.dev/text/template#pkg-overview; I went with the below.

        {{ range where (where site.Pages "Type" "post") "Params.featured" "!=" nil  }}
        {{ if(eq .Params.location "nashville")}}

                {{ .Render "li" }}

        {{ else}}
         Coming Soon
        {{end}}
        {{end}}