Query node properties into lists, related node properties into list of lists, tracking hierarchy

Question: Given the following schema / data set:
(a:A1)-[ONE]->(b:B1)-[TWO]->(c:C1)
(a:A1)-[ONE]->(b:B1)-[TWO]->(c:C2)
(a:A1)-[ONE]->(b:B2)-[TWO]->(c:C3)
(a:A2)-[ONE]->(b:B3)
(a:A2)-[ONE]->(b:B4)-[TWO]->(c:C4)
(a:A2)

I'm trying to assemble a query for some a properties, a list of b properties (list of strings), and finally a list of c property lists (list of list of strings). I'm pretty close using collect() but running into an issue keeping track of which c's belong to which b's.
The query I seek would produce a single row per a (2 rows for given data set), notice that the data can be sparse, thus an empty array in the results indicating hierarchy:

"A1", ["B1", "B2"], [["C1","C2"],["C3"]]
"A2", ["B3", "B4"], [[],["C4"]]
Answer: When you aggregate using COLLECT [or any other aggregation], the other, uncollected [unaggregated] values in the row serve as the aggregation key, so only rows that share all the other values will match. For your query, you basically need to stack COLLECTs in two separate steps like so, to first get lists of c keyed by a and b, and then collect all of the bs and all of the lists of cs keyed by a, like so:
MATCH (a) - [:ONE] -> (b)
OPTIONAL MATCH (b) - [:TWO] -> (c)
WITH a, b, COLLECT(c.property) AS cs
WITH a, COLLECT(b.property) AS bs, COLLECT(cs) AS cs_per_b
RETURN a.property, bs, cs_per_b

You can replace property with whatever property you want to get from the node, and if it's not a node property, but label or other value, just replace the whole expression inside COLLECT( ). You'll also get empty lists inside cs_per_b this way if there are no cs, as desired.
Answer: Although your question states you want to list node "properties", your sample results list node labels instead.
To display the node labels, the following query should work:
MATCH (a)-[:ONE]->(b)
OPTIONAL MATCH (b)-[:TWO]->(c)
WITH a, b, COLLECT(DISTINCT LABELS(c)[0]) AS lcs
RETURN LABELS(a)[0] AS la, COLLECT(LABELS(b)[0]) AS lb, COLLECT(lcs) AS lc;

The query assumes that it is sufficient to use the ONE and TWO relationship types to distinguish between the Ax, Bx and Cx node labels, and that those nodes only have a single label. It uses an OPTIONAL MATCH for the TWO relationship since your sample results imply that it is optional.
Comment: Thanks for the answer! It was the `collect` results of  previous `collect` I needed. Tore's answer explained what I was after & how to achieve; your answer is correct as well :-)


How come the Pauli Matrices are the generators of SU(2)

Question: The special unitary group's elements fulfil the unitary condition, i.e. $aa^\dagger=1$, and have determinant 1 (special).
I have read, that the Pauli matrices generate SU(2).
Since all Pauli matrices have determinant -1, how can they generate the group, when they are not contained.
I'm referring to the common representation
$\sigma_x=\begin{pmatrix}0&1\\1&0\end{pmatrix}$
$\sigma_y=\begin{pmatrix}0&-i\\i&0\end{pmatrix}$
$\sigma_z=\begin{pmatrix}1&0\\0&-1\end{pmatrix}$
Comment: The Pauli matrices are not themselves part of $SU(2)$ (as a _Lie group_), but rather they are part of its generating _Lie algebra_, in the sense that they form a basis from which you can write down (using a map from the algebra to the group) any element of $SU(2)$.
Comment: Do you know about Lie groups and Lie algebras?
Answer: Pauli matrices are not generators of the Lie group $SU(2)$, but after multiplication by$~\mathbf i$ they are so-called infinitesimal generators. These are elements of the Lie algebra $\mathfrak{su}(2)$ of $SU(2)$, and for such elements $X$ the exponential mapping $t\mapsto\exp(tX)$ gives a one-parameter subgroup of the Lie group. In view of this relation, the determinant of the Pauli matrices is not important; what is relevant is that they are Hermitian (so after multiplication by$~\mathbf i$ they become anti-Hermitian, and the exponential mapping gives unitary matrices) and have trace zero (so that exponential mapping gives matrices of determinant$~1$).
No countable set of group elements could generate the uncountable groups $SU(2)$, but the one-parameter subgroups for the Pauli matrices do generate $SU(2)$. Maybe more pertinent is the fact that the Pauli matrices generate the real vector space of traceless Hermitian matrices. Thus every element of $SU(2)$ is the image under the exponential mapping of a real linear combination of the multiples by $~\mathbf i$ of the Pauli matrices (although the fact that $SU(2)$ is connected and compact is instrumental for this fact).


Music Theory: Frequencies related to playing a note on guitar

Question: I am studying the physics related to playing guitar. I need to understand the relationship between the fundamental frequency of a guitar string and its harmonics.
For e.g., the top string has the fundamental frequency (E2~82.4hz). When one plucks the top string the output is a mix of the fundamental frequency and its harmonics. I need to understand the relationship between the amplitude of the fundamental frequency (82.4 Hz in this case) and the amplitude of harmonics (164.8 Hz, 247.2 Hz, 329.6 Hz and so on..)
I have been reading a lot on the internet (including this forum) and most people suggest that fundamental frequency should have the highest amplitude and the amplitude should keep decreasing with increasing harmonics.
However, my experiments suggest that this might not be true. For e.g., when I play the bottom string (E2 ~ 82.4 Hz), the largest amplitude in my output (through audacity) is around 247.2 Hz (third harmonic!). Is this possible or there is some problem with my guitar instrument?
EDIT4: Thanks for the responses. I understand that some issues could be around the guitar, recording instrument, and even the recording room. However, the important question is - In case of a guitar, what is a realistic (or most probable) relationship between a fundamental and its harmonics? (assuming a normal scenario, similar to when we hear someone play). I need to come up with the most probable mathematical relationship.
The output frequency distribution for plucking E2 string is:

EDIT:
Another sample for E2 string pluck (after properly checking the tuning and ensuring no other string vibrates):

EDIT2:
Sample for E2 when the string is plucked close to the center instead of near the bridge:

EDIT3: Sample for E4 (330 Hz - top most string) has highs at second and third harmonic.

Sample for B open string (250 Hz):
Answer: When you pluck a guitar string you are always generating all of the harmonics to varying degrees.  For your E2

    N:     1  2  3   4  5   6   7   8    9   10   11     12
    Note:  E2 E3 B3  E4 G#4 B4 (D4) E5   D5  G#5  (n/a)   B5   ...

    N; ratio of harmonic's frequency to the fundamental frequency
    7th harmonic is pretty badly tuned in equal temperament, 11th is very badly so.

It would require a very special mechanical set  to only generate the fundamental.  However, any but the lower dozen or so (a) lie in the audible
range, and (b) persist long enough to affect anything other than the tone of
the note's attack to be work considering.  The question is not so much, which harmonics are generated (they all are), it's a question of what their relative amplitudes are.
Theoretically, the precise spectrum measured from a vibrating string is a complicated function of how the string was plucked in conjunction with when the sound sample was taken.  In addition you are taking measurements from a complicated wooden object through a complicated measuring device, which itself affects the spectrum of the sounds emanated.
How the string was plucked affects the degree to which different harmonics are initially excited by the attack (mathematically: the initial conditions of problem).  Plucking near the 12th fret (the midpoint of the string) should be most effective in generating the fundamental tone.  Using your finger rather than a plectrum should further help (the force is spread over a wider area -- this also reduces the initiation of higher harmonics).  Conversely, plucking with a plectrum near the bridge (or the nut!) has a different timbre, which can be explained (perhaps not fully) in terms of the fact that different harmonics get excited by different plucking positions/methods.
The other feature is that, in general, the lower order harmonics should persist longer than the higher order ones (there is a shorter time-decay constant for the higher harmonics).  At least in part, this is why the higher natural harmonics (e.g. the natural harmonics at approx. the 4th and 5th fret) sound weaker and last less long than the lower ones (e.g. the natural harmonics at the 7th and 12th frets).
These considerations are mainly based on consideration of an ideal string vibrating in isolation.  In your data, the coupling to the body of the guitar (which has its own weak resonances) may be affecting the measured signal in a way that suppresses the fundamental relative to some of the lower harmonics
(c.f. research into guitar body acoustics at the University of New South Wales).  In addition, the observed spectrum may be further modified by the acoustic features of the room in which the collection was taken, as well as the response characteristics of the microphone (and possibly other components).
As a final note, I think it's entirely possible that you may have discovered that the conventional wisdom is incorrect, at least for the lowest notes on a conventional guitar (it might be worth checking if this feature is present for higher notes);  but note that the listeners' ears will "fill in" the fundamental even if it is missing, the "Missing Fundamental Phenomenon". If I recall correctly, several of the example spectra from various music instruments in Music, Physics and Engineering (H. Olson) have this feature that the lower harmonics are slightly higher than the fundamental.  Thus the lower amplitude of the fundamental does not affect the perceived pitch of the note.
Comment: Is there any research on the relationship between fundamental frequency and harmonics: say, lower harmonics could be higher than the fundamental for smaller frequencies (due to some inherent quality of the instrument); however, for higher frequencies harmonic amplitude will decrease by a factor of xx
Answer: Resonant Frequency
Good guitars have the wooden top and body of the guitar carefully carved to resonate at a certain single frequency.
While the luthier is carving and bracing the top of the guitar, long before the guitar is assembled and the strings are put on, he repeatedly taps the top with a knuckle, as if it were a drum, and listens to the fundamental pitch it produces. He continues carving until the top resonates at a certain specific frequency.
If the top is not specifically tuned, then the guitar might end up having a certain resonant frequency that is a random artifact of its construction. I have come across more than one guitar like this.
So it may be that the body of your acoustic guitar has a strong resonant frequency of B. When you pluck a string and play a note which has B in its overtone series, that frequency is exaggerated in amplitude.
To learn more, Google these terms: "tuning the top", "tap-tuning the top" and "Helmholz resonance".
Answer: Could you provide us with the wave sample that you analyzed, so as we hear it ?
Also could you zoom the spectrum window from 150Hz to 330Hz... because at this zoom level, the curve is obviously not accurate at all, then provide us the image at this level ( from E3 to E4).
Maybe have you simply played a EM or Em chord wich contains a strong B at the fifth ;-) (just joking that's why it should be better if we had the wave sample)
What you could try also, is to put a thin parametric eq, with big resonnance, so as to cutoff only the 247Hz zone, and hear if that alter the pitch/note that you hear.
For the theory, you should look at the model of a string in physics. Because what you hear is only the result of the string vibrating. And all the resulting vibrating modes (harmonics) are related to the string length, and the mode 1, the fundamental, has the most energy, biggest amplitude (as far as I remember). Then you have modes 2, 3, 4 etc... which are waves related to the length/2, length/3, length/4 and so on... (length of the played string).
Comment: well, the sound is not pure :-) at the beginning **there is a foreign vibration**, as if the strings was buzzing when played: have you check the action of your strings that may be too low... sometimes the angle of the neck of the guitar might produce such buzz too. Then about the sound, I have been astonished, maybe there is a resonance phenomenon... but the B harmonic is **clearly huge** and I hear it well. Try to do spectrum analysis only on the second half of the sound, where the buzz is no longer, and where the B harmonic has mostly disappeared (maybe the first was the cause of the second)
Comment: Uh... what have you done to your guitar ? this time it has almost the sound of a sitar, with one sympathetic string doing the B. Maybe you play a dobro resonator or a banjo ;-), but there is definitely a resonance on B, that is HUGE. There must be a physical cause.
Comment: @Paulski73: Very valid points - and this is exactly how i understand the physics behind music from a guitar. However, the observations do not corroborate this theory. How do i put my music file here - it only allows me to put an image file?
Comment: So here's the link to the audio file: https://docs.google.com/open?id=0B34A0q7mbCBpRmRPYm5hcmI1ZDQ
Comment: You can actually hear B, wow! Can you check this another sample: https://docs.google.com/open?id=0B34A0q7mbCBpMG5oRXExYkpQWFk - the string has been plucked at the center; though, it still gives highest amplitude at ~250 Hz. In the meantime, i will do analysis for the second half of the sound.
Comment: Well I don't know what to say. I just picked one of my guitars (folk accoustic), and I don't hear that 3rd harmonic so strong. As for the 2 harmonic, it is still an E, one octave upper the fundamental, I see no problem with this. @Dave answers pointing on studies where there is perceived pitch while the fundamental is missing is really interesting. It kinds of remember the Fraunhofer MP3 algorithms that substract frequencies that the human ear will perceive all the same.
Answer: Overall, the understanding through various inputs and experiments run over music (self-generated and available on internet) is the following:

Fundamental frequency need not have the largest amplitude (human brain has the ability to fill the base frequency based on the harmonics)
2nd and 3rd harmonics (lower harmonics) tend to be higher especially for lower frequencies
The amplitude does decrease with increase in harmonics (noticeable after the third harmonic and steep decrease after the 5th), but there is no clear mathematical relationship, which came out to be true for all our experiments
Answer: Something near 250 Hz is what you expect as 3 times the fundamental.
If you draw pictures of a sinewave with no motion at the ends of the string, the 3 rd harmonic is the one with a peak in the middle at the same place as the fundamental, and also a peak (going opposite direction) at about 1/6 of the string length which is not far from the hole in the box, and also not far from where the string is normally plucked.


Under what conditions does GNU Make change the stack size, and why?

Question: Consider this makefile:
.PHONY: all

all: dummy test
    ulimit -s

include dummy

dummy: test
    touch dummy

When I run it, I get:
$ make -v
GNU Make 4.1
Built for x86_64-pc-linux-gnu
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
$ touch test; make
touch dummy
ulimit -s
unlimited

However, if I remove the include dummy or replace touch dummy with true, then ulimit -s gives 8192.  What's going on?
Answer: This is bug 48009 which was fixed in GNU make 4.2.1.


IE text wrapping issues

Question: On jensglobaltravel.com front page under "Upcoming Featured Trips". When Internet Explorer is zoomed in 125% or higher. The title text within a paragraph tag is not wrapping instead it is clipped off. The website is built using the website builder Square space. We have tried,

text-overflow
overflow
things having to do with width and flex

Everything we have tried does not work.
Any help is greatly appreciated!
Answer: This is due to the white-space: nowrap on the image-slide-title div. Removing that seems to fix the issue.
Alternatively, you can try adding white-space: normal to the paragraph element. This should reset the white-space attribute without affecting the image-slide-title class itself, assuming you plan on using that class elsewhere on the site.

IE text wrapping issues


Invalid STDGMEDIUM structure (Exception from HRESULT: 0x80040066 (DV_E_STGMEDIUM)) error

Question: I am writing a program written in C# that interfaces with a Sage Payroll database - essentially an Access database.
This uses a Sage library to connect to the database and returns error codes if any occur.  I have the program working correctly on 2 machines.  When I run it on the production machine I get the following Sage error:
Error value: 102
Error code: -2147221402
Error text: Database file locked, not valid or corrupt

I am confident that there is not a problem with the database as if I copy this to any other machine and run the program it works correctly.
The exception I get is:
Exception: Message: Invalid STDGMEDIUM structure (Exception from HRESULT: 0x80040066 (DV_E_STGMEDIUM))

I think the error is something COM/Interop related on the production machine.  I have Administrator privileges and the Sage dlls have all been registered correctly.
Can anyone shed any light on this error code?
Comment: Contact the vendor for support.
Answer: I never got to the bottom of this problem but from speaking to the vendor I think it was something connected to their library, possibly permissions or unsupported on certain OSes.


Capturar evento de logon do Linux usando Java

Question: Olá, gostaria de uma ajuda para criar uma classe que capturasse o evento de logon de um usuário no Linux, utilizando o Java.
Comment: Olá Alca, bem vindo ao Stack Overflow. Da maneira que você descreveu sua pergunta faltaram informação para elaborarmos uma resposta concreta e apropriada. O que você já tentou? O que está precisando fazer? O que você tem atualmente em termos de código? Por que não fazer o contrário (um *shell script* que notifica o Java?). Enfim, por favor amplie sua pergunta com informações relevantes.
Comment: O quê este evento deveria retornar?
Answer: No linux você pode criar um script que roda toda vez que o usuário logar. Você pode encontrar uma descrição aqui.
Depois você criar um script que executa seu programa java.
Mas puramente em java você não vai conseguir fazer isso.


Coefficient of Determination ($r^2$): I have never fully grasped the interpretation

Question: I want to fully grasp the notion of $r^2$ describing the amount of variation between variables. Every web explanation is a bit mechanical and obtuse. I want to "get" the concept, not just mechanically use the numbers.
E.g.: Hours studied vs. test score
$r$ = .8
$r^2$ = .64

So, what does this mean?
64% of the variability of test scores can be explained by hours?
How do we know that just by squaring?
Comment: your question is not about R vs R-square (you understand that $0.8^2=0.64$) it is about interpretation of $r^2$. Please reformulate the title.
Comment: a similar question: http://stats.stackexchange.com/questions/28139/why-squaring-r-gives-explained-variance?rq=1
Comment: @amoeba agreed, I pulled the tag.
Comment: You need $n$ to determine the significance. Also see, http://stats.stackexchange.com/a/265924/99274.
Answer: Start with the basic idea of variation.  Your beginning model is the sum of the squared deviations from the mean.  The R^2 value is the proportion of that variation that is accounted for by using an alternative model.  For example, R-squared tells you how much of the variation in Y you can get rid of by summing up the squared distances from a regression line, rather than the mean.
I think this is made perfectly clear if we think about the simple regression problem plotted out.  Consider a typical scatterplot where you have a predictor X along the horizontal axis and a response Y along the vertical axis.
The mean is a horizontal line on the plot where Y is constant.  The total variation in Y is the sum of squared differences between the mean of Y and each individual data point.  It's the distance between the mean line and every individual point squared and added up.
You can also calculate another measure of variability after you have the regression line from the model.  This is the difference between each Y point and the regression line.  Rather than each (Y - the mean) squared we get (Y - the point on the regression line) squared.
If the regression line is anything but horizontal, we're going to get less total distance when we use this fitted regression line rather than the mean--that is there is less unexplained variation.  The ratio between the extra variation explained and the original variation is your R^2.  It's the proportion of the original variation in your response that is explained by fitting that regression line.

Here is some R code for a graph with the mean, the regression line, and segments from the regression line to each point to help visualize:
<code>library(ggplot2)
data(faithful)

plotdata <- aggregate( eruptions ~ waiting , data = faithful, FUN = mean)

linefit1 <- lm(eruptions ~ waiting, data = plotdata)

plotdata$expected <- predict(linefit1)
plotdata$sign <- residuals(linefit1) > 0

p <- ggplot(plotdata, aes(y=eruptions, x=waiting, xend=waiting, yend=expected) )

p  + geom_point(shape = 1, size = 3) +
     geom_smooth(method=lm, se=FALSE) +
     geom_segment(aes(y=eruptions, x=waiting, xend=waiting, yend=expected, colour = sign),
                  data = plotdata) +
     theme(legend.position="none")  +
     geom_hline(yintercept = mean(plotdata$eruptions), size = 1)
</code>
Comment: R^2 = 1-(SSR/SST) or (SST-SSR)/SST. So, in your examples, R^2=.80 and 1.00. The difference between the regression line and each point is that left UNexplained by the fit. The rest is the proportion explained. Otherwise, that's exactly right.
Comment: > The ratio between the variation explained and the original variation is your R^2

Let's see if I got this.

If the original variation from mean totals 100, and the regression variation totals 20, then the ratio = 20/100 = .2   You're saying R^2 = .2 b/c 20% of the mean variation (red) is accounted for by the explained variation (green)

(In the case of r=1) If the original variation totals 50, and the regression variation totals 0, then the ratio = 0/50 = 0 = 0% of the variation from the mean (red) is accounted for by the explained variation (green)  I'd expect R^2 to be 1, not 0.
Comment: I edited that last paragraph to try to make it a bit clearer. Conceptually (and computationally) all you need is there. It might be clearer to actually add the formula and refer to the SST SSE and SSR, but then I was trying to get at it conceptually
Comment: ie: R^2 is the proportion of the total variation from mean (SST) that is the difference b/w the expected regression value and mean value (SSE).  In my example of hours vs. score, the regression value would be the expected test score based on correlation with hours studied.  Any additional variation from that is attributed to SSR.  For a given point, hours studied variable/regression explained x% of the total variation from the mean (SST).  With a high r-value, "explained" is big percentage of SST compared to SSR.  With a low r-value, "explained" is a lower percentage of SST compared to SSR.
Comment: @BrettMagill, I think the link to the image is broken...
Comment: It seems that ImageShack has deleted your image and [replaced it with an ad banner.](http://meta.stackexchange.com/q/263771) If you still have the original image, or can recreate it, please reupload it using the image upload button in the editor toolbar.
Answer: A mathematical demonstration of the relationship between the two is here: Pearson's correlation and least squares regression analysis.
I am not sure if there is a geometric or any other intuition that can be offered apart from the math but if I can think of one I will update this answer.
Update: Geometric Intuition
Here is a geometric intuition I came up with. Suppose that you have two variables $x$ and $y$ which are mean centered. (Assuming mean centered lets us ignore the intercept which simplifies the geometrical intuition a bit.) Let us first consider the geometry of linear regression. In linear regression, we model $y$ as follows:
$y = x\  \beta + \epsilon$.
Consider the situation when we have two observations from the above data generating process given by the pairs ($y_1,y_2$) and ($x_1,x_2$). We can view them as vectors in two-dimensional space as shown in the figure below:
alt text http://a.imageshack.us/img202/669/linearregression1.png
Thus, in terms of the above geometry, our goal is to find a $\beta$ such that the vector $x\ \beta$ is the closest possible to the vector $y$. Note that different choices of $\beta$ scale $x$ appropriately. Let $\hat{\beta}$ be the value of $\beta$ that is our best possible approximation of $y$ and denote $\hat{y} = x\ \hat{\beta}$. Thus,
$y = \hat{y} + \hat{\epsilon}$
From a geometrical perspective we have three vectors. $y$, $\hat{y}$ and $\hat{\epsilon}$. A little thought suggests that we must choose $\hat{\beta}$ such that three vectors look like the one below:
alt text http://a.imageshack.us/img19/9524/intuitionlinearregressi.png
In other words, we need to choose $\beta$ such that the angle between $x\ \beta$ and $\hat{\epsilon}$ is 900.
So, how much variation in $y$ have we explained with this projection of $y$ onto the vector $x$. Since the data is mean centered the variance in $y$ is equals ($y_1^2+y_2^2$) which is the square of the distance between the point represented by the point $y$ and the origin. The variation in $\hat{y}$ is similarly the distance from the point $\hat{y}$ and the origin and so on.
By the Pythagorean theorem, we have:
$y^2 = \hat{y}^2 + \hat{\epsilon}^2$
Therefore, the proportion of the variance explained by $x$ is $\frac{\hat{y}^2}{y^2}$. Notice also that $cos(\theta) = \frac{\hat{y}}{y}$.  and the wiki tells us that the geometrical interpretation of correlation is that correlation equals the cosine of the angle between the mean-centered vectors.
Therefore, we have the required relationship:
(Correlation)2 = Proportion of variation in $y$ explained by $x$.
Hope that helps.
Comment: I do appreciate your attempt at helping, but unfortunately, this just made things 10x worse.  Are you really introducing trigonometry to explain r^2?  You're way too smart to be a good teacher!
Comment: I thought that you wanted to know why correlation^2 = R^2. In any case, different ways of understanding the same concept helps or at least that is my perspective.
Answer: The Regression By Eye applet could be of use if you're trying to develop some intuition.
It lets you generate data then guess a value for R, which you can then compare with the actual value.


Maximum of Independent Gamma random variables?

Question: Suppose $Y=\max\{X_1, X_2,\dots,X_N\}$ where all $X_i$ are independent and  follows gamma distribution. I know that extreme value theory deals with maximum of random variables. Can anybody tell me, hopefully with reference, $Y$ will follow which extreme value distribution (Gumbel, Weibull or Frechet) ?
Comment: @wolfies That's what the theory has found.
Comment: @AlecosPapadopoulos Quite the opposite, the question mentions nothing about asymptotic behaviour ... and none of the 3 posited distributions are a valid answer to the question posed.
Comment: [This](http://math.stackexchange.com/questions/847595/problem-with-the-expectation-of-a-maximum-of-independent-gamma-distributed-rando) may be helpful.
Comment: Why are we limited to 3 choices?
Comment: It seems you are looking for the **limit** law (as $N \to \infty$).  Perhaps better to mention that in the question.
Comment: @wolfies Indeed, it doesn't, but it created (to me) that impression, exactly because he referred to the three possible asymptotic distributions. So the OP should clarify the point.
Comment: @upol94 As wolfies points out, the correct answer to the question you have posed is "none of the above". If you're seeking asymptotic results you need to make that clear in your question.
Answer: The gamma distribution is in the Gumbel domain of attraction.  You can
refer to the book by L. de Haan and A Ferreira, Extreme Values Theory,
an Introduction.
See therein theorem 1.1.8 and exercise 1.7 for its application to the
gamma distribution. Another very useful book even provides explicit
values for the two sequences required in the normalisation:
P. Embrechts, C. Klüppelberg and T. Mikosch Modelling Extremal Events
for Inusurance and Finance; This is in section 3.4,
p. 156 in my edition.
Answer: Taken from
David, H. A., & Nagaraja, H. N. (2003). Order statistics 3d ed., ch 10. p 296

The "two references that give the most complete and rigorous discussion of the problem" are
Comment: This answer reads like your justification for saying Frechet is that it has non-negative support.  But the extreme value limit laws are **after** normalisation.  E.g. for the maximum of Exponential random variables (which are non-negative), the limit is Gumbel.
Comment: More precisely, if $X_1, \ldots$ are i.i.d Exp($\lambda$), then you can show (bare hands) that $$\mathbb{P}( \lambda \cdot \max_{i = 1,\ldots,n} X_i \le \ln(n) + x) \to e^{-e^{-x}}$$, and Theorem 10.5.1 applies with $a_n =1/\lambda$, $b_n = \ln(n)/\lambda$.  (Just to clarify-- I have no idea which class the Gamma limits belong to, but it is not as simple as looking at the supports).
Comment: @P.Windridge  Thanks, that's a standard source of confusion (for me that is). I deleted the reference to Frechet while I am digging this.
Comment: Cool, I'll be interested in the answer.  I suspect it is Gumbel, just because the Gamma and Exponential distributions are so closely related... but that's only speculation :)
Comment: @P.Windridge, Thanks, I am also confused on the same point. Is gamma also follow Gumbel distribution ?
Comment: @upol94 the exponential distribution is a special case of the gamma.  So, for some parameters, the limit class is certainly Gumbel... but off the top of my head I don't know whether this holds generally.
Comment: The question does not ask about the asymptotic distribution of $Y$ ... it seeks the distribution of $Y$.
Comment: That's a pretty extensive quote ... and not readable by anyone using a screen reader (as a few of our sight-impaired users do). Could you consider whether you can take a few parts - whatever you need most - and write them as actual quotes rather than screenshots? \[You might be able to make reference to one of these wikipedia articles [(1)](https://en.wikipedia.org/wiki/Fisher%E2%80%93Tippett%E2%80%93Gnedenko_theorem), [(2)](https://en.wikipedia.org/wiki/Extreme_value_theory), [(3)](https://en.wikipedia.org/wiki/Generalized_extreme_value_distribution) for part of it, perhaps.]


Circular definition in React's render method when using react-router

Question: What is props.children in React?
What defines these children?
Are they defined in a component's render method? I assume yes.
Are children always rendered? If yes, then why do I need to manually put {this.props.children} into the render method when using react-router? How does that make any sense ?
This is what I mean :
// modules/App.js
// ...
  render() {
    return (

React Router Tutorial

<Link to="/about">About</Link>

<Link to="/repos">Repos</Link>

        {/* add this */}
        {this.props.children}

    )
  }
// ...

Taken from this tutorial.
How does this not blow up due to circular definition?
Render method defines what is in props.children but render method itself contains props.children .
Why is this not a problem ?
Why is it needed to make this circular definition in the first place ?
I am confused.
EDIT:
index.js:
import React from 'react'
import { render } from 'react-dom'
import App from './modules/App'
import { Router, Route, hashHistory } from 'react-router'

// insert into index.js
import About from './modules/About'
import Repos from './modules/Repos'

// index.js
// ...
render((
    <Router history={hashHistory}>
        <Route path="/" component={App}>
            {/* make them children of `App` */}
            <Route path="/repos" component={Repos}/>
            <Route path="/about" component={About}/>

        </Route>

    </Router>
), document.getElementById('app'))

Answer: The clue to this answer is that children lives under the props of the component. Basically, this.props.children is nothing more than a property of the component. Granted it is a somewhat special prop and an opaque data structure, but it is a prop nonetheless.
What this means is that render does not define what this.props.children is. Like any other prop, children is passed down from a parent component to a child. There is nothing fantastically special about this.props.children except it acts as a handy, built-in way to pass arbitrary inner elements from parent to child.
Passing children to a component like this:
<MyComponent>

Hello

World

</MyComponent>

Is not so different than doing it like this (and in fact you CAN do it like this, but it would be silly to do so because you end up bypassing some important React housekeeping):
<MyComponent children={[
Hello
,
World
]} />

So, there is no circular logic here. Components receive their children from their direct parent as a prop. The only thing that render does is define how a component is rendered. render is the presentational part of the component and is intentionally disconnected from the data model. If you did not put {this.props.children} into the render method, then the children simply wouldn't be displayed.
Since children are much like any other component prop, and they are represented as an array, you can do convenient stuff like using Array.map to modify or wrap each child in some way:
render() {

{this.props.children.map(function(ea){return {ea}})}

}

I hope that clears it up for you.
Comment: @jhegedus Yes. `this.props.children` is just data... it has no intrinsic value to the component that receives it and you can think of it just like any other `prop` that is passed from parent to child.
Comment: Many thanks for the detailed answer JCD ! I think this cleared up a lot of confusion in my mind.
Comment: So basically `children` are only rendered if they are explicitly referred to in the render function ? If not then the value of children does not at all affect what appears on the screen ?


Get the number of nodes in a variable-length relationship

Question: Let's say I'm searching a books database with :CATEGORYs and :BOOKs.
I'm trying to find similar books to a current one written by a certain author. :BOOKs have :similar relationships to other books (the direction of the relationship is not relevant), and I would like to look for up to 3 similar chains. Here's my query:
MATCH (currentBook:BOOK {ISBN: {ISBN}})-[:similar*1..3]-(newBook:BOOK {author: {currentAuthor}})
RETURN newBook

Here's the problem:
I need to find out how many similar relationships where used.
And by that, I mean how much the *1..3 actually meant for a specific book. So something like this:
MATCH (currentBook:BOOK {ISBN: {ISBN}})-[sim:similar*1..3]-(newBook:BOOK {author: {currentAuthor}})
SET newBook.simsUsed = AMOUNT_EXPANDED(sim)
RETURN newBook

Here's a (fake) sample of my dataset.
Answer: SIZE(sim) is probably what you are looking for.
For example, this query will return the length of each path:
MATCH (currentBook:BOOK {ISBN: "978-0446310789"})-[sim:similar*1..3]-(newBook:BOOK {author: "fake"})
RETURN currentBook, newBook, SIZE(sim) AS lth;

You should NOT be setting newBook.simsUsed to that value, though, since the path length to any book depends on which book you started from, and the path length (starting from any particular book) might change over time. In general, you should avoid storing redundant data.


Interpreting categorical variable if reference class includes several levels

Question: I have a dataset with several categorical variables. I have been running some regressions and used dummy coding for these categorical variables. The problem is that some specifications lead to perfect collinearity between a few vars when including all (but one) levels of a categorical variable of interest. Thus I need to omit two levels instead of one.
For instance, suppose variable $x_1$ is categorical and has four levels. Including the first three levels as dummies leads to perfect collinearity between the third level and variable $x_2$. Thus, the third level of $x_1$ is dropped for modeling purposes. Then variable $x_1$ has two instead of one reference levels.
This leads to statistically significant results, but I am not sure it is correct to do this at all. If so, is there any proper way to interpret the results?
Comment: Welcome. You may not have a problem at all. What do these variables represent? Do you have any output to share?
Answer: If a variable or one of its levels is perfectly contained in another one you are right to exclude it from the model. Proceed! The only problem you'll have is that you won't be able to tell if the variation in the dependent variable comes from variable x1 or x2 when they assume the collinear level. Try reading about instrumental variables or understand if there is a causal relationship between x1 and x2.


How to trim String in Java

Question: I have a string:
Am trying to do the below :
int i =0;

for(String s : appFields){
    i++;
    String divid = "chart_"+i;
    divid = divid.replaceAll("[\\r\\n]+$", "");
}

I would like to trim it so that the value is only chart_1 and so on.
Can someone help me please?
<%
    String[] appFields = "Account Information,Action Status,Activity Name,Activity Status,Last Activity Timestamp,Geographical Region,Enterprise Status,Business Process,Numer of Pages,Message Direction".split(",");

    int i =0;

    for(String s : appFields){
        i++;
        String divid = "chart_"+i;
        divid = divid.replaceAll("[\\r\\n]+$", "");
%>

    <% out.println(i); %>
    <% out.println(s); %>

<svg id="<% out.println(divid); %>" class="sparkline"></svg>

<%
    }
%>

This is the output i get in Chrome Web Inspector

<svg id="chart_1
" class="sparkline"></svg>

Comment: @Bosko Are you sure the edit of putting the `"` on the same line was valid?
Comment: @user3176143 Then show a short program demonstrating the problem.
Comment: @user3176143 Likely you are using it as `temp.trim()`, which will not modify the current string as Strings are immutable. Try with `temp = temp.trim()` and it will work.
Comment: @MathiasMuller you edited away the issue the op was talking about...
Comment: I don't know what you mean with `trim` but the string `"strngval"` cannot be trimmed anymore because it has no leading or trailing whitespaces.
Comment: the new version of the question makes no sense: 's' is never referenced, and you create a string without crud at the end, then ask how to remove the crud at the end? The original question seemed to be asking how to remove trailing whitespace, including a newline, to which .trim() is the right answer.
Comment: I'm voting to close. After all of this you still haven't told us what you are expecting and what you are getting.
Comment: That's not a valid `String` literal if it appears on multiple lines.
Comment: there's a trim fnc yes?
Comment: @ZouZou Trim doesnt work!
Comment: int i =0;

                         for(String s : appFields){
                           i++;
                           String divid = "chart_"+i;
                           divid = divid.replaceAll("[\\r\\n]+$", "");
}

Am getting string in the above format while i try to do the above.
Comment: There isn't any space there?
Comment: I don't think I did that. Look at the edit history first.
Comment: @user3176143 Can you [edit] your short example into the question? It's difficult to read in the comment because formatting is lost.
Comment: @MathiasMüller I did that before commenting.
Comment: The original questions was about another string: http://stackoverflow.com/revisions/21189535/4
Can somebody restore this?
Comment: @assylias: No, look again. The post was edited many times before I did.
Comment: @thegrinner edited the question. do you get my problem now ?
Comment: @user3176143 To clarify: [edit] the question so the original case remains and just use your second example to expand on it.
Comment: Your example doesn't show any need for trimming. What do **you** mean by trimming?
Comment: Please run the code in any of your local machines and then give your solution. trim() doesnt work
Comment: @user3176143 _"trim() doesnt work"_ Show your attempt using `trim()` with an example of input/output.
Comment: Since your string only contains `chart_` and a number, there is no spaces to remove.  trim() shouldn't be needed.
Comment: @ZouZou I wouldneed a reputation of 10 to post images. this doesnt allow
Comment: Why do you need an image? Just post it with text. It's a `String` after all.
Comment: @user3176143 Why post images? Post your actual code as text.
Comment: I have posted the actual code.. Can anybody please help now
Comment: Answers anybody ? Please run it in your machine and answer
Comment: Now when i posted the actual code and output why is anybody not replying ?
Answer: temp = temp.trim();

Strings are immutable so operations return new Strings that you have to assign back to the original reference variable.
Comment: I edited the question sir. Can you please help me with the issue am facing.
Comment: This answer is no longer relevant.
Answer: Change your line to
<svg id="<%out.print(divid);%> " class="sparkline"></svg>

In other words, use print instead of println. println adds a new line after your String.
Comment: @ShabeerMothi Because we got tired of not getting relevant information from you. You should always try to provide as much relevant information as possible.
Comment: Wonderful! Worked. Thanks a ton!
Comment: @ShabeerMothi Note that it makes no different in a browser. The browser typically trims any whitespace anyway.
Comment: Sure. but am just wondering why people marked my question as irrelevant and voted it one down!

How to trim String in Java


ScrollLeft doesn't run

Question: I have seen this example: http://jsfiddle.net/UwEe2/306/ that is implemented with scrollleft.
Now I have done a modification.
This is my script but is doesn't run: http://jsfiddle.net/njKXB/39/
What is the problem?
Comment: I know exactly _why_ it's not scrolling left/right but cannot give you a good solution because you have not explained what you're trying to do.  Why would you want a bunch of `li` items (without a `ul`) side by side each only containing a number "1"?  Weird.
Comment: Sorry, its is that I want to do, a list of links in same line with scroll. http://jsfiddle.net/njKXB/63/
Answer: I have no idea what you're trying to achieve by putting a list of 1's inside li elements without the required ul container.
Simply replacing the text with the img element in your code demonstrates that it's functional.
http://jsfiddle.net/njKXB/54/
The reason you can't scroll your list of 1's left/right is because it's wrapping.  If you increase the height, you can see it wrapping below.  Since it's wrapping down, there is nothing there to scroll side to side.
http://jsfiddle.net/njKXB/55/
The solution is to remove the float on the li's and add display:inline; which causes them all to stay in one line.  Then add white-space: nowrap; to the container to prevent wrapping.
http://jsfiddle.net/njKXB/75/
Answer: Your scroll amount was too small for you to notice the movement.
Also, you can animate to +=10px and jQuery will automatically add that value to the current value.
var scroll = 100;
var speed = 200;

$('#left').click(function() {
    $('#container').animate({
        'scrollLeft': '-=' + scroll
    }, speed);
});

$('#right').click(function() {
    $('#container').animate({
        'scrollLeft': '+=' + scroll
    }, speed);
});

$('#up').click(function() {
    $('#container').animate({
        'scrollTop': '-=' + scroll
    }, speed);
});

$('#down').click(function() {
    $('#container').animate({
        'scrollTop': '+=' + scroll
    }, speed);
});

Also, don't close the  tag with a closing tag.  tags are self-closing:

Demo: http://jsfiddle.net/UwEe2/311/
Comment: Sorry but in my example don't runs. This is my example. http://jsfiddle.net/njKXB/39/
Comment: My example that the content is a li not runs. My browser is chrome. I'm talking with this example. http://jsfiddle.net/njKXB/39/
Comment: @ sparky672 Yes I put float, because I want that it has in horizontal. Thanks

ScrollLeft doesn't run


Dependent increments?

Question: Let us assume that $X_1,..., X_n$ are i.i.d exponential random variables with $\lambda$ each. Define $M = \max\{X_1,..., X_n\}$. If I'm interested in $\mathbb{E}M$, then I can divide $M$ into (independent?) incerements, namely
$$
M = X_{(1)}^{(n)}+ X_{(1)}^{(n-1)} + ... + X_{(1)}^{(1)},
$$
where $X_{(1)}^{(n)}$ is $\min \{X_1,.., X_n\}$ and $X_{(1)}^{(n-1)}$ is the minimum of the rest $n-1$ random variables and so on. Due to the lack of memory property each $X_{(1)}^{(k)} \sim \mathcal{E}xp (k\lambda)$. Hence,
$$
\mathbb{E}M = \sum_{k=1}^n\frac{1}{k\lambda},
$$
and
$$
\mathbb{V}(M)=\sum_{k=1}^n\frac{1}{k^2\lambda^2},
$$
that means where $n \to \infty$ the variance converges to $(\pi/\lambda)^2/6$ but the expectation diverge. That is nonsense. What am I missing? Are those increments dependent and then I have to account for the co-variance that will "explode"?
Thank you.
Comment: How is the maximum of a set of $n$ random variables equal to the sum of the minima of those sets of random variables?
Comment: How is $$\max\{X_1,\ldots,X_n\} = \sum_{k=1}^n\min\{X_1,\ldots,X_k\}$$?
Comment: If you take two exponential r.vs that designate some waiting time and you are interested in the expectation of their maximum, then why it is not the same as the expected time until the "first" event plus the expected time between the first and the "second" event?
Comment: I've ran some simulations, and the variance indeed converge to the aforementioned constant, where the expectation indeed slowly grows with $n$
Answer: You can think of the independent exponentials as wait times to the first click of $n$ independent Poisson processes. The maximum is the total time till the last one clicks.
Say the first $n-1$ have clicked. Then by memorylessness, the remaining time till the final click is exponential and independent of everything else. If the first $n-2$ have clicked, then the remaining time till the $n-1$-st one clicks is the minimum of two exponentials, independent of everything else. So continuing backward inductively, the time till the final click is a sum of $n$ independent variables, where the first is distributed like the minimum of $n$ exponentials, the second is distributed like the minimum of $n-1$ exponentials, and so on.
EDIT
I realize I forgot to answer your whole question. Hopefully it's clear from above that you can use independence in the way you wanted to and that your expressions are correct. There is no contradiction that the expectation diverges as $n\to\infty$ while the variance goes to a constant. Imagine you had $X_n,$ a sequence of normal random variables where $X_n$ has mean $n$ and variance one. The mean diverges while the variance converges. There is absolutely no problem with this.
I think you're confusing it with a case where a single random variable has infinite expectation but finite variance which would indeed be impossible. But here each of the random variables $M_n = \max(X_1,\ldots, X_n)$ has a finite expectation and a finite variance. It's just that as the sequence goes on the means get bigger and bigger while the variances don't.
Comment: OK. Thank you, So what would be the limiting distribution of $M_n$?
Comment: @V.Vancak $M_n-\log(n)$ converges in distribution to a Gumbel. (A Gumbel has CDF $e^{-e^{-x}}$).

Dependent increments?


Showing this sum is $\sim n^{3-\alpha}$.

Question: I want to show that
$$\sum_{i=1}^n i^{2-\alpha} \sim c n^{3-\alpha}$$
for some constant $c$. Here, $\alpha$ is assumed $0 < \alpha < 1$.
I know that
$$\sum_{i=1}^n i^2 \sim c n^3$$
for some constant $c$. So it certainly seems "obvious", but how do I show this?
For starters, we have
$$\sum_{i=1}^n i^{2-\alpha} \geq n^{-\alpha} \sum_{i=1}^n i^2 \sim c n^{3-\alpha}$$
which gives one direction. How can I show the other?
Answer: Approximate the sum by the integral $\int_0^n x^{2-\alpha}\,dx$.
Let $S_n$ denote this sum, and $I_n$ the integral. Then
$I_n\le S_n\le I_{n+1}$. But $I_n= cn^{3-\alpha}$ where $c=1/(3-\alpha)$
and the asymptotic swiftly follows.
Answer: Beside Lord Shark the Unknown's simple and good solution, you could also consider that
$$\sum_{i=1}^n i^{2-\alpha}= H_n^{(\alpha -2)}$$ where appear generalized harmonic numbers.
Now, using asymptotics
$$H_n^{(\alpha -2)}=n^{2-\alpha } \left(\frac{n}{3-\alpha }+\frac{1}{2}+\frac{2-\alpha}{12n}+O\left(\frac{1}{n^3}\right)\right)+\zeta (\alpha -2)$$


Load new files only from FTP to BLOB Azure data factory

Question: I am trying to copy files from an FTP to Blob , the probleme is that my pipeline copies all files including the old ones. I would like to do an incremental load by only copying new files. how do U configure this. BTW in my FTP dataset the parameters ModifiedStartDate and ModifiedEndDate are not showing. I would also like to configure theses dates dynamically
Thank you!
Answer: There's some work to be done in Azure Data Factory to get this to work. What you're trying to do, if I understand correctly, is to Incrementally Load New Files in Azure Data Factory. You can do so by looking up the latest modified date in the destination folder.
In short (see the above linked article for more information):

Use Get Metadata activity to make a list of all files in the Destination folder
Use For Each activity to iterate this list and compare the modified date with the value stored in a variable
If the value is greater than that of the variable, update the variable with that new value
Use the variable in the Copy Activity's Filter by Last Modified field to filter out all files that have already been copied
Comment: Hello, thanks for your response. This solution is not possible for me because my source data is an FTP and there is no field for filtering by Last Modified


C: Passing argument into Program to convert characters into ASCII values

Question: I am writing a program that takes a command line argument and user input, and calculates the difference between the two characters (cryptography). I would like to pass my argument into a variable within the program, but am unable to do so.
#include <stdio.h>

int main(int argc, char** argv) {

char plain[2];
char cipher[2];   /*locations of plain and cipher text*/

char *ppoint; /*pointers to plain and cipher*/
char *cpoint;

scanf("%s",plain);
*ppoint=plain[0];     /* ppoint points to 1st character in plain*/

cipher=argv[1];  /* cpoint points to first argument character*/
*cpoint=cipher[1];

printf("%s %d \n",ppoint,plain);
printf("%s %d \n",cpoint,cipher);

return 0;

}

For line 14, I am met with a compiler error ,
(cipher=argv[1];) " Incompatible types in assignment "
I have been experimenting with many methods such as type casting but I can not get anything to work.
I would like the two last lines of my program to output the actual character and their respective ASCII values. Please help me past this block!
UPDATE:
#include <stdio.h>
#include <string.h>

int main(int argc, char** argv) {

char plain;
char *cipher;   /*locations of plain and cipher text*/

int *ppoint; /*pointers to plain and cipher*/
int *cpoint;

scanf("%s",plain);
*ppoint=(int) plain;     /* ppoint points to 1st character in plain*/

cipher=argv[1];  /* cpoint points to first argument character*/
*cpoint=(int) cipher;

printf("%s %d \n",plain);
printf("%s %d \n",cipher);

return 0;

    }

I used type casting to fix any compiler errors. However upon running the program and in putting a value for 'plain', I am met with a segmentation fault. I have looked long and hard but cannot see where this memory error is occurring. Please help.
Answer: You are attempting to assign a char pointer to a char array, which is not allowed.  You'll need to copy the argument some other way.  For example, you could use strcpy:
strcpy(cipher,argv[1]);

Alternatively, you could make cipher be a char pointer instead if you never modify it.
const char *cipher;

...

cipher = argv[1];

Answer: try using,
ppoint=(int) plain;     /* ppoint points to 1st character in plain*/

Without the '*', as you cannot use the de-referencing operator on the pointer variable as the pointer doesn't point to any location yet.


Postfix, sender_bcc - send copy on multiple adress

Question: I have sender_bcc_maps = pcre:/etc/postfix/conf/sender_bcc in my postfix
in this file I have rules such as
/email@example.com/       firstname.lastname@example.com

Now i need to send blind copy to more than one email.
I tried use whitespace and comma as delimeter, but it did not work.
What is the solution here? Thank you.
EDIT:
The solution is (thx dynax60) to send copy to alias in sender_bcc_maps file.
And then set this alias with desired addresses.
Answer:
in /etc/postfix/main.cf:

sender_bcc_maps = pcre:/etc/postfix/sender_bcc

in /etc/postfix/sender_bcc:

/firstname.lastname@example.com/       email@example.com

in $virtual_alias_maps:

email@example.com email@example.com, email@example.com, firstname.lastname@example.com
Answer: Try this in main.cf:
sender_bcc_maps = hash:/usr/local/etc/postfix/bcc

Content of bcc file is:
firstname.lastname@example.com email@example.com
email@example.com email@example.com
firstname.lastname@example.com email@example.com

Don't forget postmap bcc under /usr/local/etc/postfix/.
Comment: Thanks, but this seems to not solve my problem. I need something like
`email@example.com firstname.lastname@example.com, email@example.com`
Comment: why don't you use alias for this way? bigbro@ could be an alias to target users :)
Comment: Clever.I did not realize that i can do that. I will try it.


Algebra of dimensions of Subspaces.

Question: $\newcommand{\span}{\operatorname{span}}$Prove that the following is true for any subspaces $V, W$ of $\mathbb{F}_n$:
$$\dim(V + W) = \dim(V) + \dim(W) - \dim(V\cap W).$$
My attempt:
Let $V, W$ and $Z$ in $\mathbb{F}_n$ be given.
If $V\cap W=\{\mathcal{O}\},$ we have that $V\bigoplus W=V+W.$ Remark that $\dim(V\cap W)=\dim({\mathcal{O}})=0$ Thus, it follows that
$\dim(V + W) = \dim(V) + \dim(W)= \dim(V) + \dim(W)- \dim(V\cap W)$.
If $V\cap W\neq\{\mathcal{O}\},$ let $\mathcal{B}$ be a basis for $V \cap W$. Enlarge $\mathcal{B}$ to a basis $\mathcal{C}$ of $V$, and enlarge $\mathcal{B}$ to a basis $\mathcal{D}$ of $W$.
It suffices to show that $C \cup D$ is a basis of $V + W.$ Now, $V+W$ is the smallest subspace that contain both $V$ and $W.$ And $\span(\mathcal{C}\cup\mathcal{D})=\span(C)+\span(D)$ is also the samllest subspace that contain both $V$ and $W,$ consequently, $\span(\mathcal{C}\cup\mathcal{D})=V + W.$ We are left to show that $\mathcal{C}\cup\mathcal{D}$ is lineraly independent. Note that $\mathcal{C}\cup\mathcal{D}=\{c_1,c_2,\cdots, c_e, d_1, d_2, \cdots , d_f, u_1,u_2,\cdots, u_g\}$ for some $e,f,g\in \mathbb{R}$ where $c_i\in \mathcal{C}\cap \mathcal{D}^C, d_j\in \mathcal{D}\cap \mathcal{C}^C,$ and $u_j\in \mathcal{C}\cap \mathcal{D}.$ We wish to show that
$=\alpha_1 c_1 + \cdots +\alpha_{e+1} d_1+ \cdots +\alpha_{e+f+1} u_1 + \cdots = \mathcal{O}
$
only holds when $\alpha_i=0.$
End.
How should I proceed to show that the vectors are independent. It is intuitively true but I just cannot get it.
I appreciate any help.
Answer: You covered the case $V \cap W = \{0\}$.
Hint: For a different approach in case $V \cap W \neq \{0\}$.
$$A : V \times W \to V + W$$ where $A (v,w) = v + w$ for $v \in V$ and $ w \in W$ is surjective. And its kernel is given by $$\ker (A) = \{ (u,-u); u \in V \cap W\}$$
Notice that the correspondence $u \mapsto (u,-u)$ is an isomorphism between $V \cap W$ and $\ker (A)$.
Now use the Rank-Nullity Theorem.
Comment: Feel free to ask if you have any questions.

Algebra of dimensions of Subspaces.


How can I calculate closed form of a sum?

Question: As we know the closed form of
$$
{1 \over k} {n \choose k - 1}
\sum_{j = 0}^{n + 1 - k}\left(-1\right)^{\, j}
{n + 1 - k \choose j}B_{j} =
\bbox[10px,border:2px solid #00A000]{{n! \over k!}\,
\left[\, z^{n + 1 - k}\,\,\,\right]
{z \exp\left(z\right) \over 1 - \exp\left(-z\right)}}
$$
where $B_{n}$ the Bernoulli sequence defined by the exponential generating function
$$
{x \over \mathrm{e}^{x} - 1} = \sum_{n = 0}^{\infty}{B_{n} \over n!}\,x^{n}
$$
The problem is here !. How can I get to this closed form ?.
Comment: what is $z$ in your expression?
Comment: Actually I do'nt know . Please see this http://math.stackexchange.com/questions/2000843/an-identity-for-bernoulli-numbers/2001237#2001237
Comment: I'm pretty sure it's a typo.
Answer:
We obtain
\begin{align*}
\frac{ze^z}{1-e^{-z}}&=\frac{-z}{e^{-z}-1}\cdot e^z\\
&=\left(\sum_{j=0}^\infty\frac{B_j}{j!}(-z)^j\right)\left(\sum_{k=0}^\infty\frac{z^k}{k!}\right)\tag{1}\\
&=\sum_{n=0}^\infty \left(\sum_{{j+k=n}\atop{j,k\geq 0}}\frac{B_j}{j!}(-1)^j\frac{1}{k!}\right)z^n\\
&=\sum_{n=0}^\infty \left(\sum_{j=0}^n\binom{n}{j}B_j(-1)^j\right)\frac{z^n}{n!}\tag{2}\\
\end{align*}
Comment:

In (1) we expand the exponential generating function $\frac{z}{e^z-1}$  of the Bernoulli numbers and substitute $z\rightarrow -z$.

We use the coefficient of operator $[z^n]$ to denote the coefficient of $z^n$ in a series.

We obtain from (2)
  \begin{align*}
\frac{n!}{k!}[z^{n+1-k}]\frac{ze^z}{1-e^{-z}}
&=\frac{n!}{k!}\sum_{j=0}^{n+k-1}\binom{n+1-k}{j}B_j(-1)^j\frac{1}{(n-k+1)!}\tag{3}\\
&=\frac{n!}{k!(n-(k-1))!}\sum_{j=0}^{n+1-k}\binom{n+1-k}{j}B_j(-1)^j\\
&=\frac{1}{k}\binom{n}{k-1}\sum_{j=0}^{n+1-k}\binom{n+1-k}{j}B_j(-1)^j\\
\end{align*}
  and the claim follows.
Comment:

In (3) we select the coefficient of $z^{n+1-k}$ from (2).

Note:  Usually we don't call the RHS of the summation formula a closed form but instead the coefficient of its generating function.


Confusion about major and minor second intervals

Question: Why is a major second interval different from a minor second interval considering that in the natural scales formulae they are both one whole step?
Comment: Be careful about loose usage of the term "whole step".  In music, a semitone is called a "half step", twice that is a "whole step".  (In British English we say "semitone" and "tone".)  A scale starting on C may have D as the next note.  Or Db.  A "whole step" or a "half step".  Either way, it's the second note of the scale!
Comment: The distance between the first and second tone of a minor scale is a major second...
Comment: Have you actually played a major scale or a minor scale on an instrument yourself, or are you just reading about scales on a website or in a book ? If you would actually play a few scales on your instrument, you would hear the distinction and you would answer your own question.
Comment: I have only now realized that the question is "why are the intervals different when the second degree of the minor scale is, like that of the major scale, a whole step above the first degree?"  I will edit [my answer](https://music.stackexchange.com/a/127040/2257) to address this.
Answer: On the face of it, it doesn't make sense. But intervals are taken from the major scale notes. Thus a major 3rd is, say, from C to E. When an interval is made smaller by a semitone, it's called a minor. Thus a minor 3rd is C to Eb. Yes, it happens to be in the minor scale/key as well. This applies to most intervals, but not perfect ones - fifths, for instance. Major 7ths would be C to B, whereas C to Bb is a minor 7th.
The major second, in your question, is C to D, so when that is changed into C to Db, it's called a minor 2nd. Note that C to C# is NOT the same, even if, on most instruments, it sounds it. The way it gets written down is important. It doesn't mean that the Db is in the minor scale.
The 6th is another confusing one. C to A is major 6th, and C to Ab is minor 6th. However, a minor 6th CHORD doesn't have a minor 6th interval. It's spelled C Eb G A - with a minor triad, but a major 6th interval.
Going back to perfects - there are no minor 5ths. If C to G is a perfect 5th, then C to Gb is called a diminished 5th.Perfect 4ths are treated the same.
So, in summary - 2nds,3rds, 6ths and 7ths can all be major or minor, and if they are made even smaller, by another semitone, they are called diminished. Perfect 4ths and 5ths change to diminished when they are one semitone smaller.
Comment: please tell me why C to Db and C to C# is not the same and how the way it gets written down is important .i only know a rule is "don't mix sharps and flats together in a single scale".Isn't the reason ?
Comment: In the harmonic minor scale, the 7th note will be raised with an accidental. In G minor, key signature 2 flats, that will be an F sharp.  There is no "don't mix flats and sharps" rule.
Comment: C to D is called a second. Db is a sort of D (in name) and gets written on the stave as D. C and C# get written where C is on the stave. If you talk about note names in a diatonic scale, each note has a letter name, no missing letters, no repeat letters. C to Db will not be written the same as C to C#. # and b are mixed in some minor scales/keys. But the rule is otherwise generally followed.
Comment: @LaurencePayne - well aware of that! Generally, I prefer to read something in #s that has altered notes still written in #s. For example, in Amaj., I would expect an occasional D# rather than an Eb.But technically this may be written wrongly. Guitarists seem to be the main culprits!
Comment: "Intervals are taken from the major scale notes": more accurately, major intervals happen to be the same as the major scale notes.  The intervals got their names first, a couple of centuries before the scales did if I recall correctly.  The scales were named after their third degrees by analogy with major and minor keys.  See [my answer](https://music.stackexchange.com/a/127040/2257) for more detail.
Answer: The terminology is confusing here, because "major" and "minor" have two different meanings. One meaning is "major and minor scales". The other, which is taken directly from Latin, is that "major" means "big" and "minor" means "small".
A "second" means an interval between two successive note-letters in a scale - taking into account any sharps or flats in the scale, of course. In both major and minor scales, there are two different sizes of seconds - one and two semitones wide. The could just be called small seconds and big seconds, but the conventional Latinized names are minor seconds and major seconds.
The same naming system applies to thirds, sixths, and sevenths as well.
Fourths, fifths, and octaves are different. First, they sound different from the other intervals. Historically, the sound of 4th, 5ths and 8ves was described as "perfect" compared with "imperfect" for all the other intervals. The "perfect" intervals are the same size for almost all positions in major and minor scales. The very few exceptions (like F to B in C major and minor) are called "augmented" or "diminished", which just means "bigger than perfect" and "smaller than perfect".
Final note: in the harmonic minor scale, there is one second that is three semitones wide (A flat to B natural, in C harmonic minor). The term "augmented" is used for that, i.e. "bigger than a big second". Similarly, B natural to A flat is "smaller than a small seventh", and called a "diminished" seventh.
Comment: A succinct way to describe intervals. Like the 'small/smaller' ides for ;minor/diminished'. +1
Comment: In fact, major and minor scales and keys were named after their third degrees, so the tonality sense is directly related to the relative-size sense.
Answer: You wrote:
considering that in the natural scales formulae, they are both one whole step

This is the crux of your question.  M2 and m2 (major 2nd and minor 2nd) intervals are not both whole steps.  Only the M2 is a whole step.  The m2 is a half step.  Nonetheless, in the diatonic scale, each can represent a step.  Step-wise motion includes m2s and M2s, and also even m3s in most textbooks.  So they represent steps, but just not necessarily whole steps.
Comment: +1 for quickly & concisely getting to the root of the OP's confusion. To clarify: in a diatonic scale, the term "step" can be used generically to refer to *both* whole steps (M2's) *and* a half steps (m2's) that occur in the scale. Though I don't think I've ever heard a m3 (a skip) referred to as a step.
Comment: In undergraduate counterpoint courses, m3s belong to the category of stepwise motion.  See Fux's Counterpoint, and all textbooks that stem from it.
Comment: I think the question is actually asking "why are the intervals different when the second degree of the minor scale is, like that of the major scale, a whole step above the first degree."
Answer: The major intervals 2, 3, 6, and 7 come indeed from the major scale. However, as you noted, the corresponding minor intervals do not come from the (natural) minor scale, because then there wouldn't be any minor 2nd interval.
All minor intervals can be obtained from the descending major scale. If we use C major as an example, a minor 2nd is the interval between C and the B below the C. A minor third is the interval from C down to A, a minor 6th from C down to E, and, finally, a minor seventh from C down to D. Equivalently, you get all the minor intervals (2, 3, 6, 7) from the phrygian mode, which is an inverted major scale in the sense that the sequence of intervals when ascending is the same as the sequence of intervals of a descending major scale.
Comment: @LocVu: I meant that if all minor intervals were defined by intervals between the root and other scale tones of the natural minor scale, then the "minor" second would be identical to the major second, and we wouldn't get a (real) minor 2nd at all. But we know that there is one, because we do have intervals of a semi-tone, e.g. in a major scale between the 3rd and 4th note, and between the 7th note and the root.
Comment: Very nice, I've never really connected the concept of the major scale descending have all of the minor intervals.  That may become a good teaching tool for me.
Comment: Thank you so much for this answer. I've spent a few days trying to understand the *significance* of interval qualities. It just seemed so arbitrary and every mnemonic I could invent was flawed. This explanation totally clicked for me and is also incredibly elegant. This explanation even made the relationship to inversions click. Thank you!
Comment: I wasn't trying to understand the "why" here. The "why" is still pretty arbitrary. Matt's answer is just really elegant way to learn to remember these or to derive them, even if the explanation isn't a definitional part of the intervals.
Comment: i don't understand this " then there wouldn't be any minor 2nd interval " if we don't have 2nd minor interval so why we can't have "perfect second" (funny) :D
Comment: @BoJeanes I'm glad this explanation works for you, but the real explanation is in [user19146's answer](https://music.stackexchange.com/a/30423/2257): whether an interval is a second, third, fourth, etc., depends on the letter names, counting inclusively, and whether the interval is major or minor depends on the distance in semitones (half steps), where the minor interval is always one semitone smaller than the major. This system includes the perfect intervals and extends to diminished and augmented intervals as well. Major intervals are not called major because they exist in the major scale.
Comment: @phoog - now I'm confused! If major intervals don't come from major scales, where do they come from?
Comment: @Tim the explanation is in my comment above.  Why would you think that major intervals come from major scales when the second degree of the _minor_ scale is a _major_ second?  The fact that the major intervals are all contained in the major scale may be a useful mnemonic device, but it is an accident of history.  Major and minor intervals were being called that before scales were a particularly important theoretical concept, and, more importantly, before the major scale received its name.  In fact, the major and minor scales were named after their third degrees, not the other way around.
Comment: @BoJeanes that's true.  Even though I don't do it consciously anymore, I do still in some way relate most major intervals to the major scale (though I often think of the major sixth as the distance from 5 to 3, ascending so maybe 5 to 10 is a  better way of putting it).  And the same with the minor third and the minor scale.  But the minor sixth is generally either 3 to 8 of the major scale or 5 to 10 of the minor scale.  And I almost always imagine sevenths as inverted seconds.  It doesn't lend itself to a simple mnemonic device!
Comment: @phoog  of course! A>B, B>C, C>D etc. are all seconds - of some sort. The M/m shows whether they're bigger/smaller respectively. It's that elephant in the room!
Answer: A major second interval consists of 2 semitones (or as you say a whole step) whereas a minor second interval consists of a semitone.
Example of major second is C - D.
Example of minor second interval is B - C.
" considering that in the natural scales formulae, they are both one whole step ?" this is wrong. Of the second intervals only the major second consists of a whole step.
Comment: An Augmented unison also consist of one semitone.
Answer: I'm not sure what you mean by "the natural scales formulae", but it should be clear that any "natural scale" will not "naturally" have steps of the same size.
The diatonic scales were discovered long before the 12-edo tuning that we now use for playing these scales on piano etc., and for measuring the size of intervals therein. The original derivation uses no equally-spaced grid at all, but defines intervals by their frequency ratio. For the purposes of "harmonic music" we basically need the Ptolemaic scale of just intonation. You get it by making the I, IV and V chords just major chords, which are the "ideal consonant sound":

I is, well, the base frequency, by convention we call it 1/1.
iii has to be the the pure major third in the I chord, that requires a relative frequency 5/4.
V is the pure fifth in the I chord, rel.freq. 3/2.
IV is the pure fourth (so I will be the fifth of the IV chord) ⇒ relative frequency 4/3.
vi is the pure major third above IV, rel.freq. 4/3 · 5/4 = 5/3.
ii is the fifth in the V chord (one octave down), rel.freq. 3/4 · 3/2 = 9/8.
vii is the pure1 major third above V, rel.freq. 3/2 · 5/4 = 15/8.

Now... if you order these and do the maths, you'll find there are actually not just two, but three different steps! Namely,

The greater tone is found between I and ii as well as IV and V and also vi and vii, with ratio 9/8 each. That is 204 cents (i.e., a little bit wider than a whole tone step on a 12-edo instrument such as piano).
The lesser tone (not to be confused with minor) is found between ii and iii as well as V and vi, with ratio 10/9, which is 182 cents. Significantly smaller than a whole tone in a 12-edo.
The semitone is found between iii and IV as well as vii and I, with ratio 16/15, or 112 cents. A bit wider than a 12-edo semitone.

Now, while the major chords sound indeed amazing in the Ptomemaic scale, other things you'd like to do musically are complicated by all these different intervals; that's why most western instruments with fixed pitch detune the steps a bit, so the system becomes easier to overview for composers and players.
The greater and lesser tones are reasonably similar, so if you approximate them both by one single size in between you can still have pretty consonant chords in your scale. That's the idea behind meantone temperaments (12-edo is one of these).
OTOH, the semitone is arguably not similar to either of the whole tone steps, so if tried to also include these in a "one size, fits all" step, the chords would really sound out of tune2. But it's quite close to half the size of a whole step. 12-edo makes it exactly half the size, so your overall scale then lies on a fixed grid of semitones, where whole notes simply are a double step.

1It is widely accepted that at least the vii note, which is the leading tone from the dominant to the tonic, should typically be played higher than this value, to emphasise that the dominant is a dissonance that wants to resolve to the tonic.
2Which doesn't mean you can't use such a scale musically.
Comment: "original" is probably an overstatement.  I doubt anyone was tuning just major thirds in the days before polyphony or when the major third was considered a dissonance (12th century and earlier).  Since fourths and fifths were more important in those days, Pythagorean major thirds seem rather more likely.  It's also worth noting that the Ptolemaic major scale as you've outlined it does not support the ii chord, which is in some styles more common than the IV chord.
Comment: @phoog I doubt your doubt is warranted. The ancient Greeks had quite advanced harmony and scales, at least 5-limit if not 7-limit. Like so much of antique culture, it was largely lost in the Middle Ages and we were back to 3-limit monophonic melody, but the diatonic scales they used then are still remnants of the Greek time (and the names of the "church modes" witness that. Note however that these modes were originally _not_ just shifted copies, but actually had different, non-Pythagorean fine tuning.)
Comment: As for "**ⅱ** chord more common than **Ⅳ** chord" – well, not really; **ⅱ** is essentially a minor variant of classic the **Ⅱ** double-dominant, which is a borrowed chord and as such not exactly bound to the scale's tuning. Only relatively recently has **ⅱ** become such a standard in-scale chord of its own right. Especially for Jazz, all this discussion is of course moot because enharmonics are all over the place – 12-edo is always assumed there.
Comment: ...not that you need 12-edo for a proper **ⅱ** chord though: any meantone temperament will do.
Comment: Do you have any evidence that ancient Greek music employed harmony in the sense in which we use the word today?  Certainly Pythagoras seems not to have identified the 5:4 interval as one of interest. That the medieval modes were given Greek names does not show that the diatonic scale is a remnant of the Greek time, but that medieval theorists thought that they were.
Comment: On ii chords, I am thinking for example of the Baroque period in which ii harmonizes the first note in a re-ti-do cadence, whereas IV harmonizes the analogous note in a do-ti-do cadence. Even in 16th century England, that which would come to be analyzed as a ii (6/5) chord (i.e., a ii7 chord in first inversion) was quite common.  Pure just intonation is rather difficult to achieve, and generally useless for a keyboard instrument.
Comment: @phoog I've never dived into the details of Greek music with its strange tetrachords. I just know for sure that 5:4 thirds were explicitly studied by [Ptolemy](https://en.wikipedia.org/wiki/Ptolemy) in his work _Harmonics_. Whether Pythagoras really _excluded_ them in any way I'm not sure either; mostly his achievement seems to have been discovering about integral frequency ratios in the first place. I also don't know how much these harmonies were already in use "informally" and only then studied by the theoreticians, or what was only used after they instructed the musicians how to tune.
Comment: If you have "never dived into the details of Greek music with its strange tetrachords" then why are you posting statements such as "the ancient Greeks had quite advanced harmony and scales"?  How do you know that these were "5-limit if not 7-limit"?  My point is that 5-limit major thirds are certainly not *original,* and if you want to evaluate that in the context of the Greeks, note that they are "Ptolemaic" while 3-limit major thirds are "Pythagorean," and Ptolemy was hardly an ancient Greek, living as he did 700 years after Pythagoras in the 2nd century AD.
Comment: @phoog Well, I made none of these statements in my answer, only raised doubts when you made the _opposite_ assertion ("all ancient Greek music was 3-limit"), without – it seems – yourself knowing anything more about it. I say "at least 5-limit" because I do remember samples of "Greek tunings" that sounded quite wacky and distinctly un-Pythagorean. — What I did say in the answer with "originally" was merely that the origin on diatonicism is not skips in an equal-step scale, but just-intonation freq ratios. And that for the context of modern Western harmony, Ptolemaic 5-limit is what's needed.
Comment: I did not say that all ancient Greek music was 3-limit.  Which of the things I actually said led you to the incorrect conclusion that I was making that assertion?  My first comment was not about Greek music but about early medieval music, which works quite nicely using 3-limit hexachords. The need for 5-limit considerations only arose as the music became more polyphonic and people started caring about the major third as a consonant interval. But then you mentioned the Greeks, so I pointed out that Pythagorean tuning is both earlier than Ptolemaic and 3-limit.
Comment: I'm back because of a comment by Tim.  Again on ii chords, you can see them in a subdominant function in cadential formulas all over the renaissance and early baroque long before secondary dominants started to be used in cadences to the tonic.  In other words, it has a rather longer history than the secondary dominant that even predates tonal music, so it's not "relatively recently" that it's a standard chord in its own right.  But the main reason I'm commenting now is that I realized that the question is about the fact that the second degree of both major and minor scales is a major second.
Answer: In music theory "Whole step" has a special meaning.  The distance from one note on the piano keyboard to the next highest (whether it be a black note, C to C# or a white one, E to F) is called a "Half Step".  Two half steps make a "Whole step".   In British English we say "semitone" and "tone".
A major scale goes Whole step, Whole, Half, Whole, Whole, Whole, Half.  (I hope I got that right!).   So don't call the distance between EACH note of a scale a "Whole step", you'll just confuse yourself!
Not every interval in a minor scale is a minor interval.   From ^1 to ^2 in both the major and minor scales is a major 2nd, a 'whole step'.   Both C major and C minor (any variety) scales start with C, D.  They both contain a Perfect 4th (C, F) and a Perfect 5th (C, G) too.
Comment: I think the question is actually asking "why are the intervals different when the second degree of the minor scale is, like that of the major scale, a whole step above the first degree."
Answer: A minor second is a semi tone closer to the root note than a Major Second. D - Eb is a Minor Second. D to E is a Major second.
As a general rule of thumb if you have a Major interval and you bring the notes closer to each other by either raising the bottom note or lowering the top note by a semi tone then you have a minor interval.
Comment: Indeed, it's not a general rule of thumb but a strict rule.
Answer:
Why is a major second interval different from a minor second interval considering that in the natural scales formulae they are both one whole step?

They are not both whole steps.

Major second (M2) = 2 semi-tones (whole-step)
Minor second (m2) = 1 semi-tone (half-step)

These interval distances and names apply no matter the scale or chord.
In an octatonic scale, major scale, various inverted seventh chords, chromatic chord, etc. a major second is always 2 semi-tones and a minor second is always 1 semi-tone.
How the interval is written in staff notation or letter names does matter for naming the interval (C to Ebb is a diminished third, but is enharmonically a major second.) But that is an issue of enharmonic interval naming, and is really a different subject that doesn't need to be explained here.
Comment: I have at last realized that the question is intending to ask "why is the minor second different from a major second when the second degree of the minor scale is, just like the second degree of the major scale, a whole step above the root."  In other words, it's based on a misconception about the origin of the names "major" and "minor."
Comment: @phoog So, the misunderstanding being all imperfect intervals in a major scale would be major, all imperfect intervals in a minor scale would be minor?
Answer: It seems that your question can be rephrased as

Why are the major and minor second different when the second degree of both the major and minor scale is the same, a whole step above the first degree?

This bespeaks a misconception about where the words "major" and "minor" come from in intervals' names.  The fact that most of the major and minor intervals can be found as the corresponding degree of the corresponding scale is a historical accident.  Therefore it is a pattern that the second doesn't follow rather than a strict rule.  The strict rule is that a minor interval is always a half step smaller than the corresponding major interval.
The major scale and the natural minor scale both have seven seconds.  Every pair of adjacent pitches is a second.  If you look at all the seconds, you see that they come in two sizes, namely one semitone (B-C and E-F) and two semitones (A-B, C-D, D-E, F-G, and G-A).  To differentiate these two types of seconds, theorists called one type "bigger" and the other "smaller."  These theorists were writing in Latin, and the Latin words meaning "bigger" and "smaller" are "major" and "minor."
Similarly, there are two classes of thirds: A-C, B-D, D-F, and E-G are smaller -- minor -- while C-E, F-A, and G-B are bigger -- major.
In arriving at this system, the interval B-F or F-B was essentially discounted, so the augmented fourth was not called "major" nor was the diminished fifth called "minor."  The terms were applied only to the second and third along with their inversions the sixth and seventh.
There is another point to be made: not only didn't the major and minor intervals get their names from the major and minor scales; in fact the opposite is true.  The major and minor scales got their names from their third degree.  The major scale is so called because its third is major, and the minor scale because its third is minor.
Why is the third degree given this special power over the naming of scales?  It is because the third degree determines the quality of the tonic chord.
Answer: A minor second, literally a smaller second, is an interval of one semitone.
A major second, literally a larger second, is an interval of one whole tone.
They're called minor and major because one of them is smaller and the other is larger.
Same pattern goes for the thirds, sixths, sevenths, ninths, tenths, thirteenths and so on. One of the pair is smaller (in Latin, minor), the other is always half a tone larger (in Latin, major).
The minor and major key are only named after the fact that they contain a minor and major third above their root tone, respectively. The names are basically shorthand for "the one with the minor (smaller) third in it" and "the one with the major (larger) third in it".
It wouldn't make sense trying to distinguish them by something they have in common.
No strict claims in that about the other tones in the scale. In fact, minor key music frequently makes use of the major seventh.


Why is the second example not a Simplicial Complex?

Question: This is my first encounter of simplex and simplicial complex, hence I am not very sure about the concepts.
In the definition of Simplicial Complex
, I am not sure why is the second picture not a simplicial complex?
The intersection of the two triangles is a line, which is also a "face" isn't it?
Comment: Umm, point 2 in the definition? The intersection of the second pair is not a face of either of them (which are the lines joining the vertices).
Answer: As stochasticboy321 said, in the second example the intersection of the two simplices is a proper subset of the faces of each of them.  A proper subset of a face is not a face!


MGF from a conditional distribution

Question: I'm having a difficulty with this problem, it is not for submission.
Let Y~U(0,1) be a continuous random variable, and X is another random variable such that given Y=p:
$X|_{Y=p}$~B(n,p).
I need to find the moment generating function of X.
I honestly don't have much here, but I will try to add some context. It's weird to me that they ask about Y=p while being a continuous random variable, but my guess is that this will be relevant later.
 I have the MGF formula of the Unified distribution:
$$M_x(t) = \frac{e^{tb}-e^{ta}}{t\left(b-a\right)} $$ And I thought about using that, but I still don't really see the way.
Another direction I thought of going through but couldn't advance with it is going to the definition:
$$M_x(t) = \sum _x\:e^{tx}P\left(X_{|Y=p}=x\right) $$ but I couldn't really solve it.
Thanks in advance for any help provided.
Comment: Welcome to MSE. Your question is phrased as an isolated problem, without any further information or context. This does not match [many users' quality standards](http://goo.gl/mLWc8), so it may attract downvotes, or be closed. To prevent that, please [edit] the question. [This](http://goo.gl/PlJyVQ) will help you recognize and resolve the issues. Concretely: please provide context, and include your work and thoughts on the problem. These changes can help in formulating more appropriate answers.
Answer: Starting with the definition is the right step. Insert in the sum the expression for $B(x,n,p)$ ,considering for the moment $p$ to be fixed: you'll get a $M_x(t,p,n)$, that is the mgf subject to being $Y=p$. Thereafter, multiply that for $Pr(Y=[p, p+dp))$ and integrate over the support of $Y$
Answer: We can first write conditional MGF of bernoulli random r.v.$(I\sim BN(p))$, $MGF_{I}=pe^{t}+1-p$ then given that binomial r.v. is $B(n,p)=\sum_{k=1}^{n}I_{k}$
the MGF of binomial r.v. $B(n,p)$ is,
\begin{equation}
M(p,n)=E(e^{t\sum_{j=1}^{n}I_{j}})=\Pi_{k=1}^{n}E\left[e^{tI_{k}}\right]=\left(pe^{t}+1-p\right)^{n}=\left(p(e^{t}-1)+1\right)^{n}
\end{equation}
Given that $p=Y$,
\begin{equation}
M(X,t,n,p=y)=\left(y(e^{t}-1)+1\right)^{n}
\end{equation}
Now given that $p=Y\sim U(0,1) $ we can compute the MGF as follows,
\begin{equation}
M(X,n,p=Y\sim U(0,1))=\int_{0}^{1}\left(y(e^{t}-1)+1\right)^{n}dy
\end{equation}
Using standard integration arguments for above, we will have the final MGF,
\begin{equation}
M(X,t,n)=\frac{e^{t(n+1)}-1}{(n+1)(e^{t}-1)}=\frac{\sum_{k=1}^{n}e^{t(n-k)}}{n+1}
\end{equation}
A quick check on first moment will be which is,
\begin{equation}
E\left(X(n,y)\right)=nE(y)=\frac{n}{2}
\end{equation}
\begin{equation}
\frac{\partial M(X,t,n)}{\partial t}|_{t=0}=\frac{1}{n+1}\sum_{k=1}^{n}(n+1-k)=\frac{n(n+1)}{2(n+1)}=\frac{n}{2}
\end{equation}
which confirms the MGF.
Hope this is helpful for your question.
Comment: This is the correct solution, but can you please explain this: $M(X,n,p=Y∼U(0,1))=\int _0^1\left(y\left(e^t-1\right)+1\right)^ndy$ Thank you!
Comment: Yes sure. This is from the law of iterated expectations such that $E(f(X))=E(E(f(X)|Y=y))=\int_{0}^{1}E(f(X)|Y=y)f(y)dy$ as $Y\sim U(0,1)$. Here $E(f(X)|Y=y))=(y(e^{t}-1)+1)^{n}$ since MGF of binomial r.v. is $(p(e^{t}-1)+1)^{n}$ and we assume $p=y$ we will then apply previous formula for MGF and write out $E(e^{tX})=\int_{0}^{1}(y(e^{t}-1)+1)^{n} dy$ and $f(y)=1$ due to uniform distribution.

MGF from a conditional distribution


Styling attributes nested inside id and class

Question:
What I want to do is remove the margin for the p nested inside the id then class.
Please note I cannot add a direct id or class for this p since this is a Wordpress site.
Answer: Something like this I believe is what you're looking for
.textwidget p
{
    margin: 0;
}

or if you specifically need that first paragraph tag
.textwidget p:first-child
{
    margin: 0;
}

Comment: Yup that might work, but i do not want all p's inside this class to have no margin, i tried adding the #id .class p{ } but that did not work
Answer: You need to use the #id, .class, p and possibly :first-child selectors, like this:
#panel-w59fa3473baf71-0-1-0 .textwidget p:first-child {
   /* your styles */
}

Keep in mind that id might change since this is a Wordpress site. If that's the case you'll need to use one of the classes on that same element. Like:
.so-panel .textwidget p:first-child {
   /* your styles */
}

Answer: Actually it was my mistake, i have prefixed the p with a (.)
/*Style header whatsapp area*/
#panel-w59fa3473baf71-0-0-0 .textwidget p{
margin:0px;
}
#panel-w59fa3473baf71-0-1-0 .textwidget p{
margin:0px;
}


Get contents from old .CSR

Question: At one of my new customer sites, I have a SSL certificate which is about to expire.  I've been notified by my provider of expiry.  The previous admin was pretty detailed and I've located the .CSR which was used to request the about-to-expire certificate.
However, this host is a debian host, and I've confirmed that the .CSR was generated when Debian was suffering from the OpenSSL random number generation issue.
So.  Now that I've updated OpenSSL on my debian host, I presume I have to regenerate the .CSR for the renewal.  Is there a way to find out what values were used in the .CSR I have, to ensure that the new .CSR is consistant?
Answer: Try this:
openssl req -in file.csr -noout -text

Answer: For future reference, you don't even need the original CSR.
You can create a new request from the existing x509 certificate.
openssl x509 -x509toreq -in file.crt -signkey file.key -out file.csr

As a general rule nearly all of the OpenSSL commands support the flags correctly answered by others.
-noout -text

Which simply prevent PEM output and display human readable content instead.
Answer: If the key was generated on a Debian or Ubuntu server while openssl had a broken random number generator, you must regenerate the key. Do not just generate a new CSR from the old key. You are still vunerable.  Once you have a new key, you can create a new CSR with the right values.
Comment: I think he just wants reminded of what values he put in the CSR. God knows I can never remember what I put in the last time I requested a certificate. It's possible to be completely accurate each time, and still be completely different.
Comment: Other answers have answered that. The question sounded like he was going to use the old key, which would have still left him vunerable.
Comment: Good to know.  I didn't know the key was vulnerable.
Answer: I completely agree with David Pashley (but i have something to add...).
The keys itself are vulnerable not the csr!
There is no point in regenerating the csr you have to regenerate you keys!
Most CA will not even accept signing requests associated with these "compromised" keys.
And here are some useful links:

replacing your keys: Debian key rollover
There was a very good Debconf7 presentation on this topic (site seems down atm.)
Answer: openssl req -text -noout -in FILENAME.csr
should do the trick.
Answer: Depending on EXACTLY what you're trying to do here but if we're talking a regular SSL certificate used with web servers sometimes the simple solution is to just pull up the site (https://www.mywebsite.com) and look at the properties of the certificate there.
Right click the "lock" in the browser while its in HTTPS/SSL mode and you should be able to see pretty much all the values entered.
Hope this helps.
Answer: You can also probably work out what info was put into the original CSR by examining the current cert:
openssl x509 -in <certfile> -text -noout

Get contents from old .CSR


basic and minimal java development setup

Question: I am using Ubuntu and I would like to know the basic tools to install so I can begin develop in java.
With 'minimal' I mean the most transparent way without fancy tools and stacks etc. Like for minimal C programming you just write code and run 'gcc file.c -o myapp'.
Thank you
Answer: Just download JDK.
Minimal tools are javac for compiling and java for executing JVM. Both are in bin directory.
Answer: You need to install JDK to start with hello world
Answer: Eclipse IDE. It's probably the most comprehensive Java IDE. I understand that isn't what you're looking for but light, simple ones like JCreator are not free to use. I don't see the sense in developing without an IDE of any kind.
Comment: I would consider Eclipse a pretty "fancy tool"
Comment: Even though Eclipse is great to have for Java development, it's clearly not what the OP is asking about.
Comment: so would I. Just a suggestion, the most minimal tool is the ubuntu equivalent of notepad.
Comment: 'notepad'?  so as to not start a holy war - pick vi or emacs - neither are the wrong choice
Answer: Install the JDK. An IDE is a minimal requirement for development in Java. Not all developers would agree, but IMHO its the most productive way to develop in Java. I suggest IntelliJ CE which is free.
Comment: "most productive" != "minimal" / "most transparent"


Logback RollingFileAppender maxHistory

Question: I have config:
 <appender name="file" class="ch.qos.logback.core.rolling.RollingFileAppender">
    <file>/logs/logFile.log</file>
    <encoder class="ch.qos.logback.classic.encoder.PatternLayoutEncoder">
        <pattern>${PATTERN}</pattern>
    </encoder>

    <rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">

        <fileNamePattern>/logs/logFile.%d{yyyy-MM-dd}.%i.log</fileNamePattern>
        <timeBasedFileNamingAndTriggeringPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedFNATP">
            <maxFileSize>1MB</maxFileSize>
        </timeBasedFileNamingAndTriggeringPolicy>
        <maxHistory>2</maxHistory>
    </rollingPolicy>
</appender>

But,logs are not deleted after two days, in what could be the problem?
Maybe problem in:
<fileNamePattern>/logs/logFile.%d{yyyy-MM-dd}.%i.log</fileNamePattern>

But I need save all logs
Comment: Did you check this out: [link](http://stackoverflow.com/questions/34772372/logback-rollingfileappender-xml-not-rolling-over-or-deleting-old-archived-logs) ?
Comment: Ajith's answer below worked for me. Also, using totalSizeCap alongwith maxHistory makes sense, since usually its the filesystem space which is of interest for many applications
Answer: Please set
<cleanHistoryOnStart>true</cleanHistoryOnStart>

and check. This is false by default. This will be added under the rollingPolicy tag.
https://logback.qos.ch/manual/appenders.html
Comment: I wish this worked for the `SizeAndTimeBasedRollingPolicy` as well.

Logback RollingFileAppender maxHistory


Do postseason games count against the NHL games played limit for rookie status?

Question: Adding to the question here, do NHL postseason games count towards the current 25 game limit for a player to maintain rookie status?
The wording of the current NHL rules seem a bit ambiguous as to whether a young player called up for the Stanley Cup playoffs would still maintain rookie status if he played 28 post season games, but no regular season games. The rules quote:

To be considered a rookie, a player must not have played in more than 25 NHL games in any preceding seasons, nor in six or more NHL games in each of any two preceding seasons. Any player at least 26 years of age (by September 15th of that season) is not considered a rookie.
Answer: No, postseason games do not count for rookie eligibility.
For example, Matt Murray was eligible to be considered for the Calder Trophy in 2017, the year after he won the Stanley Cup, despite playing 13 regular season games and 21 postseason games in 2015-2016. He did not win it, instead finishing fourth, but was named to the NHL All-Rookie team in 2017.