Frequencies/percentages different from zero - which test?

Question: I conducted an experiment and had participants indicate binary judgments by either pressing "1" or "0" when seeing different types of stimuli. Now I want to test whether the proportions of number presses differ from chance likelihood of 50% for the different stimulus conditions. My supervisor always used to run a one-sample t-test against 0.5 on the subject-level aggregated data (with the resulting mean representing the percentage of 1-presses); however, I am wondering this is the best way to do it. Since I am dealing with a binary variable (1/0), wouldn't it be more appropriate to run a chi-square goodness of fit test on the unaggregated data?
Any input is highly appreciated!
[Update] This is a fictive example for my data structure:
Subj    type    response
1   target_top      1
1   target_bottom   0
1   target_bottom   0
1   target_top      1
1   target_bottom   0
1   target_top      1
2   target_bottom   0
2   target_top      0
2   target_top      0
2   target_bottom   1
2   target_bottom   1
2   target_top      0

As can be seen, it is a repeated measures design. Stimuli differ in their vertical position and we test the hypothesis that spatial position influences judgments (i.e., for example, 1-presses when presented on top position significantly differ from chance likelihood).
Comment: Could you perhaps add a (fictive) small data sample for 1-2 participants so that we can grasp the data structure? What research question(s) are you trying to answer by the hypotheses tests?
Comment: Your update is about a completely different question from your title. What exactly do your want to do? Perhaps you need to edit the title?
Comment: Thank you, I have changed the title now and please excuse the previous misunderstanding! I am interested in testing whether the observed frequencies of pressing the respective buttons (whether in relative or absolute terms) differs significantly from chance.
Answer: The presumptive appropriate approach would be mixed effects logistic regression, where the dependent variable is Response, the independent variable is Type, and Subject is treated as the random subject. This is the approach described in the answer by @Noah.
Using a simple chi-square goodness-of-fit test or binomial test ignores the fact that the same subject is responding several times.
A t-test is probably not a good solution considering that the dependent variable is binomial and not continuous, as well as the fact that a t-test ignores the repeated responses by each subject.
Answer: My inclination is to use multilevel logistic regression. Your outcome is whether the observation was 0 or 1. Your level-1 predictor is the target location. Your clustering variable is participant ID. Alternatively, logistic regression with cluster-robust standard errors or fixed effects for participant ID would work as well.
Your output would be a coefficient on target location, which indicates the difference in the log odds of selecting 1 vs. 0 between the target locations, and a constant, which would represent the probability of selecting 1 in the baseline target location. With these, you could transform the log odds ratio into a difference in probabilities, but the significance test on the coefficient would be the test of whether target location affects the probability of selecting 0 or 1.
Answer: If I am understanding you correctly, you wish to see if the proportion of 1's in your data is significantly different from .5. You can calculate the sample proportion, say, $\hat{p}=\frac{\# \ of \ 1}{N}$. You can then calculate a $z$-statistic: $z=\frac{\hat{p}-p_0}{\frac{p_0(1-p_0)}{N}}$ where $p_0=.5$ and $N$ is your total sample size. Then you can calculate a $p$ value given the $z$ statistics and conclude statistical significance or lack thereof.
This can be done for each type of stimuli. If the stimulus are independent of each other and the order is randomized, a Bonferroni correction can be applied: you should compare your $p$ value to $\frac{\alpha}{ \# \ of \ stimulus}$, e.g., you have 4 different types and your overall significance level is .05, then you should compare your $p$ values to .0125.
Comment: This doesn't actually answer the question, which is whether a chi-square test would be better.  The OP obviously knows about the test you are proposing as he refers to it in the question.
Comment: Oh sorry. I was not sure if the OP mentioned this. I saw that the OP mentioned an one sample t test, which is slightly different because the denominator here can be known given the $p_0$. Then the OP mentioned a chi-square test, which I am not sure how it would apply since it seemed to be an one-sample problem comparing sample proportions to .5. So I added this. But my bad if this is what OP is already doing.
Comment: @jbowman, it's not clear OP knows about this test. The t-test they propose does not use binary variables rather a proportion correct for each individual as the dependent variable. A binomial test would therefore not make sense for them to contemplate.
Answer: The probably most obvious choice to test, whether an event ("1") happend by chance $p$ or not would be an binomial test. In R this can be done via the binom.test function.
So if 30 participants voted "1" and 35 voted "0" the test of votings happening bei 50:50 chance ist
> binom.test(c(30, 35), p=.05)

     Exact binomial test

data:  c(30, 35)
number of successes = 30, number of trials = 65, p-value < 2.2e-16
alternative hypothesis: true probability of success is not equal to 0.05
95 percent confidence interval:
 0.3370209 0.5896749
sample estimates:
probability of success
         0.4615385

This is an exact test that does not rely on approximations as opposed to $\chi^2$ tests, which seem still more reasonable then a t-test.
Comment: Shouldn't the fact that these are repeated measures be given any consideration?  Contemplating that suggests (to me at least) that we need to clarify the specific statistical question that is being asked.
Comment: Thank you for your reply! I have to apologize because I did not mention important aspects of the design (repeated measures) in my first post. However, I still learned from you answer!
Comment: @whuber The way I understood the question was, that there was a number of conditions that yield 0 or 1 from each participant and that a dedicated test for each condition should be performed. Are not in each of these tests the results indipendend, because they are singular? But yes, maybe the question was not as clear as it appeared to me.


Problemas com múltiplas expressões nas legenda com ggplot

Question: Meu gráfico está sendo gerado com a legenda triplicada, ou seja, uma para cada escala. Estou tentando plotar os modelos de estimação para cada linha de tendência na legenda.
Abaixo são apresentados os dados,o código utilizado e a saída com a legenda triplicada:
Os modelos de estimação:
eqs<-list(D1 = "italic(hat(Y))==  2.816 ^\"***\" - 0.094 *x^\"***\" *\",\"~~~italic(R)^{2}== 0.4632",
    D2 = "italic(hat(Y))==  3.3635 ^\"***\" - 0.1202 *x^\"***\" *\",\"~~~italic(R)^{2}== 0.622",
    D3 = "italic(hat(Y))==  3.7997 ^\"***\" - 0.152 *x^\"***\" *\",\"~~~italic(R)^{2}== 0.7494",
    D4 = "italic(hat(Y))==  4.0633 ^\"***\" - 0.167 *x^\"***\" *\",\"~~~italic(R)^{2}== 0.7954")

Exemplo de código do gráfico:
ggplot(data.frame(trat=c(1:4),resp=c(1:4),grupo=c(LETTERS[1:4])),aes(x=trat,y=resp))+
  geom_line(color="black",aes(linetype=grupo,group=grupo))+
  geom_point(aes(fill=grupo,shape=grupo,group=grupo),size=3,color="black")+
  scale_shape_manual("Modelos",labels=parse(text=eqs),values=c(21,22,8,24))+
  scale_fill_manual("Modelos",labels=parse(text=eqs),values=viridis(direction = -1, 4))+
  scale_linetype_manual("Modelos",labels=parse(text=eqs),values=c(1:4))

Saída do  gráfico:
Answer: O problema está no uso de parse repetidas vezes; ggplot não entende que são os mesmos rótulos e separa as chaves de legenda. Passe os rótulos já no formato final:
library(ggplot2)

dados <- data.frame(trat = 1:4, resp = 1:4, grupo = LETTERS[1:4])

eqs <- list(
  D1 = "italic(hat(Y))==  2.816 ^\"***\" - 0.094 *x^\"***\" *\",\"~~~italic(R)^{2}== 0.4632",
  D2 = "italic(hat(Y))==  3.3635 ^\"***\" - 0.1202 *x^\"***\" *\",\"~~~italic(R)^{2}== 0.622",
  D3 = "italic(hat(Y))==  3.7997 ^\"***\" - 0.152 *x^\"***\" *\",\"~~~italic(R)^{2}== 0.7494",
  D4 = "italic(hat(Y))==  4.0633 ^\"***\" - 0.167 *x^\"***\" *\",\"~~~italic(R)^{2}== 0.7954")

rotulos <- parse(text = eqs)

ggplot(dados, aes(x = trat, y = resp)) +
  geom_line(aes(linetype = grupo)) +
  geom_point(aes(fill = grupo, shape = grupo), size = 3) +
  scale_shape_manual("Modelos", labels = rotulos, values = c(21, 22, 8, 24)) +
  scale_fill_manual("Modelos", labels = rotulos, values = rainbow(4)) +
  scale_linetype_manual("Modelos", labels = rotulos, values = 1:4)

Pode aproveitar e colocar todos os elementos comuns das legendas em uma lista, reduzindo repetição:
rotulos <- list("Modelos", labels = parse(text = eqs))

ggplot(dados, aes(x = trat, y = resp)) +
  geom_line(aes(linetype = grupo)) +
  geom_point(aes(fill = grupo, shape = grupo), size = 3) +
  scale_shape_manual(rotulos, values = c(21,22,8,24)) +
  scale_fill_manual(rotulos, values = rainbow(4)) +
  scale_linetype_manual(rotulos, values = c(1:4))

Answer: Para evitar que a legenda seja triplicada, basta remover as duas últimas linhas do seu código, que são as que estão adicionando as escalas de cor e forma. Isso deve resolver o problema da legenda triplicada.
O seu código ficaria assim:
ggplot(data.frame(trat=c(1:4),resp=c(1:4),grupo=c(LETTERS[1:4])),aes(x=trat,y=resp))+
  geom_line(color="black",aes(linetype=grupo,group=grupo))+
  geom_point(aes(fill=grupo,shape=grupo,group=grupo),size=3,color="black")+
  scale_shape_manual("Modelos",labels=parse(text=eqs),values=c(21,22,8,24))

Essa alteração vai fazer com que apenas a escala de linetype seja exibida na legenda, mostrando os modelos de estimação como rótulos.


calculate a summation or a complex integral!

Question: I am here again! This time is a complex integral question! I can not work it out by myself!

Consider
$I(x)=\sum_{n=-\infty}^{+\infty}g_n(x)$ and $g_n(x)=\frac{1}{i(2n+1)-x}$, where x is a real variable and i is the imaginary unit.
The goal of this question is to calculate the sum above by transforming it into a complex integral. The hint is to show that $I(x)=\int_Cf(z)\frac1{z-x}dz$ by introducing z as a complex number and $f(z)=\frac1{2\pi i}(\frac1{e^z+1})$ and choose a proper contour C for integration at the same time. Then calculate the integral to get $I(x)$
From my point, there must be a connection between the singularities of $f(z)$ and the $i(2n+1)\pi$ in $g_n(x)$ and I need to use the residue. Then, game is over.
Comment: Done yet, only to find this way not working! This is exactly why I'm here.
Answer: Proof sketch that uses the fact that $f(z) + f(-z) = 1$:

Since $I(x) = -I(-x)$, you can assume without loss of generality $x < 0$. The semicircular contour $$
C_N = \{x/2+iy: -2\pi N < y< 2\pi N\}\cup \{x/2 + 2\pi N e^{i\theta}:-\pi/2 < \theta < \pi/2\}
$$contains the first $2N$ poles of $f(z)$. In the limit as $N\rightarrow\infty$, this will include all the poles of $f(z)$, but never contains $x$, and you can show the value of $\int_{C_N}f(z)/(z-x)dz$ will go to $-I(x)$.
Consider $f(-z)/(z-x)$ using the semicircular contour $$
C^-_N = \{x/2+iy: -2\pi N < y< 2\pi N\}\cup \{x/2 - 2\pi N e^{i\theta}:-\pi/2 < \theta < \pi/2\}.
$$This contour contains none of the poles of $f(-z)$ for any $N$, but does contain $x$ for $N > -x/(4\pi)$. You can show from this that $\int_{C^-_N}f(-z)/(z-x)dz = f(-x)$ for large $N$.
As $N\rightarrow\infty$, you can show the semicircle part of the integrals of $f(z)/(z-x)$ over $C_N$ and $f(-z)/(z-x)$ over $C_N^-$ to to zero. From this, you can show $$
 I(x) + f(-x) = -\int_{x/2+i\infty}^{x/2-i\infty} \frac{f(-z)dz}{z-x}+\int_{x/2-i\infty}^{x/2+i\infty} \frac{f(z)dz}{z-x}  = \frac{1}{2\pi i}\int_{x/2-i\infty}^{x/2+i\infty} \frac{dz}{z-x} = \frac{1}{2}
$$
Since $f(-x) = 1/(e^{-x} + 1)$, you can conclude that $I(x) = -\tanh(x/2)/2$.
Comment: So the answer is to choose the contour whose origin is at $x/2$ and utilize the property of the functions. I still can not figure out the '1/2' result in the last step of the third part.
Comment: @Yankang Any value between $x$ and $0$ works. I just chose $x/2$ because it's always true that $x < x/2 < 0$ if $x < 0$. The final integral equal to $1/2$ can be done explicitly: just substitute $z = x/2 + iy$ and expand into real and imaginary parts.
Comment: Well, the $''1/2''$ question above seems to be a little bit dumb now. The solution is really awesome! This is a really great practice! Thank you so much!
Comment: @eyeballfrog Do semicircle parts of the integrals $f(z)/(z-x)$ and $f(-z)/(z-x)$ really tend to zero? I mean $|e^z| = |e^{x+iy}|=|e^{x}|$ and there are parts of the semicircle where $x$ don't move much (near the imaginary axis.)


MKReverseGeocoder: where is location string stored?

Question: I found this tutorial:
http://evilrockhopper.com/2010/01/iphone-development-reverse-geocoding/
and implemented this code:
if (reverseGeocoder != nil)
{
    // release the existing reverse geocoder to stop it running
    [reverseGeocoder release];
}

// use whatever lat / long values or CLLocationCoordinate2D you like here.
CLLocationCoordinate2D locationToLookup = {52.0,0};
MKReverseGeocoder *reverseGeocoder = [[MKReverseGeocoder alloc] initWithCoordinate:locationToLookup];
reverseGeocoder.delegate = self;
[reverseGeocoder start];

The question is, when I started reverseGeocoding, where is location string stored?
I have coordinate and I give them to reverseCeocoder to find me address, but how to get this address in some string for example?
Answer: Just read the documentation for MKReverseGeocoder:

The reverse geocoder returns information through its associated delegate object, which is an object that conforms to the MKReverseGeocoderDelegate protocol.

So you have to implement these two methods in your delegate:
– reverseGeocoder:didFindPlacemark:
– reverseGeocoder:didFailWithError:

and the geocoder will call them when it has information for you.


Subconsulta retorna mais de um valor

Question: Boa noite!
Tenho uma consulta sql baseado numa CTE e quero pegar o maior valor entre uma subconsulta, porém quando executo a consulta principal o erro de subconsulta retorna mais de um valor aparece. Poderiam me ajudar?
Segue código:
WITH CTE AS(
            SELECT TOP 1 PERSON.PERSON.FirstName AS NOME,
        (SELECT COUNT(*) AS A FROM PERSON.PERSON
        WHERE EmailPromotion = 0

        UNION ALL

        SELECT COUNT(*) FROM PERSON.PERSON
        WHERE EmailPromotion = 1) AS EMAIL

        FROM PERSON.PERSON)SELECT MAX(EMAIL) FROM CTE

Comment: Tente explicar qual resultado deseja obter pois esta query está estranha. O subselect com UNION ALL retornará duas linhas a primeira com a quantidade total de registros da tabela PERSON.PERSON com EmailPromotion = 0 e a segunda com a quantidade com EmailPromotion = 1.
Comment: Eu desejo obter o maior valor entre EmailPromotion = 1 e EmailPromotion = 0. Eu fiz um union all para com base nisso pegar o maior valor (MAX)
Comment: Tentei colocar um TOP 1 mas não resolveu
Comment: Avalie o uso da função GREATEST destes COUNT.
Comment: No SQL SERVER não exite essa função. Sabe alguma alternativa?
Comment: Se quer o maior valor EmailPromotion (contagem) por pessoa (person) ? Dá um exemplo dos dados e da saída requerida.
Answer: Bom dia,
Almino, se você quer obter o maior Count de EmailPromotion por pessoa, experimente fazer uns testes dessa forma:
WITH CTE_Count AS
(
  SELECT
    FirstName,
    COUNT(CASE WHEN EmailPromotion = 0 THEN 1 END) AS EP0,
    COUNT(CASE WHEN EmailPromotion = 1 THEN 1 END) AS EP1
  FROM PERSON.PERSON
  GROUP BY
    FirstName
)

SELECT
  FirstName AS NOME,
  CASE WHEN EP0 > EP1 THEN EP0 ELSE EP1 END
FROM CTE_Count

Na CTE são feitas as contagens e na parte final da consulta é utilizado o Case para obter a maior contagem entre as 2.
Espero que ajude
Comment: Perfeito muito obrigado!

Subconsulta retorna mais de um valor


increase input type number value by 10 intervals

Question: I am using <input type="number"> where up arrows increase the vale +1 by per click or it goes on when press and hold. But is it possible to increase it by 10, 20, 30 ..... because my input numbers are very in range of 900-20000.
Answer: by using the step attribute you can do it
use step=10
<input type="number" step=10 />

FIDDLE DEMO


Facebook Server IP Whitelist Range?

Question: I've found that I can add multiple domains to my facebook app by including the server IP address in the "Server IP Whitelist" field and the "Valid OAuth redirect URIs" field. It would be really nice to be able to add a range of IPs instead of a single IP address in the whitelist field.
Instead of 127.0.0.1, I've tried using 127.0.0.0, 127.0.0.*, and 127.0.0.1-127.0.0.100. None of which seem to work.
Does anyone know if this can be done?
Comment: have you tried `127/8` (or similar)?
Comment: I'm not sure I understand that syntax. Could you write out the entire IP, or... is that the entire IP?
Comment: That is equivalent to `127.*`
Comment: Ah, OK. Yeah, I tried doing that and facebook said that it doesn't meet the requirements of a valid IP address. :(
Comment: You could also try the longer `127.0.0.0/8` format
Comment: Hmm, that didn't seem to work either. Any other suggestions would be greatly appreciated.
Comment: Neither 127.1.0.0/16 or 127.1.* are accepted, it just says invalid ip format
Answer: Go to your dns settings for your website hosting and copy the ip address it should be like
220.127.116.11
If you are hosting in Azure you can go to the custom domains tab and copy the ip address
Im sure that you found an answer by now. This is for anyone who is searching the issue for the first time, because nobody ever posts an answer if they find one outside of stack overflow, lol.
Answer: May be somebody looking how to set IP range to maximum - for all IPs(similar to remove Facebook Server IP Whitelist). I search it all day, may be i stuped, but answer is very simple - just set this field empty:D
I need it to working app access token from all IPs.

Facebook Server IP Whitelist Range?


Tonality and Rules

Question: One can find many books on "tonality"during the common practice period. e.g., Piston.
Tonality seems to be definable as the way in which composers express the chromatic scale in a organized way around one central pitch. E.g., There are 12 notes, if we express any one single pitch as "central" in some way(which way?) with the other tones falling in place in some way then we have tonal organization(e.g., just like chess, we have the king, obviously the central piece with the other pieces having specific relations to it)
Now, harmony books tend to give all kinds of rules about how to express tonality(voice leading, establishing the tonic, note resolution, etc).
The question I have, is there some specific fundamental concept that all this is built off of or is it just some arbitrary set of rules to create a structure on that produces a specific result?
Much of modality and modern music contrast and even contradict many of the tonal principles but in some ways overlap with tonality. Even many tonal pieces "break the rules".
Is all this hoopla simply to create a logical structure that has inherent stability and instability? e.g., without tonality we generally don't have a sense of a "home key", which means we don't have a place to go and a place to come back to. This seems to mimic human behavioral aspects. Hence, tonality is simply more "human like" than non-tonality.
If that is the case, are the rules of tonality born out of centuries of experience on how to achieve tonality, codified in our harmony books... or is there a mathematical foundation that the rules are derived from or are people just making it up as they go along?
When I read Piston, I tend to find a lot of circular reasoning about why things are done the way they are done...
e.g., Bach wrote a lot of music and obviously would have a certain functional pattern of composing. We find some example that backs up/demonstrates rule X. We ignore/neglect all examples that go against rule X and/or create new rules to explain why rule X was violated.
Just to be clear on what I'm trying to get at: In physics, all things essentially are derived from the basic laws governing how mass and energy interact. These laws are generally codified gravity and the nuclear forces. Most other things in physics macroscopic simplifications to make thinking about that sort of stuff easier. But fundamentally everything is derived from a few fundamental concepts. The same holds true in math and I also believe it probably holds true in all life(since, after all, painting, music, psychology etc are fundamentally based in physics). Does tonality also have some fundamental laws?
Any ideas on the subject?
Comment: Physics also tells us that if one verified example of a rule being broken is found, the rule is invalid. The "Rules" of tonality are far inferior by comparison - they are dictated by opinion and by the amount of harmony and discord that a certain set of people regard as "musical". Purely opinion, in other words.
Comment: There are no laws or rules per se. There is lots of theory, but thankfully it stays as theory because there are few absolutes in music. We learn theory and some then try to adhere to it religiously, only to find others taking no notice and having fun.
Comment: There is the idea of tonality and its system and how best to utilize it, but there are no "rules". Sure classes set them up as rules but the main purpose of that so you understand the concept and the effect it has on what you compose.
Comment: Note that tonality -- in the sense of the establishment of a principal pitch -- existed before the development of counterpoint and harmony and can still exist without it.  For example, the tune of "Mary had a Little Lamb" is clearly, by itself, tonal.
Answer: tl;dr: Yes, there are probably relatively simple underlying principles, but we're still working on what they are.
You make a really common and really valid criticism of music theory. Nothing seems to be founded on clear and simple principles, or core truths about human perception of sounds. It's all "this is just how it's done," or at best we're told that this or that musical device sounds sad or happy or stable or unstable, but not why. Most of the work going on in music theory just piles more and more abstractions on the existing framework without really dealing with the fact that in a sense it's all castles built on air.
But here's the good news: for hundreds of years there has been ragtag group of people around the edges trying to develop theories that re-construct common practice theory and harmony from simple rules based on the core facts of human cognition. It ranges from music theorists with an interest in perceptual foundations, to neuroscientists studying music, to experienced musicians just trying to better understand what they do.
Here are the best examples I know of:

Helmholtz was a 19th century doctor and physicist who built up a
theory of many of the basic ideas of harmony from simple principles of physics and psychoacoustics. His book On the Sensations of Tone is celebrated and studied by mainstream music scholars. I haven't read it, but I have the sense that he gives a convincing explanation for triads and the major scale, but not the nitty gritty of Piston-type harmony and voice leading.
To deal with the Piston-type stuff, a lot of people in music theory have tried to explain harmonic progressions in terms of movement through geometric spaces. A music theorist named Dmtri Tymoczko has gotten a lot of attention lately, even in the mainstream press. He's the first music theorist ever to be published in Science, and he claims his theory encompasses all of the other geometric approaches so far and can explain almost all of Western harmony. He has a book about it called The Geometry of Music. This book is probably your best place to start because it's relatively simple, written for a general audience, and it's probably the best comprehensive theory we've got so far. You can also read his papers in Science if you want to cut straight to the hairy math stuff.
W.A. Mathieu's Harmonic Experience. Mathieu is a respected expert in both jazz and Hindustani classical music and he has a grand unified theory of harmony based on the overtone series and the sensations we feel hearing different intervals. He doesn't try and reduce things to a small set of core principles, but he is good at making sure everything is grounded in how different sounds makes us feel, and even asks the reader to sing intervals and pay close attention to how they affect your feelings and state of mind.

There are a lot of common threads through all these explanations and I wouldn't be surprised if things start to congeal into a consensus theory in the next 10 or 20 years. But for now, there's just a lot of good ideas swimming around. Tymoczko is probably the closest thing we've got right now.
Answer:
The question I have, is there some specific fundamental concept that all this is built off of or is it just some arbitrary set of rules to create a structure on that produces a specific result?

I suggest that the answer is "yes, there is a specific fundamental concept", and the fundamental concept is consonance versus dissonance.
Western functional harmony and the common practice period as a whole are typically taught based on a foundation of consonance versus dissonance, and I think that is because that foundation is central to how tonality is created and expressed, and even central to the choice of the twelve notes.
In addition, the preception of consonance versus dissonance is only partly subjective. I'm not aware of any culture that has pitched music where two tones an octave apart are not seen as being the same or at least more closely related than any other pairs of tones. Fifths are also widely used, and there are some largely objective aspects of consonance farther along the harmonic series, certainly including fourths and, to a lesser extent, thirds and sixths.
A survey of different scales and tunings from cultures around the world, along with understanding of the acoustic properties of the instruments used in those cultures and how music is made in those cultures supports the idea that dealing with consonance and dissonance is central to all pitched music. In music, humans seem to seek a balance between the pleasing aspects of consonance tempered with the more interesting or exciting aspects of dissonance, and this is certainly true with the common practice period.
One thing that distinguishes Western common practice theory when it comes to dealing with consonance and dissonance is that both consonance and dissonance are created mainly by the selection of tones to be played or sung, regardless of the instruments, and that the instruments almost always play well-defined pitches. Instruments with less clear pitch definition, such as tubular bells, are not central to Western harmony or common practice, and are even relegated to a separate category, like "pitched percussion". Contrast that with Balinese gamelan where some amount of dissonance is created by deliberate tuning variations between instruments played in pairs to add "shimmer" to the overall sound that is essentially a just tuning composed of relatively consonant intervals. The sound of a gamelan has less motion between consonance and dissonance, rather the two exist simultaneously to create a sound that is beautiful and interesting even though it is fairly static.
Western harmony deals with consonance and dissonance in several ways, but the main way is by arranging in time mostly consonant chords with more disonnant chords to create both pleasing sounds and interesting sounds, as well as flows of tension and release. A more subtle aspect of this is the use of cadences and harmonic resolution, where a chord that would sound consonant on its on actual creates harmonic tension in a particular context because of the dissonance between the tones of that chord and tones that are well established in the piece that are expected and or remembered by the listener.
To give a specific example, suppose a piece firmly establishes the key of C major, thereby fixing in the mind of the listener both the central note of C and major tonality. In that context, a G major chord will have a kind of implied or remembered dissonance between the B natural of the G major chord and the key note of the piece, namely C. When the G major chord is followed by a C major chord, the implied dissonance is dispelled in the most consonant way possible, and there is a feeling of resolution.
Note that this answer is about tonality and expression of tonality and leaves aside any discussion of rhythm and meter.
Comment: "consonance versus dissonance": yet tonality existed before, and can still exist without, counterpoint and harmony.
Answer: Well, I cannot say that I truly have the answer to your question exactly, but I can at least give you my take on a possible answer.  There seem to be many questions that you have asked, and I'll try to investigate each one of them.
FIRST, In tonal music, the very fact of having a key and having a tonic sets a hierarchical structure of chords in their relationship to the great almighty tonic.  The tonic is, like you said, the king in chess, and I would argue that therefor the dominant is the queen.  The dominant contains the leading-tone, which is an incredibly important note due to its relation to the tonic.  All other chords (i.e. pre-dominants, secondary-dominants, even momentary or expanded modulations and tonicizations) are all (in the big picture) eventually functioning for the purpose of decorating those two fundamental tonic and dominant chords.
SO, your question, then, seems to ask where and why exactly humans have created these rules and ways of thinking about music.  Well, I'm not sure of the historical reasoning for this.  But, When speaking of the WHY aspect to your question, it is here where I think that music might not best be compared to physics or math, but psychology.  If you read up on any Schenkerian analysis, Schenker talks about notes being bodies of masses which have their own gravitational pull.  This isn't necessarily something we recognize by way of algebraic induction or anything, but more as a human psychological response to pitches and their relations to others.  For example, when a tonic is set in stone in our ears, the tonic has a strong and dense mass that will require other notes to be drawn towards it.  It is only when these notes move toward this tonic mass, or RESOLVE, that we feel RESOLUTION.  In this description, we see why it is that the leading-tone is so important in common practice period music.  Our ears have this pull to want to resolve up to that densely important tonic note, and that half-step resolution becomes one of the key concepts in voice-leading, as voice leading helps to make transitioning sound clean from chord to chord, or in other words, contain those half-step resolutions that we want to here so intuitively.  So when we break the rules of tonal music, we are manipulating these resolutions and stretching the concept of what defines as being dissonant and consonant.  One of the all important biggest differences between Jazz and Classical Music is that Classical Music's most important chord in any key is "I", whereas in Jazz, the "I7" chord becomes a staple of total consonance.  That seventh scale degree becomes less of a passing-tone, deriving form Fuxian species counterpoint, and more as an actual diatonic note.
SECOND - It seems to be that when you look at old Medieval and Renaissance (or even acient Greek), and Baroque, Classical, Romantic, and post-tonal music, all of these eras hold different rules and boundaries.  However, they all seem to never change when it comes to understanding INTERVALS.  Intervals are extremely important to observe in the Greek modes and are vital to understanding post-tonal music.  You might look towards the history and development of how we have set rules about intervals because these don't seem to have changed as much through history.  Combinations of intervals make up triads, they make up chords.  They are like the protons and neutrons to the atom (the atom being the triad itself).  They might even the bases for which we can draw similarities between different genres and eras of music.  I know that Schoenberg stressed incredible importance on avoiding repeated imperfect consonances (3rds and 6ths).  By doing so, it too closely implied some sort of tonality in his works.  There really might be something going on here with the importance of our responses to intervals.  I don't know.
Not sure if this helped, but I hope so!
Answer: Basically, as the answers of the others have already suggested, the answer is "yes and no".  Yes, there is a great deal of order imposed upon our ideas of tonality based upon the mathematics of music, which we can perceive to some extent in our feelings of tonal relationships (octaves, fifths, etc) and consonance vs. dissonance of intervals.  No, there is also a lot of historical/accidental culture behind particular choices of what is considered "good" vs. "bad" tonality.  It's not a simple question to answer.
Answer: The pentatonic scale exists in nature. (1 2 3 5 6 1) The greatest common factor of the distances between these notes is 1/2 step. 12 of these distances span an octave. (Chromatic scale)
Educated humans used math to expand the scale by adding 2 notes (4 and 7) creating the major scale. These tones have a strong tendancy to resolve. You might imagine their tension is from being forced in to the scale. the 4 resolves downward by 1/2 to the 3. The 7 resolves upward by 1/2 to the 1.
Tonality is all about tensions and resolutions.
Comment: "the greatest common factor is 1/2 step": that depends on how you define your pentatonic scale.  The greatest common factor of of 9:8, 10:9, and 6:5 is 81:80, which is far smaller than a half step.

Tonality and Rules


Using Struts html tag, render attribute not present in TLD

Question: I'm trying to validate Struts 1.3 - made forms with jQuery Validator plugin. Even though Struts 1.x has reached it's end-of-life, I'm not allowed to switch to another MVC framework.
jQuery validator uses attributes on <input> tag to determine which validation rules to apply. For example:
<input type="text" minlenght="30" required />

will check if the textbox was filled in and it's contents length is at least of 30.
I'm trying to achieve the same with , which is supposed to render as an <input type="text"> element. But minlength and required are not defined in struts-html.tld as attributes, causing the JSP compiler to throw the following (translated from Spanish) exception:
org.apache.jasper.JasperException: /WEB-INF/path-to-my-jsp Attribute xxx invalid for tag xxx according to TLD

According to this question it is possible, despite the fact that Struts is used to generate the form. But I couldn't make it work.
Is there any way to force the JSP compiler to ignore those undefined attributes and make Struts render them "as-is"?
Note: I've chosen jQuery Validator due to it's ease of use, but I'm open to suggestions on other methods to perform the same task. However, I still want to know if it's possible to make the JSP compiler to ignore an invalid / undefined attribute.
P.S. Please excuse my english. I've tried my best.
Comment: you can edit tld and related file to add attribute to it
Comment: I don't think their is way to force the JSP compiler to ignore those undefined attributes.
Comment: You've misspelled `minlength` as `minlenght`.  Perhaps this is your compilation error?
Comment: @rajeshkakawat not a bad idea, but having too many rules, plus the possibility to add custom ones, multiplied by the different input types, makes it hard to maintain
Answer: Quote OP:

"jQuery validator uses attributes on  tag to determine which
  validation rules to apply."

<input type="text" minlenght="30" required />

You do not have to declare rules using HTML5 attributes.
You could instead declare your rules from within the .validate() method:
$(document).ready(function() {

    $('#myform').validate({
        rules: {
            fieldname: {  // <- field name attribute
                required: true,
                minlength: 30
            }
        }
    });

});

Corresponding HTML:
<input type="text" name="fieldname" />

NOTE: the jQuery Validate plugin mandates that the input field contains a unique name attribute no matter how the rules are applied.  The name attribute is how the plugin keeps track of the inputs.  If you fail to assign a unique name attribute, the plugin will behave unpredictably or not at all.

I just noticed that you've misspelled the minlength rule as minlenght.  Perhaps this is the root cause of your compilation error?
Comment: Your tip was very helpful. Actually I didn't copy/paste the real code (my fault). I just tried to write an understandable example. The above java exception is thrown with any attribute not declared in TLD, misspelled or not.


Alpine.js - show/hide div based from select input values

Question: I'm trying to show and hide div's based from a select box selected value. I have my select boxes working so that it changes the value like so:
// x-data="{ week: false, day: false }

            <select @change="week = $event.target.value">
                <option x-bind:value="Week 1">Week 1</option>
                <option x-bind:value="Week 2">Week 2</option>
                <option x-bind:value="Week 3">Week 3</option>
            </select>
            <select @change="day = $event.target.value">
                <option x-bind:value="1">Monday</option>
                <option x-bind:value="2">Tuesday</option>
                <option x-bind:value="3">Wednesday</option>
                <option x-bind:value="4">Thursday</option>
                <option x-bind:value="5">Friday</option>
            </select>

I am then trying to show and hide divs based on the selections like so, but having no luck.

{{ $week['name'] }}

How can I correctly set the class? or can I do this using x-show?
Comment: Is `{{ $week['name'] }}` handled by the backend template system, e.g. Jinja2?
Comment: Yesh, I can confirm that its using blade to set to the same as the values set on the select options.
Answer: When you insert strings from the backend template system, you have to make sure that you place it in a correct environment. Blade does not know that you actually want to generate JS code, it just parses Blade-specific part of the template. In the :class attribute you are missing quotations marks around {{ $week['name'] }}. Blade just inserts the string e.g. Week 1 but you have to add the quotations marks around it to create valid JS code. And yes, you can use the x-show directive to hide/show content. Furthermore instead of @change for input element you can use x-model directive.

<select x-model="week">
    <option x-bind:value="Week 1">Week 1</option>
    <option x-bind:value="Week 2">Week 2</option>
    <option x-bind:value="Week 3">Week 3</option>
</select>
<select x-model="day">
    <option x-bind:value="1">Monday</option>
    <option x-bind:value="2">Tuesday</option>
    <option x-bind:value="3">Wednesday</option>
    <option x-bind:value="4">Thursday</option>
    <option x-bind:value="5">Friday</option>
</select>

{{ $week['name'] }}


Saving a String value with SharedPreferences but for some reason it is not getting saved or due to other issue

Question: I'm trying to save marker with Latlng and two strings with SharedPreferences and i'm doing a for loop to retrieve it when the activity is lunched again i had another question before because i couldn't delete the marker from the SharedPreferences So my mind is so missed up i can't figure it out what is the issue now please check the code below and any suggestions  that could help i appreciated
I'm Using the et String so i match it to Marker title and on Marker Click i delete the Marker from sharedPreferences according to its title and already initilized the SharedPreferences in onCreated Method like so  SharedPrefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
So I save the values like this,
int Int,cycler,IncreaseAmount;
String testSample;
private static final String StringLat= "Latitude",StringLng="Longitude",StringDis="Dis",StringName="Name";

String SinputNames = inputName.getText().toString();
Sinputdiscription = inputdiscription.getText().toString();

dLatitude = AddedLatLng.latitude;
dLongitude = AddedLatLng.longitude;
SharedPreferences.Editor editor = SharedPrefs.edit();

IncreaseAmount++;
editor.putInt("IJSS",IncreaseAmount);
IncreaseAmount = SharedPrefs.getInt("IJSS",0);
//SJSS = SinputNames;
//SJSS = Double.toString(dLatitude);

editor.putString("ErrorTest","Pulling up the info is working");
editor.putLong(SJSS+StringLat,Double.doubleToLongBits(dLatitude));
editor.putLong(SJSS+StringLng,Double.doubleToLongBits(dLongitude));
editor.putString(SJSS+StringName,SinputNames);
editor.putString(SJSS+StringDis,Sinputdiscription);
// editor.putString("lat"+ Integer.toString((IntCoords)), Double.toString(point.latitude));
editor.putString("ForLooper"+Integer.toString((IncreaseAmount)),SinputNames);
editor.apply();

and then pull it off from sharedPreferences
String CheckErrortest = SharedPrefs.getString("ErrorTest","Not working!");

Log.i("AlertSinput:",CheckErrortest);
cycler = SharedPrefs.getInt("IJSS",0);
if(cycler !=0) {
    String Name="";
    double Lat321,Lng321;
//     Log.i("ifCycler","if Cycler != 0 is working");
    Int = SharedPrefs.getInt("IJSS",0) +1;
    for(int i=0; i< Int ; i++ ) {
        Log.i("ForLoop:","The for loop is also working");
        // editor.putString("ForLooper"+Integer.toString((IncreaseAmount)),SJSS+StringLat);

        //Here i can't pull up the info
        String iCheck = SharedPrefs.getString("Forlooper"+Integer.toString((Int)),"");
        Log.i("TheMarkerName:","Should be"+iCheck);
        Name = SharedPrefs.getString(iCheck+StringName,"Marker");
        Lat321 = Double.longBitsToDouble(SharedPrefs.getLong(iCheck+StringLat,0));
        Lng321 = Double.longBitsToDouble(SharedPrefs.getLong(iCheck+StringLng,0));
        Log.i("Markertitle:#",Name);
        Log.i("TestTheInteger:#",Integer.toString((Int)));

        if(Lat321 !=0) {
            AddedLatLng = new LatLng(Lat321,Lng321);
            drawMarker(AddedLatLng,Name);
        }
    }
}

So the CheckErrortest and Log.i("ForLoop:","The for loop is also working");
are working Just fine but the String String iCheck = SharedPrefs.getString("Forlooper"+Integer.toString((Int)),"");
Is not working when i pull up the info for some reason and i couldn't figure out what is the issue anything that could help is appreciated thank you very much
Answer: I don't see you're commiting your changes. You need to do
editor.apply();

or
editor.commit();

All changes you make in an editor are batched, and not copied back to the original SharedPreferences until you call commit() or apply()
Comment: Sorry i did not add it but i'm already applying editor.appy(); thats why the log.i(); is working just fine
Comment: @ alanazi: Isn't possible that you want to use `i` instead of `Int` here? `SharedPrefs.getString("Forlooper"+Integer.toString((Int)),"")`
Comment: Nope, The i is for the for() loop So i don't know what i'm missing :(
Comment: @alanazi Have you triple checked that key being stored on `"ForLooper"+Integer.toString((IncreaseAmount))` is the same you use on get here `"Forlooper"+Integer.toString((Int))`. There isn't a lot of magic here... if the rest works... something should be off with the key.
Comment: WTF the whole time i missspelled the ' editor.putString("ForLooper"+Integer.toString((IncreaseAmount)),SinputNames);' and i get it with an lowercase l lol 'SharedPrefs.getString("Forlooper"+Integer.toString((Int)),"");' i'm so dumb haha
Answer: You need to apply your changes after work with editor.
editor.commit();

or
editor.apply();


Makefile: How to apply an equivalent to filter on multiple wildcards

Question: I am writing a Makefile and I get stuck on a filter function limitation.
Indeed, filter takes only one wildcard.
What I would like to do is:
I have a list a files, some matching the regexp blabla, some not. But for this I need 2 wildcards, thus i cannot use filter function.
I would like to split my original list in 2 lists, one containing all the element containing the blabla string (filter equivalent) and the other one containing the not matching one (filter-out equivalent).
thanks for your help.
Comment: Please provide an example list of files, filter expression and desired result. The way you describe it now, it is not clear to me why the `$(filter ...)` and `$(filter-out ...)` functions are not good enough for you.
Comment: Are you using GNU make or some other variant? And show your current code, it's not clear what the problem is.
Comment: Thanks for your reply. I am using gnu make. I don't have code to show because I can't figure out how to write it.

Say i have LIST= a_old_tt x_old_da a_new_da q_ty_we.

I would like to sort LIST content in:
LIST_OLD that contains all members of LIST containing the expression old (a_old_tt and x_old_da in my example), and
LIST_NOT_OLD  that contains all members of LIST not containing the expression old (a_new_da q_ty_we in my example).
Answer: You can do this without running any external commands. Define the two macros
containing = $(foreach v,$2,$(if $(findstring $1,$v),$v))
not-containing = $(foreach v,$2,$(if $(findstring $1,$v),,$v))

Now you can do
LIST := a_old_tt x_old_da a_new_da q_ty_we
LIST_OLD := $(call containing,old,$(LIST))
LIST_NOT_OLD := $(call not-containing,old,$(LIST))

Comment: Sure, as Beta said in his answer, `make` cannot deal with regular expressions at all, so if you need them (but OP doesn't), you obviously cannot use this answer. The first reaction to this problem is often to bring out the big guns and invoke an external command to do the matching, but as this case shows, that can be huge overkill. I avoid running external commands as much as possible, both for portability and speed. I have seen  huge performance gains from getting rid of unnecessary external commands in large make-based build systems.
Comment: +1, looks reasonable, personally I would implement it in the same way.
Comment: Limiting if you need full regular expressions to compute the 'containing' boolean, but it works for this particular case. I personally wouldn't worry about the external commands, since the performance/inner loop of Make will most likely be in the target, in the build/compile command.
Comment: This doesn't work for me as part of a target dependencies list using %. It just comes up as an empty string. Perhaps it's searching for a literal % sign?
Answer: One of Make's greatest shortcomings is its poor ability to handle regular expressions. The functions filter and filter-out can't find "old" in the middle of a word. I'd suggest this hack:
NOT_OLD = $(shell echo $(LIST) | sed 's/[^ ]*old[^ ]* *//g')
OLD = $(filter-out $(NOT_OLD), $(LIST))

Answer: You could take advantage of your shell's more advanced string handling capabilities. Assuming that you have bash, you could use the following in your makefile:
LIST := a_old_tt x_old_da a_new_da q_ty_we
LIST_NOT_OLD := $(shell l=($(LIST)); echo $${l[@]//*old*})
LIST_OLD := $(filter-out $(LIST_NOT_OLD),$(LIST))

You can find an explanation of the bash string replacement mechanism in how to delete elements from an array based on a pattern. The double $ is required to keep the $ sign in the shell invocation.


Show $(1,1)$ tensor acts as a map from vectors to vectors

Question: In Sean Carroll's Spacetime and Geometry book, pg. 22, it was stated that a (1,1) tensor acts as a map from vectors to vectors:
$${T^\mu}_\nu: V^\nu\rightarrow {T^\mu}_\nu V^\nu.$$
I tried showing this myself by considering the action of the $(1,1)$ tensor $T$ on a vector $V$:
$$T(0,V)={T^\mu}_\nu e_\mu\otimes e^\nu(0,V),$$
where $e_\mu$ and $e^\nu$ are the basis vectors for the vector space and the dual vector space respectively.
I then proceed on to get
$$\begin{equation}
T(0,V)={T^\mu}_\nu e_\mu(0)\times e^\nu(V) \\={T^\mu}_\nu e_\mu(0)\times e^\nu(V^\rho e_\rho)\\={T^\mu}_\nu e_\mu(0)\times V^\rho e^\nu( e_\rho)\\={T^\mu}_\nu e_\mu(0)\times V^\rho \delta^\nu_\rho\\={T^\mu}_\nu \times0\times V^\nu\\=0
\end{equation}$$
where I used $e_\mu(e^\rho)=\delta^\rho_\mu$ so $e_\mu(0)=0$.
The result is clearly not corret. What am I doing wrong?
Comment: @TaeNyFan you are right, you take two arguments - but remember the result you get is linearly dependent on *both* variables, so if one of your variables is 0, the answer will also be zero. Another way of thinking about the question is to think of dual vectors as row vectors, and normal vectors as column vectors. Then a (1,1)-tensor is just an $n\times n$ matrix (so that $T(x^{\perp},y)=x^{\perp} M y$), but then we all know an $n\times n$ matrix is just a map from $V$ to $V$!
Comment: Why are yuou evaluating it on $(0, V)$ and not on $V$?
Comment: @PeterFranek Can you explicitly show what you mean by evaluating on $V$? What I learned is that a rank 2 tensor takes two arguments and produce a number.
Answer: Ok, I think there is some confucion here. First of all, if you admit that $T$ is a map $V\to V$, then the computation is very simple: in coordinates, $T(V)$ would be computed as
$$
(T^\mu_{\,\,\,\nu} e_\mu\otimes e^{\nu}) (V^{\mu'} e_{\mu'}) =
T^\mu_{\,\,\,\nu}  V^\nu e_\mu
$$ (exploiting $e^\nu e_{\mu'} = \delta_{\nu \mu'}$).
That means, the $\mu$-th component of the resulting vector is $T^\mu_{\,\,\,\nu} V^\nu$. In coordinates, i'ts just matrix multiplication.
Formally, if you consider $T$ as a $(1,1)$-tensor, you can think of it as a map $V\otimes V^*\to \mathbb{C}$ (or, if you want, a bilinear map $V\times V^*\to\mathbb{C}$). So then, for any $e^{\mu}\in V^*$ (which is in fact the $\mu$-th coordinate), you get that $T(V \otimes e^\mu)$ (or, if you want, $T(V, e^\mu)$) is indeed the number that is the $\mu$-th coordinate of the vector before. So it's the complex number $T^\mu_{\,\,\,\nu}  V^\nu$.
Maybe this helps: there are natural identifications of these 3 spaces:

Bilinear maps $X\times V^*\to \mathbb{C}$
Linear maps $X\otimes V^*\to \mathbb{C}$
Linear maps $X\to V$.
Comment: That makes sense! So instead of $T(0,V)$, the author actually meant $T(e^\mu,V)$.
Comment: Might be. The $0$ indeed looks strange.


Enumerating all possible combination of values for binary variables

Question: Assume I have n variables that each take on two values: 0 or 1. If I wanted to enumerate all possible combinations of values, that would be 2^n possible combinations. I was wondering how to generate this in a clean and simple way?
Imagine n=4. We would want to produce a numpy array or something similar like the following manually generated example.
[[0 0 0 0]
 [0 0 0 1]
 [0 0 1 0]
 [0 0 1 1]
 [0 1 0 0]
 [0 1 0 1]
 [0 1 1 0]
 [0 1 1 1]
 [1 0 0 0]
 [1 0 0 1]
 [1 0 1 0]
 [1 0 1 1]
 [1 1 0 0]
 [1 1 0 1]
 [1 1 1 0]
 [1 1 1 1]]

Note that the ordering matters. The first column always looks at cases for col1 = 0, then moves on to cases where col1 = 1. Then col2 looks at cases where col2 = 0 given that col1 = 0, then col2 = 1 given that col1 = 0, then col2 = 0 given that col1 = 1, and finally col2 = 1 given that col1 = 1. And so on. Basically I would need this kind of ordering approach to hold regardless on n.
Can this be solved through an iterative approach?
Answer: itertools.product([0, 1], repeat=4) will give an iterator that produces such a sequence. np.array(list(itertools.product([0, 1], repeat=4))) will give you a numpy array.
Comment: @flakes "The nested loops cycle like an odometer with the rightmost element advancing on every iteration. This pattern creates a lexicographic ordering so that if the input's iterables are sorted, the product tuples are emitted in sorted order." - [docs](https://docs.python.org/3/library/itertools.html#itertools.product).
Comment: Does `itertools` guarantee to always format the output as such?
Comment: This is amazing! Thank you!
Answer: Here's a purely numpy solution:
import numpy as np

def bin_array(n):
    numbers = np.arange(2 ** n).reshape(2 ** n, 1)
    exponents = (2 ** np.arange(n))[::-1]
    return ((exponents & numbers) > 0).astype(int)

print(bin_array(4))

Walkthrough with n = 3
numbers will become:
[[0]
 [1]
 [2]
 [3]
 [4]
 [5]
 [6]
 [7]]

exponents will become:
[4 2 1]

(exponents & numbers) applies bitwise-and from each row in numbers to all of exponents:
[[0 0 0]
 [0 0 1]
 [0 2 0]
 [0 2 1]
 [4 0 0]
 [4 0 1]
 [4 2 0]
 [4 2 1]]

((exponents & numbers) > 0).astype(int) reduces this to zero and ones:
[[0 0 0]
 [0 0 1]
 [0 1 0]
 [0 1 1]
 [1 0 0]
 [1 0 1]
 [1 1 0]
 [1 1 1]]

Comment: This is a neat solution as well. Thanks for sharing!
Answer: Well, that's just iterating over the number from 0 to 2^n and printing then in binary notation, so I guess this would work in a simple iterative way:
n = int(input())

for i in range(0, pow(2, n)):
    cur = ""
    for j in range(0, n):
        if i & (1 << j): # If the bit is on add '1' to the string
            cur = cur + '1'
        else:
            cur = cur + '0' # If the bit is off add '0' to the string
    print(cur[::-1]) # Reverse the resulting string


How can I have all drupal links work on ajax based?

Question: Is it possible to have all drupal internal links work on ajax based without any page refresh?
If there is any ready module, please share the link. Your help is really appreciated.
Answer: Maybe this module will help you: http://drupal.org/project/ajax_links_api

Ajax links API module help you to load any content to a specified DIV
  using JQuery Ajax. This module will also load JS and CSS for
  Ajax-loaded content by using Drupal.attachBehaviors(). Links will work
  as normal if Javacript is disabled.
In HTML5 browsers, title bar and url will change using
  window.history.replaceState() (This feature is disabled by default.
  Check ajax_links_api.js to enable).


Irrationality measure of $\alpha+\beta$, $\alpha\beta$

Question: Let $\alpha$ and $\beta$ be real numbers with finite irrationality measures. My question is:

Are the irrationality measures of $\alpha+\beta$ and $\alpha\beta$ also finite?

I tried using triangle inequality
$$
\left| \alpha - \frac {p_1}{q_1} + \beta - \frac{p_2}{q_2}\right| \geq \left| \left| \alpha - \frac{p_1}{q_1}\right|-\left|\beta-\frac{p_2}{q_2}\right|\right|$$for the sum, but this doesn't lead me anywhere. For the product, I am not even sure where to start.
I wonder if this is well-known. If so, I am looking for a reference. If this is true, we would have results as $e+\pi$ has a finite irrationality measure. But, I could not find any reference for such results.
My progress so far is:
If one of $\alpha$, $\beta$ is  a rational number, then the result is true.
From Hata's result, we have
$\pi/\sqrt{k}$ has finite irrationality measure for any integer $k\geq 1$. So, $\pi/\sqrt{k} +1$ has a finite irrationality measure. But, that would not necessarily imply that $\pi+\sqrt{k}$ has finite irrationality measure.
Added on 2017 May 22
In fact $\pi + \sqrt{k}$ has a finite irrationality measure. This can be done by Baker's theorem.

[Baker's Theorem]
If $\alpha_1, \ldots, \alpha_n$ are algebraic numbers, not $0$ or $1$. If $\log\alpha_1, \ldots, \log\alpha_n$ are linearly independent over $\mathbb{Q}$, then $1, \log\alpha_1, \ldots, \log\alpha_n$ are linearly independent over $\overline{\mathbb{Q}}$.
  Moreover, there is an effectively computable constant $C>0$ such that for any algebraic $\beta_0, \ldots, \beta_n$ not all zero,
  $$
|\beta_0+\beta_1\log \alpha_1 + \cdots + \beta_n \log \alpha_n |\geq H^{-C}
$$
  where $H=\max(h(\beta_i))$.

For positive integers $p, q$, we have
$$
|q(\pi+\sqrt k)-p|\geq H^{-C}
$$
where $H=\max(h(q\sqrt k-p) , q^2)\ll q^{A}$ for some effectively computable
constant $A>0$. This shows that $\pi+\sqrt k$ has a finite irrationality measure.
This can be generalized that $\pi+\alpha$, $\pi/\alpha$ has a  finite irrationality measure for any nonzero algebraic $\alpha$.
Answer: By Khinchin's theorem, the set of real numbers $\alpha$ such that $\mu(\alpha)>2$ has Lebesgue measure $0$. It follows that the sets $\{\alpha \in \mathbb R \mid \mu(L-\alpha)>2\}$ and $\{\alpha \in \mathbb R\setminus\{0\} \mid \mu(L/\alpha) > 2\}$ also have Lebesgue measure $0$, where $L$ is Liouville's constant.
So for almost all real $\alpha$, both $\alpha$ and $L-\alpha$ have irrationality measure $2$, yet their sum has irrationality measure $\infty$. Similarly, for almost all real $\alpha$, both $\alpha$ and $L/\alpha$ have irrationality measure $2$, yet their product has irrationality measure $\infty$.
Comment: This answers my question negative. Thank you.
Comment: Although we have the existence of such $\alpha$ but finding it explicitly will be difficult. I have no idea on finding $\alpha$ explicitly.


CSLA CLASSES with C#.net and using of csla clases in different cases

Question: how to code validations for a textbox fields using csla classes,please explain clearly with one example and using of csla classes in different cases..
Answer: The use of business, validation, and authorization rules is covered pretty thoroughly in the Using CSLA 4: Creating Business Objects ebook.


Removing title from content pane

Question: I have used a content pane in a panel to add a description on top of it. It was a success but I can't find a way to remove the pane title in the view. The screenshots are below:

I have also set the content pane title to none

There is no option in the panel for title.
So how can I remove it?
Answer: In the view, there is an 'allow settings' link (bottom right of your screen shot). This allows you to select which settings can be changed within panels, including the title.
You can then, in panels, override the title with an empty string.
Comment: Contrary to what what Nikit said on Povylas's post, _this_ is the correct answer :)
Answer: If I am not mistaken if you write <No Title> in the pane title field the pane title will not be displayed.
Comment: This is correct answer.
Comment: This is good for blocks, but not for pages, because you still want the actual window title. I think removing it through a tpl file is the best method, for me at least.
Answer: In drupal 7, if we don't want to show title in Content Pane, then leave the Title field empty, even don't write None in the textfield, Just leave it empty.
Answer: Module Exclude Node Title:
Configure by content type and display mode from

admin/config/content/exclude_node_title
Answer: I use <none> in the title field. Seems to work just fine.
Answer: If you implement your panel through  hook_default_page_manager_pagesor hook_default_page_manager_handlers you can add this code:
    $pane->configuration = array(
      'override_title' => 1,
      'override_title_text' => '',
      'override_title_heading' => 'h2',
    );

Answer: You can hide the title using CSS, for example with style="display:none;".
Comment: Not the kind of exact formal solution I was looking for but, what the heck, it works. Thanks..

Removing title from content pane


How to declare multiple objects at once

Question: I tried this but it only set the value to obj1
let obj1, obj2, obj3, obj4, ..., objn = {} // only obj1 is set, the rest is undefined.

I looked at this post: assign multiple variables to the same value in Javascript and they suggested this:
let obj1 = obj2 = obj3 = obj4 = ... = objn = {}

But the above says that any change in obj1 will affect obj2, obj3, ...
Is is possible to initialize all obj as {} at once without a for loop ?
Comment: `without a for loop?` yes, you can do it with a `while` loop :D
Comment: I think there is no solution without a loop. If you don't want to have kind of a chained reference.
Comment: Why don't you use an array of objects?
Answer: Using array destructuring assignment, you can use map/reduce to create objects, but neither will be as fast as a for-like loop.

let [o1,o2,o3] = Array(3).fill().map(()=>({}))

o1.id = '1'
o2.id = '2'
o3.id = '3'

console.log(o1)
console.log(o2)
console.log(o3)
Answer: You can use Object.assign, this function come with ES6 syntax, you can check the documentation : Object.assign

const [obj1, obj2, obj3] = [{id: 1}, {id: 2}, {id: 3}];
Object.assign(this, {obj1, obj2, obj3});
Answer:

var [obj, obj2, obj3] = [{"a":1},{"a":2},{"a":3}];

console.log(obj);
console.log(obj2);
console.log(obj3);

This seems to work.
Answer:

let  {obj1, obj2, obj3 }= {obj1:{}, obj2:{}, obj3:{}};

obj1.id =10;
obj2.id =20;
obj3.id =30;

console.log("obj1",obj1);
console.log("obj2",obj2);
console.log("obj3",obj3);
Answer: Here's an interesting way to initialize an arbitrary amount of objects without explicitly initializing an array of values. This answer is very similar to Vol7ron's answer except that this uses a generator function to lazily iterate values without a pre-allocated array. The iterator returned by initialize() will only iterate as far as the destructuring assignment requires, so make sure to not use a ... rest parameter in your destructuring assignment or your iterator will never terminate.

function * initialize (fn) { while (true) { yield fn() } }

const [obj1, obj2, obj3, obj4, obj5, obj6] = initialize(() => ({}))

// all initialized
console.log(obj1, obj2, obj3, obj4, obj5, obj6)
// all unique
console.log(new Set([obj1, obj2, obj3, obj4, obj5, obj6]).size)
Answer: function declareMultipleObjects(...args){
    var arrayOfObjects = []
    args.forEach(function(each){
        each = new Object();
        arrayOfObjects.push(each);
    })

    alert(arrayOfObjects);}

declareMultipleObjects("obj1", "obj2", "obj3");

Comment: While this may answer the question it's better to add some description on how this answer may help to solve the issue. Please read [_How do I write a good answer_](https://stackoverflow.com/help/how-to-answer) to know more.

How to declare multiple objects at once


Display node with mixed languages

Question: My nodes, with entity translation enabled, need to be able to handle a node where the content of the node is displayed differently regarding the labels and menus.
Let's say I am on a french page, displaying a list of all nodes, translated into french or not. If I click on a non-translated projects url I need the node to be displayed in a french environment (menus and labels in french) but displaying the node in its original language.
Any idea how to achieve this?
Answer: This is more or less the default behavior, depending on your Languages Detection and selection configuration.
In Drupal 7 every translation of a node is a new node, with its own node ID. So when you call for that node it will be displayed (call it by node/[nid] or a path alias).
Interface language (menus etc) is calculated separately from content, by the Detection and selection settings (/admin/config/regional/language/configure).
The most common setting is to only enable the URL Detection method and configure your default language not to use the Path prefix language code or Language domain and set one for all the other languages.
This way if you have an English node and you want to open it with a French interface the link should be constructed as:
/fr/node/[englishID]
or
/fr/[french-path]/[english-title-pattern]
So whatever method you're using to display node lists you have to adjust their URLs output to follow that logic.
Comment: Perfect, that seems to work as wished

Display node with mixed languages


Bakery doesn't pre-sync accounts

Question: I want to use the Bakery module to login and synchronize users, but I am not able to synchronize existing accounts. Users that exist only on slave cannot login confirms Bakery doesn't provide pre-sync facility.
May someone help me to synchronize existing user accounts, possibly at database level, for example with drush rsync or sql sync?
Answer: I would go with the migrate module, it's no syncing but export and import in two steps. But i cannot tell you if existing users will be replaced, skipped or doubled ..
Maybe account_sync does what you want.
Also have a look here How to sync users profiles and user tables in 2 drupal sites.
Comment: I want to replicate users with same user id as Master Site, is it possible with "migrate module" or "Account sync" ? ( My Slave DB only have admin, no other users exist)
Comment: uh - if you want the same userid you probably need to do it by a script yourself, or let the users merge themself with [usermerge](https://www.drupal.org/project/usermerge)
Comment: if you only want to sync the slave admin to master, do it by hand !

Bakery doesn't pre-sync accounts


Variance of $\hat{\beta}$ in Ridge Regression

Question: If you are using ridge regression, what happens to the variance of your parameter estimates relative to regular regression?
My intuition is telling me that it would decrease because you are doing a constraint optimization problem so the possible values the function could take are fewer.
Comment: It depends on how you select the penalty.  In many applications the penalty is automatically estimated in some way (perhaps through cross-validation, or otherwise).  To obtain a correct variance estimate, *you need to account for the uncertainty in estimating the penalty.*  The results may confound your intuition.  In particular, *all* of the variables will be involved, not just those whose coefficients have not been driven close to zero in size.
Answer: This question seeks information that is similar to an answer in another question here, though it is not a duplicate of that other question.  Most of the present answer is adapted from the answer to the linked question.
It is possible to obtain a general form for the variance matrix of the ridge-estimator, which holds for all penalty parameters $\lambda$.  To do this, we first write the ridge-estimator \in terms of the underlying regression coefficient and error vector as:
$$\begin{align}
\hat{\boldsymbol{\beta}}(\lambda)
&= (\mathbf{x}^\text{T} \mathbf{x} + \lambda \mathbf{I})^{-1} (\mathbf{x}^\text{T} \mathbf{Y}) \\[6pt]
&= (\mathbf{x}^\text{T} \mathbf{x} + \lambda \mathbf{I})^{-1} \mathbf{x}^\text{T} (\mathbf{x} \boldsymbol{\beta} + \boldsymbol{\varepsilon}) \\[6pt]
&= (\mathbf{x}^\text{T} \mathbf{x} + \lambda \mathbf{I})^{-1} (\mathbf{x}^\text{T} \mathbf{x}) \boldsymbol{\beta} + (\mathbf{x}^\text{T} \mathbf{x} + \lambda \mathbf{I})^{-1} \mathbf{x}^\text{T} \boldsymbol{\varepsilon}. \\[6pt]
\end{align}$$
Using the Woodbury matrix-inverse formula gives the exact form:
$$\begin{align}
(\mathbf{x}^\text{T} \mathbf{x} + \lambda \mathbf{I})^{-1}
&= \frac{1}{\lambda} \bigg( \frac{\mathbf{x}^\text{T} \mathbf{x}}{\lambda} + \mathbf{I} \bigg)^{-1} \\[6pt]
&= \frac{1}{\lambda} \bigg( \mathbf{I} - \frac{1}{\lambda}  \mathbf{x}^\text{T} \bigg( \mathbf{I} + \frac{\mathbf{x} \mathbf{x}^\text{T}}{\lambda} \bigg) \mathbf{x} \bigg) \\[6pt]
&= \frac{1}{\lambda^3} \bigg( \lambda^2 \mathbf{I} - \lambda (\mathbf{x}^\text{T} \mathbf{x}) - (\mathbf{x}^\text{T} \mathbf{x})^2 \bigg), \\[6pt]
\end{align}$$
and this allows us to express the ridge-estimator (or its moments) in terms of matrix operations that do not involve inversion.  (We do not need to give this formula here, and it is somewhat cumbersome at this stage.)  Consequently, the variance matrix for the ridge estimator is given by:
$$\begin{align}
V(\lambda, \mathbf{x})
&\equiv \mathbb{V}(\hat{\boldsymbol{\beta}}(\lambda) | \mathbf{x}) \\[6pt]
&= (\mathbf{x}^\text{T} \mathbf{x} + \lambda \mathbf{I})^{-1} \mathbf{x}^\text{T} \mathbb{V}(\boldsymbol{\varepsilon}) ((\mathbf{x}^\text{T} \mathbf{x} + \lambda \mathbf{I})^{-1} \mathbf{x}^\text{T})^\text{T} \\[6pt]
&= \sigma^2 (\mathbf{x}^\text{T} \mathbf{x} + \lambda \mathbf{I})^{-1} \mathbf{x}^\text{T} \mathbf{I} ((\mathbf{x}^\text{T} \mathbf{x} + \lambda \mathbf{I})^{-1} \mathbf{x}^\text{T})^\text{T} \\[6pt]
&= \sigma^2 (\mathbf{x}^\text{T} \mathbf{x} + \lambda \mathbf{I})^{-1} (\mathbf{x}^\text{T} \mathbf{x}) ((\mathbf{x}^\text{T} \mathbf{x} + \lambda \mathbf{I})^{-1})^\text{T} \\[6pt]
&= \sigma^2 (\mathbf{x}^\text{T} \mathbf{x} + \lambda \mathbf{I})^{-1} (\mathbf{x}^\text{T} \mathbf{x}) (\mathbf{x}^\text{T} \mathbf{x} + \lambda \mathbf{I})^{-1} \\[6pt]
&= \frac{\sigma^2}{\lambda^6} \bigg( \lambda^2 \mathbf{I} - \lambda (\mathbf{x}^\text{T} \mathbf{x}) - (\mathbf{x}^\text{T} \mathbf{x})^2 \bigg) (\mathbf{x}^\text{T} \mathbf{x}) \bigg( \lambda^2 \mathbf{I} - \lambda (\mathbf{x}^\text{T} \mathbf{x}) - (\mathbf{x}^\text{T} \mathbf{x})^2 \bigg) \\[6pt]
&= \frac{\sigma^2}{\lambda^6} \begin{bmatrix}
\lambda^4 \mathbf{I} - \lambda^3 (\mathbf{x}^\text{T} \mathbf{x}) - \lambda^2 (\mathbf{x}^\text{T} \mathbf{x})^2 \\
- \lambda^3 (\mathbf{x}^\text{T} \mathbf{x}) + \lambda^2 (\mathbf{x}^\text{T} \mathbf{x})^2 + \lambda (\mathbf{x}^\text{T} \mathbf{x})^3 \\
- \lambda^2 (\mathbf{x}^\text{T} \mathbf{x})^2 + \lambda (\mathbf{x}^\text{T} \mathbf{x})^3 + (\mathbf{x}^\text{T} \mathbf{x})^4 \\
\end{bmatrix} (\mathbf{x}^\text{T} \mathbf{x}) \\[6pt]
&= \frac{\sigma^2}{\lambda^6} [ \lambda^4 (\mathbf{x}^\text{T} \mathbf{x}) - 2 \lambda^3 (\mathbf{x}^\text{T} \mathbf{x})^2 - \lambda^2 (\mathbf{x}^\text{T} \mathbf{x})^3  + 2 \lambda (\mathbf{x}^\text{T} \mathbf{x})^4 + (\mathbf{x}^\text{T} \mathbf{x})^5 ]. \\[6pt]
\end{align}$$
In a related question here we see that as $\lambda \rightarrow \infty$ the variance matrix reduces to the simple asymptotic form:
$$V(\lambda, \mathbf{x}) \sim \frac{\sigma^2}{\lambda^2} (\mathbf{x}^\text{T} \mathbf{x}).$$


How to use CURLU_ALLOW_SPACE with curl_easy_perform

Question: In the 7.78.0 release the CURLU_ALLOW_SPACE was introduced when rejecting spaces was made default; https://github.com/curl/curl/pull/7073.
Is it possible to allow spaces when using curl_easy_init/curl_easy_setopt/curl_easy_perform?
Comment: Could you explain with examples what you mean? How spaces allowness is expected to affect those functions?
Answer: You need to create CURLU object and set the URL by curl_url_set() and then set your easy handle to use it by curl_easy_setopt().
A small example:
CURLcode result;
CURL *easyp = curl_easy_init();
if (easyp == NULL)
  return error();

CURLU *urlp = curl_url();
if (urlp == NULL)
  return error();

if (curl_url_set(urlp, CURLUPART_URL,
                 "https://example.com/space path",
                 CURLU_ALLOW_SPACE) != CURLUE_OK)
  handle_error();

if (curl_easy_setopt(easyp, CURLOPT_CURLU, urlp) != CURLE_OK)
  handle_error();

result = curl_easy_perform(handle);

curl_url_cleanup(urlp);
curl_easy_cleanup(handle);

return result;

You may also want to use CURLU_PATH_AS_IS option.


Affine map maps simplex onto a simplex

Question: I am reading John Lee's Introduction to Topological Manifolds and I am trying to prove Theorem 5.39 (Simplicial Maps are determined by vertex maps. Let $K$ and $L$ be simplicial complexes. Suppose $f_0:K_0 \to L_0$ is any map with the property that whenever $\{v_0,\dots,v_k\}$ are the vertices of a simplex of $K$, $\{f_0(v_0),\dots, f_0(v_k)\}$ are the vertices of a simplex of $L$ (possibly with repetitions). Then there is a unique simplicial map $f: |K| \to |L|$ whose vertex map is $f_0$. It is a simplicial isomorphism if and only if $f_0$ is a bijection satisfying the following additional condition: $\{v_0,\dots, v_k\}$ are the vertices of a simplex of $K$ if and only if $\{f_0,\dots, f_0(v_k)\}$ are the vertices of a simplex of $L$.
An affine map $F: \mathbb{R}^n \to \mathbb{R}^m$ is any map of the form $F(x)=c+A(x)$, where $A$ is a linear map and $c$ is some fixed vector in $\mathbb{R}^m$.
$\sigma=[v_0,\dots, v_k]$ is a $k$-simplex if $\{v_0,\dots, v_k\}$ is an affinely independent set of $k+1$ points in $\mathbb{R}^n$ and $[v_0,\dots v_k]=\{\sum_{i=0}^k t_i v_i : t_i \ge 0\; \text{and} \;\sum_{i=0}^k t_i=1\}.$ Each of the points $v_i$ is called a vertex of the simplex.
Given a set of vertices $\{v_0,\dots, v_k\}$, for which $\{f_0(v_0),\dots f_0(v_k)\}$ are the vertices of a simplex of $L$ (possibly with repetitions), I am trying to use Proposition 5.38 which states that given $\sigma=[v_0,\dots, v_k]$ a $k$-simplex in $\mathbb{R}^n$, and any $k+1$ points $w_0,\dots, w_k \in \mathbb{R}^m$, there is a unique map $f:\sigma \to \mathbb{R}^m$ that is the restriction of an affine map, and takes $v_i$ to $w_i$ for each $i$.
I can prove the theorem if I can show that $f$ takes $\sigma$ onto a simplex of $L$. But I can't show why the affine map maps a simplex onto another simplex. How can we prove this from the definition? I would greatly appreciate some help.
My attempt: The image of $f(\sigma)$ is of the form $\{f(\sum_{i=0}^k t_i v_i): t_i\ge 0, \sum_{i=0}^k t_i =1\}$.
$f(\sum_i t_i v_i) =c+A(\sum_i t_i v_i) = c+ \sum_i t_i A v_i = \sum_i t_i c + \sum_i t_i A v_i = \sum_i t_i(c + Av_i)=\sum_i t_i f(v_i)=\sum_i t_i f_0(v_i),$ because $\sum_i t_i=1$.
So the image of $f(\sigma)$ is $\{\sum_{i=0}^k t_i f_0(v_i): t_i \ge 0 \; \text{and}\; \sum_{i=0}^k t_i=1\}$. But I can't conclude that $f(\sigma)=[f_0(v_0),\dots, f_0(v_k)]$ because the definition requires $\{f_0(v_0),\dots, f_0(v_k)\}$ be affinely independent, and indeed here they may be some repetitions. So assume that $\{f_0(v_0),\dots , f_0(v_l)\}$ are the vertices of a simplex of $L$ by hypothesis of the Theorem. Then by the definition of a vertex, these points are affinely independent, and $[f_0(v_0),\dots, f_0(v_l)]=\{\sum_{i=0}^l t_i f_0(v_i): t_i \ge 0, \sum_{i=0}^l t_i=1\} $ is exactly the set $\{f(\sum_{i=0}^k t_i v_i):t_i\ge 0, \sum_{i=0}^k t_i=1\}$ because in the sum above we can combine the repetitive points together.
Comment: @MW You are right I should have included the full statement. I updated it and also my attempt which I think now is correct.
Comment: Any chance you could show us what you have tried so far? You want to show that $f(\sigma)$ satisfies the definition of a simplex, using the fact that $\sigma$ satisfies the definition of a simplex and $f$ satisfies the definition of an affine map.
Comment: I am not sure what you ask. Is the question whether the image of a simplex under an affine map is a simplex? And what is $f_0$?
Comment: @KritikerderElche $f_0$ is just a map of vertices. So $f_0(v_i)$ are just vertices of $L$ possibly with repetitions. My question is how to show that the image of a simplex under an affine map is a simplex.
Comment: @Deane I have updated my attempt and hopefully it's clear where I'm stuck at.
Comment: Even after your update I don't see a statement of the theorem you are trying to prove...
Comment: @MW Where isn't it clear? I am trying to prove that given an affine map $f$ that maps the simplex $[v_0,\dots, v_k]$ which takes each $v_i$ to $f_0(v_i)$ (where $f_0(v_i)$ have possible repetitions), the image of the simplex under $f$ will be a simplex with vertices contained in $\{f_0(v_0),\dots, f_0(v_k)\}$.
Comment: @nomadicmathematician Maybe I'm missing something obvious but I didn't notice any statement to that effect in the main post.  I think it would help clarify things greatly to put a formal statement of whatever theorem 5.39 is, since without having access to the text its not clear at all what that theorem says.
Comment: Looks good to me.
Answer: A $k$-simplex in $\mathbb R^n$ is the convex hull $\sigma = [v_0,\ldots,v_k]$ of $k+1$ point $v_i \in \mathbb R^n$ which are affinely independent.
Q1. Given an affine map $F : \mathbb R^n \to \mathbb R^m$, is $F(\sigma)$ a simplex in $\mathbb R^m$?
In general no. You have shown in your question that it is the convex hull of the points $F(v_i) \in \mathbb R^m$, thus it is a convex subset of $\mathbb R^m$. But Lee's Proposition 5.38 shows that the $F(v_i)$ can be arbitrary (not necessarily distinct) points of $\mathbb R^m$. For example, consider a $4$-simplex $\sigma = [v_0,\ldots,v_4] \subset \mathbb R^n$ for $n \ge 4$. Then there is an affine map $F : \mathbb R^n \to \mathbb R^2$ such that $F(v_i) = w_i$ with
$$w_0 = (0,0), w_1 = (1,0), w_2 = (1,1), w_3 = (0,1),  w_4 = (1/2,1/2) .$$
$F(\sigma)$ is the square with vertices $w_0, w_1, w_2, w_3$. The point $w_4$ lies in the interior of of the square.
Q2. If the $v_i \in \mathbb R^n$ are affinely independent, does there exist a unique affine map $F : \mathbb R^n \to \mathbb R^m$ which maps the $v_i$ to the prescribed $w_i$?
This is is true only when $n = k$. As in Lee's proof it suffices to consider the case $v_0 = w_0 = 0$. If $n = k$, then $\{v_1,\ldots,v_k\}$ is a basis of $\mathbb R^k$ and we get uniqueness. If $n > k$, we can extend the linearly independent set $\{v_1,\ldots,v_k\}$ to a basis $B$ of $\mathbb R^k$. Then each $b \in B \setminus \{v_1,\ldots,v_k\}$ can be mapped arbitrarily into $\mathbb R^m$ which produces infinitely many $F$ with $F(v_i) = w_i$.

The point of Proposition 5.38 is that all these maps agree on $\sigma$.

Q3. So what does Proposition 5.39 say?
The essence is this:
By Proposition 5.38 there exists a unique $f: \sigma \to \mathbb R^m$ which is restriction of an affine $F : \mathbb R^n \to \mathbb R^m$ such that $F(v_i) = f_0(v_i)$.
If the set $f_0(\{v_0,\ldots,v_k\}$, which can be written in the form $\{w_0,\ldots,w_r\}$ with pairwise distinct $w_i$, is the vertex set of an $r$-simplex in $\mathbb R^m$ (which means that the $w_i$ are affinely independent), then $f(\sigma)$ is the simplex $[w_0,\ldots,w_r]$.
In fact, we know that $f(\sigma)$ is the convex hull of the set $\{w_0,\ldots,w_r\}$ .

Affine map maps simplex onto a simplex


Find a formula for partial sums

Question: How to find a formula for:
$$
\sum_{n=1}^N \frac{1}{n\,(n+2)\,(n+3)}\:\:\:?
$$
I have tried to decompose each term into partial fractions to get a telescoping sum, but similar terms are too scattered around for me to find a pattern:
$$
a_n = \frac{1}{6n} - \frac{1}{2n+4} + \frac{1}{3n+9}, \: n \geqslant1
$$
WolframAlpha gives the answer $\frac{5}{36}$ for the infinite sum which I am interested in, and yes, I know what telescopic cancellation is as mentioned above.
$$\sum\limits_{n=1}^N\frac 1{n(n+2)(n+3)}=\frac {N(5N^2+30N+37)}{36(N+1)(N+2)(N+3)}$$
Comment: You have done most of the job, now just do a change of index to cancel most terms since $\frac{1}{6} - \frac{1}{2} +\frac{1}{3}=0$.
Comment: @JeanMarie done.
Comment: You should include in your post the things you have tried, what techniques do you know, or where you're stuck in your process, or else you'll get downvoted and probably won't get a good answer
Comment: @alosc okay thanks
Comment: Why do you think such a formula exists ?
Comment: You have ill-typed your formula, it should be $\sum_{k=1}^n \frac{1}{k(k+2)(k+3)}$
Comment: @JeanMarie because WolframAlpha says so
Comment: $\frac1{2n+4}=\frac1{3n+6}+\frac1{6n+12}$. Then?
Comment: 1) What is the answer given by Wolfram Alpha ? 2) Do you know the technique called "telescopic cancellation" ? it could be a way to solve your problem.
Comment: I don't understand : the answer 5/36 is surely for $N=\infty$. But you want a closed-form formula for a finite $N$...
Comment: @JeanMarie sorry, I'm a little bit tired rn, edited again
Comment: @Lelouch solved, I'll post the answer soon
Answer: You have done most of the job. Just note that $(\frac{1}{6} - \frac{1}{2} +\frac{1}{3}) = 0$ (which is always the kind of equality required when we want to do telescoping after a partial fractions decomposition).
\begin{align}
\sum_{k=1}^n \frac{1}{k(k+2)(k+3)} &= \frac{1}{6} \sum_{k=1}^n \frac{1}{k} - \frac{1}{2} \sum_{k=1}^n \frac{1}{k+2} + \frac{1}{3} \sum_{k=1}^n \frac{1}{k+3} \\
&= \frac{1}{6} \sum_{k=1}^n \frac{1}{k} - \frac{1}{2} \sum_{k=3}^{n+2} \frac{1}{k} + \frac{1}{3} \sum_{k=4}^{n+3} \frac{1}{k} \\
&= (\frac{1}{6} - \frac{1}{2} +\frac{1}{3}) \sum_{k=4}^n \frac{1}{k} + \frac{1}{6} ( 1 + \frac{1}{2} + \frac{1}{3}) - \frac{1}{2}(\frac{1}{3} + \frac{1}{n+1} + \frac{1}{n+2}) + \frac{1}{3} (  \frac{1}{n+1} + \frac{1}{n+2} + \frac{1}{n+3}) \\
&= \frac{1}{6} ( 1 + \frac{1}{2} + \frac{1}{3}) - \frac{1}{2}(\frac{1}{3} + \frac{1}{n+1} + \frac{1}{n+2}) + \frac{1}{3} (  \frac{1}{n+1} + \frac{1}{n+2} + \frac{1}{n+3}) \\
\end{align}
Then it is only a matter of simplification.
As a sanity check we can notice that this expressions goes to $\frac{1}{6} ( \frac{1}{2} + \frac{1}{3} ) = \frac{5}{36}$ when $n$ goes to infinity.
Answer: $$
\sum_{n=1}^{N} a_n = \frac16\sum_{n=1}^N\frac1n - \frac12\sum_{n=3}^{N+2}\frac1n + \frac13\sum_{4}^{N+3}\frac1n  \\=\frac{5}{36}
+\frac13\left(\frac1{N+1} + \frac1{N+2}+ \frac1{N+3}\right) - \frac12\left(\frac1{N+1} + \frac1{N+2}\right)
$$

Find a formula for partial sums


Snowboarding in powdery trees

Question: I have been snowboarding for 10 years on and off and would consider myself intermediate.  I am confident on all runs and most off piste situations but as soon as I get in tight trees with powder, I lose it.
Any tips on how to improve my style in trees with powder snow?
Answer: 3 things I've found for tight areas:

Wear a helmet, I've bounced off of trees and it HURTS.
Move both of your bindings back at the start of the day to help you keep your weight over the back, preventing the tip from digging in and sending you into a cartwheel.
Don't push too hard into the outer branches of the trees, the branches catch all the snow meaning there's often a big hole underneath that's very easy to fall into, and very hard to climb out of.
Comment: +1 - very good points. All have caught me out before :-)
Answer:
Start your turns early, which will result in wider turns.
Use minimal edge; keep board as flat as possible while maintaining control.
Look where you're going (ideally, a couple turns ahead), rather than at the trees.
Answer: Work your way into tight areas.
Go find some trees with a good bit of space between them, where you can start getting used to the flow of picking a side and how hard to cut into each one.
Gradually move into areas where the trees are tighter together. If things get hairy, don't try and come to a stand-still, you'll wind up hitting something anyway while you're out of position, which winds up being even worse. Instead, focus on going left or right of every tree (whichever you're more confident with or whichever works with the flow you're in). If you just focus on doing that you'll eventually wind up bleeding off enough speed to regroup or come to a stand still.
And definitely wear a helmet!

Snowboarding in powdery trees


User unable to change password - Active Directory Group Policy

Question: I've seen this issue come up, but no answers seem to be applicable.
When a user tries to change their password using control-alt-delete -> change password, they're getting a "Unable to update the password. The value provided for the new password does not meet the length, complexity, or history requirements of the domain." We've even tried extremely long complex strings as tests, which also generates the error message.
In AD U&C, I can force the account password to be changed on next logon, which works successfully.
The applicable security setting is applied at the domain level in the Default Domain Policy GPO.  When I run a gpupdate /force and then view the RSOP on one of the workstations, I can see the settings below (which are consistent with the GPO):

Enforce Password History: 2 passwords remembered
Maximum Age: 120 days
Minimum password age: 0 days (this is enabled and set to 0 days in the GPO)
Minimum Length: 6 characters
Password must meet complexity requirements: disabled
Store passwords using reversible encryption: disabled

I've run a dcdiag against our DC's. They pass all tests. Any suggestions on why this problem might be occurring, or how to remedy it?
Comment: After running RSOP on the DC, all settings were listed as "Not defined". If I run "net accounts" on the DC, I can see that it has a minimum password age of 30 days. I've checked both GPO's that apply to the domain controllers (Default domain policy, and Default Domain Controller Policy. Both policies are set to have a minimal age of 0 days. I did a gpupdate /force on the DC, and ran net accounts, and it is still displaying a 30 day minimum age.
Answer: It appears that your default domain policy is enforcing minimum password complexity- you will probably need to edit Group Policy if you want to change this behaviour.
From Microsoft:
"Password must meet complexity requirements
This policy setting checks all new passwords to ensure that they meet basic requirements for strong passwords. By default, the value for this policy setting in Windows Server 2008 is configured to Disabled, but it is set to Enabled in a Windows Server 2008 domain for both environments described in this guide.
When this policy setting is enabled, users must create strong passwords to meet the following minimum requirements:
Passwords cannot contain the user's account name or parts of the user's full name that exceed two consecutive characters.
Passwords must be at least six characters in length.
Passwords must contain characters from three of the following four categories:
English uppercase characters (A through Z).
English lowercase characters (a through z).
Non-alphabetic characters (for example, !, $, #, %).
Each additional character in a password increases its complexity exponentially.
For instance, a seven-character, all lower-case alphabetic password would have 267 (approximately 8 x 109 or 8 billion) possible combinations.
At 1,000,000 attempts per second (a capability of many password-cracking utilities), it would only take 133 minutes to crack such a password.
A seven-character alphabetic password with case sensitivity has 527 combinations.
A seven-character case-sensitive alphanumeric password without punctuation has 627 combinations.
An eight-character password has 268 (or 2 x 1,011) possible combinations. Although this might seem to be a large number, at 1,000,000 attempts per second it would take only 59 hours to try all possible passwords.
Remember, these times will significantly increase for passwords that use ALT characters and other special keyboard characters such as "!" or "@".
Proper use of the password settings helps to prevent the success of a brute force attack."
Source: http://technet.microsoft.com/en-us/library/cc264456.aspx
Answer: I see you have run the RSOP on the workstation.  This will affect local accounts, but if the password being changed is a domain account it will be validated against the RSOP on the domain controller processing the password change if I recall.
Additionally, it is possible to write third-party plugins which validate password complexity using the windows API.  Hitachi ID Systems publishes one such component (which queries a remote server to check whether the password meets the rules set out there); when such a plugin rejects the password it looks identical to what happens when the Windows builtin 3-of-4 complexity rule rejects it.  You should investigate as to whether you have such things in your environment (they would be installed on the DCs) and if they are, either determine what is wrong with them, or get rid of them.
That said, since forcing a password change fixes the problem, it's probable that the issue is that a minimum age rule is getting applied.  Check the RSOP on the DC for this.
Answer: Confirm that, no fine grained password policies is created or applied for that particular user account (If the functional level is 2008 or later). Check msDS-resultantPSO attribute for the user, it contains the applied fine grained password policy for the corresponding user. msDS-resultantPSO is a constructed attribute. If the attribute is not available is not available, default domain policy is applied.


Cassandra - Is there a way to limit number of async queries?

Question: I would like to know if there is way to limit the number of queries executed simultaneously by the cassandra java driver ?
Currently, I execute a lot of queries as follows :
...
PreparedStatement stmt = session.prepare("SELECT * FROM users WHERE id = ?");
BoundStatement boundStatement = new BoundStatement(stmt);
List<ResultSetFuture> futures = Lists.newArrayListWithExpectedSize(list.length);

for(String id : list ) {
     futures.add(session.executeAsync(boundStatement.bind(id)));
}

for (ListenableFuture<ResultSet> future : futures) {
ResultSet rs = future.get();
... // do some stuff
}

Unfortunately, this may lead to NoHostAvailableException.
Thanks you.
Answer: You can use a semaphore to throttle the number of concurrent queries:
final Semaphore semaphore = new Semaphore(numberOfConcurrentQueries);
...
semaphore.acquire();
try {
    ResultSetFuture future = session.executeAsync("...");
    Futures.addCallback(future, new FutureCallback<ResultSet>() {
        @Override
        public void onSuccess(ResultSet result) {
            semaphore.release();
        }

        @Override
        public void onFailure(Throwable t) {
            semaphore.release();
        }
    });
} catch (Exception e) {
    semaphore.release();
}

But at the end of the day it's not so different: instead of getting a NoHostAvailableException when you exceed the capacity, the semaphore will block (or throw if you use a timed version of acquire). So you'll probably want to apply backpressure to the component that triggers these queries as well.
You might also want to tune your connection pools to adjust the capacity, see our docs (that's for 2.1, use the dropdown at the top of the page if you're on 2.0).


Evaluate these series

Question: Please help me to evaluate these series. I am working on my physics project and I have encountered to these series. I know that
$\sum\limits_{n = 0}^\infty  {\frac{{{{(\alpha )}^{2n}}}}{{(2n)!}}}$
is $\cos$ function, but I have problem with $n$. How do i evaluate these series?
$$\sum\limits_{n = 0}^\infty  {n\frac{{{{(\alpha )}^{2n}}}}{{(2n)!}}} $$
and
$$\sum\limits_{n = 1}^\infty  {n\frac{{{{(\alpha )}^{2n - 1}}}}{{(2n - 1)!}}}$$
Comment: 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 put on hold. To prevent that, please [edit] the question. [This](http://goo.gl/PlJyVQ) will help you recognise 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: Hint. Note that for $n\geq 1$,
$$ {n\frac{{{{(\alpha )}^{2n}}}}{{(2n)!}}}=\frac{\alpha}{2} \cdot{\frac{{{{(\alpha )}^{2n-1}}}}{{(2n-1)!}}}\quad
\text{and}\quad {n\frac{{{{(\alpha )}^{2n - 1}}}}{{(2n - 1)!}}}=\frac{d}{d\alpha}\left(\frac{\alpha}{2} \cdot{\frac{{{{(\alpha )}^{2n-1}}}}{{(2n - 1)!}}}\right).$$
Now recall the expansions of the main hyperbolic functions.
Answer: Since
$$
\sinh x = \sum\limits_{n = 1}^{ + \infty } {\frac{{x^{2n - 1} }}
{{\left( {2n - 1} \right)!}}}
$$
you have that
$$
x\sinh x = \sum\limits_{n = 1}^{ + \infty } {\frac{{x^{2n} }}
{{\left( {2n - 1} \right)!}}}  = \sum\limits_{n = 1}^{ + \infty } {2n\frac{{x^{2n} }}
{{2n\left( {2n - 1} \right)!}}}  = 2\sum\limits_{n = 1}^{ + \infty } {n\frac{{x^{2n} }}
{{\left( {2n} \right)!}}}
$$
thus
$$
\sum\limits_{n = 1}^{ + \infty } {n\frac{{x^{2n} }}
{{\left( {2n} \right)!}}}  = \frac{1}
{2}x\sinh x
$$
By derivation you get the other series

Evaluate these series


How can I view the cache-hit ratio for a single column-family in Cassandra?

Question: I've enabled row-caching in for one of my column-families in Cassandra and I'l like to view the cache-hit ratio?
I can see the cache-hit ration metric in Cassandra's OspCenter but it seems to show me the information for the entire cluster? Is there a way I could get this metric?
Answer: As of version 1.2, the key cache and row cache are global to make better use of the off-heap functionality. Unfortunately, this means those stats are no longer available on the column family level.
If you only have it enabled for one column family, you should be able to see what you need via the global stats per-node on the cassandra-level options (I think that's what they are called in OpsCenter, have not looked in a while) when you go to 'Add a Graph.'
These stats are available from the command line via nodetool info (last 2 lines of output).


Asks me to specify electronVersion in a webdriverio/electron project, but I already have

Question: Working on a webdriverIO project for an electron app. When I try to run it it tells me:
Error in "undefined"
Error: Failed to initilialise launcher service "electron":
Error: You must specify the electronVersion, or provide a chromedriverCustomPath value
    at new ChromeDriverLauncher (file:///C:/Users/Me/Myproject/node_modules/wdio-electron-service/dist/launcher.js:62:50)
    at initialiseLauncherService (file:///C:/Users/Me/Myproject/node_modules/@wdio/utils/build/initialiseServices.js:97:39)
    at async Launcher.run (file:///C:/Users/Me/Myproject/node_modules/@wdio/cli/build/launcher.js:69:65)
    at initialiseLauncherService (file:///C:/Users/Me/Myproject/node_modules/@wdio/utils/build/initialiseServices.js:118:15)
    at async Launcher.run (file:///C:/Users/Me/Myproject/node_modules/@wdio/cli/build/launcher.js:69:65)

However in my wdio.config.js, I've already done that:
wdio.config.js
services: [
    'chromedriver', {
        logFileName: 'wdio-chromedriver.log',
        outputDir: 'driver-logs',
        args: ['--silent']
    },
    'cucumber-viewport-logger',
    'electron',
    {
        appPath: join(dirname, './packages/client/.build/main.js'),
        appName: 'appname',
        appArgs: [''],
        binaryPath: './node_modules/.bin/electron.cmd',
        chromedriver: {
            port: 9519,
            logFileName: 'wdio-chromedriver.log',
        },
        electronVersion: '^13.1.4',
    },
],

I took that formatting exactly from the docs.
package.json
"devDependencies": {
    "@types/chalk": "^2.2.0",
    "@types/chart.js": "^2.9.34",
    "@types/command-line-args": "^5.0.0",
    "@types/execa": "^2.0.0",
    "@types/node": "^14.6.0",
    "@types/request": "^2.48.7",
    "@typescript-eslint/eslint-plugin": "^2.18.0",
    "@typescript-eslint/parser": "^2.18.0",
    "@wdio/allure-reporter": "^8.5.0",
    "@wdio/cli": "^8.5.8",
    "@wdio/cucumber-framework": "^8.5.6",
    "@wdio/local-runner": "^8.5.8",
    "chromedriver": "110.0.0",
    "command-line-args": "^5.1.1",
    "cross-env": "^7.0.2",
    "electron-packager": "^15.2.0",
    "electron-wix-msi": "^3.2.0",
    "eslint": "^6.8.0",
    "eslint-plugin-import": "^2.20.0",
    "execa": "^4.0.3",
    "rimraf": "^3.0.2",
    "ts-node": "^10.9.1",
    "typescript": "^4.1.5",
    "wdio-chromedriver-service": "^8.1.1",
    "wdio-cucumber-viewport-logger-service": "^1.0.4",
    "wdio-electron-service": "^4.0.0",
    "webdriverio": "8.5.8",
    "yarn-run-all": "^3.1.1"
}

Can anyone deliver salvation? I don't know what the issue is. I even tried to put in a chomedriverCustomPath and got the same message.
Answer: I had same issue, and resolved removing ^ from version:
package.json
{
  ...
  "devDependencies": {
    ...
    "electron": "<exact version>" # without ^ or ~
  }
}

wdio.conf.js
const electronVersion = require('./package.json').devDependencies.electron
...

{
        appPath: join(dirname, './packages/client/.build/main.js'),
        appName: 'appname',
        appArgs: [''],
        binaryPath: './node_modules/.bin/electron.cmd',
        chromedriver: {
            port: 9519,
            logFileName: 'wdio-chromedriver.log',
        },
        electronVersion: electronVersion,
    }


npm ERR while installing ionic

Question: I am on Windows 10 trying to install Ionic. I ran the following code in the terminal:
npm install -g @ionic/CLI

And I get this error:
npm ERR! code EEXIST
npm ERR! path C:\Users\Lari\AppData\Roaming\npm\ionic.ps1
npm ERR! Refusing to delete C:\Users\Lari\AppData\Roaming\npm\ionic.ps1: is outside C:\Users\Lari\AppData\Roaming\npm\node_modules\@ionic\cli and not a link
npm ERR! File exists: C:\Users\Lari\AppData\Roaming\npm\ionic.ps1
npm ERR! Remove the existing file and try again, or run npm
npm ERR! with force to overwrite files recklessly.

npm ERR! A complete log of this can be found in:
npm ERR! C:\Users\Lari\AppData\Roaming\npm-cache\_logs\2020-08-12T22_24_22_577Z-debug.log

I have ran the following commands to debug:

npm uninstall -g ionic
npm install -g @ionic/cli
npm install -g cordova @ionic/cli

and much more for over a week now.
Answer: I copied and paste this path in windows
C:\Users\Lari\AppData\Roaming\npm\ionic
Deleted all ionic folders, and then this path
C:\Users\Lari\AppData\Roaming\npm
Deleted some ionic files present as well.
Ran npm I -g @ionic/cli and it did install version 6.11.0.
Thanks everyone, hope it helps someone

npm ERR while installing ionic