Not normally distributed raw data are compatible with a multiple linear regression?

Question: I have to analyse the predictive value of some neuropsychological data (ex time taken to complete a test, anxiety scores..) with a multiple linear regression model.If the raw data don't follow a normal distribution what I have to do? My prof told me that if there is a really big asimmetry I can transform them in z-scores...it is correct?
Thank you for your answers!
Comment: Many (*many*) answers and comments on site address this already. There's no assumption about the distribution of IVs whatever, and there's no assumption about the raw (i.e. marginal) DV either. *If* you use a test that assumes normality, there's an assumption about the conditional distribution of the DV (which people tend to assess by looking at residuals).
Answer: A standard assumption in linear regression is that the residuals will be normal.$^{\dagger}$ We do not, however, care about the distribution of the response variable (e.g. hist(y)), and we definitely do not care about the distribution of the predictor variables.
The assumption of normal residuals is not essential to estimating the parameters, note. In particular, the legendary Gauss-Markov theorem that gives conditions where the estimated parameters have a nice statistical property called unbiasedness does not assume normal residuals. The normal residuals help with doing hypothesis testing and confidence intervals on the parameters, which may be of interest to you.
I think your professor's comment has to do with accounting for when variables are on wildly different scales, such as having one variable range from $0$ to $0.001$ and another range from $0$ to $987,654,321$. Transforming to a z-score could help with some issues related to doing calculations on a computer. However, that has nothing to do with the distribution of data being normal or not.
$^{\dagger}$Technically speaking, the assumption is about the error term, which we do not observe but estimate by the residuals. See Glen's comments.
Comment: The assumption is actually about the errors; the residuals are simply an estimate of those; the residuals are neither independent nor identically distributed (while the errors are presumed to be both).
Answer: I would expect time taken and anxiety scores to be normally distributed. Check for outliers using Cooks Distance and z-scores that are greater than some large size (e.g. greater than 4.0). You might choose to do a transformation, in which case I'd suggest Box-Cox transformation.
Comment: Time taken will not be normally distributed -- it's necessarily positive. Times are typically right skew. Anxiety scores are presumably discrete and so not actually normal either. This may not matter much.
Comment: As my post indicates, it is not the distribution of data but the distribution of residuals (estimating the error term) that concerns us in regression.


$7\mid5^{2n}+3\cdot2^{5n-2}$; $43\mid6^{n+2}+7^{2n+1}$

Question: Use congruences to demonstrate
$$7\mid5^{2n}+3\cdot2^{5n-2}$$
$$43\mid6^{n+2}+7^{2n+1}$$
When you are trying to see if something is divisible by 7, 8 or any number, do you automatically use that number as the modulus?
Comment: I answered [your previous question](http://math.stackexchange.com/q/1942297/131263) which showed a small yet reasonable amount of effort, but this is not a 'do my homework for free' service. Please show your effort if you're expecting others to make an effort for you.
Comment: No effort?${}{}$
Comment: Hint: $5^2\equiv 2^5 \pmod 7$, so you can factor its $n$th power out of the sum. Similarly $6\equiv 7^2\pmod{43}$.
Comment: @ParclyTaxel : The proper notation is $3\mid 6$ (coded as 3 \mid 6), not $3|6. \qquad$
Comment: just compute the value $\pmod 7$  and  $\pmod {43}$ remark cyclicity etc...
Comment: @barak manos I'm sure you could tell by my previous question which was much easier than this one, that I have no idea what I am doing with congruence's yet. A hint or step in the right direction is better than a reprimand. And this isn't HW BTW, I am trying to prep for an exam.
Comment: @ntgootadmth Henning Makholm's hint is sufficient for you to complete this exercise.
Comment: I understand that $5^2≡2^5$ (mod 7) but I don't see how to get to that point..

$$5^{2n}+3*2^{5n-2}$$

$$=5^{2n}+3*2^{5n}*2^{-2}$$

and then I am not sure where to go from here..
Comment: $\equiv 2^{5n}+3*2^{5n}*2^{-2}=2^{5n-1}(2^5+24)=2^{5n-1}*56 \pmod 7$
Answer: You can solve it by induction too ! (assuming that you are familiar with induction )
For the first one , assume P(n) to be true.
P(n+1) : $25.5^{2n }+ 3.2^{(5n-2)}.2^5 $which is congruent to $4.5^{2n }+ 3.2^{(5n-2)}.4 $which is divisible by 7 due to our hypothesis ( just take 4 outside).
For the second one , note  that $ 6^{(n+2)}= -7.6^n ( mod 43 )$
So it suffices to show that $43| 7(7^{2n}-6^n)$
Again note that 43 and 7 are co prime and hence if we show that $7^{2n}=6^n( mod 43) $then we are done .
Again assume P(n) : $ 43 | 7^{2n}-6^n  $ to be true
P(n+1) : $  43| 49.7^{2n }-6.6^n $ .Note that 49 = 6 ( mod 43) hence take 6 outside and the result immediately follows.
Comment: I don't know how to solve this problem only using congruence. Such problems are most easily solved using induction ( and you have little bits of congruence in the inductive proof too ! )
Comment: Yeah I have seen the inductive solution but I was trying to go through the congruence route, I am just not sure how
Answer: I will show you for $7\mid5^{2n}+3\cdot2^{5n-2}$,same is for $43$
$gcd(7,5)=1\Rightarrow \phi(7)=6\Rightarrow5^{6}\equiv1\pmod7$
$gcd(2,5)=1\Rightarrow \phi(7)=6\Rightarrow2^{6}\equiv1\pmod7$
$$5^{2n}\equiv(5^{2})^{n}\equiv25^{n}\equiv4^{n}\equiv2^{2n}\pmod{7}$$
$2^{2n}\pmod{7}$ is cyclic:
$$(n=1):2^{2}\equiv4\pmod{7}\\(n=2):2^{4}\equiv16\equiv2\pmod{7}\\(n=3):2^{6}\equiv64\equiv1\pmod{7}\\(n=4):2^{8}\equiv256\equiv4\pmod{7}\\(n=5):2^{10}\equiv1024\equiv2\pmod{7}\\(n=6):2^{12}\equiv4096\equiv1\pmod{7}$$
you see the pattern.
so:
$if(n=3k=3t+3)\Rightarrow 2n=6k$
$$2^{6k}\equiv 2^{6k}\pmod{7}\equiv (2^{6})^{k}\equiv 1^{k}\equiv 1\pmod{7}$$
$$$$
$if(n=3k+1)\Rightarrow 2n=6k+2$
$$2^{6k+2}\equiv 2^{6k}\cdot2^{2}\pmod{7} \equiv [2^{6k}\pmod{7}\cdot2^{2}\pmod{7}] \\\equiv[(2^{6})^{k}\pmod{7}\cdot4\pmod{7}]\equiv[1^{k}\pmod{7}\cdot4\pmod{7}]\equiv4\pmod{7}$$
$$$$
$if(n=3k+2)\Rightarrow 2n=6k+4$
$$2^{6k+4}\equiv 2^{6k}\cdot2^{4}\pmod{7} \equiv [2^{6k}\pmod{7}\cdot2^{4}\pmod{7}] \\\equiv[(2^{6})^{k}\pmod{7}\cdot16\pmod{7}]\equiv[1^{k}\pmod{7}\cdot2\pmod{7}]\equiv2\pmod{7}$$
$$$$
Now we deal with:  $3\cdot2^{5n-2}$
$if(n=3k=3t+3)\Rightarrow 5n-2=5(3t+3)-2=15t+1$
$$3\cdot2^{15t+1}\equiv 3\cdot2^{12t}\cdot2^{3t}\cdot2^{1}\equiv [3\pmod{7}\cdot2^{12t}\pmod{7}\cdot2^{3t}\pmod{7}\cdot2\pmod{7}]\\\equiv [3\cdot(2^{6})^{2t}\pmod{7}\cdot(2^{3})^{t}\pmod{7}\cdot2]\equiv [3\cdot1\cdot(8)^{t}\pmod{7}\cdot2]\equiv[3\cdot1\cdot1\cdot2]\equiv6\pmod{7}
$$
so:  $1+6\equiv0\pmod{7}$
$$$$
$if(n=3k+1)$
$$3\cdot2^{5n-2}\equiv 3\cdot2^{2n}\cdot2^{3n-2}\equiv [3\pmod{7}\cdot4\pmod{7}\cdot2^{9k+1}\pmod{7}]\\\equiv [3\cdot4\cdot2^{3k}\pmod{7}\cdot2^{6k}\pmod{7}\cdot2^{1}\pmod{7}]\equiv\\ [3\cdot4\cdot(8)^{k}\pmod{7}\cdot(2^{6})^{k}\pmod{7}\cdot2]\equiv[3\cdot4\cdot1\cdot1\cdot2]\equiv3\pmod{7}
$$
so:  $4+3\equiv0\pmod{7}$
$$$$
$if(n=3k+2)\Rightarrow 5n-2=2n+2n+n-2=2n+2n+3k+2-2=2n+2n+3k$
$$3\cdot2^{5n-2}\equiv 3\cdot2^{2n}\cdot2^{2n}\cdot2^{3k}\equiv [3\pmod{7}\cdot2\pmod{7}\cdot2\pmod{7}\cdot(8)^{k}\pmod{7}]\\\equiv [3\cdot2\cdot2\cdot1]\equiv5\pmod{7}
$$
so:  $2+5\equiv0\pmod{7}$
Answer: \begin{align*}
5^{2n}+3\cdot2^{5n-2} &= (7-2)^{2n}+ 3 \cdot 2^{3(n-1)} \cdot 2^{2n+1} \\
&= ((-2)^{2n} + 3 \cdot 8^{n-1} \cdot 2^{2n+1}) \mod 7 \\
&= ((-2)^{2n} + 3 \cdot  2 \cdot 2^{2n})\mod 7 \\
&= 2^{2n}(1+6) \mod 7 \\
&= 0 \mod 7
\end{align*}
\begin{align*}
6^{n+2}+7^{2n+1} &= (6^{n+2} + 7 \cdot  49^n) \mod 43 \\
&= (36 \cdot 6^n + 7 \cdot 6^n) \mod 43 \\
&= 6^n (36+7) \mod 43 \\
&= 0 \mod 43
\end{align*}


Updating a database automatically using ColdFusion

Question: I need to carry out certain updates to MSSQL field data at times determined by certain events, e.g. after 200 new records have been added.
CFSCHEDULE refers to a certain date and time, not the date and time of an event.
I cannot find anything in the Adobe documentation.
Anyone any ideas?
Answer: If you are doing purely updates to data fields within MSSQL server based on events that happen in SQL Server there is NO need for any coldfusion code. Your best course of action would be to use a trigger on the database table you are interested in along with some kind of helper table.
e.g. You could set up a helper table dbo.MY_HELPER with a column called rowsSinceLastEvent
a trigger on your target table could then check on each insert what the row count is since your last event and either fire an event if your target number of rows has been reached or bump up the row count number.
The trigger definition would look something like this. (This is just pseudo code)
DECLARE @rowsSinceLastUpdate INT

SELECT @rowsSinceLastUpdate = h.rowsSinceLastUpdate
FROM dbo.MY_HELPER h

IF @rowsSinceLastUpdate > 200
BEGIN
/* UPDATE ANY REQUIRED COLUMNS OR EXECUTE A STOREDPROCEDUT */
UPDATE dbo.MY_HELPER SET rowsSinceLastUpdate = 0
END ELSE BEGIN
UPDATE dbo.MY_HELPER SET rowsSinceLastUpdate = rowsSinceLastUpdate + 1
END

If you have to use coldfusion depending on your use case you may have to either do some kind of polling on the database or build a event gateway that monitors your database.


What's the difference between biconditional iff and logical equivalence?

Question: I am confused about the difference between ↔ (biconditional iff) and ≡ (logical equivalence). For instance, p→q can be rewritten as ∼p∨q. Would it be correct to say p→q↔∼p∨q or p→q≡∼p∨q?
Secondly, is ⇔ another symbol for ≡?
Finally, what's the difference between → and ⇒?
Comment: You should look in that book to see what the symbols mean.  For example, it could be that $\rightarrow$ combines two wffs into a new wff, while $\Rightarrow$ is a relation between wffs.
Comment: The issue is not with the *symbols* but with the *concepts*. We have a *connective*: the [biconditional](https://en.wikipedia.org/wiki/Logical_biconditional) that can produce a "complex" sentence (or formula) from simpler ones: $p \leftrightarrow q$.
Comment: And we have the relation of [logical (or semantical) equivalence](https://en.wikipedia.org/wiki/Logical_equivalence) between formulas. Logical equivalence is different from the biconditional, although the two concepts are closely related; in a nutshell: $p \leftrightarrow q$ is a tautology iff $p$ is logically equivalent to $q$.
Comment: See also this answer on SE Philosophy: https://philosophy.stackexchange.com/questions/65024/what-is-the-difference-between-logical-equivalence-and-material-equivalence
Comment: https://en.wikipedia.org/wiki/Logical_connective#History_of_notations seems to suggest they could mean the same across time
Comment: Does this answer your question? [What is the difference inbetween $\leftrightarrow$, $\iff$, and $\equiv$?](https://math.stackexchange.com/questions/3926367/what-is-the-difference-inbetween-leftrightarrow-iff-and-equiv)
Answer: In short, $P \leftrightarrow Q$ is statement that could be either true or false.  $P \equiv Q$ means that $P \leftrightarrow Q$ is always a true biconditional (so, $P$ and $Q$ have the same truth value no matter what).
So, one could say that $\neg (P \vee Q) \equiv \neg P \wedge \neg Q$ (DeMorgan's) but you typically wouldn't write $\neg (P \vee Q) \leftrightarrow (\neg P \wedge \neg Q)$.
The arrow $\Rightarrow$ usually is slang for "implies" but different people use it differently.  The arrow $\Leftrightarrow$ is usually treated the same way as $\leftrightarrow$.
Comment: I found it's clearer to mention the **components** in logical equivalence: $\phi \equiv \psi$ means for that every truth assignment applied to **the components of** $\phi$ and $\psi$, the resulting truth values of $\phi$ and $\psi$ are identical.
Answer: In case you can use a somewhat philosophical explanation: $\leftrightarrow$ is a logical operator within statements, while $\equiv$ serves to state an equivalence between statements and thus may be thought of as meta-logical.
As Randall explained, $P \leftrightarrow Q$ is a statement $-$ one statement and a logical statement. The $\leftrightarrow$ will cause it to be true under certain truth value distributions for $P$ and $Q$. The same applies to $\neg(P \vee Q) \leftrightarrow (\neg P \wedge \neg Q)$.
For $\neg(P \vee Q) \equiv (\neg P \wedge \neg Q)$ however, you compare two truth tables, the one of $\neg(P \vee Q)$ and $(\neg P \wedge \neg Q)$, two distinct statements. If and only if both are true exclusively for the same truth value distributions, the equivalence applies and so the meta-logical statement $\neg(P \vee Q) \equiv (\neg P \wedge \neg Q)$ is true.
Comment: This is what I've expected to hear actually. So thank you for the insight!
Comment: A fancy way to put this is to say that $\leftrightarrow$ appears in object-language whereas $\equiv$ appears in meta-language
Comment: Do you mean that $\ldots≡\ldots$ is the same as $\forall \ldots ↔\ldots$?
Answer: Consider this analogy. You wouldn't say the following:

Prove that 3 + 5.

You might instead say this:

Prove that 3 = 5.

Similarly, following doesn't make sense:

Prove that $p \leftrightarrow q$.

Instead one of these would be correct:

Prove that $p \leftrightarrow q$ is always true.
  or
  Prove that $p \equiv q$.


Comparing two NSDates constantly even outside the app

Question: I decided for my first application i would create an alarm application. So far i understand to create two NSDate objects and compare them with isEqualToDate and UILocalNotifications for notifications. How do i continually compare the set date to the current date. Do i create a loop, or is there a more efficient way on Objective C? How do i continually check in the background?
[very new to objective c, sorry and thank you]
This what iv'e started:
NSDate * now = [NSDate date];
NSDate * later = [[NSDate alloc] initWithString:@"2001-03-24 10:45:32 +0600"];
NSComparisonResult result = [later compare:mile];

NSLog(@"%@", later);
NSLog(@"%@", mile);

Comment: Why do you need to compare dates if you have a notification set up? It has a fire date which the system takes care of.
Answer: You don't need to create loops or compare dates yourself. One way to have your alarm sound could be via a local notification. A quick sample code to schedule yourself a local notification:
// Initialize your notification
NSUserNotification *notification = [[NSUserNotification alloc] init];

// Set the title of your notification
[notification setTitle:@"Alarm finished!"];

// Set the text of your notification
[notification setInformativeText:@"My Text"];

// Set the time and date on which the notification will be delivered (in this case 60 seconds after the current time)
[notification setDeliveryDate:[NSDate dateWithTimeInterval:60 sinceDate:[NSDate date]]];

// Set the sound, this can be either nil for no sound, NSUserNotificationDefaultSoundName for the default sound)
[notification setSoundName:NSUserNotificationDefaultSoundName];

// Schedule the notification
[[NSUserNotificationCenter defaultUserNotificationCenter] scheduleNotification:notification];

If you don't want to use a local notification but want to execute something different once your alarm finishes, you could use NSTimer to execute your action once the alarm fires.
Comment: Interesting, but this will trigger an interval after a time. What I'm really trying to do is trigger when the current time is the same as the set date. Any hints?
Comment: What do you need, a notification on desktop or mobile? Or do you need to trigger a NSTimer?
Comment: @JustinShulman: You can't literally do what you're asking to do. You can't run code to check the time when your app isn't running (and even if your app was running, looping to poll the time is _incredibly_ wasteful). What you can do is give the system the date at which you need to do something, via either an `NSTimer` or, if your app might stop running in the meanwhile, a local notification. The system will then check that "the current time is the same as the set date" and "trigger" your code.


Proving the radius of convergence lies between $\liminf|\frac{c_{n}}{c_{n+1}}|$ and $\limsup|\frac{c_{n}}{c_{n+1}}|$

Question: I am working on an analysis problem and I am looking for some insight.
Problem:
Let R be the radius of convergence of a power series $\sum c_nx^n$ with nonzero coefficients $c_n$. Prove that as n tends to infinity that
$$\liminf|\frac{c_{n}}{c_{n+1}}|\leq R\leq \limsup|\frac{c_{n}}{c_{n+1}}|$$
What I know so far:
$R=\frac{1}{\limsup [(|c_{n}|)^{\frac{1}{n}}]}$
$\limsup(a_{n}b_{n})=\lim(a_{n})\limsup(b_n)$
and by the ratio test
$R=\lim |\frac{c_{n}}{c_{n+1}}|$ provided that it exists.
Would it be accurate to state that $$\liminf|\frac{c_{n}}{c_{n+1}}|\leq \lim |\frac{c_{n}}{c_{n+1}}|\leq \limsup|\frac{c_{n}}{c_{n+1}}|?$$ I am not really sure what would be sufficient to prove this problem.
Answer: You cannot assume that any of limit $\frac {|c_n|} {|c_{n+1}|}$ exists. I will give  a proof of the right hand inequality and leave the other one to you. Suppose $|x| > \lim \sup \frac {|c_n|} {|c_{n+1}|}$. Choose $t$ such that $|x| >t> \lim \sup \frac {|c_n|} {|c_{n+1}|}$. Then $t >\frac {|c_n|} {|c_{n+1}|}$. for $n$ sufficiently large, say for $n \geq n_0$. Thus $|c_{n+1}| >|c_n|/t$ for $n \geq n_0$. Iterating this we get $|c_{n+1}| >|c_{n_0}|/t^{n+1-n_0}$. Hence $\sum\limits_{k=n_0}^{\infty} |c_n||x|^{n} >\sum\limits_{k=n_0}^{\infty} |c_{n_0}| |\frac x t|^{n}|t|^{n_0}=\infty$. Hence the series $\sum c_nx^{n}$ is divergent whenever $|x| > \lim \sup \frac {|c_n|} {|c_{n+1}|}$. This implies that  $R \leq \lim \sup \frac {|c_n|} {|c_{n+1}|}$.
Comment: Didn't you just showed that *only* the absolut series diverges?
Comment: That is enough because a power series converges absolutely inside the circle of convergence.
Comment: I see, thank you!


Understanding probability of being dealt a two pair

Question: just need help wrapping my head around this:
I understand that the sample space consists of C(52,5) elements.
And that the logic behind calculating the probability is that we first find the product of
choosing 2 ranks from the 13 available and 1 rank from the 11 remaining. Then find the product of this with the square of choosing 2 suits from 4 (for the pairs),and with choosing 1 from 4 (for the remaining card).
i.e. C(13,2)C(11,1)C(4,1)[C(4,2)^2]
But I don't understand (logically) why this doesn't provide the same result (off by a factor of two)
as if we first choose 1 rank from 13, then 1 from 12, then the rest is the same.
i.e. C(13,1)C(12,1)C(11,1)C(4,1)[C(4,2)^2]
Why make a special case of the pairs?
Why not even choose 3 ranks from 13 initially - as oppose to choosing 2 then 1?
i.e. C(13,3)C(4,1)[C(4,2)^2]
Comment: Because in you second computation, you can pick your two ranks in two ways. Indeed, $13\cdot 12/2 = C(13,2)$. So the reason we use $C(13,2)$ is to not count that one case twice.
Comment: As for why not choosing the three denominations all at once, your computation would not allow you to decide which denomination occurred in pairs. However, you could multiply that last line by $C(3,2)$ to choose which two denominations had pairs, and then you'd get the same result, because $C(13,3)C(3,2)=C(13,2)C(11,1)$.
Comment: Thank you! Makes sense now.
Comment: Of all the poker hands, two pairs is the easiest to make a mistake on, double-counting is common.
Answer: Think of it this way: we have to paint a car using three colors, we can chose out of three colors, the way it works is the three colors are mixed and then used to paint the car. Clearly  all three colors are the same and the order in which we chose them don't matter. So there is only 1 way to choose(or not choose;)).
Another option is that 1 of the colors is chosen as the main color and then the other 2 are mixed and are used to paint the interior. Then there are 3 ways because the only choice you have to make is which of the colors is the main color.
Finally there is a third option in which 1 color is used for the middle of the car, one for the back and one for  the front. Then there are 6 options because every permutation of the colors changes the way the car is painted.
Your example is like the second example. You need to chose the non-pair color first because it plays a different role. On the other hand the 2 pair ranks play exactly the same role. So the order in which they are chosen is irrelevant. So it is the same as chosing 2 ranks from the remaining 12.
Answer: In your second computation, you can pick your two ranks in two ways. If you divide $C(13,1)C(12,1)$ by $2$, though, you get $C(13,2)$.
Similarly, if you just pick three ranks, how do you know which ranks have pairs? You have to choose two from the three ranks for pairs, yielding:
$$C(13,3)C(3,2) = C(13,2)C(11,1)$$
which is the same as the original formula.


SAS - reordering dataset variables based on month

Question: I have a SAS dataset whose column layout is like this:
Col1      Col2      Col3
A_jan2018 A_feb2018 A_mar2018
B_jan2018 B_feb2018 B_mar2018
C_jan2018 C_feb2018 C_mar2018

I need to re-order the columns that start with A or B or C in such a format --
Col1      Col2      Col3
A_Jan2018 B_Jan2018 C_Jan2018
A_Feb2018 B_Feb2018 C_Feb2018
A_Mar2018 B_Mar2018 C_Mar2018

The A,B,C prefixes need not be in any sorting order (meaning they can start with anything), but my requirement is to re-order them based on the month-year (meaning B_Jan2018 A_Feb2018 C_2018 is okay).
Is there any way of achieving this in SAS?
Comment: Well, if you're having small amount of variables, you can use `retain Col1 Col2 Col3 A_Jan2018 B_Jan2018 C_Jan2018 A_Feb2018 B_Feb2018
           C_Feb2018 A_Mar2018 B_Mar2018 C_Mar2018;` before set. If not, then you have to create some additional helping variables to do this.
Comment: This is a Q&A site, not a free code writing service. You will get a better response if you make an attempt to solve your problem yourself and post a reproducible code example if you run into a specific problem.
Comment: Is that your actual data? Or are you trying to convey that data is currently in columns ordered by date and rows ordered by variable (A,B,C) and you want to transpose it to have columns by variable (A,B,C) and the rows ordered by date?  Do you have an id variable to indicate which variable a current row represents?  How do you know what date a particular column represents?
Answer:
Change the data structure so that you have a long dat set instead of
a short data set. (DATA STEP)
Separate out the prefix from date portion (DATA STEP)
Sort into your desired order (PROC SORT)
Transpose to desired format (PROC TRANSPOSE)
%*create sample data;
data have;
    informat col1 col2 col3 $10.;
    input Col1  $    Col2  $    Col3 $;
    cards;
A_jan2018 A_feb2018 A_mar2018
B_jan2018 B_feb2018 B_mar2018
C_jan2018 C_feb2018 C_mar2018
;
run;

%*Make it wide table;
data _long;
    set have;
    array _col(3) col1-col3;

    do i=1 to 3;
        prefix=scan(_col(i), 1, "_");
        date=input(scan(_col(i), 2, "_"), anydtdte.);
        value=catx('_', prefix, put(date, monyy7.));
        output;
    end;
    format date date9.;
run;

%*Sort by desired output;
proc sort data=_long;
    by date prefix;
run;

%* transpose to the desired format;
proc transpose data=_long out=want1;
    by i;
    var value;
run;

If your data is exactly as posted and the output is transposed exactly then this also works but its entirely reliant on the source data being as specified and sorted correctly.
proc transpose data=have out=want2;
     var col1-col3;
run;

Comment: Just curious - is there any particular reason you use the `%*` comment format rather than `*;` or `/* */`?
Comment: Nope, It means I've been writing macros lately.


Let ()=log() where we don't know the base .

Question: Let ()=log() where we don't know the base .
However, we do know that
(2)=0.37031
and
(3)=0.58692
Use this information to compute
(4)=
(^2)=
(^3)=
(6^5)=
I tried to do 0.37031=log2 and 0.58692=log3 and convert both to exponential form but I'm not sure how to find the base  value. Any tips on how to properly start this question would be appreciated!
Comment: Thanks saulspatz!
Comment: Please review the properties of logarithms. Also the fact that $\log_a a=1$
Comment: A more general version of the equation which GReyes provided is $\log_a{a^n} = n$ for all $n$. You can use this solve $2$ of the values you are trying to compute.
Comment: And $\log_a mn = \log_a m + \log_a n$ will solve all the rest.
Comment: It would be very mean of me to actually answer your question.  But I am mean so I will.  If $\log_a 2 = 0.37031$ then $a^{0.37031} =2$ so $\ln a^{0.3701} = \ln 2$ so $0.3701 \ln a = \ln 2$ so $\ln a = \frac {\ln 2}{0.3701}$ so $a = e^{\frac {\ln 2}{0.3701}} = 2^{\frac 1{0.3701}} = 2^{\frac {10000}{3701}}$
Answer: Just do it.
You know $\log_a b^m = m\log_a b$ so you can use this to solve $L(4) = \log_a 2^2$.
And you know $\log_a a^k = k$ which you can use to solve the next two.
And you know $\log_a bc = \log_a b + \log_a c$ which you can use to solve the last one.


File upload with Behat, Mink & PhantomJS

Question: I am trying to upload a file using Behat. Therefore I wrote this simple HTML page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

    <form method="post" enctype="multipart/form-data">
      <input type="file" name="file" id="file" />

      <input type="submit" />
    </form>

and a simple Behat feature:
Feature: test
  Scenario: Some Test
    Given I am on "/upload.php"
    And I attach the file "/path/to/tile" to "file"

When the I attach the file ... to ... phrase is executed, the selenium 2 driver generates a curl request and sends it to PhantomJS: http://localhost:4444/wd/hub/session/5b9a8630-ed8e-11e4-956f-956a9ce75127/element/:wdc:1430215640681/value with params: {"value":["\/path\/to\/file"]}
The request does not terminate unless aborting it and PhantomJS does not react on the request in any way.
I already searched through the net and found several threads saying that it does work and several saying that does not work including an issue on github (https://github.com/detro/ghostdriver/issues/282) which was closed and reopend multiple times.
Versions:
PhantomJS: 2.0.0
Behat: 3.0.15
Mink: 1.6.1
Mink-Selenium2-Driver: 1.2.0
Does anyone know a working solution for this problem?
Answer: Could this behaviour exist due to inability to upload files that is a known bug with PhantomJS v 2.0.0?

Basically, a change made in Qt 4.8 and incorporated subsequently in Qt 5.0 prevented clicking on file input elements that were not caused by user gestures.

The solution is discussed further in the issue thread.
To quote, you have to comment one if condition in
/src/qt/qtwebkit/Source/WebCore/html/FileInputType.cpp
//if (!ScriptController::processingUserGesture())
//    return;

then compile the binary.
Comment: Totally forgot about this post. Yes you are right. It's the PhantomJS bug.


Exercise 5.A.10(b) Find all invariant subspaces of $T$ ("Linear Algebra Done Right 3rd Edition" by Sheldon Axler)

Question: I am reading "Linear Algebra Done Right 3rd Edition" by Sheldon Axler.
The following exercise is Exercise 5.A.10 on p.139.

Define $T\in\mathcal{L}(\mathbb{F}^n)$ by $$T(x_1,x_2,x_3,\dots,x_n)=(x_1,2x_2,3x_3,\dots,nx_n).$$
(a) Find all eigenvalues and eigenvectors of $T$.
(b) Find all invariant subspaces of $T$.

I solved (a), but I cannot solve (b).
Please tell me a solution for (b).

(a)
Assume that $\lambda\in\mathbb{F}$ is an eigenvalue of $T$.
Then there exists a non-zero vector $(x_1,x_2,x_3,\dots,x_n)\in\mathbb{F}^n$ such that $T(x_1,x_2,x_3,\dots,x_n)=(x_1,2x_2,3x_3,\dots,nx_n)=\lambda(x_1,x_2,x_3,\dots,x_n).$
Assume that $x_i\neq 0$.
If $\lambda\notin\{1,2,3,\dots,n\}$, then $ix_i=\lambda x_i$.
So, $(i-\lambda)x_i=0$.
Since $x_i\neq 0$, $i-\lambda=0$.
So, $\{1,2,3,\dots, n\}\ni i=\lambda$.
This is a contradiction.
So, $\lambda\in\{1,2,3,\dots,n\}.$
Conversely, if $\lambda\in\{1,2,3,\dots,n\}$, then $T(e_\lambda)=\lambda e_\lambda$, where $0\neq e_\lambda=(y_1,y_2,y_3,\dots,y_n)$ ( $y_i=\delta_{i\lambda}$).
So, $\lambda$ is an eigenvalue of $T$.
Let $\lambda\in\{1,2,3,\dots, n\}$.
We want to find all $(x_1,x_2,x_3,\dots,x_n)$ such that $0\neq (x_1,x_2,x_3,\dots,x_n)$ and $T(x_1,x_2,x_3,\dots,x_n)=(x_1,2x_2,3x_3,\dots,nx_n)=\lambda(x_1,x_2,x_3,\dots,x_n)$.
Assume that $i\neq\lambda$.
Then, the solution of the equation $ix_i=\lambda x_i$ is $x_i=0$ because $i\neq\lambda$.
Assume that $i=\lambda$.
Then, the solutions of the eqution $ix_i=\lambda x_i$ are arbitrary elements of $\mathbb{F}$.
So, the set of all the eigenvectors of $T$ corresponding to $\lambda$ is $\{te_\lambda\mid t\in\mathbb{F}-\{0\}\}$, where $e_\lambda=(y_1,y_2,y_3,\dots,y_n)$ ( $y_i=\delta_{i\lambda}$).
My attempt is here:
(b)
Let $U$ be an invariant subspace under $T$.
Let $i\in\{1,2,3,\dots, n\}$.
If there exists $(x_1,x_2,x_3,\dots,x_n)\in U$ such that $x_i\neq 0$, then $\frac{y}{x_i}(x_1,x_2,x_3,\dots,x_n)\in U$ for any element $y\in\mathbb{F}$ because $U$ is a subspace of $\mathbb{F}^n$.
Comment: You've shown that there are $n$ distinct eigenvalues, each with a one-dimensional eigenspace. Each of these eigenspaces is an invariant subspace; the other invariant subspaces are the direct sums of these eigenspaces.
Comment: It's best to avoid unnecessary proof by contradiction. In the first part of (a), you can just assert directly that in order for $(x_1, \dots, x_n)$ to be an eigenvector of eigenvalue $\lambda$, it must be the case that $ix_i = \lambda x_i$ for each $i \in \{1, \dots, n\}$. Thus, if $x_i \neq 0$ for some $i$, then $\lambda = i$, and so $x_j = 0$ for all $j \neq i$.
Comment: @SammyBlack thank you very much for your advice.
Comment: @angryavian Thank you very much for your answer.
Answer: I see you've already figured out the eigenspaces. Now what are the invariant subspaces?
Let $U$ be an invariant subspace, and let $T_U:U\to U$ be the restriction of $T$ to $U$.
Prove the following three statements:

If none of the roots of the characteristic polynomial of $T_U$ is repeated, then $U$ is a direct sum of eigenspaces of $T_U$ and every eigenspace of $T_U$ is one-dimensional.
$\text{char}_{T_U}(x)$ divides $\text{char}_T(x)$.
Every eigenspace of $T_U$ is an eigenspace of $T$.
Comment: Chris Sanders, Thank you very much for your answer.
Answer: Sammy Black, angryavian, Chris Sanders, thank you very much for your comments and answer.
But I cannot understand why the answers by angryavian and Chris Sanders are correct.
Anyway I got to know the answer of (b) and I tried to solve (b) again.
Is my solution ok?
Let $U$ be an invariant subspace of $T$.
Let $S:=\{i\in\{1,\dots,n\}\mid (x_1,x_2,\dots,x_n)\in U\text{ for some }x_1,x_2,\dots,x_n\in\mathbb{F}\text{ and }x_i\neq 0\}$.
Note that if $v\in U$ and $i\in\{1,\dots,n\}-S$, then the $i$th slot of $v$ is $0$.
Suppose that $1\leq i_1<i_2<\dots<i_k\leq n$ and $S=\{i_1,i_2,\dots,i_k\}$.
Let $e_{i_j}\in\mathbb{F}^n$ be the $n$-tuple with $1$ in the $i_j$th slot and $0$ in all other solts.
We prove that $e_{i_1},e_{i_2},\dots,e_{i_k}$ are elements of $U$.
Let $x_{i_k}\neq 0$ and $(0,\dots,0,x_{i_1},0,\dots,0,x_{i_2},\dots,x_{i_k},0,\dots,0)\in U$.
Then, since $U$ is an invariant subspace of $T$,
$T(0,\dots,0,x_{i_1},0,\dots,0,x_{i_2},\dots,x_{i_k},0,\dots,0)-i_1(0,\dots,0,x_{i_1},0,\dots,0,x_{i_2},\dots,x_{i_k},0,\dots,0)=(0,\dots,0,0,0,\dots,0,(i_2-i_1)x_{i_2},\dots,(i_k-i_1)x_{i_k},0,\dots,0)\in U.$
Similarly,
$T(0,\dots,0,0,0,\dots,0,(i_2-i_1)x_{i_2},\dots,(i_k-i_1)x_{i_k},0,\dots,0)-i_2(0,\dots,0,0,0,\dots,0,(i_2-i_1)x_{i_2},\dots,(i_k-i_1)x_{i_k},0,\dots,0)=(0,\dots,0,0,0,\dots,0,0,\dots,(i_k-i_2)(i_k-i_1)x_{i_k},0,\dots,0)\in U.$
We continue this and we finally get
$(0,\dots,0,0,0,\dots,0,0,\dots,(i_k-i_{k-1})\cdots(i_k-i_2)(i_k-i_1)x_{i_k},0,\dots,0)\in U.$
Since $(i_k-i_{k-1})\cdots(i_k-i_2)(i_k-i_1)x_{i_k}\neq 0$, we get  $e_{i_k}\in U.$

Let $x_{i_{k-1}}\neq 0$ and $(0,\dots,0,x_{i_1},0,\dots,0,x_{i_2},\dots,x_{i_k},0,\dots,0)\in U$.
Then, $(0,\dots,0,x_{i_1},0,\dots,0,x_{i_2},\dots,x_{i_k},0,\dots,0)-x_{i_k}e_{i_k}=(0,\dots,0,x_{i_1},0,\dots,0,x_{i_2},\dots,x_{i_{k-1}},0,\dots,0)\in U.$
Then, by similar method, we get $e_{i_{k-1}}\in U$.

We continue this and we finally get $e_{i_1},\dots,e_{i_k}\in U.$

Remember that if $v\in U$ and $i\in\{1,\dots,n\}-S$, then the $i$th slot of $v$ is $0$.
So, $U=\mathbb{F}e_{i_1}+\dots+\mathbb{F}e_{i_k}$.


Why does this Pandas csv import fail?

Question: I am trying to import the following csv text:
name, favorites, age, other_hobbies
joe, "[madonna, elvis, u2]", 28, "[football, cooking]"
mary, "[lady gaga, adele]", 36, "[]"

With the following pandas command
file_name = "new_data.csv"
df = pd.read_csv(file_name, sep =",")
print(df)

And I get this result:
                             name  favorites          age  other_hobbies
joe   "[madonna    elvis     u2]"         28   "[football      cooking]"
mary  "[lady gaga  adele]"     36       "[]"          NaN            NaN

Why is this happening, and how can I get pandas to read this properly?
Comment: How is your file generated? Is it hand-crafted or is it saved by some program?
Comment: did you create this file? you should use a different separator if so on both ends (read_csv allows specifying anything you want; you could use something like `:` maybe). if not, you will need to read the file yourself and handle creating the DataFrame yourself.
Answer: Pass skipinitialspace along with the sep:
df = pd.read_csv("in.csv",sep="," , skipinitialspace=1)

print(df)

Output:
   name             favorites  age        other_hobbies
0   joe  [madonna, elvis, u2]   28  [football, cooking]
1  mary    [lady gaga, adele]   36                   []

Comment: that's cool... but how does it work? reading the docs, i would not have expected it to do that.

Why does this Pandas csv import fail?


How do I find the most common result in a column in my MySQL table

Question: Using PHP and MySQL, I want to query a table of postings my users have made to find the person who has posted the most entries.
What would be the correct query for this?
Sample table structure:

[id] [UserID]
1     johnnietheblack
2     johnnietheblack
3     dannyrottenegg
4     marywhite
5     marywhite
6     johnnietheblack

I would like to see that "johnnietheblack" is the top poster, "marywhite" is second to best, and "dannyrottenegg" has the least
Comment: Can you provide the table structure for the postings table?
Comment: Yup, that would help ;-)
Comment: totally...check edit in one minute:)
Answer: Something like:
SELECT COUNT(*) AS `Rows`, UserID
FROM `postings`
GROUP BY UserID
ORDER BY `Rows` DESC
LIMIT 1

This gets the number of rows posted by a particular ID, then sorts though the count to find the highest value, outputting it, and the ID of the person.  You'll need to replace the 'UserID' and 'postings' with the appropriate column and field though.
Answer: I believe this should work...
SELECT user_id, COUNT(*) FROM postings ORDER BY COUNT(*) GROUP BY user_id LIMIT 1

Answer: Assuming posting is a tuple (user_id, recipient_user_id), where each row represents one posting, from user_id to recipient_user_id:
select user_id, count(*) as posts
from postings
group by user_id
having count(*) = max(count(*)) ;


Laurent Series of a function in general

Question: I need to find the laurent series of a function. the function in question has the interesting characteristic where the singularities of the function are:
z= 0, +i, -i
and my $z_0$ = 0
when my $z_0$ is not equal to zero hence in the other parts of the problem $z_0$ = z
I am trying to find laurent for one function but in multiple domains hence the different parts of the one problem, there are exactly 8 parts to my one problem each with a different domain, I have looked at other examples in the similar questions area BUT i have not found one similar enough to my question where as i say: $z_0$ = z which in my understanding kinda blows the equations that i want to use up...
mainly for my term $$\frac{-1}{z_0}$$ since my $z_0$ =z as stated above z=0 for one of my domains and this kills my entire Laurent series...
my original function that i am working with is called: $$f{(z)} = \frac{1}{z(z^2+1)}$$
anyone with any help please as i have said i have 8 parts to this one question that i WANT TO ANSWER.
Answer: Knowing the singularities is not enough. For example, the function $z \mapsto z^{-n}$, where $n$ is a positive whole number, all have singularities at $z=0$. However, they all have different Laurent Series. In fact, they are their own Laurent Series. In conclusion: you need to know the order of each pole.
Let's assume that $\operatorname{f}$ has simple poles at $z=0,\pm\operatorname{i}$. Then, we have:
$$\operatorname{f}(z) = \frac{\operatorname{g}(z)}{z(z^2+1)}$$
where $\operatorname{g}$ is some function with the properties that $\operatorname{g}(0) \neq 0 $ and $\operatorname{g}(\pm\operatorname{i}) \neq 0$. If $z=0,\pm\operatorname{i}$ are the only poles of $\operatorname{f}$ then $|\operatorname{g}(z)|<\infty$ for all $z$. One such example is your function: $\operatorname{g}(z) \equiv 0$ and
$$\operatorname{f}(z) = \frac{1}{z(z^2+1)}$$
The find the Laurent Series about $z=0$, notice that
$$\frac{1}{1+z^2} = 1-z^2+z^4-z^6\pm \cdots$$
for all $|z| < 1$. Hence:
$$\frac{1}{z(z^2+1)} = \frac{1}{z}-z+z^3-z^5 \pm \cdots$$
For all $z \in \mathbb{C} \backslash \{0,\pm\operatorname{i}\}$, the Laurent Series will be the ordinary Taylor Series, since $\operatorname{f}(z)$ is well-defined at such points.
To find the Laurent Series around $z=\pm\operatorname{i}$, decompose $\operatorname{f}$ into partial fractions:
$$\frac{1}{z(z^2+1)} \equiv \frac{1}{z}-\frac{1}{2(z+\operatorname{i})}-\frac{1}{2(z-\operatorname{i})}$$

Laurent Series of a function in general


Displaying content according to the OG membership of the creator

Question: In our Drupal 7 site, we are using Organic Groups to create private groups. Users are also able to upload content to a gallery (using custom Content Types "Gallery image" and "Gallery video"). On users' profile pages, we are showing a carousel of their N most-recent uploads, with a View using a Contextual Filter on Author uid.
We would like to add a similar carousel to each OG group page, showing the most-recent N uploads by members of the group. [Edit: This is uploads to the general Gallery, the OG groups do not have their own galleries.] If it makes a difference, almost all users will be members of more than one group (for reasons that are unimportant, there are two kinds of group: geographic groups and interest-based groups).
This seems like it's probably very easy, but I just can't see how to do this, either from the View's Contextual Filters or the View's Relationships.
Am I missing something obvious?
Comment: For clarification: do you want to show "group content" from member who belong to the current group or do you want to show "any content" from members who belong to the current group? Btw, checkout this awesome OG tutorial: http://modulesunraveled.com/organic-groups.
Comment: The latter. Galleries are unrelated to the OG groups, but all users will be in at least two groups. User pages have a carousel that shows the most recent _N_ uploads from that user, we would like to add a carousel to the OG group pages that show the most recent _N_ uploads from "users who are members of this group". I've edited the question to make that [slightly] clearer. Thanks for the tutorial link; I'll go take a look in a moment.
Comment: this is a view that will show group content uploaded by  members of the group: http://s3.amazonaws.com/awesome_screenshot/1360583?AWSAccessKeyId=0R7FMW7AXRVCYMAPTPR2&Expires=1327942737&Signature=e4v4DUVhpMu3xiSLxVodL76BsGQ%3D. If you remove the "Group membership: Node group membership" relationship it might show all content by members of the group.
Answer: In Drupal 6 you would add a relationship to the Organic Group: node then filter by Organic Group: user and use the relationship. I believe it should be something very similar by using the contextual filters...
Comment: Thanks; that gives me somewhere to start looking, at least :o)


'Serialization of 'SimpleXMLElement' is not allowed Error insert in session xml value

Question: Hi all I have a site developed in codeigniter.
I'm parsing an xml that I retrieve from a server and I want to put the return value into a session variable.
But return me this error:

Fatal error: Uncaught exception 'Exception' with message 'Serialization of 'SimpleXMLElement' is not allowed

My PHP version on my vps is:
PHP Version 5.3.10-1ubuntu3.4
This is my code:
<code>$xml = new SimpleXMLElement(curl_exec($ch2));
$error2=curl_getinfo( $ch2, CURLINFO_HTTP_CODE );
curl_close($ch2);
foreach ($xml->DATA as $entry){
    $code_travco = $entry->attributes()->COUNTRY_CODE;
    $name_en =  $entry->COUNTRY_NAME;
    $newdata = array(
        'code'  => $code_travco,
        'name_en'     =>  $name_en
    );
    $this->session->set_userdata($code_travco.'_nation_en', $newdata);
 }
</code>
Answer: may be try changing it to string before adding, like:
<code>foreach ($xml->DATA as $entry){
    $code_travco = (string) $entry->attributes()->COUNTRY_CODE;
    $name_en =  (string) $entry->COUNTRY_NAME;
    $newdata = array(
        'code'  => $code_travco,
        'name_en'     =>  $name_en
    );
    $this->session->set_userdata($code_travco.'_nation_en', $newdata);
 }
</code>
Comment: It's not resource type but an object of type `SimpleXMLElement`. Just FYI. And it can not be serialized as the error message says. But it supports casting to string (which resource types to not support that way).
Comment: it works great! But why isn't a string? which format is before put (string)?
Comment: @AlessandroMinoccheri its resource type and resources cannot be serialized, hence the error..
Comment: This was so helpful - what I don't understand is why is this not an error 500 - rather, my Firefox just says page cannot be displayed. I only found this error deep in my error log! #HairPullout


How do I convert an index to an Excel-like column number in a functional way?

Question: I'd like to write a function that generates the corresponding column name for a specific number, for example A for 1 or AA for 127. I know this has been answered quite a lot already, but I'd like to do it in a functional way.
Sure, you should be able to convert the existing (imperative) answers pretty easily, but I find myself getting stuck every time I try to.
Any good ideas / functional implementations?
Comment: Since there's not much effort in the question, here's an "answer" without much effort ;) `var toLetterCode=i=>(i.toString(26).split("").map((i26,i,is)=>"ABCDEFGHIJKLMNOPQRSTUVWXYZ"[parseInt(i26,26)-(i===0&&is.length>1?1:0)]).join(""));`
Answer: Here's a working implementation.

var letters = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'];

function toLetter(number) {

  if (!number || number <= 0) {
    return 0;
  }

  var code = "";
  for (var i = 0; i < Math.floor(number / 26); i++) {
    code += letters[i];
  }
  code += letters[(number % 26) - 1];

  return code;
}

console.log(toLetter(27)); // returns AA;
Comment: Thanks, but this isn't a functional approach. Functional, meaning there are no mutable variables and no loops (while/for) changing those variables.


In $\triangle ABC$, $AB=AC$, $I$ is the incenter, and $PD^2=PE\cdot PF$. Show that $\square IPBC$ is a cyclic quadrilateral.

Question:
In $\triangle ABC$, $AB=AC$, $I$ is the incenter, and $PD^2=PE\cdot PF$. Show that $\square IPBC$ is a cyclic quadrilateral.
Comment: can you show us that you've thought a little bit about this, beyond drawing the picture (on which, by the way, D, E, and F are not labelled)?
Comment: can I construct circle on $IBC$ and $AC$ is a tangent. Can I show that P is on this circle?
Comment: @THETA What is the source of this problem?
Comment: My university past exam
Answer: Hint: The weird condition that $PD^2=PE\cdot PF$ is, since the triangle is isosceles, equivalent to $\square PFCD \sim \square PDBE$. Can you continue from there to show that $\angle BPC = \angle BIC$?
Comment: thank you. I will try.
Answer: Let $\measuredangle BAC=\alpha$.
Since $\measuredangle EPD=\measuredangle DPF$ and $\frac{PD}{PE}=\frac{PF}{PD}$, we obtain $\Delta EPD\sim\Delta DPF$,
which gives $\measuredangle DEP=\measuredangle FDP$ and $\measuredangle EDP=\measuredangle DFP$ and since $BEPD$ and $CFPD$ are cyclics,
we obtain:
$$\measuredangle BPC=180^{\circ}-(\measuredangle PBD+\measuredangle PCD)=180^{\circ}-(\measuredangle PED+\measuredangle PCD)=$$
$$=180^{\circ}-(\measuredangle PDF+\measuredangle PCD)=180^{\circ}-(\measuredangle PCF+\measuredangle PCD)=$$
$$=180^{\circ}-\measuredangle ACB=180^{\circ}-\left(90^{\circ}-\frac{\alpha}{2}\right)=90^{\circ}+\frac{\alpha}{2}.$$
In another hand,
$$\measuredangle BIC=180^{\circ}-\frac{1}{2}(\measuredangle ABC+\measuredangle ACB)=180^{\circ}-\frac{1}{2}(180^{\circ}-\alpha)=90^{\circ}+\frac{\alpha}{2}.$$
Id est, $\measuredangle BPC=\measuredangle BIC$, which gives that $B$, $I$, $P$ and $C$ are cocyclics.
Done!
Answer: HINT (A way to solve).-For IPBC to be a cyclic quadrilateral it is necessary and sufficient that the circumcircle  to any trio of points of the four I, P, B, C, coincide. You have the formulas you need in Wikipedia if you do not know them.
1) Let $$A=(0,b),B=(-a,0) , C=(a,0),\overline{BC}=2a, \overline{AB}=\overline{AC}=\sqrt{a^2+b^2}$$
2) Incenter $I=\left(0,\dfrac{ab}{a+\sqrt{a^2+b^2}}\right)$
3) Circumcircle of triangle $\triangle {BCI}$: an equation is obtained making the determinant equal to $0$ of the matrix $$\begin{pmatrix} x^2+y^2&x&y&1\\a^2&-a&0&1\\a^2&a&0&1\\\dfrac{a^2b^2}{(a+\sqrt{a^2+b^2})^2}&0&\dfrac{ab}{a+\sqrt{a^2+b^2}}&1\end{pmatrix}$$
4) You have to verify that the point $P$ is in this circle.


Small question regarding surface areas and volumes

Question: This is a question that i was not able to solve, help about it is highly appreciated.
The radii of the bases of a cylinder and a cone are 3:4 and their heights are in the ratio 2:3, what is the ratio of their volumes?
Answer: You have a cylinder with height $h_1$ and radius of base $r_1$. Then the volume is $V_1 = h_1\pi r_1^2$.
You have a cone with height $h_2$ and radius of base $r_2$. The volume is $V_2 = \frac{1}{3}h_2\pi r_2^2$
Now you are told that
$$\begin{align}
r_1 &= \frac{3}{4}r_2\quad\text{and} \\
h_1 &= \frac{2}{3}h_2.
\end{align}
$$
Use this to find
$$
\frac{V_1}{V_2}.
$$
Comment: Slightly incorrect - aayush is told that the ratio of the *radii* of the bases is 3/4. So it should be $B_1 = (3/4)^2 B_2$.
Comment: That is, unless it's a typo.
Comment: @GlenO: You are right. I misread the question. I updated the answer.
Answer: since you have just to compute the ratio of their volumes and you have the ratio of the bases and heights, you may just choose convenient values for the latter.
Take a cylinder with base 3 cm and height 2 cm and a cone with base 4 cm and height 3 cm, and do the math.


Foreground of Button not changing in property trigger

Question: Why does this trigger work (Changing the foreground of the button to "Red" when the mouse is over)
<Grid>
 <Grid.Resources>

  </Style>
 </Grid.Resources>
 <Button Content="Hello"/>
</Grid>

but not this trigger, when the foreground of the button is set to a color (in this case "Blue")?
<Grid>
 <Grid.Resources>

  </Style>
 </Grid.Resources>
 <Button Foreground="Blue" Content="Hello"/>
</Grid>

Answer: The local value of the button overrides the Style.  Try:
<Grid>

    <Grid.Resources>

        </Style>
    </Grid.Resources>

    <Button Content="Hello"/>

</Grid>

Answer: I know it's an old post, but this is the solution (in property trigger). Answer:
<Setter Property="TextElement.Foreground" TargetName="contentPresenter" Value="Blue"/>

The most logical way to do it:
<Setter Property="Foreground" Value="Blue"/>

But.. Don't work..
Comment: I'm not sure but imho it's better to remove the language-specific sentences except english.
Answer: Just add a control template, then bind the ContentPresenter's TextElement.Foreground to {TemplateBinding Foreground} in your style:
<Grid>
    <Grid.Resources>

        </Style>
    </Grid.Resources>
    <Button Content="Hello"/>
</Grid>


theme_suggestions_html_alter not being picked

Question: I'm trying to implement a custom template html--front--anonymous.html.twig which replaces html.html.twig. The suggestion is being showed, but its file is not being picked.
my_theme.theme
<code>function MY_THEME_theme_suggestions_html_alter(&$suggestions, $variables) {
    if (\Drupal::currentUser()->isAnonymous()) {
        if (\Drupal::service('path.matcher')->isFrontPage()) {
            $suggestions[] = 'html--front--anonymous';
        }
    }
}
</code>
Answer: Suggestions need to use underscores rather than dashes:
<code>$suggestions[] = 'html__front__anonymous';
</code>
Comment: I had tried that, but setting underscores in the filename too, which didn't work. Now I understand that the declaration of the suggestion must be with underscores, but the filename must be with dashes.


Custom ComboBox Selection display

Question: I currently have a custom made combobox allowing to choose an image from its drop down and display the image inside the toggle button of the combobox. It works fine but I have one problem. If i set my currently selected item from code or xaml(with selectedIndex for example), the display of the image in the button is wrong(Only half the image appears in the button). If i selected it manually by going through the drop down it works fine(the image is stretched to the button size). In fact, simply clicking on the drop down seems to fix the problem.
My question is, what exactly happens when you click on the togglebutton of a combobox. That way i can replicate it and make it work.
Image: http://postimg.org/image/tlwg0gdq3/
<ComboBox Name="Spell1ComboBox" Style="{StaticResource SpellComboBox}" IsSynchronizedWithCurrentItem="True" Width="55" DockPanel.Dock="Left" SelectionChanged="OnSelectionChanged" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch">
<controls:MyComboBoxItem Tag="Rage" Description="Le mode rage augmente considérablement la cadence de tir du vaisseau." Grid.Row="0" Grid.Column="0">
    <Image Source="/AsteroidsInterface;component/Media/spell1.jpg" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Stretch="Fill"/>
</controls:MyComboBoxItem>
<controls:MyComboBoxItem Tag="Chaîne" Description="Créer une chaîne laser entre les deux joueurs pour 5 secondes. Tout les astéroides entrant en contact avec la chaine sont détruits. Si un seul joueur est présent, celle-ci s'attache à la station la plus proche." Grid.Row="0" Grid.Column="1" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
    <Image Source="/AsteroidsInterface;component/Media/spell2.jpg" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Stretch="Fill"></Image>
</controls:MyComboBoxItem>
<controls:MyComboBoxItem Tag="Bouclier" Description="Le vaisseau devient invulnérable et détruit les astéroides avec lesquelles il entre en contact." Grid.Row="0" Grid.Column="2" >
    <Image Source="/AsteroidsInterface;component/Media/spell3.jpg" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Stretch="Fill"></Image>
</controls:MyComboBoxItem>
<controls:MyComboBoxItem Tag="Réparation" Description="Les tirs du joueur peuvent redonner des points de vie aux stations. Peux être combiné avec rage pour augmenter l'efficacité. " Grid.Row="1" Grid.Column="0" >
    <Image Source="/AsteroidsInterface;component/Media/spell4.jpg" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Stretch="Fill"></Image>
</controls:MyComboBoxItem>
<controls:MyComboBoxItem Tag="Téléportation" Description="Permet au vaisseau de se téléporter dans la direction qu'il face." Grid.Row="1" Grid.Column="1" >
    <Image Source="/AsteroidsInterface;component/Media/spell5.jpg" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" Stretch="Fill"></Image>
</controls:MyComboBoxItem>

Comment: Could you post some images to illustrate the symptom? upload them to some website and provide the links, I can help you import them into Stackoverflow.
Comment: Also, post your relevant XAML markup and code (if any).
Comment: I don't know why a combobox would have a toggle button, seems that's not a default property. But here are the events a combobox generates: https://msdn.microsoft.com/en-us/library/system.windows.controls.combobox_events(v=vs.110).aspx Typically these event's can be triggered from code if you want to test them.
Comment: added code and screenshot
Answer: Sorry, I can't add comments yet, but does calling invalidate() manually inside your code also show the full image?
If it is, maybe loading your image to the checkbox is being done asynchronously while invalidate() is first called when the loading haven't even finished,
And then the loading is asynchronously finished so everytime the view is refreshed after the initial draw it works fine.
It's just an assumption.
Comment: I tried calling invalidate after setting the selected index from code, still get the same problem. The image doesnt stretch
Comment: Hmm can i see how you are loading your image to the combo box toggle button through code ?
Comment: its in the code above, image is the content of comboboxitem, passed to the toggle button in the style using a contentpresenter in spellcombobox
Comment: Can you try setting the horizontalcontentalignment and verticalcontentalignment of the togglebutton to stretch?
Comment: I did, i get the same problem
Comment: That isn't an answer and it should be deleted.

Custom ComboBox Selection display


For continuous Linear functional show $L \notin (C[0,1] , || . ||_2)^* $

Question: For $L: C[0,1] \to \mathbb{C}$ denote the linear functional by $L(f) = f(0)$. Show $L \notin (C[0,1] , || . ||_2)* $
If I were to show $L \in (C[0,1] , || . ||_2)^* $ I would need to show that $L$ is continuous for all $f \in C[0,1]$ in $|| . ||_2$. To do this I could show it was bounded and thus try and show $^{sup}_{||f||_2 \leq 1} ||Lf||<\infty$. However as we are trying to prove by counterexample  I need to find some unbounded sequence for $||f||_2 \leq 1$ but I can't think of any ideas, could I have some help please?
Answer: Take $f_n = (n-n^3x)1_{x\in [0, \frac{1}{n^2}]}$, then $\|f_n\|_2 \leq 1$, but $Lf_n = n \to +\infty$


I have the equation $(1 − B)y_t = (1 − B)a_t$, can I conclude from this that $y_t=a_t$ for all $t$?

Question: I have the equation $(1 − B)y_t = (1 − B)a_t$, am I able to say that this equation implies that $y_t = a_t$ for all t?
$B$ is the backward shift operator where $Bz_t = z_{t-1}$ and
$y_t = y_{t-1} + \mu + \sigma a_t$ where $a_t$ is a sequence of independent random variable $N(0,1)$, $\sigma$ is the volatility, and $\mu$ the mean growth rate.
I know: $y_t = y_{t-1} + \mu + \sigma *a_t$
$y_t -\mu * t= y_{t-1} - \mu * (t-1) + \sigma *a_t$
where $z_t = z_{t-1} + \sigma * a_t$
so $a_t = (z_t - z_{t-1})/ \sigma$
I Guess I just don't know how to show whether or not $y_t$ and  $a_t$ are defined for the same t. I know according to time series that t is today where as t-1 was yesterday (or the past) and t+1 is the future.
Comment: What the equation $(1-B)y_t=(1-B)a_t$ says is that the increments in $y_t$ equal the increments in $a_t$. Does that sound sufficient for $y_t\equiv a_t$?
Comment: You are trying to prove something that might or might not be true. What about two sequences: $y=(1,2,3)$ and $a=(11,12,13)$? Isn't it true that $(1-B)y_t=(1-B)a_t$?
Comment: This is most definitely a self-study, I am preparing for an up coming test, essentially I don't know how to use time series in order to conclude if yt=at for all t. what do you mean read its wiki?  @gung
Comment: Thank you for adding the tag; if you click the hyperlinked [wiki](http://stats.stackexchange.com/tags/self-study/info), you will be taken to a page explaining our policies. Please tell us
what you understand thus far, what you've tried & where you're stuck. We'll
provide hints to help you get unstuck.
Comment: Are you sure the equations are correct? I mean, if $(1-B) y_t = (1-B) a_t$ then $y_t = y_{t-1} + a_t - a_{t-1}$. From now on it seems that there is some information missing. How do you get from the equation above to $y_t = y_{t-1} + \mu + \sigma * a_t$? Is this given? And how $\mu$ turns into $\mu * t$?
Comment: yt=yt−1+μ+σ∗at is given. to get u*t i just added and subtracted u*t from the yt formula
Comment: @RichardHardy well the way I see it is that i need to show that (1-B)^(-1) exists for yt=at...
Comment: i know (1-B)yt=(1-B)at so in order for it to be implied that yt=at i need to show that (1-B)(1-B)^(-1)yt=at where the inverse (1-B)^(-1) has to exist in order to imply that yt=at. @RichardHardy
Comment: well no clearly that won't be true
Answer: Look at the comment by @Richard Hardy:

What the equation $(1-B)y_t=(1-B)a_t$ says is that the increments in $y_t$ equal the increments in $a_t$. Does that sound sufficient for $y_t\equiv a_t$?

To make it more clear, make a numerical example where two series have the same increment:
<code>1 2 3 4 5 6 7 8  9  10
3 4 5 6 7 8 9 10 11 12
</code>
and the answer should be clear. An analogy with calculus is that two functions might have the same derivative without being equal.


Excel. Convert text to values and calculate the values in a formula

Question: I want to convert text to values and then with this values calculate a result:
Text "A" is always = 8
Text "B" is always =7
In my sheet:
In cell A1:"A" and in B1: "B". Now in cell C1 I want the sum of A1 and B1 (8+7=15).
I always want the cells A1 och B1 to show text not values.
And if it possible I dont want any intermediate cells that convert A1 to 8 and B1 to 7 so the resultformula points at that intermdediate cells. I want my result (C1) to calculate the text cells directly. Is this possible?
Answer: <code>=IF(A1="A",8,IF(A1="B",7,NA()))*IF(B1="A",8,IF(B1="B",7,NA()))
</code>
It is easier to have a separate translation list, say on Sheet2 cells A1:B6:
A   8
B   7
C   6
D   5
E   4
F   3
and then use:
<code>=VLOOKUP(A1,Sheet2!$A$1:$B$6,2,FALSE)*VLOOKUP(B1,Sheet2!$A$1:$B$6,2,FALSE)
</code>


Do classical musicians sometimes go deliberately out of pitch?

Question: Can anyone explain to me what's going on?:

I am not and have never been a professional classical musician, but I don't think you need to be one to see that something is definitely wrong here — starting from the very intro by cello and then throughout the whole piece. And I am more than assured that performers themselves realize that. And that's what puzzles me greatly. They, nevertheless, perform it as if it were exactly the way it is supposed to be. And it doesn't seem to be any kind of joke on their part either.
Is there any more or less reasonable explanation to this? This act reminded me of my first experience of having one kind of French cheese. It smelled like nothing less than a piece of well-rotten remains of a corpse. However, before I was ready to vomit, one good person explained to me that that was a special French delicacy and was, in fact, good for health. Well, while I was still doubtful about how it was good for health, at least I got some explanation.
So, is there any similar plausible explanation for this case?
EDIT [2023.03.15]: Here is a similar case:
Comment: It's a high school orchestra - it's not intentional. Proper intonation is very difficult and takes years to develop. This is being performed by older children - teenagers. Unless they were **very** dedicated to practicing, they have not had enough time to learn to play better than this.
Comment: …& at a guess, only one or two of those will keep it up long enough to ever get good at it. Musicianship has a natural wastage, with a high early discard-rate.
Comment: @ToddWilcox - Aaaah. I see now. Thank you!
Answer: While the linked video is explained as an amateur (high school) orchestra in which the musicians haven't fully developed their intonation, there are situations in which classical musicians play deliberately out of tune. (Of course, since they typically do this at the composer's instruction, one could say they really aren't out of tune at all.)
Microtonality
The prime examples of "out-of-tuneness" would be those in the realm of microtonal music. Microtonality broadly refers to contemporary music (and sometimes music from non-Western cultures) that is composed outside the accustomed equal-tempered scale.
One example: Krzysztof Penderecki's Threnody for the Victims of Hiroshima. In this piece, the instruments are, by intention, out of tune with each other.

Detuning to achieve a specific pitch
Traditionally, the lowest pitch on a string bass is E, but there are scores that require an Eb. To do this, the bass player retunes the E string to Eb. Technically, the string is now "out of tune", but also plays an accurately tuned Eb.
See How do you play a low Eb on a double bass?
Peg scordatura
Sometimes a composer will ask a string player to "detune" their instrument for some passage of music.
For more on this, plus some examples of other "detuned" instrument and pieces of music that employ the technique, see Are there pieces that require retuning an instrument mid-performance?
Toy instruments
Some composers or ensembles work with toy instruments which are (more or less) inherently out of tune. One example, John Cage's Suite for Toy Piano.

"Correcting" for equal temperament
The compromise that equal temperament makes (12-TET, specifically) is that most intervals are "out of tune" in comparison to their more sonorous "just" relationships. When I sang in unaccompanied choirs, the voice with the chordal third would often adjust their pitch up or down, depending on the needs of the chord. Similarly with fifths. String, brass, and woodwind ensembles will do this as well. (Basically, as long as there's no piano. ;-))
One post that discusses this is Making part of a triad chord sharper, but is it counted as minor?
Temperaments
There is a strong case to be made that the only "in tune" scenarios are those adhering to "just" intonation, meaning that intervals are integer ratios of frequencies. A "temperament" is a tuning in which those ratios are adjusted — "tempered" — to achieve some musical purpose. For example, 12-tone equal temperament — the adjustment of intervals such that 12 equal-sized semitones divide each octave — allows for the practical use of 12 different keys, but only by making most intervals slightly out of tune in comparison to their just ideals.
In this way, one could say that all classical musicians — pianists especially — play out of tune as a matter of course. (But, then, is it really out of tune...?)
Comment: @ToddWilcox Oh, maybe I understand. You're thinking of spontaneous adjustments to "correct" for equal temperament and give better sonorities for chords and intervals?
Comment: @ToddWilcox equal temperament is often described as "everything being a little bit of of tune."  In fact, this is true of every temperament.  By that standard, almost everyone plays deliberately out of tune _except_ for those using just intonation -- but pure just intonation is almost impossible to achieve in practice, and it frequently results in pieces finishing at a different frequency from where they started, so it is also out of tune by a different measure.
Comment: @Aaron Hehe, I'd argue that's a pianist's perspective! Most stringed instruments, even fretted, can alter the pitch, and most wind instruments can through breath control, and obv unfretted instruments and human voice can it all. (Even clavichord!) I'd argue that, for these, intentional alteration for expressive purposes—not just temperament or harmonic reasons like leading tone—have been around forever. In fact, vibrato is kind of part of this conversation...
Comment: You left out sonority achieved by flattening thirds and slightly sharpening fifths. Assuming not playing equal tempered counts as "out of tune".
Comment: @ToddWilcox I'm not certain I follow. You're thinking in terms of just intonation? I intentionally left it out (or, rather, thought of it as included in microtonality) so as not to start a debate over whether j.i. was in or out of tune.
Comment: @phoog That's a good point. I took ET as normative for my post. Do you think it's worth an add, or will it just lead to confusion and debate?
Comment: @Aaron I'm not sure.  You're right to tread carefully, but it's probably worthwhile to mention.
Comment: Correction to my earlier comment: in temperaments other than equal, not everything is a little bit out of tune -- there could be some intervals or chords that are in tune, but there will always be some that are out.  Ultimately, though, this discussion so far suffers from a failure to define "out of tune" or "in tune": they can be defined relative to acoustical phenomena such as the overtone series or relative to equal temperament or any other temperament.  A performance can be both in tune and out of tune depending on the definition (or it can be out of tune under all definitions).
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/142575/discussion-between-aaron-and-phoog).
Comment: There's one other thing not covered in this exhaustive answer, something I thought of immediately from the OP's question: what I call "expressive intonation." I guess it could fall under the umbrella of microtonality, but I think there's an important distinction. Microtonal systems like middle eastern music are still dictating a certain "target pitch"; it's not "out of tune," just "differently tuned." But there are plenty of times that a system both conceptualizes a "target pitch" and chooses not to hit it, or to deviate from it: all the pitch bends that are possible on the vast majority of
Comment: instruments and the human voice. There's the ability to slide "into" or "out of" the note, or even to intentionally never quite hit it. I learned the Franck and Debussy violin sonatas around the same time that I really discovered Ella Fitzgerald and the jazz age in general, and had the epiphany that "Hey, just because the dot on the page is an A, doesn't mean that I have to produce 440Hz for a full quarter note, or even that I have to ever get right to 440Hz if I choose!" It's a conversation about "blue notes," not necessarily in the strict mathematical sense of the blues scale, but...
Comment: ... in the sense of a note being "a bit blue." I don't have time right this second to flesh that out into its own answer, but you could add to yours if you're pickin up what I'm puttin down.
Comment: @AndyBonner Blue notes being "a jazz thing", and pitch-bending ornamentation being something of an "Indian thing", I chose to leave them out, since the question is focused on Western classical music — where they would tend to fall within microtonality.
Comment: With respect to 12-TET, you could even go as far as saying that *all intervals except the octave* are out of tune in comparison to their just ideals.
Answer: The other answers have given lots of reasons why classical musicians might go off pitch. But in this case, most of the issue is simply as Todd Wilcox and Tim wrote: the orchester is inexperienced, they didn't mean to play out of tune, still it happened.
But I would say a bit more about that, more as an apology on behalf of these musicians than anything.
First: specifically for the cello introduction but also the rest
– Well, to begin, this is a high school student who has perhaps never played in front of an audience of the size they were facing here. And then she has to begin this piece all alone, with literally every eyeball in the room upon her. Easy to see how that can affects one's performance. (Maybe not so much for the kind of personality who plays lead guitar in a metal band, but orchestra musicians tend to fall a bit more on the shy side.) Even nerves aside – string instruments are tricky enough to play accurate under the best of conditions, but when you've just taken your seat, maybe the position isn't quite right, maybe there's something wrong with the chair, etc. etc..
Professional musicians have the experience from hundreds of public performances to guide them through such adversities, and even they get it wrong sometimes, and/or they're hyper-sensitive about the temperature backstage and whatnot because they know the dangers.(Well, and there's also musicians who are super-relaxed badasses that just step on stage and kill it every time, but it's a big skill.)
Second, intonation isn't everything.
We're living in a world where so much music is hyper-corrected. Leaving aside the question of whether the predominant 12-edo tuning is even a good ideal – often other aspects of a performance are far more important than ideal pitch. This piece is a rock song. For sure an unusual one and in a different arrangement, but it doesn't change the fact that it's much more about powerful expression and rhythmic energy, than about clean intonation. And that's frankly something many orchestras totally suck at, even professional ones. MHS is doing a pretty good job at it I have to say, at least until about 2:30 where the tempo starts dragging a bit (probably bow arms getting tired). Even in the melody, there's a lot of simply anger and desperation. This can involve phrasing, effects like portamento (sliding/bending into- or out of notes), but also simply a certain not-giving-a-damn about intonation.
In summary: these musicians did the best job that could realistically be expected from them in the situation.
Comment: Thank you. I should've seen from the outset that they were just kids. I had been watching a lot of professional symphonic orchestral music videos earlier that morning and got carried away into not noticing that obvious fact when this vid popped up in my recommendations.
Comment: This should be the accepted answer, it nails it.
Answer: All that, with no conductor in sight!
I'd put it down to possibly not enough rehearsal time, or an inexperienced orchestra. There's always this sort of intonation/tuning problem with either. Playing in tune with other strings takes years to get right - playing one string instrument by itself in tune is enough of a challenge, and they did really well with a challenging piece.
It's true that choirs and string orchestras sometimes do move slightly 'off key', particularly the more amateur choirs, when there's no reference point like a piano to follow, but the better ones will all tend to move all together, rather like tempo changes with no conductor to keep time. But your 'off key' I guess is meant for 'out of tune with each other' - something subtly different.
Answer: Aside from what Aaron already said(which is all correct), there is a certain practice that some people frown upon, but many others think it's fine. In instruments that can manipulate their intonation on the spot, like the violin, a soloist might sharpen or flatten tendency tones to create stronger tension/desire to the resolution. For example, a leading tone can be slightly sharpened, and a subdominant can be slightly flattened if it goes to the mediant. This only works for tones that resolve by semitone, and only in a solo or small chamber context, as an orchestral context would create a dissonant clash between the person doing this and the rest of the section.
Comment: Regarding the very last sentence in your answer, can you, please, take some time to elaborate on why that would work in chamber, but not in orchestra?
Comment: @brilliant if only *one* out of a whole section of *sixteen* first violinists changed the pitch they were playing... it would not sound good
Comment: @AakashM - I was thinking, in fact, totally the opposite - if one out of a section of sixteen goes slightly out of pitch, it won't be noticeable - just like, say, it is not that noticeable when suddenly one of them stops playing in order to turn the score page.
Comment: @brilliant A slightly different pitch is very different from dropping out. Try [this online tone generator](https://onlinetonegenerator.com/multiple-tone-generator.html?f[]=440&f[]=442&f[]=440&f[]=440&f[]=440&w[]=sa&w[]=sa&w[]=sa&w[]=sa&w[]=sa&v[]=14&v[]=12&v[]=12&v[]=15&v[]=15). The On Off buttons control 4 "violins" at 440 Hz and one at 442 Hz. Note the difference between dropping out one of the 440s, and dropping in/out the 442.
Comment: @AakashM - I see. Thank you.
Answer: Another example of deliberately playing out of tune I'd like to bring to the table is perhaps one of the most stunning pieces on the classical guitar: Nikita Koshkin's Usher Waltz. This piece was inspired by the novel The Fall of the House of Usher, and the composer deliberately wrote out of tune passages to showcase the absurdity that the story has fallen into. Here is an example performance, and the out-of-tune "Bartok pizzacatos" start at 3:50:
Comment: Thanks for introducing me to this piece. Really cool. On the same subject, here's a film version of "Usher", with an improvised organ accompaniment: [*The Fall of the House of Usher*](https://www.youtube.com/watch?v=E5tFr2iFrUw&list=PLimnV6h4UMJEV0S4ZQ1zycq3rShJjiPoh)
Answer: Yes it is a thing. If you go into modern practice of old music (baroque and prior) it is quite common to see intentional out-of-tuneness for effect. And even more that that slight shifts from intonation can influence the character of a piece and are thus rather common. But in this case this is simply because these are not fully trained classical musicians, this is a high school orchestra.
This is the actual recording of the string quartet this arrangement came from:


How can I force a JavaScript library to load in the  of a page?

Question: How do I force a JavaScript library to load in the  in Drupal 8?
Here's my themename.libraries.yml file:
zaccordion:
  version: 1.x
  js:
    js/jquery.zaccordion.js: { header: true }
    js/jquery.zaccordion.min.js: { header: true }
    js/zaccordionUsage.js: { header: true }
  dependencies:
    - core/jquery

It still loads in the footer however.
Answer: header: true needs to go under your js declaration, not within each file.
See: https://www.drupal.org/docs/8/theming-drupal-8/adding-stylesheets-css-and-javascript-js-to-a-drupal-8-theme

By default, all JS assets are now loaded in the footer. Being loaded
  in the header is now an opt-in choice, that is only necessary for
  critical UI elements that cannot be shown unless their corresponding
  JS has already run.

js-header:
  header: true
  js:
    header.js: {}

js-footer:
  js:
    footer.js: {}

You have to set the new header property on asset library definitions
  to true, to indicate that the JavaScript assets in that asset library
  are in the critical path, and should therefore be loaded from the
  header. Note that any dependencies — direct and indirect — of asset
  libraries marked as being in the critical path are also automatically
  loaded from the header, so you don't need to worry about dependencies
  being unavailable.


Pegar nome da tabela respectiva PHP em SELECT UNION

Question: Olá, pessoal tudo bem?
Alguém sabe como fazer para pegar o nome da tabela respectiva do valor puxado?
Eu tenho o seguinte código:
$query= "
SELECT DISTINCT titulo, categoria, views
FROM (
  SELECT DISTINCT titulo, categoria, views FROM secao_aves UNION ALL
  SELECT DISTINCT titulo, categoria, views FROM secao_peixes
) as dados
ORDER BY views DESC
LIMIT 3
";

Daí eu pego os dados e rodo o loop:
//PEGA OS DADOS
if($stmt_mvw = $mysqli->prepare($query)){ /* INICIA DECLARAÇÃO PRINCIPAL */

    //ABRE DECLARAÇÃO
    $stmt_mvw->execute();

    //TRAZ O RESULTADO DA CONSULTA
    $stmt_mvw->bind_result($titulo, $categoria, $views);

    while($stmt_mvw->fetch()){
        echo ''.$titulo.'('.$views.' visualizações)';
    }
}

Digamos que meu banco de dados esteja assim:
Tabela "secao_aves":
id |      titulo      | categoria | views |
1  |      Pardal      |     AA    |  250  |
2  |    Beija-Flor    |     AB    |  100  |
3  |  João-de-Barro   |     AC    |  145  |

Tabela "secao_peixes":
id |      titulo      | categoria | views |
1  |      Bagre       |     PX    |  180  |
2  |     Dourado      |     PY    |  165  |
3  |     Pintado      |     PZ    |  75   |

Até aí, tranquilo. Por exemplo, seria impresso isto (os 3 registros com mais "views"):
<a href="busca.php?table=<?>">Pardal (250 visualizações)
<a href="busca.php?table=<?>">Bagre (180 visualizações)
<a href="busca.php?table=<?>">Dourado (165 visualizações)

Mas na verdade, eu gostaria que imprime-se assim:
Pardal (250 visualizações)
Bagre (180 visualizações)
Dourado (165 visualizações)

No caso, não sei como puxar o nome da tabela relativa ao dado, para criar a variável $NOME_DA_TABELA :/
Como proceder? :v
Comment: Tente colocar nas consultas internas algo como `select título, categoria, views, 'nome da tabela' as tabela`, assim cada registro terá o nome da tabela como uma coluna.
Comment: Opa, obrigado, Anderson. Fui ver as respostas agora. Obrigado novamente por se dispôr, realmente era algo simples.
Answer: Você pode criar um campo 'fictício' adicional dentro do SQL identificando a tabela:
SELECT DISTINCT titulo, categoria, views, tabela
FROM (
  SELECT DISTINCT titulo, categoria, views, 'secao_aves' as tabela FROM secao_aves UNION ALL
  SELECT DISTINCT titulo, categoria, views, 'secao_peixes' as tabela FROM secao_peixes
) as dados
ORDER BY views DESC
LIMIT 3

Assim, através do campo tabela você obtém a origem da linha resultante:
titulo  categoria   views   tabela
Pardal  AA           250    secao_aves
Bagre   PX           180    secao_peixes
Dourado PY           165    secao_peixes

Veja o modelo em: http://sqlfiddle.com/#!9/b6d0fd/3
Comment: Muito obrigado, Rogério por se dispor a mostrar de uma maneira mais direta. Com certeza é mais uma técnica pro eterno aprendizado. Um abraço!
Comment: Obrigado, lembrando para que dê a resposta como aceita, ok?
Comment: Prontamente. Estava testando hehe mas deu tudo certo. Até ;)


How do I turn off notices and warnings?

Question: I am developing a site and am getting a few warning messages that cover the page. I want to deal with them later and turn them off for now so I can concentrate on theming.
I've tried going to Config>>Development>>Logging and turning them off from there, but although it says the save was successful refreshing the pages shows the 'All Messages' option is still selected and the messages still appear on the front end.
I searched how to do this in Drush and tried drush vset -y error_level 0 and drush vset error_level 0 and got the response "error_level was set to 0." but this too had no affect.
I've tried clearning my cache after each attempt as well.
Would anyone know how to achieve this?
Comment: Some error messages cannot be turned off thru config, especially if serious. Plus you kinda want to see errors to know if you're doing something wrong. I'd recommend developing with one browser logged in as admin, and testing in another browser logged in as general user (this user won't see the errors). But you can try to hide the messages like mentioned [here](https://www.drupal.org/node/1036982#comment-10220137)  if really bothered by it.
Answer: If you don't want to add CSS you can comment out the $messages variable in your page.tpl.php file while you are developing.
Comment: Nice alternative, assuming you are not developing as a team and using the same dev server as others may want to see the messages.
Answer: To followup on @longboardnode's comment, If you really want to remove them, you can always download an app for your browser where you can style with css.
Such as Stylish for Chrome or Stylish for Firefox, which remembers your styling even after page refresh.
Then you simply hide it with css.
.messages.status {

   display: none;

}

Note: This will only turn it off for you / your browser.
Side Note: For theming I like to use a Live Editor such as Live CSS Editor for Chrome unlike Stylish, this one is not global, it will only remember your code on a per page basis.
Answer: Turn them off here: admin/config/development/logging
Or to show up all errors you could also set these in your local.setting.php
//Spew out all the errors!
$conf['error_level'] = 2;
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);

Answer: Learn how to set your error reporting level either within your php.ini file or by using the
error_reporting()

function.
The approporiate docs are here :-
http://php.net/manual/en/function.error-reporting.php
You can also set :-
display_errors = stderr

In your php.ini file to force errors to only go to the log file.
http://php.net/manual/en/errorfunc.configuration.php#ini.display-errors

How do I turn off notices and warnings?


In music notation, what would be the duration of a one-beat note followed by an infinite number of dots?

Question: Pretty sure the answer is two beats. Am I right?
But that's a side issue, interesting though it is.
What are the benefits of using dot notation to specify a note length over notating the note length using several tied noteheads?
Comment: Seems like this belongs on Math.SE. I think it's a geometric series that sums to 2, yes
Comment: I'm voting to close this question because it is a hypothetical thought exercise ultimately unrelated to music.
Comment: Since I voted to close, there have been several edits. The latest, "What are the benefits ...", is a perfectly valid question. But seems to me, a completely separate question from "how long is an infinite-dots note." I would suggest editing to remove the original question and fully convert to the new one. (One of my objections to the original is it's a "how many angels can dance on the head of a pin" problem: it's impossible to *write* infinite dots within our universe. It's a "how long would a performance of 4'33" last at the speed of light" sort of question.)
Comment: I know this is music **theory**, but is that taking it too far..?
Comment: Ah, Achilles & Tortoise, not tortoise & hare - one of Zeno's paradoxes https://en.wikipedia.org/wiki/Zeno%27s_paradoxes#Achilles_and_the_tortoise
Comment: I'm voting to reopen. Yes, indeed this question involves math, but just high school math, and it also has strong connection with music theory. I'm not convinced we should close a question just because it's interdisciplinary. Maybe it should be migrated to math, but then OP would need to explain what a dot is, which here most of us understands. I can also imagine someone else searching for a similar question, even if I don't see an immediate practical application.
Comment: ∑(n=0,∞)1/2^n=2
Comment: It's a bit like the tortoise & the hare problem… it would approach 2, but never actually reach it.
Comment: This sounds like the most brilliant ploy ever for a composer to delay a commission. "It will be ready when it's ready, ok? I'm on the last note!" "That's what you said 10 years ago!"
Comment: I've voted to keep closed. To reopen, I think OP needs to make a case for why the question is useful. Ordinarily, a lack of usefulness would just be a downvote reason, but since the question is already closed, I think, for now, it should stay that way.
Comment: While I also tend to like theoretical extremes to demonstrate concepts, I think this one is a little outside what most would consider a working extreme that show the concept. Even a note with 10 dots would stretch the bounds extremes with this concept. I do however think there is a way to ask this question that makes more sense as a whole, but with the focus on at what point the subdivisions become too small to be distinguishable notation wise. At that point, X dots  on a one beat note vs the two beat note doesn't matter and the answer would be well before infinity.
Comment: One way in which i found the question genuinely useful: I actually didn't know - or at least had forgotten - that you could put multiple dots after a note to change the duration in the way suggested...
Comment: As currently written, this question is a duplicate of [What is the smallest difference in note lengths that an average listener can still perceive?](https://music.stackexchange.com/q/73170/70803). An answer in terms of dots, however, would be meaningless, since it would be dependent on tempo.
Comment: As posed the question may not belong here, although it has an answer in the comments.  But there are some interesting side issues here in my view.  For example has anyone ever used more than three dots after a note rather than using a different notation and why.  If that was the question I would be happy to vote to reopen.
Comment: Yeah these are two completely different questions please pick one to focus on. There's already one answer that only focuses on only one of them.
Answer:
What are the benefits of using dot notation to specify a note length over notating the note length using several tied noteheads?

It's easier to write: fewer noteheads, stems, and possibly flags, and no ties.
It's easier to read: no need to differentiate between a tie and a slur.
Comment: I've actually read that one drawback is that multi-hit notation is *harder* to read by virtue of being rarer notation, so it's less likely to be understood.
Comment: Since this is all theoretical and unlikely to have any musical significance in practice anyway, I'd like to point out (as I'm sure you know, phoog) that neither dots nor several tied noteheads can cover all possible note lengths: for instance, a note length that is 1/3 of a beat longer.
Comment: @Dekkadeci by multi-hit do you mean ties?  I am sure that the unfamiliarity is a big part of it, but I suppose it's not the only reason.
Comment: @ScottWallace for that you need either compound meter or the triplet sign, possibly in addition to tied notes.  Interestingly, the dot arose in the context of triple subdivisions, indicating that the note decorated with the dot is "perfect," consisting of three subdivisions, when one might otherwise read it as "imperfect," having two subdivisions and 2/3 the length of a perfect note.
Comment: @phoog - Sorry, by multi-hit, I mean multi-dot.
Comment: @phoog - Indeed. But dots alone would need to be further qualified to cover all exigencies.  Not that such exigencies are musically important.
Comment: @Dekkadeci aha, that makes more sense.  Double-dotted notation is not that common, but I never found it particularly difficult to read, perhaps excepting the first time I encountered it.  I suppose it would be difficult to decipher outside of the usual context of exaggerated "normal" long-short dotted rhythm, but don't remember ever encountering a double dot in any other context.
Comment: @phoog - I just remember reading a recommendation some time ago to split double-dotted notation into 2 notes tied together (possibly in a more pop music context).
Answer:
Pretty sure the answer is two beats. Am I right?

Yes. The length of the notes with increasing number of dots is described by geometric series. https://en.wikipedia.org/wiki/Geometric_series In the page we find formula showing that for infinite series:
1 + 1/2 + 1/4 + ... = 1 + r + r² + ... = (for -1 < r < 1, which is fulfilled by r=1/2)  1/(1-r)  = 2.
Of course in practice writing infinite number of dots seems non-realistic, but also there are limits of hearing, as well as performer capabilities, imposing how many dots would make a note indistinguishable from a twice longer note; it would happen with a finite number of dots.

What are the benefits of using dot notation to specify a note length over notating the note length using several tied noteheads?

Dots were used to indicate a dotted rhythm (i.e. pairing of a longer and a shorter note, like dotted eight note and a sixteen note). That's a very characteristic and significant rhythm, which could be compared to swing rhythm.
Just like swing is not always performed with popular triplet division, dotted rhythms are also sometimes not performed with mathematical precision, except while swing rhythm is rather softened, dotted rhythm is sometimes played sharper than written. Also, unlike swing rhythm, dotted rhythm very often coexists with straight rhythm.
It seems therefore reasonable to have a dedicated notation for dotted rhythm, to distinguish it from any other arbitrary rhythmic structure.
Comment: I think dotted notation is also much more readable than ties.
Answer: I'm going to challenge the frame of your question. Music notation is, above all else, a tool used to communicate musical ideas. Math notation is similar, but math has an idea of rigor that isn't present is music. Correct notation is easy to read first and foremost, even if it doesn't perfectly reflect what is being played. It's better to indicate that a piece is swung, leave it at that, and write eighth notes everywhere, for example, than it is to add triplets that show precisely how long each note should be played.
Given this, a note with an infinite number of dots wouldn't ever be written down. You could notate it if you really wanted to with something like a note followed by a bunch of dots and an infinity sign. But that would always be much harder to read than a half note, so it's not a useful communication tool and fails the most important function of notation.
Likewise, that's why we use dotted notes instead of tied noteheads in some situations. Depending on the context, dotted notes can simply be easier to read.
Comment: "triplets that show precisely how long each note should be played": even triplets don't capture swing precisely.


Funneling echoes into an output file

Question: I'm asynchronously posting to a PHP file that echoes out a few key things. I want to write all of its output to a logfile. What would be the simplest way to do this?
Comment: I'm posting form data from a webpage, the form will post to the outside PHP file in question, and does not show/go to it.
Answer: I would use a simple wrapper, like http://www.redips.net/php/write-to-log-file/. All you need to do is include the file, instantiate the Logger class, and set a path. You would need to perform the logging operation after/before each echo.
Answer: <code><?php
// Before you have any output!
ob_start();

// All of your other code, echos, etc.

// Sends the Output Buffer, also captures it in the $output variables
$output = ob_get_flush();

// Some extra info for the Logfile, so you know when and who saw it
$logPrefix = "\n\n".
             "Time: ".date( 'Y-m-d H:i:s' )."\n".
             "IP:   ".$_SERVER['REMOTE_ADDR']."\n\n";

// Write the data to the Logfile, and append it to the end (if file already exists)
file_put_contents( 'yourLogfile.txt' , $logPrefix.$output , FILE_APPEND );
?>
</code>

Funneling echoes into an output file


DateTime Picker em português

Question: Eu adicionei o componente de DateTimePicker ao meu projeto.

Porém o mesmo está todo em inglês, adicionei a option de pt-BR na function que o cria no campo, e mesmo assim ele continua em inglês. Como faço para que os meses/dias da semana fiquem pt-BR ?
function atualizarCalendariosHora() {
    $(".calendarioHora").mask("99/99/9999 99:99");
    $(".calendarioHora").datetimepicker("destroy");

    $(".calendarioHora:not([readonly='readonly']):not([readonly='true'])").datetimepicker({
        format: 'd/m/Y H:i',
        lang: 'pt-BR',
        mask: '99/99/9999 99:99',
        onClose: function () {
            try {
                $(this).valid();
            }
            catch (e) {
            }
        }
    });
}

Comment: qual o plugin amigo?
Answer: Você pode escolher o que quer inserir de informação, por exemplo.
DAYNAMES = Nome dos dias.
Você coloca dentro de uma array os nomes e vai aparecer em seu calendário!
O código a seguir demonstra alguns atributos que você pode alterar.

$(".data").datepicker({
    dateFormat: 'dd/mm/yy',
    dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado'],
    dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
    dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'],
    monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
    monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
    nextText: 'Próximo',
    prevText: 'Anterior'
});
<link type="text/css" href="http://www.botecodigital.info/exemplos/datapicker/css/custom-theme/jquery-ui-1.8.20.custom.css" rel="stylesheet" />

<input type="text" class="data hasDatepicker" id="dp1458823238871">

Você pode verificar um exemplo neste site:
http://www.botecodigital.info/exemplos/datapicker/
Inspecione o código fonte e verá como é simples!
Tente deixar seu script assim:

function atualizarCalendariosHora() {
    $(".calendarioHora").mask("99/99/9999 99:99");
    $(".calendarioHora").datetimepicker("destroy");

    $(".calendarioHora:not([readonly='readonly']):not([readonly='true'])").datetimepicker({
        format: 'd/m/Y H:i',
        lang: 'pt-BR',
       dateFormat: 'dd/mm/yy',
    dayNames: ['Domingo','Segunda','Terça','Quarta','Quinta','Sexta','Sábado'],
    dayNamesMin: ['D','S','T','Q','Q','S','S','D'],
    dayNamesShort: ['Dom','Seg','Ter','Qua','Qui','Sex','Sáb','Dom'],
    monthNames: ['Janeiro','Fevereiro','Março','Abril','Maio','Junho','Julho','Agosto','Setembro','Outubro','Novembro','Dezembro'],
    monthNamesShort: ['Jan','Fev','Mar','Abr','Mai','Jun','Jul','Ago','Set','Out','Nov','Dez'],
    nextText: 'Próximo',
    prevText: 'Anterior',
        mask: '99/99/9999 99:99',
        onClose: function () {
            try {
                $(this).valid();
            }
            catch (e) {
            }
        }
    });
}

Comment: Note que o componente é o `DateTimePicker` e não o `DatePicker`.
Comment: Tenta colocar:
 locale: 'pt'
Answer: Consegui resolver o meu problema com: $.datetimepicker.setLocale('pt-BR'); após a definição do DateTimePicker.
function atualizarCalendariosHora() {
    $(".calendarioHora:not([readonly='readonly']):not([readonly='true'])").datetimepicker({
        format: 'd/m/Y H:i',
        mask: '99/99/9999 99:99',
        onClose: function () {
            try {
                $(this).valid();
            }
            catch (e) {
            }
        }
    });

    $.datetimepicker.setLocale('pt-BR');
}

Answer: Tente criar o DatePìcker assim:
$(".calendarioHora").datepicker({
    dateFormat: 'dd/mm/yy',
    dayNames: ['Domingo', 'Segunda', 'Terça', 'Quarta', 'Quinta', 'Sexta', 'Sábado', 'Domingo'],
    dayNamesMin: ['D', 'S', 'T', 'Q', 'Q', 'S', 'S', 'D'],
    dayNamesShort: ['Dom', 'Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sáb', 'Dom'],
    monthNames: ['Janeiro', 'Fevereiro', 'Março', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro', 'Outubro', 'Novembro', 'Dezembro'],
    monthNamesShort: ['Jan', 'Fev', 'Mar', 'Abr', 'Mai', 'Jun', 'Jul', 'Ago', 'Set', 'Out', 'Nov', 'Dez']
});

Comment: Note que o componente é o `DateTimePicker` e não o `DatePicker`.

DateTime Picker em português