Solve the following inequalities

Question: Does there exist a general formula for comparing two prime numbers powers .
Ex. $$ max(2^{2002},3^{1335} )$$ or $$ max(2^{2004} ,3^{1202} ) $$
NOTE: Im a twelfth grader and i accidentally stumbled across these problems.I am curious for an universal method or ,at least , for their solution.
Comment: Yes there is an universal method : using the logarithms
Comment: If you use the logarithm you still have to know the value of log2 or log 3 etc.
Comment: of course .This is what I meant .
Answer: I'll explain a general method (will not work for all problems but for your problems is enough ) . This is essentially equivalent with the logarithm method in some way .
First find some $x$ and $y$ such that $3^x >2^y$ . Use fairly big values and not something like $3^2>2^3$ . For example $3^7=2187>2048=2^{11}$ would suffice .
Now suppose you want to prove something like $3^a>2^b$ .Use our inequality $3^7>2^{11}$ and raise it to the power $\frac{a}{7}$ so :
$$3^a>2^{\frac{11a}{7}}$$
Now with a little wishful thinking we would want that $\frac{11a}{7}\geq b$ and then we would be done :
$$3^a>2^{\frac{11a}{7}}\geq 2^b$$ as wanted .So we want that $\frac{a}{b}\geq \frac{7}{11}$
Note :This is where the similarity with the logarithm method is clearly seen :
Using the logarithm method we would compare $\frac{a}{b}$ with $\frac{\log 2}{\log 3}$ but now we compare it with our approximation for $\frac{\log 2}{\log 3}$ namely $\frac{7}{11}$ .
In this case we're lucky because it can be verified that $\frac{a}{b}=\frac{1335}{2002}>\frac{7}{11}$ (use WolframAlpha if you're lazy :))
Hope you can now solve the other problem . Good luck .
Comment: It's a nice way of solving those problem.I appreciate your work!

Solve the following inequalities


Which (apparently keyboard) instrument is this?

Question: I discovered this image recently while reading about piano. I discovered this young Portuguese pianist photo, Vianna da Motta, while learning in his early stages.
I assume this is some kind of keyboard instrument but its not clear and the format is very unusual. Which instrument is it?
Answer: It looks like one of pump organs, like:

The instrument was invented in 1855, and da Motta was born 1868, so this was the high technology of its day, not some boring old pianoforte!
Answer: I'm certainly no authority on the subject, but it looks like some sort of foot operated harmonium or accordion.
The attached image shows a similar instrument and calls it an "accordion worked with pedals", but it may be more recent than your example.
Answer:
Just found this picture, it's the same picture from the original question by nsn, but with a framing and caption from a magazine. The legend says "Vianna da Motta aged five, playing the harmonium flute".
I believe it's precisely the same instrument model shown on the photo posted by alephzero, to the details of the turned shapes of the legs.
The specific name seems to be related with a french origin and making of the instrument. Quoting from Harmoniflûte wikipedia page (my translation from french):
"The parisien factory of Constant Busson...built mainly accordeons ...and other instruments. Constant Busson decided to explore the market of instruments betwwen the accordeon and the pump organ, ... and invented the harmoniflûte, presenteng it at the 1855 Paris World Fair. Another harmoniflûte was invented by Mayer in Paris at roughly the same time".
Answer: Harmoniflute, a kind of reed organ with only two ranks of reeds, both 8', but the second is celeste-tuned i.e. When played with the first rank the second produces a regular beating, due the tuning diference.


How to evaluate this integral $\int_{-a}^{a}{e^{-\iota k x}}dx$?

Question: I am having trouble to evaluate this integral.
$$\int_{-a}^{a}{e^{-i k x}}dx=2\frac{\sin\left(a k\right)}{k}$$
Here $\iota$ stands for imaginary part.
Any input will be appreciated.
Comment: It is the same as integrating $\cos(kx)$ over $[-a,a]$, since the odd part of the integrand function gives no contribute to the integral.
Comment: what is $\iota$?
Comment: 1. Surely you know a primitive of $e^{-ikx}$? 2. The RHS is incorrect.
Answer: By Eular's formulate, $e^{-ikx} = cos(kx) -i \sin kx$
$$\int_{-a}^{a}{e^{-\iota k x}}dx= \int_{-a}^{a}{cos(kx)}dx - i\int_{-a}^{a}{ \sin kx}dx $$
From this post's first answer: since $ sin x $ is a ood function and the interval $[-a,a]$ symmetric about origin.
$$\int_{-a}^{a}{e^{-\iota k x}}dx= \int_{-a}^{a}{cos(kx)}dx = 2sin(ka)/k$$
I think the a in the text is a typo.
Answer:
Use:

$$re^{\varphi i}=r\cos(\varphi)+r\sin(\varphi)i$$
$$\cos(-x)=\cos(x)$$
$$\sin(-x)=-\sin(x)$$

$$\int_{-a}^{a}e^{-ikx}\space\text{d}x=\int_{-a}^{a}\left(\cos(-kx)+\sin(-kx)i\right)\space\text{d}x=\int_{-a}^{a}\cos(kx)\space\text{d}x-i\int_{-a}^{a}\sin(kx)\space\text{d}x$$
Now, for the integrals substitute $u=kx$ and $\text{d}u=k\space\text{d}x$:
$$\frac{1}{k}\int_{-ak}^{ak}\cos(u)\space\text{d}u-\frac{i}{k}\int_{-ak}^{ak}\sin(u)\space\text{d}u$$
Now, use:

$$\int\cos(x)\space\text{d}x=\sin(x)+\text{C}$$
$$\int\sin(x)\space\text{d}x=\text{C}-\cos(x)$$

So, we get:
$$\frac{1}{k}\int_{-ak}^{ak}\cos(u)\space\text{d}u-\frac{i}{k}\int_{-ak}^{ak}\sin(u)\space\text{d}u=\frac{1}{k}\left[\sin(u)\right]_{-ak}^{ak}-\frac{i}{k}\left[-\cos(u)\right]_{-ak}^{ak}=$$
$$\frac{1}{k}\left(\sin(ak)-\sin(-ak)\right)+\frac{i}{k}\left(\cos(ak)-\cos(-ak)\right)=$$
$$\frac{1}{k}\left(\sin(ak)+\sin(ak)\right)+\frac{i}{k}\left(\cos(ak)-\cos(ak)\right)=$$
$$\frac{1}{k}\left(2\sin(ak)\right)+\frac{i}{k}\left(0\right)=\frac{2\sin(ak)}{k}+0=\frac{2\sin(ak)}{k}$$
Answer: Using the Taylor series of $e^{z}
 $ we get $$I=\int_{-a}^{a}e^{ikx}dx=\sum_{m\geq0}\frac{i^{m}k^{m}}{m!}\int_{-a}^{a}x^{m}dx=a\sum_{m\geq0}\frac{i^{m}k^{m}a^{m}}{\left(m+1\right)!}-a\sum_{m\geq0}\left(-1\right)^{m+1}\frac{i^{m}k^{m}a^{m}}{\left(m+1\right)!}
 $$ and now we note that there is canellation if $m
 $ is odd. So $$I=2a\sum_{m\geq0}\frac{i^{2m}k^{2m}a^{2m}}{\left(2m+1\right)!}=2a\sum_{m\geq0}\frac{\left(-1\right)^{m}k^{2m}a^{2m}}{\left(2m+1\right)!}=2\frac{\sin\left(ka\right)}{k}$$ from the Taylor series of $\sin$.
Comment: Why the downvote? If something is wrong please write a comment. A downvote without any comment is absolutely unconstructive.


Construction of $\sigma$-ring

Question: Let $X \neq \emptyset$ an arbitrary set and $\mathcal{C}=\{C_1,C_2, \ldots, C_n \} \subseteq \mathcal{P}(X)$. My question is if the $\sigma$-ring generated by $\mathcal{C}$ coincide with the ring generated by $\mathcal{C}$.
I know that the ring generated by $\mathcal{C}$ is
$$ R(\mathcal{C}) = \{ A_1 \triangle A_2 \triangle \ldots \triangle A_n \vert A_i \hspace{0.2cm} \text{is a finite intersection of elements of} \hspace{0.2cm}  \mathcal{C}  \}$$
And the $\sigma$-ring generated by $\mathcal{C}$ is the small $\sigma$-ring that contains $\mathcal{C}$.
Answer: Yes, with only a finite number of sets $C_1, \ldots, C_n$,
the ring they generate consists of a finite number of distinct sets, and so any countable union of these is equal to a finite union.
Comment: Thanks, it's possible to calculate the numbers of elements of $R(\mathcal{C})$

Construction of $\sigma$-ring


Calling stored procedure in MySQL takes forever to execute

Question: I have a stored procedure which I'm trying to call, and it takes forever to execute. I have no idea what's wrong. A similar stored procedure in another database executes perfectly. I'm not well-versed with MySQL Workbench, so I don't know if the database settings are different or something.
Following is my stored procedure:
CREATE
DEFINER = `admin`@`%`
PROCEDURE `calculate_daily_coil_moved_by_crane_data`()

BEGIN
    set @curr_date = curdate();
    set @pre_date = date_add(curdate(), interval -1 day);
    set @a_shift_start_ts = concat(@pre_date, ' 06:00:00');
    set @a_shift_end_ts = concat(@pre_date, ' 13:59:59');
    set @b_shift_start_ts = concat(@pre_date, ' 14:00:00');
    set @b_shift_end_ts = concat(@pre_date, ' 21:59:59');
    set @c_shift_start_ts = concat(@pre_date, ' 22:00:00');
    set @c_shift_end_ts = concat(@curr_date, ' 05:59:59');

    SELECT  @curr_date,
            @pre_date,
            @a_shift_start_ts,
            @a_shift_end_ts,
            @b_shift_start_ts,
            @b_shift_end_ts,
            @c_shift_start_ts,
            @c_shift_end_ts;

    #SET DATA
    insert into daily_coil_move_by_crane_data_for_report (crane_id, crane_name, date, a_shift, b_shift, c_shift)
    select cr.id, cr.name, @pre_date, 0, 0, 0
    from yms_phase3.crane cr
    where active = 1
    order by cr.name;

    #----------------------------------------------------------------------------------------------------
    #--> COILS MOVED BY CRANE A Shift <--
    #----------------------------------------------------------------------------------------------------
    SET @shift = 'A';

    #FETCH ROW DATA
    update daily_coil_move_by_crane_data_for_report
    set a_shift = ifnull((select COUNT(*)
                            FROM yms_phase3.workorder_history in_data
                            where in_data.crane_id = daily_coil_move_by_crane_data_for_report.crane_id
                                and current_execution_status IN (6 , 7)
                                and in_data.pick_ts between @a_shift_start_ts and @a_shift_end_ts
                            group by in_data.crane_name), 0)
    where (a_shift is null or a_shift = 0);

    #----------------------------------------------------------------------------------------------------
    #--> COILS MOVED BY CRANE B Shift <--
    #----------------------------------------------------------------------------------------------------
    SET @shift = 'B';

    #FETCH ROW DATA
    update daily_coil_move_by_crane_data_for_report
    set b_shift = ifnull((select COUNT(*)
                            FROM yms_phase3.workorder_history in_data
                            where in_data.crane_id = daily_coil_move_by_crane_data_for_report.crane_id
                                and current_execution_status IN (6 , 7)
                                and in_data.pick_ts between @b_shift_start_ts and @b_shift_end_ts
                            group by in_data.crane_name), 0)
    where (b_shift is null or b_shift = 0);

    #----------------------------------------------------------------------------------------------------
    #--> COILS MOVED BY CRANE C Shift <--
    #----------------------------------------------------------------------------------------------------
    SET @shift = 'C';

    #FETCH ROW DATA
    update daily_coil_move_by_crane_data_for_report
    set c_shift = ifnull((select COUNT(*)
                            FROM yms_phase3.workorder_history in_data
                            where in_data.crane_id = daily_coil_move_by_crane_data_for_report.crane_id
                                and current_execution_status IN (6 , 7)
                                and in_data.pick_ts between @c_shift_start_ts and @c_shift_end_ts
                            group by in_data.crane_name), 0)
    where (c_shift is null or c_shift = 0);

    #----------------------------------------------------------------------------------------------------
    #INSERT ALL CRANE ENTRY
    insert into daily_coil_move_by_crane_data_for_report (crane_id, crane_name, date, a_shift, b_shift, c_shift)
    select -1, 'ALL', @pre_date, SUM(a_shift), sum(b_shift), sum(c_shift)
    from daily_coil_move_by_crane_data_for_report
    where date = @pre_date
    group by date;

    #UPDATE TOTAL
    update daily_coil_move_by_crane_data_for_report
    set total_coils_moved = (a_shift + b_shift + c_shift)
    where date = @pre_date;
END

Also tried to execute the query from Java using the following:
jdbcTemplate.execute("CALL calculate_daily_coil_moved_by_crane_data;");

But it gives me the following Exception:
java.sql.SQLException: Lock wait timeout exceeded

Any workaround I can do to solve this?
Comment: Can you edit your question with `daily_coil_move_by_crane_data_for_report` table definition
Comment: How big are the tables?  Add `SELECT SYSDATE();` before/after each SQL to see which one(s) are the slowest.  Then let's debug that one.
Answer: Please try and edit the configuration file, also search for the same here on stack.  There are certain possibilities while checking this out,

Check and edit the config file on Hard drive for MySQL increase the cache capacity and default values as the default values are in KB's the memory allocated is very less and to execute such a big procedure it should at least be some MB.
Increase the connection String timeout, that is by setting up right time in seconds. by default it is 60 seconds, which is very less for executing such a procedure, I think in c# at least we set it to '0' seconds which means that it shall not get timed-out till the query is executed.
If Any left Joins/ inner query please try and check whether the same output is produced in inner joins ? as inner joins are faster than left or right joins.
Add Indexes, have foreign key references properly mapped for faster execution of query.
Hope it works.


Error encountered inserting into a database in C#

Question: I am inserting values into a database but i get an error when the value to be inserted has an apostrophe e.g Jo's. How do i resolve this?
This is my code
<code>     SqlDataReader readerReference = cmd_Reference.ExecuteReader();

        int loginIndex = readerReference.GetOrdinal("a column");
        int DomCodeLoginIndex = readerReference.GetOrdinal("a column");
        int dom_domain = readerReference.GetOrdinal("dom_domaine");
        int emp_surname = readerReference.GetOrdinal("a column");
        int emp_name = readerReference.GetOrdinal("a column");
        int srv_name = readerReference.GetOrdinal("a column");
        int emp_model_tel = readerReference.GetOrdinal("a column");
        int emp_EntryDate = readerReference.GetOrdinal("a column");
        int emp_Telephone = readerReference.GetOrdinal("a column");
        int emp_Mobile = readerReference.GetOrdinal("a column");
        int emp_Email = readerReference.GetOrdinal("a column");

        string insert = "INSERT INTO EMP_tracking(emp_login, emp_dom_code, emp_domain,   emp_affectation_date, emp_surname" +
            ",emp_name, emp_service,emp_telephone_model" +
            ",emp_entry_date" +
            ",emp_telephone_number" +
            ",emp_cellphone_number" +
            ",emp_email) VALUES ('{0}',{1},'{2}','"+DateTime.Now.ToString("yyyy/MM/dd hh:mm:ss") +"','{3}','{4}','{5}','{6}','{7}','{8}','{9}','{10}')";

    string toInsert = string.Format(insert, readerReference.GetString(loginIndex),
                                            readerReference.GetInt32(DomCodeLoginIndex ),
                                            readerReference.GetString(dom_domain),
                                            readerReference.GetString(emp_surname ),
                                            readerReference.GetString(emp_name),
                                            readerReference.GetString(srv_name),
                                            readerReference.GetString(emp_model_tel),
                                            readerReference.GetDateTime(emp_EntryDate),
                                            readerReference.GetString(emp_Telephone),
                                            readerReference.GetString(emp_Mobile),
                                            readerReference.GetString(emp_Email)
                                   );

    cmd_Insert.CommandText = toInsert;
    cmd_Insert.ExecuteNonQuery();
</code>
Let's say the column concerned is emp_login. How will the solution be implemented on it?
Comment: You have to escape the apostrophe
Answer: Use Parameterized queries , that will resolve your issue and will save you from SQL injection
See this tutorial: C-Sharp Database Parameterized Insert Tutorial
Answer: This question comes up over and over again. You should not create SQL strings using concatenation - instead use paremeters:
<code>string insert = "INSERT INTO EMP_tracking(emp_login, emp_dom_code, emp_domain,   emp_affectation_date, emp_surname" +
        ",emp_name, emp_service,emp_telephone_model" +
        ",emp_entry_date" +
        ",emp_telephone_number" +
        ",emp_cellphone_number" +
        ",emp_email) VALUES (@emp_login, @emp_dom_code, //... etc.";

cmd_Insert.Parameters.AddWithValue("@emp_login", readerReference.GetString(loginIndex));
cmd_Insert.Parameters.AddWithValue("@emp_dom_code", readerReference.GetInt32(DomCodeLoginIndex));
//etc...
</code>
Answer: You can try escaping the apostrophe with another apostrophe.
There's a similar question here:  How to insert a value that contains an apostrophe (single quote)?.
Warning: SQL injection alert. Don't allow db manipulation except through parameters.


Libraries Not Loaded After Cache Clear / Reload

Question: I'm experiencing a problem with drupal 8
whenever I clear the cache, my custom theme's libraries(ex: the css and js) will not be loaded
and I must reinstall the whole drupal to make it works again
is there anything I can do to trace the source of the problem ?
Nothing strange is being logged in nginx and php's error log
Answer: Solved
this issue occurred because I've another custom module with the same name as the theme.


Sobolev space on closed subset of the real line

Question: Everywhere I look in the literature, Sobolev spaces are defined on an open subset of the real line. What are the technical issues with defining a Sobolev space on a closed subset, i.e. are there problems at the boundary, and does anyone know any good references that cover this?
My main purpose is to prove $H^1([0,T];\mathbb{R}) =
\{ x \in L^2([0,T];\mathbb{R}) : ||x'||_{L^2} + \gamma^{2}||x||_{L^2} < \infty \}$ is a reproducing kernel Hilbert space. I can do this for $(0,T)$ and want to know if the proof is transferable to the case of the closed interval $[0,T]$.
Many thanks,
Matthew.
Answer: Well, I suspect you defined the Sobolev space on the close interval as the one on the open interval (i.e. using the same functional equation taking the test functions on $\mathscr{C}^{\infty}_0((0,T))$), and then extend every function of it by choosing arbitrary values on the boundary.
In that case $H^1((0,T))=H^1([0,T])$ and your problem is of little concern, because every function of $W^{1,1}((0,T))$ is also continue on the closed interval $[0,T]$ (i.e. they admit finite limit on the boundary). So you can apply, by limit, the same technique you used in the case of the open interval $(0,T)$ (for example using the continuous inclusion of $W^{1,1}(I)$ in $L^{\infty}(I)$).
Anyway, I think the main reason beyond defining Sobolev space on open sets lies in this: $\mathscr{C}^{\infty}_0(\bar{I})=\mathscr{C}^{\infty}(\bar{I})$.


Can a back row player joust at the net without jumping?

Question: A tall back-row player executes a legal back-row attack, ending up near the net, and is immediately in a position to "joust" for a tight ball by simply reaching above the net, without jumping, winning the point.  Is this an illegal block by a back-row player?
The ruleset in use by this league is unclear, bonus points for any differences.
Answer: This is an illegal block. Quoting FIVB rule 14.1.1:

Blocking is the action of players close to the net to intercept the ball
  coming from the opponent by reaching higher than the top of the net,
  regardless of the height of the ball contact. Only front-row players are
  permitted to complete a block, but at the moment of the contact with
  the ball, a part of the body must be higher than the top of the net.

and 14.6.2 which lists the faults which can be made while blocking:

A back-row player or a Libero completes a block or participates in a
  completed block.

In particular, note that it is the fact of reaching higher than the top of the net which makes it a block. Whether or not the player jumps is irrelevant.


Mostrar Div apenas no segundo pageview e eliminar o cookie em um determinado tempo

Question: Já procurei e não achei nada relacionado, queria um código para mostrar uma DIV no segundo pageview de uma pessoa em um site, e não mostrar mais num periodo pré determinado.
Answer: Pode criar um cookie com a data atual e depois procurar esse cookie. Na segunda visualização junta mais uma variavel ao cookie para saber que já foi visto.
Por exemplo:
// gerar um timestamp em milisegundos
var agora = Date.now(); // ou "new Date().getTime();" em browsers antigos

// ler a data do cookie, se houver
var dataCookie = document.cookie.match(/_criado=([\d]+)/);
dataCookie = dataCookie ? parseInt(dataCookie[0], 10) : agora;

// procurar no cookie por "_criado"
if (document.cookie.indexOf('_criado' == -1)){
    // primeira visita: criar o cookie
    document.cookie = document.cookie + '; _criado=' + agora + ';';
}
else if (document.cookie.indexOf('_segundavisita' == -1) && dataCookie + 2629740000 - agora > 0){
    // segunda visita e caso o cookie esteja dentro de 1 mês de validade
    document.cookie = document.cookie + ' _segundavisita=true;';
    // corre aqui o código da segunda visita
}

Nota: 2629740000 é 1 mês em milisegundos


Get the minimum number which can be divided by 63 and modulus 40 equals 1

Question: I have got a puzzle to find out the smallest n (natural number) that:
n modulus 2 is 1.
n modulus 3 is 0.
n modulus 4 is 1.
n modulus 5 is 1.
n modulus 6 is 3.
n modulus 7 is 0.
n modulus 8 is 1.
n modulus 9 is 0.
It is not hard to find out that n % 63 == 0 and n % 40 == 1. Then I wrote a small program to find out the smallest n is 441.
But my question is, is there any mathematical way in finding out the smallest number in the last part, rather than using a program to traverse? Or is traverse the only approach in this situation?
Comment: See https://en.wikipedia.org/wiki/Chinese_remainder_theorem , especially the  Existence (constructive proof) part. Since one of the remainders is 0 and the other is 1, a simple application of the extended Euclidean algorithm referenced therein is enough.
Answer: One way to solve this problem is by using the Euclidean Algorithm. You know $n=63k$ and $n=40j+1$ for some $j,k\in\mathbb{N}$. Setting these equal to each other, you find $63k-40j=1$. If you continually divide and keep track of remainders using the Euclidean Algorithm, you find:
\begin{align*}
63&=1\cdot40&+23\\
40&=1\cdot23&+17\\
23&=1\cdot17&+6\\
17&=2\cdot6&+5\\
6&=1\cdot5&+1\\
\end{align*}
With this system of equations, you can now start from the bottom and work your way to the top to express $1$ as a linear combination of $63$ and $40$:
\begin{align*}
1&=6-1\cdot5\\
&=6-1\cdot(17-2\cdot6)\\
&=3\cdot6-1\cdot17\\
&\dots\\
&=7\cdot63-11\cdot40\\
\end{align*}
Since $7$ and $11$ are relatively prime, there is no smaller multiple of $63$ than $7\cdot63=441$ which satisfies the original problem.
Answer: Your preliminary results capture all the prime powers in the given modulus values, so those two statements allow a complete solution through the Chinese Remainder theorem.
Since the inverse of $63\equiv 23 \bmod 40$ is $7$, we find that $7\times 63 = 441$ gives us the combination we require, $441\equiv 0 \bmod 63$ and $441\equiv 1 \bmod 40$. There will be further solutions every $40\times 63=2520$, eg at $2961$


Proving Identifiability Using Law of Large Numbers?

Question: Well normally proving identifiability follows by showing that $p_{\theta}(x)=p_{\theta'}(x)$ implies $\theta=\theta'$. Usually this proceeds by showing that a function dependent on $\theta$, such as log-likelihood (or conditional log-likelihood in the case of Logistic Regression) leading to equality implies the equality  $\theta=\theta'$. In that sense it is like showing the likelihood function is one-to-one when applied to a single data point. To be more precise for a dataset of size one $\mathcal{D}=\{X\}$ from Gaussian distribution, to show identifiability we write:
$$nll_{\mu, \sigma}(\mathcal{D})=c + \log(\sigma) + \frac{1}{2{\sigma}^2}(X-\mu)^2=c + \log(\sigma') + \frac{1}{2{\sigma'}^2}(X-\mu')^2$$. Now taking the derivative twice with respect to $X$ we get
$$\frac{1}{\sigma^2}=\frac{1}{{\sigma'}^2}$$
which then implies $\sigma=\sigma'$. Conclusion about $\mu=\mu'$ also follows with similar algebraic manipulations.
My question is what if we imply identifiablity for the likelihood of a large set of points rather than one point only, and in doing so, we could incorporate limiting laws such as LLN. For example in the case of identifiability of Gaussian distribution we can do as follows. Again assume  $X_i\sim \mathcal{N}(\mu, \sigma)$.
Now if we have
$$
nll_\mu(\mathcal{D})=c + N\log(\sigma) + \frac{1}{2{\sigma}^2}\sum_{i=1}(X_i-\mu)^2=c +N\log(\sigma')+ \frac{1}{2{\sigma'}^2}\sum_{i=1}(X_i-\mu')^2
=nll_{\mu'}(\mathcal{D})$$
dividing both sides with $N$ and taking the limit of $N\to\infty$ which implies using SLLN:
$$\log(\sigma)+\frac{1}{2}\overset{P}{=} \log(\sigma')+\frac{1}{2}$$
which implies $\sigma=\sigma'$.
So rather than using a single point, I am using a large sample of points to show identifiability. Is this allowed? If so where can I find this formally written in a textbook? If not, why not? Isn't the point to show that when large enough sample is gathered we can identify the true parameter anyway?
Comment: Because the point of LLN (weak or strong) is to show convergence to a particular constant. If you want some other result about convergence ("to a large set of points"), then please be more specific. You may have something very useful in mind, but it's not clear (to me) what.
Comment: I understand that, and I am using here the knowledge of this squared summation converging to a particular constant to conclude identifiability of normal distributions. I am trying to understand if I am allowed to do this, but I'll add more detais.
Comment: @BruceET to emphasize again what I care about is *identifiability* the whole attempt is to use LLN as a tool to prove identifiability by relying on inifinitely large sample size.
Answer: Ultimately, the problem here is that $\sigma \stackrel{P}{=} \sigma' $ does not imply that $\sigma = \sigma'$, so no, you cannot. A couple of notes though:

Well normally proving identifiability follows by showing that $p_{\theta}(x)=p_{\theta'}(x)$ implies $\theta=\theta'$.

Since the definition of identifiability is that the function $\theta \mapsto p_\theta$ is injective (one-to-one), every proof must ultimately show that $p_{\theta}(x)=p_{\theta'}(x)$ implies $\theta=\theta'$, since that is the definition of an injective function. There might be different ways to arrive at this conclusion, but it is a necessity for the proof.

[this] is like showing the likelihood function is one-to-one when applied to a single data point.

This is true, but nothing about the function $\theta \mapsto p_\theta$ has anything to do with data points, it's simply the case that the two look the same analytically when there is one data point. The function $\theta \mapsto p_\theta$ is determined only by how we decided to represent a certain set of distributions by their parameters. It's all a priori and not based on any kind of data collection whatsoever.
Addendum: Okay, let's go through it formally. Let $\mathscr{L}$ denote the negative log-likelihood, which we need to view as a function not only of the parameters $\mu$ and $\sigma$, but also as a random variable, i.e. as a function of $\omega \in \Omega$ where $\Omega$ is the sample space:
$$
\mathscr{L}_{\mu , \sigma} (\omega) = c + N \log(\sigma) + \frac{1}{2\sigma^2} \sum_{i=1}^N (X_i (\omega) - \mu)^2
$$
Start with the assumption that $p_{\mu, \sigma} = p_{\mu', \sigma'}$. Since we have two distributions, we should have two samples, say $X_i$ and $Y_i$, and we know that $E(X_i) = \mu$, $V(X_i) = \sigma^2$, $E(Y_i) = \mu'$, and $V(Y_i) = \sigma'^2$. We can cancel the constants $c$ and write
\begin{align}
N \log(\sigma) + \frac{1}{2\sigma^2} \sum_{i=1}^N (X_i (\omega) - \mu)^2 & = N \log(\sigma') + \frac{1}{2\sigma'^2} \sum_{i=1}^N (Y_i (\omega) - \mu')^2 \\
N \log(\sigma) + \frac{N}{2\sigma^2} \left(\frac{1}{N}\right) \sum_{i=1}^N (X_i (\omega) - \mu)^2 & = N \log(\sigma') + \frac{N}{2\sigma'^2} \left(\frac{1}{N}\right) \sum_{i=1}^N (Y_i (\omega) - \mu')^2
\end{align}
and now we want to apply the weak law of large numbers (WLLN) (since you are using the notation for convergence in probability, not almost sure convergence like you would get from using the strong law of large numbers) to both sides which tells us that
\begin{align}
\left(\frac{1}{N}\right) \sum_{i=1}^N (X_i (\omega) - \mu)^2 & \stackrel{P}{\rightarrow} E[(X_i (\omega) - \mu)^2] = \sigma^2 \\
\left(\frac{1}{N}\right) \sum_{i=1}^N (Y_i (\omega) - \mu')^2 & \stackrel{P}{\rightarrow} E[(Y_i (\omega) - \mu')^2] = \sigma'^2.
\end{align}
Let's remember what convergence in probability means though:
$$
\left(\frac{1}{N}\right) \sum_{i=1}^N (X_i (\omega) - \mu)^2 \stackrel{P}{\rightarrow} \sigma^2 \iff \\
\lim_{N \to \infty} P(\{\omega \in \Omega : |\overline{(X_i (\omega) - \mu)^2} - \sigma^2 | > \epsilon) = 0 \ \forall \  \epsilon > 0
$$
where I've used the bar notation for average. This only tells us that for "most" values of $\omega$ that $\overline{(X_i (\omega) - \mu)^2} - \sigma^2$. We cannot conclude that $\lim \overline{(X_i (\omega) - \mu)^2}$ is a constant, because we have not proved that it equals $\sigma^2$ for every value of $\omega$, just "most."
Comment: @Cupitor I hope I've answered this in the addendum to my answer. The (weak) law of large numbers does *not* say that $\lim 1/N \sum (X_i - \mu)^2$ is the constant $\sigma^2$. This is still a random variable, i.e. a non-constant function of $\omega$.
Comment: It's possible for a normally distributed random variable $X_1$ to be 0, because $p(0) \ne 0$, so the i.i.d. assumption implies that it is also possible for $X_2 = 0$. You can repeat this argument to prove that there is a sequence $X_1, X_2, \dots$ that is always $0$. Call this outcome $\omega$. What is confusing is that this is a probability 0 event, but that does **not** mean that this is impossible.
Comment: Technically, the outcome is $\omega$ and the event is the set $\{ \omega \}$. I should have been a little clearer. In particular, the existence of a single $\omega$ where the sample variance does not converge to $\sigma^2$ is enough to prevent you from claiming that $\sigma = \sigma '$.
Comment: as far as I know $\sigma\overset{P}{=}\sigma'$ implies $\sigma=\sigma'$. They're constant, and if they're not equal you would land on a contradiction.

And as much as that's the definition, I beg to disagree. The whole point of identifiability is to show that in the presence of large enough sample size the parameters of the true model are retrievable, and that in essence follows from identifiability. What we call a "data point" is technically a random variable so there is not much difference between the likelihood for that and the true distribution.
Comment: Well, I can explain in more detail if you'd like, but first consider this: if $x \stackrel{P}{=} y$ implied that $x = y$, why would we ever bother writing $x \stackrel{P}{=} y$? Why not just skip writing this and write $x = y$ instead if we can?
Comment: That notation is made for sequences. Here I am already dealing with constants. That's why I can remove the $P$.
Comment: \begin{align}
\left(\frac{1}{N}\right) \sum_{i=1}^N (X_i (\omega) - \mu)^2 & \stackrel{P}{\rightarrow} E[(X_i (\omega) - \mu)^2] = \sigma^2 \\
\left(\frac{1}{N}\right) \sum_{i=1}^N (Y_i (\omega) - \mu')^2 & \stackrel{P}{\rightarrow} E[(Y_i (\omega) - \mu')^2] = \sigma'^2.
\end{align}
Writing above limits in $\epsilon$/$\delta$ form (sum lhs of both and rhs of both) we can get $P\{\omega||(X_n(\omega)-\mu)^2-(X'_n(\omega)-\mu')+\sigma-\sigma'|>\epsilon\}\to 0=P\{\omega||\sigma-\sigma'|>\epsilon\}\to 0$, which implies the latter should be equal as there is no $N$ involved.
Comment: Also thanks for pointing out the L vs. S difference. My bad for confusing them. And thanks for the effort. I just upvoted your answer. I am not sure if I made a mistake but I think my reasoning is right.
Comment: Consider this: There is some value $\omega$ where $X_i (\omega) = 0$ for all $i$ and thus the sample variance is always exactly 0. If the the $Y_i (\omega)$ "do something normal" that leads to that sample variance converging to $\sigma'^2$, then we have a value of $\omega$ where the sample variances are equal even in the limit, and don't cancel out. This doesn't contradict the WLLN, because $P(\{\omega\}) = 0$, but we can't cancel the sample variances and thus we can't prove that $\sigma = \sigma'$ for this $\omega$.
Comment: I am not following how with i.i.d. Assumption you have $X_i(\omega)=0$ all the time??
Comment: That's my bad and I agree with you, but I don't get what you mean by " If the the () "do something normal" that leads to that sample variance converging to $\sigma'^2$, then we have a value of  where the sample variances are equal even in the limit, and don't cancel out. ".

Either way, I stil think the reasoning I made 6 comments ago stands. The summation I presented there literally implies
$$P\{\omega:|\sum(X_n(\omega)-\mu)^2 - \sum(X_n'(\omega)-\mu')^2+\sigma-\sigma'|>\epsilon\}=P\{\omega:|\sigma-\sigma'|>\epsilon\}\to 0 .$$

In fact let's assume that's not the case...
Comment: Choose $\epsilon<|\omega-\omega'|/2$. Then $P\{\omega:|\sigma-\sigma'|<\epsilon/2\}=1$, which is a contradiction as much as I can see.
Comment: The expression $|\omega - \omega'|$ doesn't make any sense. The sample space is not assumed to be a vector space, so you can't add or subtract the outcomes $\omega$. In fact, it's not assumed to be a metric space, so you can't even define the more general notion of distance using a metric $d(\omega, \omega')$, so I'm not sure what you mean by this.
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/111742/discussion-between-ericperkerson-and-cupitor).


Machine learning and Artificial intelligence algorithms in identifying and classifying Airplane parts

Question: Airplane parts and functions
Can Machine Learning and Artificial intelligence Algorithms assist in identifying and classifying Airplane images parts?
Comment: Seeing the other questions you're posting, you seem to be interested in the kinds of problems I discuss in my answer ("classification" problems). The general ideas will apply beyond identifying airplane parts.
Answer: THEY SHOULD
Image identification is already a major topic in machine learning, as a subset of problems with categorical outcomes. Such problems often get called classification problems, but this is really somewhat poor terminology, as the standard statistical models used actually do no classification. The typical approach is to predict class membership probabilities. If a step downstream of that wants to use those probabilities to predict the categories, such an extra step can be used but should take into consideration the costs of making mistakes (mixing up the airplane parts). This answer gets into the statistical and decision components being separate, and an answer to my question here by that same Stephan Kolassa discusses some other aspects of working with the probability values instead of just the categories and why, despite how common it is to make a categorical prediction based on the category with the highest probability, this might not be appropriate for all tasks. Yet a third answer of his discusses what is happening in problems with clear distinctions between outcomes ("high singal-to-noise ratios"), which might be the case for your problems involving aircraft parts (but maybe not). Such a situation might make it rather reasonable to take the category with the highest predicted probability, though it is useful to know you do not have to do this and that typical models do not explicitly predict categories.
The simplest statistical models for categorical outcomes are logistic and multinomial logistic regressions. For image recognition in particular, models known as convolutional neural networks (CNNs) are popular. A YouTube video by Brandon Rohrer was one of my first exposures to CNNs, and he has an expanded video. I also find it useful to think about CNNs as I draw here.
A first task, often described as the "Hello world" of image recognition, is to work with a dataset called the MNIST handwritten digits. You can find discussions about this data set all over the Internet and might consider working with it to introduce yourself to image recognition.
I suspect that techniques from image recognition and computer vision machine learning are already used for this kind of part identification for aircraft and other vehicles. There should be academic articles that explore such ideas. You also have included the relevant classification, computer-vision, and image-processing tags. It might be worth clicking on those to read the high-vote questions and answers.


Why must Gaussian random noise have 0 Covariance?

Question: In Linear Regression, when we model $Y$'s dependence on input $X$, we say that
$$Y = X\beta +\epsilon $$
where $\epsilon \sim \mathcal{N}(0, \sigma ^2 I)$ where $I$ is the identity matrix. I understand the motivation for why $\epsilon$ should have mean $0$ because we can append a $1$ to every entry of $X$ in order to make $\epsilon$ shift to 0, but why must the variance be $\sigma^2 I$? In particular, why must the covariance between the Gaussian noise of components of $Y$ be 0?
Comment: It doesn't have to be zero--this is called *generalized least squares*.  But if the covariance is nonzero, you need to specify what you think it is or find a way to estimate it, don't you?
Comment: It's mainly out of convenience. You could make the variance matrix $\sigma^2 V$, where $V$ is a positive-definite matrix. whuber mentioned GLS - this is exactly what it is.
Answer: You are referring to a very particular setup of the linear regression. It's very strict on requirements to errors. This setup is used in the textbooks because it is easy to work with. Unfortunately, in practice the requirements on errors are difficult to satisfy.
For instance, you imply that in Linear Regression the errors must be Gaussian. That's not necessary. It helps when they are, especially with small sample properties, but non Gaussian errors work fine too. Particularly, to get the coefficient estimates you don't need errors to be Gaussian, but to estimate the variances of coefficients in small samples it helps to have Gaussian errors.
Similarly, with spherical error assumption $Var[\varepsilon|X]=\sigma^2\mathbb I$ where you require that errors are uncorrelated and their variance is constant, it is nice to have but not that necessary. When this assumption holds you get nice properties of the least squares estimator, such as efficiency. Otherwise, you don't need this assumption to get the coefficients with good properties. Also, there are ways to deal with non-spherical errors such as generalized least squares.


How do you prove that $M(N)=O(N^{1/2+\epsilon})$ from the Riemann Hypothesis?

Question: I understand that if $M(N)=O(N^\sigma)$, then
$\sum_{n=1}^\infty \frac{\mu(n)}{n^s}=\frac{1}{\zeta(s)}$ and therefore
$$
 \frac{1}{s\zeta(s)} = \int_0^\infty M(x) x^{-(s+1)} dx $$
for $s>\sigma$, and that having $\sigma=1/2+\epsilon$ for every $\epsilon>0$ will thus prove the RH.
The Wikipedia article on the Mertens Conjecture states that the reverse also holds, but I don't understand the details of argument:

Using the Mellin inversion theorem we now can express M in terms of 1/ζ as
$$M(x) = \frac{1}{2 \pi i} \int_{\sigma-i\infty}^{\sigma+i\infty} \frac{x^s}{s \zeta(s)}\, ds$$
  which is valid for $1 < \sigma < 2$, and valid for $1/2 < \sigma < 2$ on the Riemann hypothesis.

Here is my first problem. It seems to me we can only extend this formula if $$\lim_{T \to \pm \infty} \frac{x^{\sigma+iT}}{(\sigma+iT)\zeta(\sigma+iT)}= 0$$ uniformly on the strip $1/2 < \sigma < 2$. If this is indeed necessary, is there an easy way to show this without
invoking heavy machinery?

From this, the Mellin transform integral must be convergent,

Again this seems to need the limit above (in order for the Mellin inversion theorem to apply).

and hence $M(x)$ must be $O(x^e)$ for every exponent e greater than $1/2$.

This is also very unclear to me. There are certainly functions $f(x)$ such
that
$$\int_0^\infty f(x)x^{-(s+1)} dx$$
converges but $f(x)$ is not $O(x^e)$ for every $e>1/2$. Take for instance
$$f(x) = \left\{\begin{array}{cc}x &\mbox{if $\lfloor x \rfloor$ is a power of two} \\
0 & \mbox{otherwise}\end{array}\right.$$
for which the integral is convergent, but $f(x)$ is not $O(x^e)$ for any $e<1$. By using that $|M(n)-M(n-1)| \le 1$, I've managed to prove that
$M(x) = \mathcal{O}(x^e)$ for $e>0.75$ but I still need $e>0.5$.
Or am I misinterpreting this and should I get that from the vertical line
Mellin integral?

From this it follows that
$$M(x) = O(x^{\frac12+\epsilon})$$
Comment: Note you say, ".. then $\sum_{n=1}^\infty \frac{\mu(n)}{n^s}=\frac{1}{\zeta(s)}$." That is not a consequence of the first statement; it is true for all $s$ where the left side converges.
Comment: Certainly, but the requirement that $M(N)=O(N^e)$ is sufficient for convergence of the LHS when $\mbox{Re}(s)>e$.
Comment: it is detailed in [Titchmarsh's book](http://www.paris8.free.fr/Titchmarsh_TheTheoryoftheRiemannZeta-Function.pdf) (the last chapter consequences of the RH), But at first you should look at page.60 to 66 where the same idea is applied to show $\zeta(s)$ has no zeros on $Re(s) = 1 \implies M(x) = o(x)$
Answer: You'll need Titchmarsh's book "The theory of the Riemann zeta-function" for this one, as pointed out by reuns:
http://plouffe.fr/simon/math/The%20Theory%20Of%20The%20Riemann%20Zeta-Function%20-Titshmarch.pdf
The argument you're looking for is given in ch.14.25, p.370, in Theorem 14.25(C), using the inverse Mellin transform on region $\sigma>1$, particularly with $\sigma=2$.
Best regards.


Preventing navigation in Ionic App

Question: I am trying to prevent navigation and show a popup in a controller.
$rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
  if(someConditionMet) {
    event.preventDefault();
    showPopup();
  }
}

This is working like a charm anything other than tab navigation. It cannot prevent navigation properly and navigates to a tab then shows popup. Another problem kicks in here because of the scope change popup fails to load properly and raises exception. I only see a blank popup with no way to exit after this.
Edit - Plunker demo http://plnkr.co/edit/r8MxO6tDZfTlHPXrVJlM?p=preview
From side menu press About it prevents normally. Then press settings tab. It is trying to navigate to settings tab then shows the popup. Also settings tab cannot be loaded successfuly.
Comment: Please provide a complete and verifiable example, reproducing your issue. The code you provided is too general.
Comment: I've added a plunker demo.
Answer: I edited the "settings" state (name "tabs.about", nested to "tabs"):
.state('tabs.about', {
  url: '/about',
  controller: 'AboutCtrl',
  templateUrl: 'about.html'
});

then I've created a new controller ("mainCtrl") attached to  and moved here the $stateChangeStart event handler, so it can listen events without regard to the current state (previously it was in the Home controller):
  $rootScope.$on('$stateChangeStart', function(event, toState, toParams, fromState, fromParams) {
    var txt = '$stateChangeStart from: '+fromState.name+" to "+toState.name;
    console.log(txt);
    $rootScope.log = txt;
  })

Here is a plunker updated:
http://plnkr.co/edit/xcTMzPJdTVgVxV5jgpho

Preventing navigation in Ionic App


nginx + fastcgi

Question: How to make nginx proxy php to fastcgi evenly on all cores.
Top shows usage of only 2 cores when I try to stress test configuration.
Cpu0  : 62.6%us, 14.9%sy,  0.0%ni, 18.5%id,  0.3%wa,  0.0%hi,  3.6%si,  0.0%st
Cpu1  : 57.1%us, 11.0%sy,  0.0%ni, 31.2%id,  0.0%wa,  0.0%hi,  0.7%si,  0.0%st
Cpu2  :  1.3%us,  0.7%sy,  0.0%ni, 97.0%id,  0.0%wa,  0.0%hi,  1.0%si,  0.0%st
Cpu3  :  2.0%us,  1.7%sy,  0.0%ni, 95.7%id,  0.0%wa,  0.0%hi,  0.7%si,  0.0%st

I got
worker_processes  20;

Set in nginx.conf
Start fast cgi with
spawn-fcgi -s /tmp/php.sock -f /usr/sbin/php -u nobody -g nogroup -U nobody -G nogroup -C 160 -P /var/run/spawn-fcgi.pid

And proxy block in nginx.conf that calls fast cgi is
location ~ \.php$
{
        include fastcgi_params;
        fastcgi_pass unix:/tmp/php.sock;
        fastcgi_param SCRIPT_FILENAME /var/www/$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_script_name;
}

Comment: nginx has no control over what the "upstream" server does when it passes the connection along. You'll need to look for a solution in fastcgi itself.
Answer: Setting your nginx worker processes to 20 is unnecessary. With four CPU cores, there is no reason to set it higher than 4. Even if you had more CPU cores, you probably wouldn't benefit from setting this higher.
In addition to setting your nginx processes too high, you maybe be seting your fastcgi processes too high. 160 is a lot. Unless your PHP code spends a lot of time waiting on slow resources, I doubt you really want to handle 160 FastCGI requests at once. Since you only have 4 cores, this will make each request take longer to complete.
I'm unsure why you think your CPU isn't being utililzed effectively.  Looking at your top output, the two cores that are busiest were still idle 20 and 30 percent of the time. This could mean that PHP was only having to pass requests on to two FastCGI processes at once to keep up with the load, or it could mean that it handled as many as 160 concurrent requests but that they didn't need much CPU time (e.g. they were waiting on the network or disk). Either way, if the work had been more evenly spread out across all four cores it wouldn't have completed any faster.
Although I wouldn't recommend it, you can force processes to run on specific cores using taskset. The basic syntax is tasket -c $CPU_LIST -p $PID. E.G. To ensure that process 17325 will only run on the first CPU core, you would run cpuset -c 0 -p 17325. This sort of functionality isn't integrated into spawn-fcgi, and since PHP processes will keep coming and going as they hit PHP_FCGI_MAX_REQUESTS (it defaults to 500) and are replaced, balancing them across cores yourself would be tricky. It's better to let the linux scheduler handle this as needed.

nginx + fastcgi


Logging Methods on Photon OS linux -my app log file is not created on the specified location by the application

Question: I have small application written in golang and i have mentioned a path to create a log file in order to track the application flow. but as soon as app started the log files created on both of my ubuntu fedora version, but log does not created on photon OS vm ware , and there is no error also showing.
this is my code and it working fine , put just for reference.
<code>f, err := os.OpenFile("/var/log/pluginlog.log", os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
if err != nil {
    return err
    logical.ErrorResponse("Error:creating log file " + err.Error())
    fmt.Sprintf("error", err)
}
defer f.Close()
loggr := log.New(f, "prefix", log.LstdFlags)
loggr.Println(logv)
return err
</code>
and i have gone thru some of the docs available for photon os  and it says

On Photon OS, all the system logs except the installation logs and
the cloud-init logs are written into the systemd journal. The
journalctl command queries the contents of the systemd journal.

which means does my log also put an entry to the journal ?
but if that the case how can i access that specific log ?
(the app is a plugin developed for hashicorp-vault  and plugin runs with the vault environment.)
any body have any idea if please help me?
thanks in advance.
Answer: figured out the issue. actually the code wasn't throwing an error. actually i had a error on permission while accessing the log path. and understood that we can create separate log file on photon os linux version as well , other than writing to journal.


How can I do a chi-square test without being given the critical value table?

Question: I have a random number generator that generate integers within [0, r).
I want to write a piece of code to test whether the numbers from it are truly uniformly distributed using chi-square test.
I select r to be very big like 1,000,000, and I generate random integers 10,000,000 times. Then I get the X^2.
The next thing I need to do is to check the chi-square value against a degree of freedom table. But I am not allowed to have one, nor using some online distribution calculator.
What should I do?
Someone told me that I can just calculate an interval: r^2 - 2*r*(sqrt r) and r^2+2*r*(sqrt r), then to see whether the value fall in that interval or not. But he doesn't know the reason either.
Is the way above correct?
Answer: With the numbers you are talking about, you don't need a chi-squared table. You can use a normal approximation. If $X$ is chi-squared with $r$ degrees of freedom, then
$$ \frac{x-(r-1)}{\sqrt{2(r-1)}} \sim N(0,1) $$
Another approach would be to do a quantile plot of your observations against the theoretical quantiles of the uniform.
However, I'm not sure these tests are really going to answer your question about the merits of your random number generator. It's not sufficient that your numbers be uniformly distributed - you also want to show that they are independent and that are no periodicities in your set.
Comment: You always lose one df from the constraint that the sum of the expected values must equal $r$.
Comment: @Jack. The normal approximation applies to the chi-squared as the number of degrees of freedom gets large, whatever the origin of the chi-squared statistic. If your theoretical probabilities are correct - so the data follow that model - then $\sum \frac{(O-E)^2}{E}$ will be approximately chi-squared, where O and E are observed and expected counts respectively. So yes; if the model fits, the test statistic is chi-squared, which can be approximated by a normal.
Comment: +1. For consistency with the problem statement, you might consider replacing $r$ by $r-1$, which is the df for the proposed test.
Comment: @whuber Are you sure about that? He isn't estimating any parameters from his simulated data .. he knows the theoretical mean and variance, and he should have r groups for the data. Or perhaps I'm missing something.
Comment: what if the numbers are not uniformly distributed? i.e., for the number range `[0, r)` we have associated a probability for each integer and all probabilities sum to 1. In this case, can I still use normal approximation? Also, could you please explain more about the normal approximation? or some quick reference I can read? I am a developer and I threw back almost all my stats knowledge back to university
Comment: ok, how can you map the normal approximation (the equation u gave) to a range as shown in my question? also, is the `x` in your equation the `x^2`?


What is ideal to learn first - scales or chords?

Question: This scale-key-chord thing is mind boggling. I wonder  what is the right method to learning music theory?
Shall we learn about the chords first and then scales or the other way round?
Comment: To learn theory, I have no idea. To learn to play - well, I know my chords, I don't really 'know' my scales, and I've played all my life, I needed to learn chords to play music, I didn't need to study scales.
Comment: There are already several answers to very similar questions on this site.
Comment: What instrument are you playing? Guitarists learn chords first, pianists learn scales first (as far as I know) and many competent folk wind players I know have no proper theoretical concept of chords, as their instrument is unable to play them.
Answer: To the extent that these subtopics are very interrelated, it doesn't really matter which one you start with. Whichever appeals to you is probably the best, all else being equal. Chords are of course built out of scales, so you could learn some chords first, then something about scales, then analyze the scales that are used to build those basic chords. At some point, if you're doing it right, they pretty much cease to be separate areas, and just become part of your harmonic analysis arsenal. Any scale can be harmonized into a spectrum of chords.


Prove that there exists $c_1, ... c_n$ such that $a_1c_1 + ... + a_nc_n = b$ iff $a_1x_1 + ... + a_nx_n\equiv b \;(\bmod\; m)$ is solvable

Question: ($n, m$ are natural numbers, and $a_1,...a_n,c_1, ... c_n, b$ are integers)
I'm quite lost on how to approach this problem, any help would be appreciated.
Comment: Do you mean "is solvable for all $\,m\,$ such that $\ldots"?\ \ $
Answer: Presumably it means "solveable $\color{#0a0}{\text{for all  }\, m}$" (or all $\,m\ge k\,$ or all $\,m\in S),\,$ else it is clearly false.
$\begin{align}{\rm Notice}\ \ \bmod m\!:\,\ &\exists\, x_i\!:\ a_1 x_1 +\cdots+ a_n x_n \equiv b\!\!\pmod{\!m}\\[.2em]
\iff\ &\exists\, x_i\!:\ a_1 x_1 +\cdots+ a_n x_n + m x_ 0 = b\\[.2em]
\iff\ &\ \ \,\gcd(a_1,\ldots,\color{#c00}{a_n,m})\mid b,\ \ \text{by Bezout}
\end{align}$
and, similarly, notice $\,\gcd(a_1,\ldots,a_n)\mid b\,$ is the solvability condition for your first equation.
Thus it suffices to choose $\,m\in S\,$ such that the two gcds are equal (e.g. if $\,\color{#c00}{a_n\mid m})$. Presumably your specific set $S$ is defined such that it contains a nonzero multiple of some $\,a_i,\,$ enabling you to choose such an $\,m\,$ that equalizes the gcds, which is clearly true if $\,\color{#0a0}{S=\Bbb N}\,$ or all $\,m\ge k.$
Comment: I thought Bezout was gcd(a1, .., an, m) = b, not "| b", can you elaborate?
Comment: @user834664 See  [here](https://math.stackexchange.com/a/3290965/242).
Answer: The "only if" part is straightforward, but I don't think the "if" part is true if $m$ is a single natural number. $2x=3 \mod 5$ is solvable but there is no integer $c$ such that $2c=5$.


GLSL soft planar shadows: matrix transformation

Question: I'm adding some modest features to an older video game engine. It has simple planar shadows, using the stencil buffer and a projection matrix popularized in SGI's cookbook years ago.

These work reasonably well, except they do not fade in intensity according to the attenuation of the light source. That's what I'd like to accomplish in my shader. Unfortunately, I can't figure out the correct transformation to allow this. Here's my shader source code. I'm stuck with #version 120.
EDIT: This is now the updated shader which works
/*
 * @brief Planar shadows vertex shader.
 */

#version 120

uniform mat4 MATRIX;

varying vec4 point;

/*
 * @brief
 */
void ShadowVertex() {

    point = gl_ModelViewMatrix * MATRIX * gl_Vertex;
}

/*
 * @brief Program entry point.
 */
void main(void) {

    // mvp transform into clip space
    gl_Position = gl_ModelViewProjectionMatrix * MATRIX * gl_Vertex;

    // and primary color
    gl_FrontColor = gl_Color;

    ShadowVertex();
}

/*
 * @brief Planar shadows fragment shader.
 */

#version 120

uniform vec4 LIGHT;

varying vec4 point;

/*
 * @brief
 */
void ShadowFragment(void) {

    float dist = distance(LIGHT.xyz, point.xyz / point.w);

    float intensity = (LIGHT.w - dist) / LIGHT.w;

    if (intensity <= 0.0)
        discard;

    gl_FragColor.a = min(gl_Color.a, intensity);
}

/*
 * @brief Program entry point.
 */
void main(void) {

    gl_FragColor = gl_Color;

    ShadowFragment();
}

MATRIX is the projection matrix from the planar shadow tutorial. The shape of the shadow is correct, so I don't believe there's any problem there. I understand that this is not an affine transformation, but I'm unclear on the implications.
LIGHT.xyz is the light source's coordinates in eye space. LIGHT.w is the light's radius (attenuation). What I'm confused on is how to get a meaningful comparison from light to point in the fragment shader -- or really, why what I'm trying there is wrong. I end up with no shadows at all; in other words, the calculated intensity value is always <= 0.0.
Answer: Helpful community members of ##OpenGL on Freenode pointed out my error. As the projection matrix MATRIX does not produce an affine transformation, I needed to divide the distance calculation by point.w. This yields the correct distance between LIGHT.xyz and point.xyz.
In short, if you're working with a projection matrix like this, be sure you understand how to deal with all 4 coordinate components, or know who to ask :)


Read data from file and sum over specific columns after hitting specific line (string) using C++

Question: I decided to open a new thread even if the problem is already solved partially but the problem is another one right now (Read data from file into 2d array and sum over specific arrays using C++). Nevertheless, here is what I want to read in:

Calculation
Number of points: 200 # Atoms: 4
Point 1 : 0.00000000 0.00000000 0.00000000 Weighting = 0.00500000
Energy 1 # with weighting 1.00000000
Atom a b c d
1 0.476 0.000 0.000 0.100
2 0.476 0.000 0.000 0.100
1 0.000 -0.000 -0.000 0.200
2 -0.000 -0.000 0.000 0.200
Energy 2 # with weighting 1.00000000
Atom a b c d
1 0.476 0.000 0.000 0.300
2 0.476 0.000 0.000 0.300
1 0.000 -0.000 -0.000 0.400
2 -0.000 -0.000 0.000 0.400
Energy 2 # with weighting 1.00000000
Atom a b c d
1 0.476 0.000 0.000 0.500
2 0.476 0.000 0.000 0.500
1 0.000 -0.000 -0.000 0.600
2 -0.000 -0.000 0.000 0.600
....
....
<code>#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;

int main()
{
    int rows = 0;
    int columns = 0;
    string line;
    int firstNumber = 0;
    vector<vector<double> > values;
    vector<vector<double> > results;
    vector<double> rowstotal;
    ofstream File;
    ifstream in("data.txt");
    File.open("Output.txt",ios::app);
    File.setf(ios::fixed);
    File.setf(ios::showpoint);
    File.precision(3);

    if(in.fail())
    {
        cerr << "File can not be opened" << endl;
        return -1;
    }

    File << "\n" << endl;

    // Save every double
    while(in.good())
    {

        bool begin_tag = false;
        while (getline(in,line))
        {
            if(line.find("Energy   2 #") != std::string::npos ) {
                begin_tag = true;
                continue;
            }
            else if (line == "Energy   1 #")
            {
                begin_tag = false;

            }

            istringstream stream(line);
            vector<double> tmp;
            double x;

            while (stream >> x)
                tmp.push_back(x);

            if (tmp.size() > 0)
                values.push_back(tmp);

        }
    }

    columns = values[0].size();
    for (unsigned i = 1; i < values.size(); ++i)
    {
        if (values[i].size() != columns)
        {
            cerr << "Row with different column number" << endl;
            return -1;
        }
    }

    for (unsigned i = 0; i < values.size(); ++i)
    {
        // If number with 1.0 is encountered, add it to the row
        if (values[i][0] == 1.0)
            results.push_back(values[i]);

        // If number with 2.0 is encountered, add it also to the row
        if (values[i][0] == 2.0)
        {
            for (unsigned j = 0; j < values[i].size(); ++j)
                results.back()[j] += values[i][j];
        }
    }

    rows = results.size();

    File << "Number of rows # " << rows << endl;
    File << "Number of columns # " << columns << endl;
    File << " " << endl;

    for(int i=0; i < rows; i++)
    {
        for(int j=4; j < columns; j++)
        {
            File << results[i][j]  <<  "     " << "  " << endl;
        }
    }

    for(int i=0; i < rows; i++)
    {
        rowstotal.push_back(0.0);
        for (int j=1; j < columns; j++)
        {
            rowstotal[i] += results[i][j];
        }
    }

    File.close();
    in.close();
    return 0;
}
</code>
The output is:
Number of rows # 6
Number of columns # 5
0.200
0.400
0.600
0.800
1.000
1.200
As stated above, what I would like to achieve is to sum over only the blocks "Energy   2 #" and ignore the block beginning with "Energy  1#". So the code should give the values:
0.600
0.800
1.000
1.200
I tried to implement a boolean to get it done but somehow I am missing something. I would be really thankful if someone is able to give me a hint or tell me how to solve it.
Thanks for any help and fruitful hints!
Best wishes,
DaveS
Answer: I found the solution to my problem. I realized that I was setting "begin_tag = false" but was never asking for it.
Thanks again for anyone who read this post and thought about it!


Is a ball that bounces in fair territory and is then touched by a fielder in foul territory fair or foul?

Question: I hit a short pop fly on the infield, the ball landed in fair territory and bounced foul; before it hit the ground in foul territory a infielder touched it. Is this a fair or foul ball?
Answer: If the ball has not yet passed the first or third base, then fair or foul is determined by where the ball is when first touched by a fielder (or where it comes to rest).
Your question seems to be asking if it bounded into foul territory, but hadn't yet touched the ground there, does that matter.  It does not have to touch the ground to be foul.
From MLB Rules glossary (bolding mine):

A FAIR BALL is a batted ball that settles on fair ground between home and first base, or between home and third base, or that is on or
over fair territory when bounding to the outfield past first or third
base, or that touches first, second or third base, or that first falls
on fair territory on or beyond first base or third base, or that,
while on or over fair territory touches the person of an umpire or
player, or that, while over fair territory, passes out of the playing
field in flight.

If the ball was first touched by the fielder when in foul territory, it is not a fair ball.  Doesn't matter if it has touched the ground in foul territory.
Answer: "You had me at landed in fair territory."
- Rene Zellweger, probably
In case you think that's sarcasm, let me clarify. If it lands in-bounds, it's in play the same way that the batter is safe from being caught out. Just to check, we can think about what would happen if that wasn't the case. Then there would be no need to catch anything close to the line when you could just knock it out of bounds and give the pitcher another chance to throw a strike.
Comment: I think you're misinterpreting the question - the ball bounces into foul territory _without being touched by a fielder_. If the ball bounced into foul territory and was picked up by a fielder on the ground, it is clearly foul (if it hasn't passed beyond the bases), so why is this different?
Comment: Ah, I see. Not touched then foul, but already foul, or presumed so, and then touched before the next bounce. Big whoops. Good eye.


Why are the Automorphisms $\text{Aut}(T_2)$ of the regular, infinite, binary rooted tree the **length-preserving** permutations?

Question: Why are the Automorphisms $\text{Aut}(T_2)$ of the regular, infinite, binary rooted tree the length-preserving permutations?
This suggests to me that only swaps of vertices (and all their children) which are at the same number of edges from the root as each other, are permissible.
But it seems to me that we could take any pair of vertices on this tree and swap them (along with all their children) and the graph would remain isomorphic to the original.
What am I misunderstanding?
Comment: The graphs would be isomorphic, but the map wouldn't be adjacence-preserving, I think.
Comment: By definition, an automorphism of a rooted tree fixes the root. Therefore, the subset of vertices connected to the root by one edge, which is the subset of vertices at distance 1 from the root, is mapped to itself by the automorphism. Continuing by induction, the subset of vertices connected to the root by a path of $n$ edges, which is the subset of vertices at distance $n$ from the root, is mapped to itself by the automorphism.
Comment: Perhaps one other thing you are missing: an automorphism of a tree (root preserving or not) is *automatically* length preserving, because the edge-path between any two vertices $v,w$ is unique and hence is mapped to the unique edge path between the image vertices $v',w'$, and the lengths of those two edge-paths are equal.
Comment: They are not. The article states it is those which preserve the initial segment relation.
Comment: @G.Sassatelli Yes, that would be right.  Adjacence-preservation is important for automorphism is it?
Comment: @DaveP I quote "**length-preserving** permutations $σ$ of ${\displaystyle \Sigma ^{*}}$ that also respect the initial segment relation"
Comment: @LeeMosher yes that's the bit I'm not getting, thanks. Still struggling to visualise it.  It's possible I've misunderstood "length-preserving". If we imagine the dyadic rationals modulo $1$ in a tree with $\frac{1}{2}$ at the top, then $\frac{1}{4},\frac{3}{4}$ next and $\frac{1}{8},\frac{3}{8},\frac{5}{8},\frac{7}{8}$ next and so on.  Does "length-preserving" mean only adjacent elements can be exchanged - i.e. $\frac{1}{4}$ is the only element which can be exchanged for $\frac{3}{4}$?
Answer: I'll turn my comments into an answer.
In any tree, one can assign lengths to the edges, so that all edges have length equal to $1$. Next, for any two vertices $v,w$ in the tree, there is a unique "edge-path" in the tree having endpoints $v,w$, and the length of that path is equal to the number of edges along it (just add up all the $1$'s, one for each edge in that path).
One can prove that any automorphism $f$ of a tree preserves lengths by a simple induction argument. The basis step of the induction goes like this: if $v,w$ are connected by an edge path of length $1$, then they are connected by a single edge, so $f(v)$ and $f(w)$ are connected by a single edge, so $f(v)$ and $f(w)$ are connected by an edge path of length $1$.
In the example of your comment, the dyadic tree with root $1/2$, we have the following relations:

the vertices that are connected to $1/2$ by an edge path of length 1 (a single edge) are indeed $1/4$ and $3/4$,
the additional vertices that are connected to $1/4$ by an edge path of length $1$ are $1/8$ and $3/8$;
the additional vertices that are connected to $3/4$ by an edge path of length $1$ are $5/8$ and $7/8$;
so, the vertices that are connected to $1/2$ by an edge path of length $2$ are $1/8$, $3/8$, $5/8$, and $7/8$.
the edge path in this tree that connects the vertex $1/8$ to the vertex $3/4$ has length $3$:
$$\frac{1}{8} --- \frac{1}{4} --- \frac{1}{2} --- \frac{3}{4}
$$

Any automorphism of this rooted tree will fix the root $1/2$, and it will permute the two vertices $1/4$ and $3/4$, and it will permute the four vertices $1/8$, $3/8$, $5/8$, $7/8$. But those permutations are not independent of each other, because the automorphism must preserve length. So, for example, if the permutation interchanges the two vertices $1/4$ and $3/4$, and if the permutation fixes the vertex $1/8$, then that permutation is not an automorphism of the tree because it does not preserve lengths: the length of the edge-path between $1/8$ and $1/4$ and equals $1$ whereas the length of the edge-path between $1/8$ and $3/4$ equals $3$, and $1 \ne 3$.
Edited: As opposed to that negative example, here is a positive example to address your latest comment. One can define an automorphism that which does not "leave any vertex where it was" except for the root vertex. Specifically, the automorphism will take $1/4 \mapsto 3/4$, and it will take $1/8 \mapsto 5/8$, and $3/8 \mapsto 7/8$, and then one can continue defining this automorphism inductively for higher and higher powers of $2$ in the denominator. And in actuality there is a simple numerical formula for this automorphism: for any dyadic rational number $r$ we have
$$f(r) = \begin{cases}
r & \quad\text{if $r = \frac{1}{2}$} \\
r + \frac{1}{2} &\quad\text{if $r < \frac{1}{2}$} \\
r - \frac{1}{2} &\quad\text{if $r > \frac{1}{2}$}
\end{cases}
$$
No vertex will "stay where it was", in other words no vertex (but the root) will be fixed by this automorphism.
Comment: I think perhaps your latest comment is still not quite right, and I've edited my answer to include an example which does not seem to match what you wrote.
Comment: Thanks. It looks like I hadn't correctly understood the nature of a tree automorphism. It appears at least in the case of this infinite, binary rooted tree, we can think of these automorphisms as equivalent to leaving the vertices where they were, and simply exchanging pairs of labels $T_L$ for $T_R$ where $T_l,T_R$ share an upward-vertex. Is that correct?
Comment: Thanks Lee, that's crystal clear. I did understand correctly but I probably didn't explain well what I meant by exchanging $T_L$ and $T_R$.  But in the example you give $T_L=-\frac{1}{4}$ and $T_L=+\frac{1}{4}$ so the automorphism swaps these for all children below a given point in the graph, moving them by $\frac{1}{2}$.


Create a new personal page instance for each user

Question: I have a content type named 'personal' and a node (page) also called 'personal' which is of that content type.
I want my users to have their own private 'personal' page on my website where every user can post their own private stuff. Like a blog page where the page layout is the same for everyone but each user has their own posts on their profile page.
I am trying to achieve something like  www.mywebsite.com/personal/username (or www.mywebsite.com/username/personal)
I am using the Rules module but each user is still getting re-directed to the one and only 'personal' page I have created.
Comment: what happens when you visit `your-domain.com/user/USERNAME` ?
Comment: Use the technique described below by @fadehelix but combine it with [Panels](https://www.drupal.org/project/panels).
Answer: You can create new Views page like this:

Let me explain underlined options:
Path: personal/% - let you to create dynamic path. In addition "%" sign is a wildcard used by contextual filter;
Relationships > Content:author - this relationship is required by filters to show only nodes created by its author. Without this we would be able to filter only by user ID.
Contextual Filters > User:name - this is value of URL wildcard. It allow you to filter nodes by put any user name instead of % sign.
For example: www.mywebsite.com/personal/john
Filter Criteria > Current User (Yes) - It shows only nodes created by current logged in user. Without this filter anyone can put any user name in url and see content created by this user.
Let me know if something is not clear to you.
Comment: thanks @fadehelix - however I am not getting the ' (author) user name ' option see screen below: http://imgur.com/JeIfoKU
Comment: Did you add relationship at first? Without this, as I mentioned, you only can set Author ID.
Comment: found it! - One more question: how do I attach the view I created to my personal page? I am confused as I thought this module replaced the need to use the personal page created using 'add content' button...


The bucket you are attempting to access must be addressed using the specified endpoint , while uploading from jenkins to s3

Question: i am trying to deploy the war file from jenkins to elastic bean stalk, the build is successful , but when it tries to upload to s3 , it is showing this error
Uploading file awseb-2152283815930847266.zip as s3://elasticbeanstalk-ap-southeast-1-779583297123/jenkins/My App-jenkins-Continuous-Delivery-
MyApp-Stage-promotion-Deploy-14.zip
Cleaning up temporary file /tmp/awseb-2152283815930847266.zip
FATAL: Deployment Failure
java.io.IOException: Deployment Failure

further error shows
The bucket you are attempting to access must be addressed using the specified endpoint. Please send all future requests to this endpoint.
(Service: Amazon S3; Status Code: 301; Error Code:

Jenkins configuration for elastic beanstalk
My beanstalk is in "ap-southeast-2" region
Bucket name is "elasticbeanstalk-ap-southeast-1-779583297123"

You can have a look at this for more clarity
enter image description here
Answer: Looks like Beanstalk and the S3 bucket are in different regions. You stated that Beanstalk is in ap-southeast-2, while it seems that the S3 bucket is in ap-southeast-1. Create that bucket in ap-southeast-2.
Comment: so i have just find a workaround for it and i just simply not provided the bucket name in the configuration , so it automatically manages it self, but now something strange that is happening is , can you please check http://stackoverflow.com/questions/34173569/jenkins-aws-elastic-deployment-plugin-just-create-a-new-ec2-on-each-update


Evaluating $\lim\limits_{ n \to +\infty} (\sqrt{n}( e^{1/\sqrt{n}} -2^{1/\sqrt{n}}))^3$

Question: I've got problems with calculating the limits in these two examples:
$$\begin{align*}
&\lim_{ n \to +\infty}\left( \sqrt{n}\cdot \left( e^{\frac{1}{\sqrt{n}}} -2^{\frac{1}{\sqrt{n}}} \right) \right)^3\\
&\lim_{n \to +\infty} n\cdot \sqrt{e^{\frac1n}-e^{\frac{1}{n+1}}}
\end{align*}$$
Can anybody help?
Comment: What kind of problems? Where do you get stuck?
Comment: Both are consequences of the fact that $\mathrm e^x-1=x+o(x)$ when $x\to0$, the first one for $x=(1-\log2)/\sqrt{n}$ and the second one for $x=1/(n(n+1))$.
Comment: @Andy, I don't even know how to start and the tip above doesn't say anything to me.
Answer: For the first one, let $u=\frac1{\sqrt n}$, and note that $u\to 0^+$ as $n\to\infty$. Then $$\sqrt n\left(e^{\frac1{\sqrt n}}-2^{\frac1{\sqrt n}}\right)=\frac1u\left(e^u-2^u\right)=\frac{e^u-2^u}u\;,$$ so you're interested in $$\lim_{u\to 0^+}\frac{(e^u-2^u)^3}{u^3}\;,$$ and I expect that you know a way to deal with that kind of limit.
I can make a similar trick work for the second one, but it gets a bit messier. First, I'm actually going to look at $$\lim_{n\to\infty}n^2\left(e^{\frac1n}-e^{\frac1{n+1}}\right)$$ and then take its square root to get the desired limit.
Let $u=\frac1n$, so that $n=\frac1u$, $n+1=\frac1u+1=\frac{u+1}u$, and $\frac1{n+1}=\frac{u}{u+1}=1-\frac1{u+1}$. Again $u\to 0^+$ as $n\to\infty$, so I look at $$\lim_{u\to 0^+}\frac{e^u-e^{1-\frac1{u+1}}}{u^2}\;;$$ applying l'Hospital's rule takes a little more work this time, but it's still eminently feasible.
Comment: L'Hôpital's rule?
Comment: @xan: That's right.
Comment: ok :-)
Does the second one can be solved with similar approach? I can't see there substitution like in first one.
Comment: @xan: It can indeed, and I've added to my answer to get you started.
Comment: great! thank you very much :-)
Answer: What Didier is suggesting the use of the little oh notation. This stands for the following:
$$e^x=1+x+o(x) \text{ for } x\to 0 $$ means that
$$\lim\limits_{x \to 0} \frac{e^x-1-x}{x} =0$$
or that we can approximate $e^x$ near $x=0$ very accurately by $1+x$, with an error that is very small in comparison to $x$ i.e $\dfrac{o(x)}{x}\to0$ (that is what $o(x)$ kinda means.)
To make things easier, put $\sqrt n=x$, to get
$$\mathop {\lim }\limits_{x \to 0} {\left( {\frac{{{e^x} - {2^x}}}{x}} \right)^3}$$
Now, we get the following:
$$\eqalign{
  & {e^x} = 1 + x + o\left( x \right)  \cr
  & {2^x} = {e^{x\log 2}} = 1 + x\log 2 + o\left( x \right) \cr} $$
So this means:
$$\mathop {\lim }\limits_{x \to 0} {\left( {\frac{{1 + x + o\left( x \right) - 1 - x\log 2 - o\left( x \right)}}{x}} \right)^3}$$
$$\mathop {\lim }\limits_{x \to 0} {\left( {1 - \log 2 + \frac{{o\left( x \right)}}{x}} \right)^3}$$
But since we said $o(x)$ is an error that tends to zero in comparison to $x$, we get
$$\mathop {\lim }\limits_{x \to 0} {\left( {1 - \log 2 + \frac{{o\left( x \right)}}{x}} \right)^3} = {\left( {1 - \log 2} \right)^3}$$
Do you follow? Can you move on to the second case analogously?
Answer: This is more or less Brian M. Scott's answer, without converting to a limit at $0^+$.
For the second limit, let's find the limit of the square. Using L'Hôpital's Rule twice:
$$\eqalign{
\lim_{n\rightarrow\infty} n^2(e^{1\over n}-e^{1\over n+1} )
&=\lim_{n\rightarrow\infty} {e^{1\over n}-e^{1\over n+1} \over 1/n^2}\cr
&=\lim_{n\rightarrow\infty} {(-1/n^2)e^{1/n}-(-1/(n+1))^2e^{1\over n+1} \over-2/n^3}\cr
&=\lim_{n\rightarrow\infty} { e^{1\over n}-({n\over n+1})^2e^{1\over n+1} \over2 /n}\cr
&=\lim_{n\rightarrow\infty} {(-1/n^2) e^{1\over n}-\Bigl[\,({n\over n+1})^2 \cdot{-1\over (n+1)^2}e^{1\over n+1}+{2n\over (n+1)^3}e^{1\over n+1}\Bigr] \over-2 /n^2}\cr
&=\lim_{n\rightarrow\infty} { e^{1\over n}-({n\over n+1})^4  e^{1\over n+1}
+ {2n^3\over (n+1)^3}e^{1\over n+1}
\over2 }\cr
&={1-1+2\over 2}\cr
&=1.
}
$$
So, the limit of the original expression is $\sqrt 1=1$.

For the first limit, I would initially ignore the cube, and first compute
$$
\lim_{n\rightarrow\infty} \bigl[\,{\sqrt n(e^{1/\sqrt n}- 2^{1/\sqrt n} )}\,\bigr]
=\lim_{n\rightarrow\infty}{ {  e^{1/\sqrt n}- e^{\ln 2/\sqrt n}  }\over 1/\sqrt n }.
$$
One application of  L'Hôpital's Rule will show the above limit is $1-\ln 2$; whence the original limit is $(1-\ln 2)^3$.
Answer: Because the limit of the cube of a sequence is the cube of the limit, it suffices to find and cube the following limit
$$\lim_{n \rightarrow \infty} \sqrt{n}(e^{1 \over \sqrt{n}} - 2^{1 \over \sqrt{n}})$$
Note that since $n$ going to infinity is the same as ${1 \over \sqrt{n}}$ going to zero, the above limit is
$$\lim_{x \rightarrow 0} {e^{x} - 2^{x} \over x}$$
L'hopital's rule gives that this limit is $1 - \ln2$, so the original limit is $(1 - \ln 2)^3$.
You can do something similar with the second one, but it's more complicated. The limit is the square root of
$$\lim_{n \rightarrow \infty} n^2(e^{1 \over n} - e^{1 \over n + 1})$$
Letting $x = {1 \over n}$ this becomes
$$\lim_{x \rightarrow 0} {e^x - e^{x \over x + 1} \over x^2}$$
Since $\lim_{x \rightarrow 0} e^x = 1$, you can factor out an $e^x$ in the above to obtain
$$\lim_{x \rightarrow 0} {1 - e^{-{x^2 \over x + 1}} \over x^2}$$
Since $x +1$ goes to $1$, this is the same as
$$\lim_{x \rightarrow 0} {1 - e^{-{x^2 \over x + 1}} \over {x^2 \over x+1}}$$
So if you let $y = {x^2 \over x + 1}$ the above becomes
$$\lim_{y \rightarrow 0} {1 - e^{-y} \over y}$$
By L'hopital's rule (or other methods) this limit is $1$, so the original limit is the square root of this, also $1$.
Comment: This answer is useful.
Answer: Let's solve them elementarily:
1st limit:
$$\lim_{ n \to +\infty}\left( \sqrt{n}\cdot \left( e^{\frac{1}{\sqrt{n}}} -2^{\frac{1}{\sqrt{n}}} \right) \right)^3=\lim_{ n \to +\infty}\left(\frac{e^{\frac{1}{\sqrt{n}}}-1}{\frac{1}{\sqrt{n}}} - \frac{2^{\frac{1}{\sqrt{n}}}-1}{\frac{1}{\sqrt{n}}}\right)^3=(1-\ln2)^{3}.$$
2nd limit:
$$L^2=\lim_{n \to +\infty} \left(n\cdot \sqrt{e^{\frac1n}-e^{\frac{1}{n+1}}}\right)^2=\lim_{n \to +\infty}n^2\left(\frac{e^{\frac{1}{n}}-1}{\frac{1}{n}}\cdot\frac{1}{n} - \frac{e^{\frac{1}{n+1}}-1}{\frac{1}{n+1}}\cdot\frac{1}{n+1}\right)$$
$$=\lim_{n \to +\infty} \frac{n^2}{n(n+1)}=1.$$
Therefore, $L=1$.
Remark: for the two limits i resorted to the auxiliary limit, $\lim_{x\to0} \frac{a^x-1}{x}=\log a$, $a>0$.
Q.E.D.
Comment: You can say that $$\log x = \lim\limits_{k \to 0}\frac{x^k-1}{k}$$ so that it is clearer.
Comment: One little other thing: QED means "which was to be demonstrated", so you can start by saying "The limit is $[\text{blah}]$" and then prove it so the QED makes sense.
Comment: I don't understand what you mean.
Comment: You end by saying "which was to be proven" but don't start with, "The limit is $X$". Just a matter of structure.
Comment: @Peter Tamaroff: oh, it's an automatism i learned from my teacher.
Comment: @Peter Tamaroff:yeah. I intended to add that auxiliary limit, but then forgot it. A lot of stuff to do here. Thanks for reminding me that.


How can I improve the tone of my Fender Strat on high frets?

Question: I have a midrange setup that I'm quite comfortable with. I have an American Strat that I bought ca. 2008 (I think it's a Standard but I have no way to know), and a Marshall Origin 20 Combo. I use light gauge strings (.09), a few stompboxes (mostly a reverb and a transparent overdrive) and I'm generally happy with the tone I'm getting.
However, whenever I play any note on the high strings (1st to 3rd) above the 17th fret, the tone loses a lot of texture. It just sounds tinny and weak, with almost no sustain. I would like the tone to be "fatter" and mellower same as when I play on the rest of the fretboard.
I know there are a lot of factors involved (including gear and technique), but I'm hoping perhaps there are some well-known ways to improve tone on those frets.
Edit: I have been using .10's up to last month, and the issues above still happened. I don't think that .10's alone are going to fix my issue.
Edit 2: Been testing this again. I would say I'm OK until fret 17, then it goes tinny beyond that. I have updated the question.
Comment: This might depend on which neck profile you have. The old necks, if you bend more than a tone say on the B string at maybe fret 14 or so, then the note will actually choke to a halt as it hits its own frets higher up. Newer necks fixed that - though in my opinion at the cost of overall tone. [Some new copies of 'old strats' returned to that profile, so the only way to tell is to try it].
Comment: Which pups do you use? Neck/middle will always give a more mellow sound than bridge. heavier gauge strings would help the sound, too.
Comment: I almost always use neck/middle combo, sometimes only neck. I can't do heavier strings. I recently hurt my hands by trying to do 2 semitone bends using .10's. I need to improve my technique before I try medium again.
Comment: If you bend say, 3rd string most, you could use something in between what the set of 009s and the set of 010s gives. I often use 012 for the 3rd string. There's always going to be a compromise between ease of playing and sound produced.
Comment: have you tried lowering the pickup(s) slightly (or not so slightly) to see if it has an effect on your issue?
Answer: Here's how I perform with my Strat. (And like you, I am fond of using the neck and neck/middle position on the pickup selectors switch.)
Give this a try;
Set your amp volume to your liking, after you have rolled the guitar's Volume Knob down to 7.5-ish. Make it your standard to play your main rhythm parts at that volume. Make things nice and loud at the amp, not the guitar.
Then, when you transition up to the upper frets for some lead work, roll the Strat's Volume Knob up to a higher volume.
You will find that this changes the audio dynamic quite a bit.
When you are done with the lead part or upper fret runs and chug back into the rhythm work, roll the Volume Knob back down to where it was before.
Bottom line, I see a lot of players start out their sets with the Volume and Tone Knobs maxxed-out at 10. This leaves you nowhere to go, in a manner of speaking!!
Answer: I think you're fretting out in some way. If I'm right, then you can verify by raising the saddles at the bridge to see if that improves your tone above the 17th fret. If you get the tone you want by raising the saddles but then the action is too high, then you need either a great setup done on the guitar or a fret leveling or both. Worst case scenario, the neck is not even above the 17th fret and you need a new neck (which happily can be bolted on easily).
I suggest finding a great tech in your area (asking a local Facebook group for musicians is one way) and take it to that tech and tell them what you told us. They should be able to fix the issue or tell you what it would take to fix it (e.g., new neck).


Entity view mode and form mode schema

Question: node_type_example module provides a file that defines form display configuration for a custom node type defined in this module. The file is named core.entity_form_display.node.basic_content_type.default.yml.
The example file clearly sets some field settings but is there a a schema for these config files? How to build my own config file for view mode and form mode?
Comment: See core.entity_form_mode.user.register.yml that defines the entity form mode or \Drupal\Core\Entity\Entity\EntityFormDisplay entity
Comment: `core.entity_form_mode.user.register.yml` doesn't seem to be relevant. It's virtually empty and it's not configuring any fields. `EntityFormDisplay` on the other hand is a class implementing `EntityFormDisplayInterface` which is also no relevant. I'm asking about schema for the yml config files for node form mode and node view mode.
Answer: First, form/user mode and form/user display isn't the same thing.
But the schema for all of them is in in core/config/schema/core.entity.schema.yml.
That said, I'm not sure why you want to build that file? Especially for a node type. Create the node type and the fields, configure the form and view displays in the UI, export it, add the files to your modules, don't. You don't have to build them yourself.

Entity view mode and form mode schema


Pass events easily from a child component to a parent in Vue 2

Question: I have a base component BaseInput.vue which accepts attributes and emits events. It's easy to bind all attributes by using v-bind="$attrs" instruction.
// BaseInput.vue
<template>

    <input
      v-bind="$attrs"
      @focus="$emit('focus')"
      @blur="$emit('blur')"
    >

</template>

Next I have a wrapper component WrapInput.vue which passes attributes to BasicInput and emits events.
// WrapInput.vue
<template>
  <basic-input
    v-bind="$attrs"
    @focus="$emit('focus')"
    @blur="$emit('blur')"
  />
</template>

My question: is there a handy way in Vue to pass a bunch of events in "proxy" components without the need to list them one by one? I expect something like this:
// WrapInput.vue
<template>
  <basic-input
    v-bind="$attrs"
    v-bind="$events" // is it possible to proxy all events in a single line?
  />
</template>

P.S. I've heard about EventBus, but doesn't fit nicely for my case.
Comment: I think you have a same question asked here: https://stackoverflow.com/questions/53825246/bind-multiple-events-to-v-on-directive-in-vue
Answer: In Vue 2, you could use v-on and $listeners to pass any event listeners to a component:
// BasicInput.vue
<input v-on="$listeners">

Vue 2 demo
In Vue 3, $listeners is removed, but any event listeners would be part of $attrs, so v-bind="$attrs" would suffice.
Vue 3 demo
Answer: Using Event Bus (Communication between any two components)
An event bus is used to communicate between any two components (Components need not have a parent-child relationship). This can be used when one needs to manually listen for events on a component instance.
You can just send the data from one component using this.$root.$emit('name-of-emitter', args1, args2, ...) and is captured using the same name like this this.$root.$on('name-of-emitter', args1, args2, ...) in the other component.
Source of the answer: https://dev.to/sanchithasr/how-to-communicate-between-components-in-vue-js-kjc


How would a position player warm up to be a "reliever?"

Question: About ten years ago, there were a series of experiments (since gone nowhere), of allowing position players to pitch, say, one inning as a "reliever," particularly if the team were losing badly (the New York Yankees' Nick Swisher, the Pittsburgh Pirates' Josh Harrison).
"Normal" relievers loosen up in the bullpen before actually pitching. I can't see position players doing this.
My understanding is that once on the mound, a reliever gets eight pitches with which to warm up.* Is this all that the position player/reliever gets?
*An exception would be made if the previous pitcher was injured. Then the reliever would get all the time reasonably necessary.
Answer: I don't know where you get the idea of an experiment; this has been possible for as long as I remember.  Mark Grace pitched an inning in 2002, for example, and definitely continuing to 2021...
Position players do, with some regularity, pitch in major league games in blowouts.  They don't, however, usually come in during an inning - they come in at the start of an inning, and warm up during the break.
Even then, assuming they were in the game, they're already somewhat warm - they warmed up at the start of the game, and stayed warm during the game.  They also aren't pitching at the edge of their ability, like other relievers, so they don't need quite the same warmup as a reliever would who's hitting 95-100.
There was a change in the rules in 2020 that changed how they're allowed to be used - the team must be up or down by 6 runs, or in extra innings, or be a designated 'two way player'.


Show that $\operatorname{Cov}(X,X^2)=0$ if X is a continuous random variable with symmetric distribution around the origin

Question: Let $X$ be a continuous random variable with symmetric distribution around the origin. All the moments of the variable exist. Show that $\operatorname{Cov}(X, X^2) = 0$.
What I've done: if $X$ is a continuous random variable with symmetric distribution around the origin, then $\mathbb{E}(X)=\mathrm{Median}=0$.
Coefficient of skewness = $\frac{μ^3}{σ^3}= \frac{\mathbb{E}(X^3)-3μσ^2-μ^3}{σ^3}=\frac{\mathbb{E}(X^3)}{σ^3}=0.$
So $\mathbb{E}(X^3)=0$
$$\operatorname{Cov}(X,X^2)=\mathbb{E}(XX^2)-\mathbb{E}(X)\mathbb{E}(X^2)=\mathbb{E}(X^3)-0*\mathbb{E}(X^2)=\mathbb{E}(X^3)=0.$$
What do you think?
Comment: It's too restrictive !  Give $X$ some freedom by assuming only the existence of the third moment.
Answer: Your proof is right and it is ok to use these formulas. I would not prove it in this way though. If you have already studied basic results on expectations (integral), I would prefer to prove it using the results for symmetric probability distributions. If $X$ is symmetric about $k$ ($P_{X-k}=P_{-(X-k)}$): then (1) $E(X)=k$ and $E[(X-k)^j]=0$ for $j$ odd, provided that moments exist. In particular, given the $3$rd moment exists, if $k=0$ and $j=3$, then $\operatorname{Cov}(X,X^2)=0$.
Answer: There are probably a good amount of ways to show this.  First of all $\operatorname{Cov}[X, X^2]=E[X^3]-E[X]E[X^2]$.  Since the pdf is stated to be symmetric about the origin (i.e. it is an even function) $E[X^3]$ is determined by integrating an even function times an odd function ($x^3$) and so $E[X^3]=0.$  For the same reason $E[X]=0$, and therefore $\operatorname{Cov}[X, X^2]=0$.


Foreach in Laravel with array of objects

Question: I have an array of objects in my Laravel controller.  I need to loop over each object in the array and set the 'status' of each object to 0.  I have the following in my controller:
            if (request('status')=='Reset') {
            $allDemoTasks = DemoTask::all();

            foreach($allDemoTasks as $index=>$key)
               $key->status=0;
               $key->save();
            }

It appears to be setting the last object in my array to 0 and not doing anything to the other objects.
Answer: Your approach will make count($allDemoTasks) separate updates to your database. It is much better to do it in a single statement like:
DB::table('demo_tasks')->update(['status' => 0]);

or
DemoTask::query()->update(['status' => 0]);

Comment: Or even `DemoTask::query()->update(['status' => 0]);`.
Comment: @Tpojka For sure, I will add it!
Answer: Here is a way using eloquent
if(request('status') == "Reset"){
        App\DemoTask::all()
      ->update(['status' => 0]);
}

Comment: why would you hit the database again to retrieve the object you already have?
Comment: You took the original question, and added an unnecessary query to it.


Which method should I use to execute an SSIS package remotely from a .net application?

Question: I need to remotely execute an SSIS package located in the SSIS Package store from a C# .net application.
Application is located on a separate server, integration services cannot be installed on the app server.
I have the functionality working on my dev machine just using the file system method because I installed integration services to get it running. Now I need to flip it to call the package remotely.
Right now I'm using the following:
<code>pkg = app.LoadFromDtsServer("\loadfile", "DBServer", Nothing)
</code>
But I get the following error:
"Connecting to the Integration Services service on the computer "DBServer" failed with the following error: "Access is denied." By default, only administrators have access to the Integration Services service. On Windows Vista and later, the process must be running with administrative privileges in order to connect to the Integration Services service. See the help topic for information on how to configure access to the service."
Certainly the user running this application in production will not be granted such rights on the database server. How can I make this run as a sql user? Is this the right way to go about this? There are other options, I know. The package does not absolutely have to be stored in the package store, but I believe this is best practice.
I should also mention that the application passes in a file name via a package variable, so any solution needs the ability to do that as well. I'm not sure how to do this if I create a job to run the package.
Comment: I had success at doing this by creating a job that calls the package, and starting the job with a sql command from .net.
Comment: Would you mind sharing if you were passing a variable using this method? If so, how did you go about doing that?
Comment: Certainly.  I created a "JobHistory" table that contained a column for every variable that needed to be passed to the package.  The .net app would run a sql command that inserted a row in that table, and then it would kick off the job.   The first step of the package was to read the variables from the most recent row in the table.   The last step was to update the table and set a "JobResult" column to "success" or some other message.
Comment: Brilliant. Were you using exec msdb.dbo.sp_start_job to kick off the job?
Comment: Pretty sure that was it, yes.   I believe I called it from the same stored proc that populated the JobHistory table.   I vaguely remember that I had to do something to handle concurrency, but I don't remember what it was.
Answer: If you are passing parameters from the .NET application to the SSIS package, check the following link for options:
How to execute an SSIS package from .NET?
If no parameters are being passed, then an easier approach would be to add the SSIS package to a job and then call the job from the .NET application.  The following link provides a code example:
http://www.roelvanlisdonk.nl/?p=1736
Comment: Thanks for your response. we are passing parameters (file name) and we cannot install integration services on the application server (see above) so these won't work, unfortunately.
Answer: you can use stored procedures in the SSIS catalog to deploy the project and execute the packages
https://msdn.microsoft.com/en-US/library/jj820152.aspx?f=255&MSPPError=-2147217396
Comment: Unfortunately we're using sql server 2008 and are unable to use catalogs, so this isn't an option- thanks though!


Rails Excel 2007 export: Add Byte Order Mark to .erb template

Question: I am exporting data to Excel by making an erb template for the xls file.  This is following the procedure recommended in Railscast 362 for making properly encoded exports.
The output opens fine in Excel for Mac 2011, but in Excel 2007 characters like é appear as é because the UTF-8 encoded file is being interpreted by Excel as Latin1.
According to this answer Excel 2007 will correctly interpret an UTF-8 file if it starts with the right Byte Order Mark (BOM).
Taking at a look at the hex version of the output it seems that indeed it doesn't have a BOM.
There are a number of sources (like this Plataformatec blog post) that explain how to add a BOM when rendering the data inline in the controller:
<code>BOM = "\377\376"
BOM + Iconv.conv('utf-16le', 'utf8', data)
</code>
My question is – is there a way of getting the template correctly interpreted by Excel 2007? Or should I go back to rendering the data in the controller?
Answer: I don't know why Excel makes this so hard, but they do.
I tried using that code myself when I ran into this encoding problem. I couldn't figure out how to apply it to what I was working with. So I did a workaround instead.
I downloaded the CSV file as indicated in the Railscast. I then opened the file with TextWrangler, which encodes it properly. Then, I copied and pasted the contents into a blank Excel document (which reads it as text, and thus, does not mess up the encoding). Following that, I selected the column all the data fell under, and then in the menubar selected "Data -> Text to Columns". I then selected a delimited list and entered a comma as the delimiter (it defaults to a tab). Then I finished it up and voila, there is a properly formatted Excel doc.