Practical (not theoretical) examples of where a 1 sided test would be valid?

Question: I know that it is generally accepted that the two-sided test is the "Gold Standard". However, I just wanted to see if there are real life, practical applications of the one-sided test in the real world, or if this only exists in academia.
Edit: "Generally accepted / Gold Standard" in the sense of being the default recommendation in the book Introduction to Statistical Learning, 2nd ed., p.558, footnote 8:

A one-sided $p$-value is the probability of seeing such an extreme value of the test statistic; e.g. the probability of seeing a test statistic greater than or equal to $T$=2.33. A two-sided $p$-value is the probability of seeing such an extreme value of the absolute test statistic; e.g. the probability of seeing a test statistic greater than or equal to 2.33 or less than or equal to −2.33. The default recommendation is to report a two-sided $p$-value rather than a one-sided $p$-value, unless there is a clear and compelling reason that only one direction of the test statistic is of scientific interest.
Comment: "generally accepted that the 2 sided test is the Gold Standard", this is news to me, could you let me know where you read this? Also, I have to admit I'm not used to one-sided tests being viewed as academic; indeed I suspect many are more inclined to view 2-sided tests "trivial" if we had to pick one of the two :). A few standard situations where 1 sided tests are appropriate: a) I developed a new product and I want to test if it's better than the old b) I want to know if women in my organization are paid less than men c) I want to know if variation in my industrial process is increasing
Comment: (And by the way most standard tests using F- and chi-squared distributions are normally used one-sided.)
Comment: I'm not sure that I would equate "Default Recommendation" with "Gold Standard" ;) Glad you found them useful
Comment: @Katsu I don't think there should be any "default recommendation" for either one- or two-sided p-values. People should be encouraged to think about what the scientific interest is in *any* situation. Tests and p-values have been recently criticised a lot for thoughtless mis- and overuse, and using "default recommendations" may well contribute to that. (Also statistical tests are around for much longer than the field of Machine Learning, and any ML book, "Bible" or not, shouldn't be considered a top authority on them.)
Comment: In the defence of the biblical comparison, the authors of ISLR are Trevor Hastie, Robert Tibshirani, Daniela Witten, and Gareth James. Each has forgotten more statistics than I ever learned. It is an excellent book, has a 2nd edition, is [freely available](https://hastie.su.domains/ISLR2/ISLRv2_website.pdf), and hence very prominent. This book is not unique in this recommendation.
Comment: @Katsu I've added the ISL quote to your question, since I found it crucial to understanding what you are asking. Also, while ISL's authors are excellent statisticians, this book is **not** meant to be an introduction to the ideas of statistical inference (confidence intervals and hypothesis testing). ISL's material on these topics is meant as a **brief reminder** of things you learned from a course on those topics; a novice to those topics needs a more careful treatment than what's given here. So if you never took such a course, please do find an Intro to Statistics book to complement ISL!
Comment: it's just that gold standards and default recommendations are two entirely different things
Comment: @Katsu Two-sided and one-sided tests give *their respective hypotheses* the same error rate of $\alpha$. The one-sided hypotheses are indeed broader (since $H_0^{TS}:\Delta \ne k$ is just a single point, while $H^{RS}_0:\Delta \le k$ and $H^{LS}_0:\Delta \ge 0$ are wider since they are a region), making one-sided nulls easier to reject. Just like a bigger boat is easier to torpedo than a small one. But it's not correct to say one-sided are laxer since they are very different hypotheses.
Comment: It's "is this new drug that I discovered better OR worse than no/old drug?" vs. "is the new drug better or at least the same as the old drug." Effective is a directional claim since the desired result is to make people healthier. Two-sided is for showing that it does something, and something can be good OR bad.
Comment: @JohnMadden bottom of page 558, introduction to statistical learning 2nd edition: "A two-sided p-value is the probability of seeing such an extreme value of the absolute
test statistic; e.g. the probability of seeing a test statistic greater than or equal to 2.33
or less than or equal to −2.33. The default recommendation is to report a two-sided
p-value rather than a one-sided p-value, unless there is a clear and compelling reason
that only one direction of the test statistic is of scientific interest."
Comment: @JohnMadden those sound like great practical examples though!
Comment: Default recommendation coming from the Bible of Machine Learning sounded like Gold Standard to me! Happy to be corrected!
Comment: Anybody trying to demonstrate something meets a threshold: a quality control expert, an environment pollution monitor, a financial monitor, *etc.*, cares in the first place about a one-sided alternative.
Comment: @dimitriy The "biblical" recommendation could in my view only be convincingly defended by convincing arguments. Author names are not arguments.
Comment: [Two one-sided tests for equivalence](https://stats.stackexchange.com/tags/tost/info) (TOST) can test null hypotheses of the general form $\text{H}_{0}\text{: }|\theta|\ge \Delta$ by breaking it into two one-sided specific null hypotheses: $\text{H}_{01}\text{: }\theta\ge \Delta$ and $\text{H}_{02}\text{: }\theta\le -\Delta$ in order to decide that there is evidence that $-\Delta \le \theta \le \Delta$ by rejecting both one-sided nulls.
Comment: @Alexis can you explain that in english please?
Comment: Two one-sided tests can provide evidence of whether the magnitude of some population statistic (e.g., a difference in means) is to small to care about. The general null is that the size of the statistic (i.e. its absolute value) is greater than or equal to some equivalence/relevance threshold ($\Delta$). If you find evidence that the size of the statistic is smaller than $\Delta$ (the first one-sided test), **and** you find evidence that the size of the statistic is greater than $-\Delta$, then you have evidence that the statistic is too small to care about.
Comment: This approach is called a test for equivalence, because "some statistic" is often something like $\mu_1 - \mu_2$ (the difference in two population means), and you want to provide evidence that they are **equivalent to one another** within some range $(-\Delta, \Delta )$. The two-sided test can provide evidence to decide whether two quantities are **different** (i.e. they are tests for difference),  tests for equivalence provide evidence in the other direction. :)
Comment: So sounds like this is a safeguard against the one-sided test being too lax and generating a type 1 error?
Comment: A practical example is in clinical trials of pharmaceuticals where a goal may be not to show a difference between formulation X and formulation Y, but to show that their effectiveness is **equivalence** (maybe Y has fewer side effects than the already approved X, but you still want Y to have the same effectiveness as X).
Comment: You can still make a Type 1 or Type 2 error in tests for equivalence, although you can also [combine tests for difference with tests for equivalence to guard against confirmation bias](https://stats.stackexchange.com/a/360997/44269).
Comment: That's akin to saying a store where it's cheaper to buy an apple than a kg of apples is laxer with their pricing. If you want to start a new question and tag me, I can post some R code that you can play around with to build up your intuition. This is a very common misunderstanding that I want to dispel, but this question is not the best place for it.
Comment: Gotcha, so it sounds like: Two sided test for "is this new drug that i discovered effective?", and One sided test for "which of these two already approved drugs is more effective?"
Comment: Wait but thats what i meant? More effective = 1 sided test? Better vs worse, effective vs not effective = 2 sided test?
Comment: More effective could be Ha: (New Drug - Placebo) - (Old Drug - Placebo) > 0. As long as the control group is the same for both drug trials, that is the same as (New Drug - Old Drug)> 0, which is plain effective. But both are one-sided. Two-sided is for showing that any relationship exists, not just a positive one.
Comment: Why cant you just do Ha: (New Drug - Old Drug) > 0? And the two sided version would be New Drug != 0
Comment: You can't always do that because sometimes the old drug is tested in a different trial, so it has its own placebo with Placebo2 != Placebo1, so stuff does not cancel. I don't see how the second test connects to anything. It's a one-sample, two-sided test of the null that the mean outcome under the new drug is zero vs. not zero.
Comment: If you have any more follow-ups, you should start asking them in new questions. This forum is not a chat room.
Answer: I would disagree that one-sided tests are academic and claim that they are more often used in industrial applications. Based on personal experience with journal referees, I would even go so far as to say that there is some bias against one-sided tests in (social science) academia. Most modern textbooks devote very little attention to them. There is some opposition in tech as well. There is a good list of pro and against examples here, going all the way back to Fisher's agricultural experiments in the 1930s. Equivalentce and non-inferiority tests in medical trials are another example.
While there is no firm boundary between science in academia and industry, the distinction is still useful. I suspect that academic science is more concerned with demonstrating the existence/nonexistence of relationships, which needs two sides. But industrial scientists focus more on directional questions, where one-sided makes more sense and is more efficient. Efficient here means allowing for more/shorter experiments, with quicker feedback on ideas. This efficiency comes at the cost of partially unbounded confidence intervals.
For practical advice, the question should determine the test:

Is A any different from B? $\rightarrow$ two-sided test.

Is A any worse/better than B? $\rightarrow$ one-sided tests.

Both tests should be combined with pre-registration, ex-ante power calculations, and robustness checks to be safe. Switching to one-sided to get significance after peeking at the data is a bad idea. There is also nothing wrong with running another experiment when you see an effect in the other, unexpected direction.
Questions or claims that produce two-sided tests tend to look like this:

Is there any relationship between Y and X? (existence)
X has no influence on Y whatsoever (nonexistence)
X has no relationship with Y (also nonexistence)
A is not any different from B (nonexistence
again)

One-sided tests come from directional questions:

Is A better than B?
Is doing X worse than doing Y?
Is A better than B by at least k?
Is the change in Y associated with changing X less than m?

Here are two final examples from the business world.

You are evaluating a marketing campaign for your company. You need the added revenue from advertising to exceed the cost of showing the ad. For the decision about launching the campaign, you don't care if the ad drives away customers; you would not launch it anyway. Quantifying the uncertainty about just how terrible the effect is wasteful.

You are considering reducing the number of photos taken per product to lower photography costs and hosting expenses. You need to make sure that the dip in sales is smaller than the savings from shorter photoshoots.
Comment: Awesome answer.
Answer:
I know its generally accepted that the 2 sided test is the Gold Standard

This is highly contextual at best; there are many statistical tests where only one-sided versions of this test are used (e.g., most tests of variance, ANOVA tests, chi-squared tests, etc.).  I presume what you have in mind is the one-sided or two-sided test for something like a test of the mean where both variations exist and are in common use (see this related question and answer).  Assuming this context, the reason that two-sided tests are generally preferred in this context is that one-sided tests sometimes occur when the analyst has used the data to first formulate a one-sided hypothesis, and this biases the test.  Consequently, use of one-sided tests is sometimes viewed with scepticism and raises some immediate questions: Why did you choose to test that one-sided hypothesis instead of the other one?  Was your choice of hypothesis affected by the data?
One of the curious and somewhat unfortunate properties of a classical hypothesis test is that the p-value cannot be compared rationally across different tests.  In particular, when comparing a one-sided and two-sided version of the test, the same evidence in favour of the (one-sided) hypothesis will give a p-value that is half as much in the one-sided test as in the two-sided test.  This means that, if you were to compare p-values across the two tests, the evidence appears to be stronger for the narrower hypothesis, which is of course absurd.  This means that hypothesis tests do not follow the kinds of desiderata we would like them to when you compare across tests, which means we have to be very careful when choosing and interpreting tests.  For this reason, I tend to take a hard line on this issue and require that you should always use the two-sided version of tests of this kind (i.e., tests which have a natural one and two-sided version).  Other statisticians are more liberal on this issue and may be satisfied with a one-sided test if they are confidence that the choice of the side was made a priori and was not affected by the data.
Answer: The F-test in a traditional ANOVA is (and should be) one-sided.
(This is not to be confused with using an F-test to compare two group variances, analogous to using a t-test to compare two group means. Such an F-test could be very reasonable.)
Loosely speaking, ANOVA assesses if the variance between the group means overwhelms the variance within the data overall. That is, we care if the "between" variance is greater than the "within" variance. If the "between" variance is less than the "within" variance, then that provides no evidence in favor of our alternative hypothesis that "between" variance is greater than "within" variance.
Consequently, we only look at one side of the F-distribution to calculate the p-value.
Answer: One sided significance tests are useful most of the time that you want an index of the strength of evidence in the data against the null hypothesis according to the statistical model. That is to say, most of the time that a significance test might be used. That means that practical examples abound, even where they mostly illustrate how two-sided testing is used where one-sided is at least as appropriate. People frequently use P-values from two-sided tests because they are expected to do so, not because one sided tests are inappropriate.
Standard arguments in favour of two-sided testing are almost exclusively relevant to hypothesis testing, not significance testing. If you are unsure why I would draw a distinction between hypothesis testing and significance testing then you should start reading about that before you try to sort out the number of tails you should be testing against. See this question for a good start: What is the difference between "testing of hypothesis" and "test of significance"?
When you are thinking about the evidential meaning of data according to a statistical model it is natural to look at likelihood functions, and indeed there is a one to one relationship between significance test-derived P-values and likelihood functions. Two-sided P-values point to likelihood function that are bimodal whereas the natural interpretation of evidence would yield unimodal likelihood functions from those same data. The one-sided P-value is the index to those unimodal likelihood functions. See here for a full explanation of the relationship between P-values and likelihood functions: https://arxiv.org/pdf/1311.0081.pdf
This chapter explains the distinction between significance tests and hypothesis tests and how P-values can be used to support scientific inferences: https://rest.neptune-prod.its.unimelb.edu.au/server/api/core/bitstreams/1d20d0cb-f3d3-5e23-be16-c20b735f8568/content
Answer: Some Scenarios
I wanted to focus on one particular part of your question:

I just wanted to see if there are real life, practical applications of
the 1 sided test in the real world

Here are some practical examples:

"Is my company's starting salary larger than a rival company?"
"Do students at my school receive less student aid than other schools?"
"Are people from my graduating class taller than other classes before me?"

These are all questions that can be answered by one-sided tests. However, this is also where hypothesis testing is very important. Using the first example, we may have a litany of informal evidence that seems to suggest salaries are greater at another company (feedback from employees there, bigger offices at their company, etc.). Rather than just asking ourselves "are their salaries different from ours?" an easier question to answer may be the one already posed: are they higher? Knowing this information would be super useful if you decided to change companies down the road.
Remember that your chances of rejecting the null hypothesis in one direction increase as a result of how big the tail is compared to a two-tailed test, with the caveat that you can only test one region. Recall that a two-tailed rejection region is larger than a one-tailed region:

Having a strong idea of what the outcome should be ensures that this test answers your question in a more direct way than a two-tailed test.
Practical Example Using R
To simulate this specific scenario, I have created two normally distributed "salary" values for two banks: Bank of America (BOA) and CitiBank. Adjusting their means to only be slightly divergent, we can then test this with a t-test using a one-tail test.
<code>#### Simulate Groups ####
set.seed(123)

group.1 <- rnorm(n = 1000,
                 mean = 100000,
                 sd = 10000)

group.2 <- rnorm(n = 1000,
                 mean = 120000,
                 sd = 5000)

df <- data.frame(CitiBank = group.1,
                 BOA = group.2)

#### Test Groups ####
t.test(group.2,
       group.1,
       alternative = "greater")
</code>
And you can see the test is significant:
<code>    Welch Two Sample t-test

data:  group.2 and group.1
t = 56.98, df = 1484.2, p-value < 2.2e-16
alternative hypothesis: true difference in means is greater than 0
95 percent confidence interval:
 19471.87      Inf
sample estimates:
mean of x mean of y
 120212.3  100161.3
</code>
However, if we plot the critical cutoff zones used for a two-tailed test and compare them to a one-tailed test:
<code>#### Plot ####
library(tidyverse)
library(ggpubr)

p1 <- df %>%
  gather() %>%
  ggplot(aes(x=value,
             fill=key))+
  geom_density(alpha = .5,
               linewidth = 1)+
  theme_classic()+
  scale_fill_manual(values = c("black","white"))+
  geom_vline(aes(xintercept = mean(group.1)),
             color = "red",
             linetype = "dashed",
             linewidth = 1)+
  geom_vline(aes(xintercept = mean(group.2)),
             color = "red",
             linetype = "dashed",
             linewidth = 1)+
  geom_vline(aes(xintercept = mean(group.1) + 1.96*sd(group.1)),
             color = "blue",
             linetype = "dashed",
             linewidth = 1)+
  geom_vline(aes(xintercept = mean(group.1) - 1.96*sd(group.1)),
             color = "blue",
             linetype = "dashed",
             linewidth = 1)+
  labs(x="Salary",
       y = "Density",
       fill = "Group",
       title = "Salary Comparison with Two-Tailed Test")+
  scale_x_continuous(n.breaks = 10)

p2 <- df %>%
  gather() %>%
  ggplot(aes(x=value,
             fill=key))+
  geom_density(alpha = .5,
               linewidth = 1)+
  theme_classic()+
  scale_fill_manual(values = c("black","white"))+
  geom_vline(aes(xintercept = mean(group.1)),
             color = "red",
             linetype = "dashed",
             linewidth = 1)+
  geom_vline(aes(xintercept = mean(group.2)),
             color = "red",
             linetype = "dashed",
             linewidth = 1)+
  geom_vline(aes(xintercept = mean(group.1) + 1.645*sd(group.1)),
             color = "blue",
             linetype = "dashed",
             linewidth = 1)+
  labs(x="Salary",
       y = "Density",
       fill = "Group",
       title = "Salary Comparison with One-Tailed Test")+
  scale_x_continuous(n.breaks = 10)

ggarrange(p1,p2, ncol = 1)
</code>
You will get these plots:

The red dashed lines are the means of each group and the blue dashed lines are the critical regions to reject the null. The plot on top shows cutoffs for the two-tailed test whereas the plot on the bottom shows a one-tailed test. You can see that for the two-tailed test we barely pass the cutoff criterion. However, we have far surpassed it in the one-tailed case.
You can see clearly that Bank of America pays more. If you were to make a judgement call about which bank to work for, which would you choose? A two-tailed test may have given you a misfire if the means were slightly different from each other. This should highlight the practicality of the test as well as why strong hypotheses are helpful to answering these questions.
Comment: I think that assumption is correct as well.
Comment: Great example! However, you also have to consider that the one sided test is more lax, so we should only use it for cases where Type 1 errors are not that serious.
Answer: The entire "framework" of testing non-inferiority and clinical superiority in clinical trials makes a perfect example.
Traditionally, these tests are performed via confidence intervals, by observing whether the lower bound crosses some threshold. We are completely NOT interested in the upper bound. Thus we use single-sided confidence interval, being equivalent to a one-sided statistical test (they are dual to each other, they must agree in indicating statistical significance).
What's the purpose of non-inferiority testing? It's common when examining a new drug or therapy. You want to know if the active drug performs no worse than the control - the current standard of care - and no more than some accepted margin. You do accept that the new treatment may perform a bit worse, while offering other benefits (works faster, fewer adverse reactions = safer, easier and/or rarer administration). You say then: "Of course I want the new drug to be efficient and safe, but initially it suffices to me that it performs not-much-worse than the current one, say no more than -10 percentage points".
Then you assess the difference in some estimate (chosen by you) between the two drugs and calculate the confidence interval around. You accept that the CI may not exclude 0, but also agree that it won't exclude some negative difference, only not too big.
So, if your non-inferiority threshold was -10% points, and your single-sided confidence interval is [-8pp - 100pp], then you reject the null hypothesis about inferiority and claim non-inferiority (be careful - these hypotheses are "reversed"). If it's [-11pp - 100pp], then you cannot reject inferiority.
Same about clinical superiority. Now, instead of laying above the non-inferiority threshold, you look whether it lies above 0 (or 1 for ratios).


Finding a sport composed of multiple other sports

Question: I am 100% sure that it was in the past 2 Olympics but not the most recent in 2016. The sport was about running but there is a twist that a competitor has to complete other tasks like shooting, swimming and other stuff in a single race.
A team who managed to do everything first are winners. What sport could this have been?
Answer: I think you're describing the modern pentathlon. Running, shooting, and swimming are three of the five events it contains - the other two are fencing and show-jumping.

The modern pentathlon is an Olympic sport that comprises five different events; fencing (one-touch épée), freestyle swimming (200 m), equestrian show jumping (15 jumps), and a final combined event of pistol shooting and cross country running (3200 m).
- Wikipedia


Is there a way to access the current view's data in material-table?

Question: My use case is that when a user filters the table data using search, I'd like to be able to use an external widget to perform actions on each row of that data as it is shown in the table.
Right now I dump all my data into cols={MyData} and sort through data[index] but ideally I'd like to be perform operations with something like currentlyDisplayedTableData[index].
There doesn't seem to be a documented way of doing this so I have no attempt to show, I'm just wondering if someone may have encountered this problem and could show me the light.
re: https://github.com/mbrn/material-table/issues/1124
Answer: Just thought I should share another tip, if you just want to intercept/intervene and operate on the currently displayed data before render you can override the component for the table body as Tyler showed in the "issue" link.
But instead of adding a render method, like Tyler did, you can just intercept the props on it's "way down" like this and inject it in the next component (Body, Row, etc.
Note; look for EditRow and other components in https://material-table.com/#/docs/features/component-overriding

    <MaterialTable
    //...

     /**
                 * be aware when making changes on data that there is a tableData object attached
                 * rowData: {
                 *  name: 'some name',
                 *  tableData : {id: 3}
                 * }
                 */
                components={{
                    Body: (props) => {
                        //intervene before rendering table
                        console.log("tampering with some table data ", props);
                        console.log(" -- table data looks like this ", props.renderData);
                        // do stuff..
                        const myRenderData = props.renderData;
                        return (
                            <>
                                <MTableBody {...props} renderData={myRenderData} />
                                {/* to show that you will make impact */}
                                {/* <MTableBody {...props} renderData={[]} /> */}
                            </>
                        )
                    },
                    Row: (props) => {
                        //intervene before rendering row
                        console.log("tampering with some row data ", props);
                        console.log(" -- row data looks like this ", props.data);
                        console.log(" -- row table data looks like this ", props.data.tableData);
                        // do stuff..
                        const myRenderData = props.data;
                        return (
                            <>
                                <MTableBodyRow {...props} data={myRenderData} />
                            </>
                        )
                    }
                }}

Answer: @imjared
I found this thread, via the issue, today and have now worked on and tested two working solutions for how to get hold on the filtered data. Maybe thisos what you want, or at least can hint you where to go, so I thought I should share it =)
Option 1 - listen for changes in MaterialTable.state.data with reference. (useRef, and UseEffect)
Option 2 - built in MaterialTable.onSearchChange combined with reference to MaterialTable.state.data
note, I have included 2 flavors of option 2.
Thanks @tylercaceres for the example you provided, it didn't fit for me but gave me a hint on how to do it.
Code is found here: MaterialTableGettingHoldOfRenderData.js
material-table example getting filtered data, the tables current view data, including 2 options and some other examples of actions/buttons, how to use SvgIcon from Material-UI


The Method of Arm weight in Playing the Piano

Question: I'm a 25 year old music enthusiast, who plays Keyboard since the age of 10, and sincerely started playing Piano since the age of 15 (10 years ago now). I practised on various different pianos (since I didn't have one my own), until I bought a digital Piano 2 years ago. I think I put a decent amount of time into practising my piano playing (on average half of an hour per day), yet I feel stuck in how far my skills developed in the last 10 years.
Especially when it's about fast runs (16th notes at a tempo of 120 bpm for example), I just fail to play them nice and accurately. I've had 4 teachers now, every one of them told me different things (that were all not working), and to be honest I don't understand it at all.
What I want to ask about in this question is about the method of "arm weight", which is mentioned to me all the time by other piano players, but I never got a satisfying explanation by my teachers about:
What I understood so far is that one should use the weight of the arm to press the keys down, instead of muscle force that one could exert with the muscles in the arm. However, if I use the weight of my arm to press a key down, then the arm will of course also lower itself by the same amount of distance that the key goes down. To play the next note, I would have to lift the arm again (which takes a good amount of time).
Did I understand the technique of arm weight wrong?
Does "use your arm weight to press down the key" mean something else, than what I would have expected it to mean (from a physics point of view)?
Edit: I'm told by an answer that arm weight is not the preferred method of playing fast runs - I think this is a topic that deserves a seperate question, and answers part of my confusion. I'd still like to have an answer to the question what playing with armweight is meant exactly, regarding the part of my question that I put emphasis on.
Answer: Arm weight is a common term, but it's a bit misleading. What it really means is that you use the strength of your arm and shoulder muscles when playing, instead of your fingers doing all the work. You don't move your whole arm up-and-down to play every note (that would be next to impossible), but you can rotate your arm and hand as you play notes with different fingers.
Human anatomy doesn't correspond with "common sense" here. Common sense probably tells you that people play the piano "with their fingers", but even the main muscles that move your fingers up and down are actually in your forearm, not in your hand, and work your fingers via tendons that pass through your wrist. This accounts for why it's hard to use your 4th and 5th fingers independently - they are actually moved by two tendons attached to the same muscles in your forearm, and you have to "teach" the muscle (and your brain controlling it) how to contract to move one without the other, by practicing.
https://en.wikipedia.org/wiki/Forearm has some anatomical drawings of how the pieces fit together (which is complicated!)
A better name for the "arm weight" technique for fast runs is "forearm rotation". See these tutorials:

… and applying the same idea to jumps:
Comment: Is there a reason why arm rotation would be feasible, compared to bending the fingers in a downward motion? I see that other muscles are involved into this, are there (for example) capable of faster movements without getting tired?
Answer: Arm weight should be used in conjunction with the pronator and supinator muscles (many call this rotation) with the addition of in/out motions to facilitate the different lengths of each finger. Grouping will aid in your query about the other fingers for grouping partakes in the weight distribution of the arm.  In other words, when employing weight, up/down, in/out, forward shifting, pronation and supination and, GROUPING, this will all give the forearm a "shape" which will make all the subsequent notes just effortlessly fall out of your hands. I don't want to use this analogy but, your hand becomes like a domino chain. None of the fingers are playing in isolation, they are all playing together BUT, you flex the one your are playing just a smidge so it is slightly lower. With all these movements combined, it is is possible to play down while your are lifting up giving you the set up for the next execution of gravity.  Even if you are executing a tremolo or trill using only the pronator and supinator, there is still in/out and up/down.  Even if you are doing something repetitions, using all these movements simultaneously means you are not using the same muscle fiber twice in a row meaning . . . . . NO TENSION.  Each fiber has an opportunity to relax before called upon a second later. Except your pronator and supinator.  They are practically indefatigable.
In regard to scales, you were probably taught to abduct the thumb under the palm and this locks up the abductors of the other fingers creating tension and uneven playing.  It can also lead to ulnar or radial deviation which also hinders even playing.  It also grinds with the index tendon but teachers don't seem to know this. Never cross the thumb under.  Use the arm to move the hand (like you are waxing a car) and place the thumb where it needs to be next.
By using arm weight, pronation and a forward shift, your thumb will play effortlessly.  As far as playing fast scales, there are several other movements for the rest of the hand to facilitate that. Even if you have all the correct movements, the inclusion of an incorrect movement such as finger abduction, isolation, ulnar or radial deviation, can hinder progress.  You must have all the correct motions and none of the incorrect ones.
No part of piano playing should be done in isolation.  Consider casting a fishing pole.  You don't cast from the wrist.  You don't cast from the elbow.  You don't cast from the shoulder.  You cast from all three AND, in addition to that, they are aided by your legs, hips, abs and back.  Likewise, piano playing isn't necessarily in the fingers, it is predominately in the arm.  The arm places the finger, the finger doesn't drag the arm. Just as poking someones eye with your finger happens with the finger, it comes from the shoulder.  Turning a doorknob doesn't happen in the wrist, it happens in the elbow (or should (pronator and supinator)).
We all know to pick up a piece of paper off the floor by bending the knees but, we are rarely taught how to be ergonomic with our arms.
You need to find a teacher who knows about the arm's anatomy, mechanical nature and physics.  There has been three hundred years of poor teaching by people who don't know what they are doing and it just keeps getting passed down.  It is a shame but I would estimate that over 90% of the teachers out there should not be teaching.  This goes for gym teachers, too.
Find a good teacher who knows what they are doing who can re-train you.  Call the Edna Golandsky school in NYC and ask if they have a teacher in your area.
If you complain to your teacher about tension, pain, fatigue, or that you can't play something, and they say "Practice more," "relax" or they assign a finger exercise (your fingers have no muscles), never go back to that teacher.  You are wasting time and money.  Not that they can't teach you other things but, they will cripple you from their ignorance of anatomy.
Comment: So (just regarding your first paragraph), the answer to my question is that it's a row of many different movements of the arm, SOME of them using the arm weight, and in this row of motions the arm is (somewhat) lifted up, if armweight actually it was used before to press down a key?
Comment: There are about 10 proper movements and 10 improper ones. When all ten are employed everything is effortless. This is why you need a teacher and not try this on your own. Weight is the starting point but any movement in isolation will create tension. This is why people who play from the fingers run into problems because the flexors and extensors can't relax in time. 2 other things, never press into the keybed, play instead to the point of sound. And always come straight down on a key. Like walking upstairs, our ascending foot lifts higher than the step then straight down-as our fingers should.
Comment: Everything you wrote sounds great, but I've allready listened to plenty of other great sounding people without any result - This method of the "Taubman approach" (I think that's what you talk about here) - is it somehow proofed to be effectiv by a scientific method?
Answer: Arm weight can help with certain aspects of piano playing, and can sometimes be used with the whole arm, from the shoulder.
You ask about fast playing (of single notes, I guess). This does not use any arm weight. In fact, the arm needs to be still (in a vertical plane) in order to hold the wrist suspended, so that fingers can move up and down, pressing the keys. Obviously, smaller muscles working smaller digits will need less time to recover to the position for the next note to be played. It sounds like you might be trying to play fast using arm weight. Techniques are mixed up!
Comment: Yes, this is what I've been told: Arm weight to be the method to play fast runs. In case this is not the right method for that, I will add this information to be part of the question, but would still like what exactly the method of arm weight is about.
Comment: From a personal point of view, I can't play fast with arm weight. Doesn't mean it's not possible. Arm weight is basically using the arms' weight to press on the keys, as opposed to stabbing them. Which works as well.
Comment: Yes, and this is precisely what I want to know about: How "Arm weight is basically using the arms' weight to press on the keys": You will see in my question why I find exactly this sentence problematic and illogical, from a physicists point of view.


Access VBA: Close Form Without Saving

Question: I've come across an interesting problem here. I'm trying to close a form manually (by clicking the "X" button on the form tab) without the form saving. I simply want the form to close and nothing attempted to be saved in any of the tables.
I think it'd be something to do with the Form.OnClose property, but can't find out anything past that.
Answer: This is not how bound forms in Access work. On closing, they always save an edited record.
Your best choice is to put a "Close without saving" button on the form, with
Private Sub btClose_Click()

    ' Undo current changes
    If Me.Dirty Then Me.Undo
    ' Note that acSaveNo applies to design changes, e.g. if you have set a filter or sort order
    DoCmd.Close acForm, Me.Name, acSaveNo

End Sub

Unless you want to do stupid things like making all bound record saves impossible:
Private Sub Form_BeforeUpdate(Cancel As Integer)

    If Me.Dirty Then Me.Undo

End Sub

Then you can close the form with "X" without saving, but you can't save anything with Access functionality.
Answer: This totally worked for me. As for closing the form on "X" on the top right corner, I disabled it (so users cannot click on "X" to close the form):
Right click on form > Form properties: Property sheet appears on the right hand side.
Choose Format and set option Close Button to No

Access VBA: Close Form Without Saving


Probability that $x>y$ and $x>z$

Question: I have three independent normally distributed variables:
$$x\sim N(0,1) $$
$$y\sim N(0,1) $$
$$z\sim N(0,1) $$
What it the probability that $x$ is greater than both $y$ and $z$ ?
$$P(x>y , x>z)$$
Analytically, I approached the problem this way:
$$P(x>y , x>z)=P(x>y) P(x>z) = 0.5 \times 0.5 = 0.25$$
But when I run simulations I get:
$$P(x>y , x>z)=0.33$$
What is wrong?
Comment: One way to approach the problem is to consider how many possible orders of the three there are, and then identify how many  of those are consistent with the condition..
Answer: Because the events $x>y$ and $x>z$ are not independent, thus you can't write
$$P(x>y , x>z)=P(x>y) P(x>z)$$
It's $1/3$ because these continuous iid RVs have equal probability of being the maximum, and $x$ is just one of them.
Comment: thank you @gunes - Intuitively I suspected that (x > y) and (x > z) were correlated, but how to show that analytically?
Comment: Think simpler, and let $y=1, z=2$. What would $x>2$ tell you about $x>1$?
Answer: One way to look at this is to note that the vector $(x,y,z)$ is exchangeable, and since they are continuous random variables, the probability of a tie is zero.  Consequently, each possible order for the values is equally likely.  Here are all the possible orders and their probabilities, with a star next to the orders that satisfy your statement.
$$\begin{matrix}
\text{Order} & & & \text{Probability} \\[6pt]
x<y<z & & & \tfrac{1}{6} & \\
x<z<y & & & \tfrac{1}{6} & \\
y<x<z & & & \tfrac{1}{6} & \\
y<z<x & & & \tfrac{1}{6} & * \\
z<x<y & & & \tfrac{1}{6} & \\
z<y<x & & & \tfrac{1}{6} & * \\
\end{matrix}$$
(Note that orderings with ties have zero probability when the random variables have a continuous distribution.)  Consequently, regardless of the particular (continuous) distribution for the variables, you have:
$$\mathbb{P}(x > y, x > z) = \frac{1}{6}+\frac{1}{6} = \frac{1}{3}.$$

Probability that $x>y$ and $x>z$


Jaxb: namespace unmarshalling issue

Question: all, I have a package full of Beans generated from xsd with Jaxb.
I want to use some of them into another Bean to marshal/unmarshal an XML like this:
<WrongDocument>
    <test>test label</test>
    <CBISDDReqLogMsg xmlns="urn:CBI:xsd:CBISDDReqLogMsg.00.01.00">
        <GrpHdr>
          ....
        </GrpHdr>
        <PmtInf>
        </PmtInf>
    </CBISDDReqLogMsg>
</WrongDocument>

the root Bean is
@XmlRootElement(name="WrongDocument")
@XmlType(name = "", propOrder = {
  "test",
  "CBISDDReqLogMsg"
})
@XmlAccessorType(XmlAccessType.FIELD)
public class WrongDocumentDTO implements Serializable {

 private static final long serialVersionUID = 8545918230166653233L;

 @XmlElement(required = true, type = String.class, nillable = true)
    protected String test;

 @XmlElement(required = true)
 protected CBISDDReqLogMsg000100 CBISDDReqLogMsg;

 ....

}

and the CBISDDReqLogMsg000100 is
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "CBISDDReqLogMsg.00.01.00", propOrder = {
    "grpHdr",
    "pmtInf"
})
public class CBISDDReqLogMsg000100
    implements Serializable
{

    private final static long serialVersionUID = 1L;
    @XmlElement(name = "GrpHdr", required = true)
    protected CBIGroupHeader2 grpHdr;
    @XmlElement(name = "PmtInf", required = true)
    protected List<PaymentInstructionInformation2> pmtInf;

    ....

}

For CBISDDReqLogMsg000100 namespace is defined with package-info file.
This is the code for unmarshalling:
jc = JAXBContext.newInstance(WrongDocumentDTO.class);
Unmarshaller unmarshaller = jc.createUnmarshaller();
WrongDocumentDTO wrongDocumentDTO = unmarshaller.unmarshal(source, WrongDocumentDTO.class).getValue();

Unfortunately, inside my wrongDocumentDTO i have test field populated with the right value, however CBISDDReqLogMsg is null.
How can i resolve this issue?
thank you in advance
Answer: You will need to specify the namespace specifically on the element if it is not default for the whole package.
@XmlElement(required = true, namespace = "urn:CBI:xsd:CBISDDReqLogMsg.00.01.00")
protected CBISDDReqLogMsg000100 CBISDDReqLogMsg;

Comment: It's work!

I made this test before posting here....using the wrong namespace.

thank you

Jaxb: namespace unmarshalling issue


How to create a script file

Question: I want to create a script file that I can call using a form on submit. For example I can use:
action="action.php?uid=1&method=deleteuser"

This would trigger the script to result in the function deleteuser in file action.php deleting uid 1. However, when I tried to create this file and put it in the home scripts folder it couldn't call basic drupal commands such as db_query. Where and how can I generate such a script file so that I can access drupals core functions?
Answer: You can make your script file with following statements:
<?php
define('DRUPAL_ROOT', $_SERVER['DOCUMENT_ROOT']); // Define the DRUPAL_ROOT constant which is used in many places.
$base_url = 'http://'.$_SERVER['HTTP_HOST']; // Again, this is used in many places.
require_once DRUPAL_ROOT . '/includes/bootstrap.inc'; // Include the boostrap file.
drupal_bootstrap(DRUPAL_BOOTSTRAP_SESSION); // Start things up to whatever level you need.
//drupal_set_message('custom script');
print db_query("SELECT title FROM {node} WHERE nid = :nid", array(':nid' => 1))->fetchColumn();
?>

But it is not a good practice to handle form submit or whatever.

How to create a script file


How to set android webview zoom to specific height

Question: I am using a Webview to look at a local image with zoom support and all that. Is there any way that I can make the WebView zoom to only fit the height of the image, instead of the width like it does with my current code? Here is what I have:
WebView image = (WebView)findViewById(R.id.map);
    image.getSettings().setBuiltInZoomControls(true);
    image.getSettings().setLoadWithOverviewMode(true);
    image.getSettings().setUseWideViewPort(true);
    image.setLayoutParams(new     LinearLayout.LayoutParams(LayoutParams.WRAP_CONTENT,LinearLayout.LayoutParams.WRAP_CONTENT));
    image.loadUrl("file:///android_asset/image.png");

Answer: Try using the webView Settings
use the webSettings class
webview.getSettings().setDefaultZoom(WebSettings.ZoomDensity.FAR);

Check out Set zoom for Webview
Update:
as setDefaultZoom deprecated you need to use another settings


Changing the order of elements

Question: I am creating a website of floating width. The users use screens from full HD resolution to some 600px on smart phones it seems a pretty good idea. This brings up a very interesting problem.
When user uses a smaller resolution than is an optimum the page gets a lot more height. This means it might be useful to change order of some elements (for example some image, search box or navigation) to make the page more readable without much need of scrooling.
So I need to be able to access DOM and change order of some page elements (swap them).
Lets say I have an list and need to swap item 1 and 2.

1

2

I found a solution based on appending already items elements to
 by using function appendChild. However there is a problem with text nodes and it gets really complicated to do it for more difficult element structure, since the need of recreating it whole again.
Do you have any suggestion to improve it?
Comment: Time to invest in learning jQuery. It makes this type of activity a lot easier.
Comment: Can you be, please, more specific? I now that library, but some link to API useful for this would be helpful.
Comment: Have you tried using jquery sortable ?
http://jqueryui.com/sortable/
Answer: For this simple case (swapping the only two elements), you can just use appendChild():

(() => {
  const list = document.querySelector("ul");
  list.appendChild(list.firstElementChild);
})();

List-item #1

List-item #2

The same node cannot exist in multiple positions; so, it's removed from its current position and placed at the end of the collection.
If you want to do more complicated sorting, you probably ought to create an array from the childNodes and get all crazy:

(() => {
  const frag = document.createDocumentFragment();
  const list = document.querySelector("ul");
  const items = list.querySelectorAll("li");
  const sortedList = Array.from(items).sort(function(a, b) {
    const c = a.textContent,
      d = b.textContent;
    return c < d ? -1 : c > d ? 1 : 0;
  });
  for (let item of sortedList) {
    frag.appendChild(item);
  }
  list.appendChild(frag);
})();

Dogs

Snakes

Cats

Bugs

Answer: In 2018 (and already a few years ago) this is possible with just CSS. Your use case would be solved by something like this:
ul {
  display: flex;
  flex-direction: column;
}

li:nth-child(2) {
  order: -1;
}

Comment: Too bad `flex` doesn't work / is buggy on fieldsets :(
Answer: You can use flex to change the order of the HTML elements very easily.
flex order: 0 by changing the order value you can decide where in the column the element appears

const ascButton= document.getElementById('asc')
const decButton= document.getElementById('dec')

//callback function for soring in ascending order
const ascending = (a,b)=> a.innerHTML - b.innerHTML

//callback function for soring in descending order
const descending = (a,b)=> b.innerHTML - a.innerHTML

let currentOrder = ascending

ascButton.addEventListener('click', ()=>{
 currentOrder = ascending
  order()
})

decButton.addEventListener('click', ()=>{
 currentOrder = descending
  order()
})

const order  = function(){
 const ordered = [...document.getElementsByClassName('col')].sort(currentOrder)
  ordered.forEach((elem, index)=>{
   elem.style.order = index
  })
}

order()
.row{
  display: flex;
  flex-direction: column;
}
.col{
  padding: 20px;
  border: 1px solid gray;
  margin: 5px;
  order:3;
}

1

2

3

10

4

5

<button id="asc">ASC</button>
<button id="dec">DESC</button>

You can find a much more complex implementation here https://jsfiddle.net/nijeesh4all/on5rsax8/
Comment: I like the usage of `data-*` attributes in your more complex example. It makes clearer what is filtered on
Comment: I love the idea to use flex order for that, thank you!
Answer: wouldn't swapping innerHTML also work?
var myList = document.getElementsByTagName("ul")[0];
temp = myList.getElementsByTagName("li")[0].innerHTML;
myList.getElementsByTagName("li")[0].innerHTML = myList.getElementsByTagName("li")[1].innerHTML;
myList.getElementsByTagName("li")[1].innerHTML = temp;

Comment: Be careful when writing to innerHTML it might have unwanted effects on event handlers and other such properties.
Eg: http://stackoverflow.com/a/5113120/370786
Comment: it happens when you try this with document.body but not in this case. a simple example -> https://jsfiddle.net/tzv5db93/
Answer: The following code will work for any number of siblings, to move one sibling up or down. Here, "element" is the element you want to move compared to its siblings.
move up:
function moveUp(element){
    var upperSibling = element.previousElementSibling;
    if(upperSibling === null) return;
    upperSibling.insertAdjacentElement("beforebegin", element);
}

This inserts the element before ("beforebegin") its previous sibling (previousElementSibling).
move down:
function moveDown(element){
    var lowerSibling = element.nextElementSibling;
    if(lowerSibling === null) return;
    lowerSibling.insertAdjacentElement("afterend", element);
}

This inserts the element after ("afterend") its next sibling (nextElementSibling).

Changing the order of elements


How do I prove this modulo relation?

Question: Any suggestions for a better title would be greatly appreciated.
This is related to a Codeforces problem for modulo arithmetic.
Given an array of non-negative positive integers:
$[a_1, a_2, \dots,       a_k]$
If $ a_2, \dots, a_k$ are all some multiples of $a_1$, I have to prove that for every non-negative integer $x$ in the array:
$(((x \bmod a_1) \bmod a_2) \dots \bmod a_{k - 1}) \bmod       a_k = (((x \bmod a_{p_1}) \bmod a_{p_2}) \dots \bmod a_{p_{k -       1}}) \bmod a_{p_k}$
where $a_p$ refers to every permutation of the array.
Example:
n=3 Array: [3, 12, 24]
Result = 0
n=3 Array: [3, 24, 12]
Result = 0
n=3 Array: [12, 3, 24]
Result = 0
n=3 Array: [12, 24, 3]
Result = 0
n=3 Array: [24, 12, 3]
Result = 0
n=3 Array: [24, 3, 12]
Result = 0
n=12 Array: [3, 12, 24]
Result = 0
n=12 Array: [3, 24, 12]
Result = 0
n=12 Array: [12, 3, 24]
Result = 0
n=12 Array: [12, 24, 3]
Result = 0
n=12 Array: [24, 12, 3]
Result = 0
n=12 Array: [24, 3, 12]
Result = 0
n=24 Array: [3, 12, 24]
Result = 0
n=24 Array: [3, 24, 12]
Result = 0
n=24 Array: [12, 3, 24]
Result = 0
n=24 Array: [12, 24, 3]
Result = 0
n=24 Array: [24, 12, 3]
Result = 0
n=24 Array: [24, 3, 12]
Result = 0

What I have tried:
I know that a multiple of one number mod another multiple of the same number will yield either 0 or another multiple. But I simply cannot understand why this can't be the case for non-multiples as well ?
Comment: "But I simply cannot understand why this can't be the case for non-multiples as well ?"  Suppose $a$ and $n$ are not both multiples of the same number.  Then they are relatively prime.  Since there are reltatively prime there exist $k,j$ so that $ak +nj=1$ and $ak \equiv 1 \pmod n$ and $1$ is not a multiple of anything.
Comment: @fleablood You have to excuse my ignorance, but what do you mean by $k$ and $j$ ? Is this a particular number theory property that you are referring to ?
Comment: Bezouts lemma.  If $a,n$ are relatively prime there will exist/we will be able to find two integers which we will call $k$ and $j$ so that $ak + nj = 1$  (obviously one of the integers will be negative and the other possitive.  So if $ak + nj = 1$ then $ak = 1 - nj$ and so $ak \equiv 1 \pmod n$.
Comment: Bezouts lemma can be express as if $\gcd(a,n) =d$ then for any integer $v,w$ then $av + nw = $ some multiple of $d$.  And there will exist integers $k,j$ so that $ak + nj = d$.  And for any mulitple of $d$, say $dh$ then $a(kh) + n(jh) = dh$ so solutions will exist for all multiple of $d$.  So that is why your result holds: If $\gcd(a,n) = d$ not only will all $ak$ but congruent to a multiple of $d$. For any multiple $dm$ there will be a $k$ where $ak \equiv dm \pmod n$.
Comment: WHat does: "$(((x \bmod a_1) \bmod a_2) \dots \bmod a_{k - 1}) \bmod       a_k = (((x \bmod a_{p_1}) \bmod a_{p_2}) \dots \bmod a_{p_{k -       1}}) \bmod a_{p_k}$" mean?  What does $b \bmod n = c\bmod m$ mean?
Comment: "But I simply cannot understand why this can't be the case for non-multiples as well ?"  Why do you care?  That's not part of the problem.
Answer: After mod $a_1$, the result is already smaller than all of the elements in the array, so taking further modulos is unnecessary. All we have left to prove is that taking mod $ka$ for $k\in \mathbb{Z}$ will not change the remainder of division by $a$.
Can you prove that?
Comment: $24 \mod 15 = 9$ and then $9\mod 3 = 0$.  If you are modding by all $a_i$ you will eventually eventually mod by $a_1$ and as all the results are multiples of $a_1$ then when you mod by $a_1$ you will get $0$.
Comment: How can you say that 'After $mod a_1$, the result is already smaller than all of the elements in the array' ? Imagine an array `[3,15,24]` `24 mod 15 = 9` which is not smaller than all the elements in the array. Could you please elaborate by what you mean ?
Comment: $15$ is $a_2$.  Not $a_1$.  YOu haven't modded by $a_1$ yet.  So *AFTER* you mod by $a_1$ you will have a number less than $a_1$ and thus less than all elements in the area.  In fact, as all the elements are multiples of $a_1$ you will get $0$ always.

How do I prove this modulo relation?


Maximizing the Lagrangian with respect to vector - help solve

Question: I need help solving this following equation, a Lagrangian problem that I encountered during my studies in principal component analysis (PCA).
One should maximize the variance with respect to the first principal component
Following is the case:
We know that $W = {\bf v}^T_1 {\bf Sv}_1 $ (eq 1) and that $\bf v_1$ is an orthonormal basis.
Therefore $||{{\bf v}_1 }||^2 = {\bf v}_1^T{\bf v}_1 = 1$ (eq 2).
The maximization of $W$ under this constraint can be done by introducing the Lagrangian multiplier λ and maximizing the Lagrangian:
$\mathcal{L} = W + \lambda (1-||{\bf v}_1||^2) = {\bf v}^T_1 ( {\bf S}-\lambda {\bf I}){\bf v}_1 + \lambda$ (eq 3)
So expanding $W$ using eq. 1, and the laws of distributivity we end up with eq 3.
Next, taking the derivative with respect to vector and $\lambda$ we obtain:
$$\frac{\partial}{\partial \lambda} \mathcal{L} = 1-{\bf v}_1^T{\bf v}_1  = 0 $$
$$\nabla_{{\bf V}}{_1}\mathcal{L} = ({\bf S} - \lambda {\bf I}){\bf v}_1  = 0 $$
This can later be shown to be an eigenvalue problem. Can anyone explain to me why the derivatives look like that? I can't seem to figure it out.
Best regards :)
Answer: I believe I found a solution, to whom this may be interesting.
First partial differentiation is straight forward, $\lambda$  is a constan. I found a slightly different approach, remember the inner product is = 1.
We know the fact that:$$ \lambda\frac{\partial}{\partial {\bf v}_1^T}  ({\bf v}_1^T{\bf v}_1) = 2\lambda {\bf v}_1$$
The second one, uses the fact that
$$\frac{\partial}{\partial {\bf v}_1} ({\bf v}_1^T({\bf S}-\lambda {I\bf }){\bf v}_1) = 2({\bf S}-\lambda {\bf I}) {\bf v}_1 $$
Hence the partial differentiation yields:
$$ \nabla _{{\bf v}_1}\mathcal{L} = 2({\bf S}-\lambda {\bf I}) {\bf v}_1  - 2\lambda{\bf v}_1
$$
The optimization problem then becomes:
$$ \frac{\partial \mathcal{L}}{\partial{{\bf v}_1}} = ({\bf S}-\lambda {\bf I}) {\bf v}_1  - \lambda{\bf v}_1 = 0$$
Normalization of ${\bf v}_1$ and rewriting of the optimization problem yields the eigenvalue problem:
$$ {\bf S v}_1 = \lambda {\bf v}_1 $$


How to import images from public folder in react in App.css

Question: The error

I am facing an issue to import images from the public folder in App.css under background image attribute.
.sign-up {
    background-image: url('/images/img-8.jpg');
    background-position: center;
    background-size: cover;
    background-repeat: no-repeat;
    color: #fff;
    font-size: 100px;
  }

React version used: email@example.com
Public folder structure

Folder structure

The aforementioned is the image of the error that is shown, It would be helpful to receive a solution to this
Comment: Did you take a look at this question: https://stackoverflow.com/questions/57111197/react-path-to-public-folder-in-css-background-image
Comment: @LahEzcen, yes I checked as( background-image: url('/images/img-8.jpg'); )  but it isn't working as (
Comment: I put my `images` folder in my `src` folder.
Comment: @Azu maybe I'll do that at last if I don't find any way for this one, thanks for the advice though
Answer: there is no img-8.jpg in your public folder please check the name again
Comment: This not an answer to the OP. Please leave a comment instead of this type of the answers.


Null set if intersection with preimage under a linear map is countable

Question: Let $T \subseteq \mathbb{R}^n$ be an measurable set and
$$\varphi:\mathbb{R}^n \rightarrow \mathbb{R}^{n-1}$$
a surjective linear map such that for all $x \in \mathbb{R}^{n-1}$ the set $T \cap \varphi^{-1}(x)$ ist countable. Show
$$\lambda^n(T) = 0.$$

It's obvious that $\lambda^n(T \cap \varphi^{-1}(x)) = 0$, since $T \cap \varphi^{-1}(x)$ is countable and we can write $T = \biguplus_{x\in \mathbb{R}^{n-1}} T \cap \varphi^{-1}(x)$, but the problem is that this is an uncountable union. Therefore we can't simply write $\lambda^n(T) = \lambda^n(\biguplus_{x\in \mathbb{R}^{n-1}} T \cap \varphi^{-1}(x)) = \sum_{x\in \mathbb{R}^{n-1}} \lambda^n(T \cap \varphi^{-1}(x)) = 0$, so there needs to be a different way solving this exercise (we haven't even used the linearity in this case).
Comment: It follows from the [coarea-formula](https://math.stackexchange.com/questions/4026851/whats-the-intuition-behind-the-co-area-formula)
Comment: @Arctic Char Might there not be an easier, more direct proof? Since we didn't had the Coarea-formula in our lecture, and the proof of this theorem is a pretty long one, I don't think its nessecary to use it here.
Comment: What do you have in class?
Answer:
Since $\varphi:\mathbb{R}^n \rightarrow \mathbb{R}^{n-1}$
a surjective linear map, then there is a linear bijective linear map $\psi: \mathbb{R}^n \rightarrow \mathbb{R}^n$ such that for all $(x_1,x_2,...,x_{n-1}, x_n ) \in  \mathbb{R}^n $, $ \varphi \circ \psi  (x_1,x_2,...,x_{n-1}, x_n)= (x_1,x_2,..., x_{n-1})$

Since for all $x \in \mathbb{R}^{n-1}$ the set $T \cap \varphi^{-1}(x)$ is countable and $\psi$ is bijective, then, for all  $x \in \mathbb{R}^{n-1}$,
$  \psi^{-1}(T) \cap ( \varphi \circ \psi )^{-1}(x)= \psi^{-1}(T) \cap \psi^{-1}( \varphi^{-1}(x)) = \psi^{-1} (T \cap \varphi^{-1}(x) )$ is countable.

We can write $\mathbb{R}^n= \mathbb{R}^{n-1} \oplus \mathbb{R}$, and for any $v \in \mathbb{R}^n$, we can write it as $(w, r)$ where $w \in \mathbb{R}^{n-1}$ and $ r \in \mathbb{R}$. Note that
$\varphi \circ \psi = \pi_1$, the projection of $\mathbb{R}^n$ onto the first factor (that is $\mathbb{R}^{n-1}$). Item 2 above means that, for each  $w \in \mathbb{R}^{n-1}$, the set $\{r \in \mathbb{R} : (w,r) \in \psi^{-1}(T)\}$ is countable.

Note that, using Fubini Theorem,
\begin{align}
\lambda^n(\psi^{-1}(T)) &= \int \chi_{\psi^{-1}(T)}(w,r) \:d \lambda^n(w,r) = \\
& = \int_\mathbb{R} \left(\int_{\mathbb{R}^{n-1}}\chi_{\psi^{-1}(T)}(w,r) \: d\lambda^{n-1}(w) \right) \: d \lambda(r)= \\
 &=\int_{\mathbb{R}^{n-1}}\left(\int_\mathbb{R}\chi_{\psi^{-1}(T)}(w,r) \: d \lambda(r) \right)\: d\lambda^{n-1}(w)
\end{align}
But, for all $w \in \mathbb{R}^{n-1}$, $\{r \in \mathbb{R} : \chi_{\psi^{-1}(T)}(w,r) \neq 0\}= \{r \in \mathbb{R} : (w,r) \in \psi^{-1}(T)\}$. So $\{r \in \mathbb{R} : \chi_{\psi^{-1}(T)}(w,r) \neq 0\}$  is countable. So, for all $w \in \mathbb{R}^{n-1}$, $\int_\mathbb{R}\chi_{\psi^{-1}(T)}(w,r) \: d \lambda(r)=0$. So, $\lambda^n(\psi^{-1}(T))=0$. Since $\psi$ is a linear bijective map, we have $\lambda^n(T)=0$.
Comment: @Lukas , I have made some adjustments / corrections to my answer. I think is now clearer. Let me know if you have any questions regarding the answer.


Given average of positive bounded sequence converges to zero, does the average of the square sequence also converge?

Question: Given $\frac{\sum\limits_{i=1}^n |x_i|}{n}\rightarrow 0, |x_i|\leq C $, does $\frac{\sum\limits_{i=1}^n |x_i|^2}{n}\rightarrow 0$ also hold true?
Answer: Hint:
$$\frac{\sum\limits_{i=1}^n |x_i|^2}{n}\leq C\frac{\sum\limits_{i=1}^n |x_i|}{n}$$


Delegated access to shared mailboxes without rights to deleting messages

Question: So I'd like to grant my users access to a shared mailbox with delegated access - easy enough. (We use Office 365)
But how can I restrict that access, so they can't DELETE anything in that mailbox? I'd like them to still be able to move items, create new folders etc.
Answer: Not possible. If you want them to be able to move content, then they need to be able to delete content, because that is what a move is.
Permissions basically fall in to two groups - read only and full control. There is no middle ground.


variable is undefined outside of subscribe() method Angular 2

Question: I am working on angular 2 and getting undefined error for variable outside of subscribe() function.employee variable id undefined outside subscribe() function.Please help me.Thanks. Below is the code
export class DetailsComponent implements OnInit {
  employee;

  constructor(private _location:Location, private _empService:EmpService, private route:ActivatedRoute) { }
  ngOnInit() {
      //let params:any = this.route.snapshot.params;

      this.editEmployee(6); //I have tried to pass static value
      console.log(this.employee); //Here this is undefined
  }
  backClicked() {
        this._location.back();
    }

   editEmployee(id) {
    this._empService.getEmployee(id).subscribe((employee)=> {
       this.employee = employee[0];
       console.log(employee[0]); //This have below output in console
       //{id: "6", emp_name: "Mohit", emp_email: "email@example.com", emp_phone: "9800000", emp_status: "y"}
    })
  }
}

Answer: Because you are using Observables, the console.log(this.employee) gets called before the employee is set. I would recommend in editEmployee that you return a Promise and use:
editEmployee(id) {
    return new Promise((resolve) => {
        this._empService.getEmployee(id).subscribe((employee)=> {
            this.employee = employee[0];
            console.log(employee[0]);
            resolve();
        });
    });
}

this.editEmployee(6).then(()=> {
    console.log(this.employee);
}

Note that it's not the best and most beautiful solution, but if you want to keep your code in this style i would do it like this.
Comment: Use the pipe: json
Comment: `{{employee | json}}`
Comment: @PsychoPfanze : Thanks for your reply but this solution not working and there another error " Property 'then' does not exists on type void"
Comment: Sorry, i didn't post the whole code, i'll edit my answer to make it work for you :D
Comment: :Your answer is correct but unfortunatly my problem did not solve my issue.I am not able to use variable `employee` in `.html` file
Comment: You could do: `{{employeeId}}`
Comment: `editEmployee(id) {
    return new Promise((resolve) => {
        this._empService.getEmployee(id).subscribe((employee)=> {
            this.employee = employee[0];
            console.log(employee[0]);
            resolve();
        });
    });
}`
In above function, I am assigning value of   `employee[0]` to   `this.employee`  so that I could use this in template file. but somehow its not accessable outside subscribe function . `employee` is undefined in template
Comment: A lot of things could be the issue, first: `public employee`, then i said you need to consider that the variable is now async so you have to use a pipe that it doesn't throw you an error on displaying it
Comment: can you tell me any function that can work in template inside {{ }} to see details of and array or object like console.log() or like we do print_r() in php ?


Hamiltonian Monte Carlo vs. Sequential Monte Carlo

Question: I am trying to get a feel for the relative merits and drawbacks, as well as different application domains of these two MCMC schemes.

When would you use which and why?
When might one fail but the other not (e.g. where is HMC applicable but SMC not, and vice versa)
Could one, very naively granted, put a measure of utility on one method compared to the other (i.e. is one, generally, better)?

I am currently reading Betancourt's excellent paper on HMC.
Comment: SMC is not an MCMC technique, i.e. there is no Markov chain that is constructed when using SMC.
Comment: Sometime you use mcmc within smc. And sometimes you use smc within mcmc. At the time of my writing this I am not aware of any papers that combine the use of hmc and smc, though.
Comment: I myself would like to understand better the relation between SMC (aka, particle filtering) and HMC. Thanks for the question! I do note this paper, which seems at first glance to represent some kind of melding of the two approaches: https://arxiv.org/pdf/1504.05715v2.pdf
Answer: Hamiltonian Monte Carlo performs well with continuous target distributions with "weird" shapes. It requires the target distribution to be differentiable as it basically uses the slope of the target distribution to know where to go. The perfect example is a banana shaped function.
Here is a standard Metropolis Hastings in a Banana function:
Acceptance rate of 66% and very poor coverage.

Here is with HMC:
99% acceptance with good coverage.

SMC (the method behind Particle Filtering) is almost unbeatable when the target distribution is multimodal, especially if there are several separate areas with mass. Instead of having one Markov Chain trapped within a mode, you have several Markov chains running in parallel. Note that you use it to estimate a sequence of distributions, usually of increasing sharpness. You can generate the increasing sharpness using something like simulated annealing (put a progressively increasing exponent on the target).
Or typically, in a Bayesian context, the sequence of distributions is the sequence of posteriors:
$$
P(\theta|y_1) \;,\; P(\theta|y_1,y_2)\;,\;... \;,\; P(\theta|y_1,y_2,...,y_N)
$$
For instance, this sequence is an excellent target for SMC:

The parallel nature of the SMC makes it particularly well suited for distributed/parallel computing.
Summary:

HMC: good for elongated weird target. Does not work with non continuous function.
SMC: good for multimodal and not-continuous cases. Might converge slower or use more computing power for high dimensional weird shapes.

Source: Most of the images come from a paper I wrote combining the 2 Methods (Hamiltonian Sequential Monte Carlo). This combination can simulate pretty much any distribution we can throw at it, even at very high dimensions.
Comment: Here's the paper for those interested: http://www.remidaviet.com/files/HSMC-paper.pdf
Comment: Nice and clear; +1. No idea why this does not have more upvotes!


Was the term "octave" coined after the development of early music theory?

Question: I have some confusion as to the use and history of the word octave in the context of music and tuning systems.
The (western) tuning system comes from the Pythagorean division of the octave, based on consonant frequencies, found by simple ratios. This already produced a division of an octave into 12 pitches. Later on, within the roman civilization and gregorian chants, this system was still applied and a notation system invented which contained 7 note names (today A to G), probably to refer to the common (ionian) major scale.
It seems to me that the term "octave" refers to these 8 notes within the 12 note system, and was used in retrospect after some music theory was already in the making (during definition and use of the ionian major scale -I know modes weren't defined up until much much later-).
All answers to questions related to the name "octave" just explain the history of modern tuning systems, but I haven't yet seen an explanation of why we use the word "octave" for a 12-tone system, which was never an 8-tone system.
When did people start using the word octave, and what does it really refer to?
To clarify: I am not asking why an octave is called an octave (meaning eight) if we have 7 notes. This is clear. My question is about the chronology of a 12 semi-tone tuning system, the use of an 8-note scale (major scale), and the introduction of the word 'octave' to refer to those 8 notes (7 notes + root).
If I want to build an 8-note system, I can divide an octave into 7 intervals using a harmonic series. This division will give me 7 pitches + an octave, but this will sound nothing like the major eight-note scale we know today. As the modern major scale arises from the division of an octave into 12 intervals (12 notes + an octave), and selecting a sub-set of 8 out of it. However in this case we require a 12 semi-tone tuning system. If the term octave refers to the 8 notes in a major scale, then in is placed in retrospect, and after the development of enough music theory to define diatonic scales.
Comment: "But the diatonic scale was defined much later than the creation of the 12-tone tuning": do you have any evidence to show that ancient Greek music had 12 tones per octave?  Regardless, even if it did, that system was not in use in medieval Europe when the term "octave" arose.
Comment: Related question: [Etymology of word "Octave"](https://music.stackexchange.com/questions/75697/etymology-of-word-octave)
Comment: The paper given as a reference to support the quote does not in fact support the conclusion that medieval theorists were theorizing about 12 tones.  See for example the table in section 3.2, which shows Pythagorean tuning of a diatonic scale from F to F (with a B-natural, not a B-flat).  I've edited the Wikipedia article accordingly.
Comment: @Aaron thank you. Yes that is probably the same question rephrased, which has yet not accepted answer. Most answers relate to "counting" of pitches in the diatonic scale. But the diatonic scale was defined much later than the creation of the 12-tone tuning, so as my question implies, the word octave must have been created in retrospect. Which promotes the other question: how was an octave called before the diatonic scale?
Comment: @phoog great point, actually it seems like it isn't the case. From wikipedia: "twelve tone Pythagorean temperament was developed by medieval music theorists using the same method of tuning in perfect fifths, however there is no evidence that Pythagoras himself went beyond the tetrachord".
 You say that the term "octave" arose in medieval europe. That is already part of an answer to my question. Would you mind elaborating on that origin? What system was in use in medieval Europe when the term octave arose, and what did the term octave refer to?
Comment: Which Wikipedia page is that from?
Comment: @phoog Pythagorean tuning : https://en.wikipedia.org/wiki/Pythagorean_tuning#:~:text=Pythagorean%20tuning%20is%20a%20system,attributed%20to%20the%20integer%203.
Answer:
Was the term "octave" coined after the development of early music theory?

No.  As shown below, it was already in use by the 11th century to denote the musical interval (although the principal name for the interval at that time seems still to have been diapason).

What system was in use in medieval Europe when the term octave arose, and what did the term octave refer to?

I'm a little hazy on the state of music theory before Guido d'Arezzo, who worked in the early 11th century, but it's pretty clear that the letter names A through G were in use before he published his system of solmization with the six syllables ut, re, mi, fa, sol, and la.
In his treatise Micrologus, published around 1026, he mostly refers to the interval that we now call the octave as the diapason, but it's also clear from chapter V that the term "octave" had come to its musical meaning.  Keep in mind that the day one week after some other day was also called the octave, which is simply Latin for "eighth," and, as has been noted elsewhere, the periods of a week and two weeks are to this day called eight and fifteen days in at least some modern Romance languages.
As an aside, I note that the only difference between numbering the intervals of the second, third, fourth, fifth, sixth, and seventh, on one hand, and the octave on the other, is that we use our native (Germanic) ordinals for the first set of intervals and a word derived from the Latin ordinal for the last.  There's no theoretical reason not to call it an eighth; it's just custom, perhaps influenced by the special status given to that interval by octave equivalence.
Guido's system had eight pitch classes, the seven letters of the "white key" scale, A through G, plus B-flat.  To distinguish, B-natural was written with a square form (), while B-flat was written with the normal round form.  The two forms of B would never be used at the same time, though, so there were seven distinct pitches in the diatonic scale.
The system comprised roughly two and a half octaves, the lowest in upper case letters, the middle in lower-case letters, and the upper in double lower-case letters.  Oh, and because he needed one note below the lowest octave, that note was designated with a Greek letter.  There were, in total, 21 notes:

Γ A B C D E F G a b  c d e f g aa bb  cc dd

Guido, Micrologus, chapter V, on octave equivalence:

Diapason autem est, in qua diatessaron et diapente iunguntur; cum enim ab A in D sit diatessaron, et ab eadem D in a acutam sit diapente, ab A in alteram a diapason existit: cuius vis est eamdem litteram in utroque habere latere, ut a B in , a C in c, a D in d, et reliq.  Sicut enim utraque vox eadem littera notatur, ita per omnia eiusdem qualitatis, perfectissimaeque similitudinis utraque habetur et creditur.  Nam sicut finitis septem diebus eosdem repetimus, ut semper primum et octavum diem eumdem esse dicamus, ita octavas semper voces easdem figuramus et dicimus, quia naturali eas concordia consonare sentimus, ut D et d.

Corrections to this translation are welcome.  To maintain the distinction between the Greek and Latin interval names in the original, I've used Greek and English names here.  Diapente is fifth, and diatessaron is fourth:

The diapason is, moreover, that in which the diatessaron and diapente are joined, for from A to D is a diatessaron, and likewise from D to acute a is a diapente, so from A to the other a there is a diapason: whose effect is having the same letter on either side, from B to , from C to c, from D to d, and the rest.  Thus as both sounds are notated by the same letter, so both by their property they are ascribed the most perfect similarity.  For as, after seven days, the same [day] repeats; as always the first [primum] and eighth [octavum] days are called the same, so octaves [octavas] are written and called alike, for we perceive their natural harmony together, as D and d.

The question assumes that the seven-note scale arose by taking a subset of the twelve equal divisions of the octave, but this is not the case.  Guido's introduction of two forms of B was the beginning of what later came to be known as chromatic alteration.  With the advent of harmony, alterations of notes other than b and  became necessary.  There was E♭, then A♭.
As the raised leading tone became important, F♯ was invented, then C♯.  Eventually the sharps and the flats met somewhere around D♯/E♭ or G♯/A♭.  Although there were some experiments with split-key keyboards to enable those pairs of notes to have different pitches, the winning strategy in the long run was to devise acceptable temperaments in which they could have the same pitch, leaving us with the 12-key keyboard we know today.  In other words, the 12-tone system arose as an extension of the diatonic system, which came first.
There is another misconception in the question:

(during definition and use of the ionian major scale -I know modes weren't defined up until much much later-).

In fact, the modern Ionian mode was not identified as such until the sixteenth century, along with the Aeolian.  The weird Locrian mode came later still (weird because its fifth degree is diminished).  The other four modes are in fact older, being directly descended from their medieval authentic counterparts, developed in the 9th century.  (These modes were named after the Greek modes, but they don't descend directly from them.)
In fact, the major and minor tonalities that were firmly established in the Baroque period developed from the four medieval modes during the Renaissance period.  The modes were much earlier, not much later.  Major and minor tonality developed as a result of the influence of harmonic considerations on various contrapuntal conventions, and the Aeolian and Ionian modes were subsequently invented to reflect this.
The basis of minor keys is the Dorian and Phrygian modes (primarily the Dorian), while the basis of the major keys is the Lydian and Mixolydian modes.  Harmonic considerations led to the raising of the leading tone in Mixolydian and Dorian, the lowering of the fourth degree in Lydian, the raising of the second degree in Phrygian, and the lowering of the sixth degree in Dorian (and even today, the sixth and seventh degrees are so commonly raised or lowered in minor keys that we are taught three different forms of the minor scale, one of which even changes depending on its direction).
Comment: Worthwhile adding some dates for Guido? Wikipedia gives "991/992 – after 1033".
Comment: @Aaron yes, thanks. I had intended to do that but spent so much time on the translation that I forgot.
Comment: Glad I'm not the only one who gets lost in my posts. :-)
Comment: @phoog thank you for the great answer! For me this indicates that the term octave was indeed added in retrospect, as there was another initial term (diapason), and after some advances in music theory (definition of notes, scales, which led to 7 note scales and thus to the term octave). Is that correct? In my question I indicate "early music theory" which is vague and can be confused with modern music theory, but Guido's system already sounds like a development in that area.
Answer: Absent a source indicating when the term "octave" can into common use, here are some references to terms implying numerical descriptions of intervals.
Ancient Greek theorists used the term "diapason" to refer to what we call the "octave." However, they also used the term "diapente", a clear numerical reference, for the fifth. "Diatessaron", the fourth, is also a numerically based term used by the Greeks.

Strings with lengths in the ratio 2 : 1 produced the interval of an octave known to the ancient Greeks as diapason,   Those in the proportion 3 : 2 produced the interval of the fifth, known to the Greeks as diapente. Strings of equal tension with length in the proportion 4 : 3 produced the interval of a  fourth known to the Greeks as diatessaron.  The Greek word dia meant between, through or across. (SOURCE)

See also: https://en.wiktionary.org/wiki/diapason
The term "diocto", clearly referencing an 8-based pitch system, was in use by 562 C.E.

The consonance diapason, also called diocto, results from the ratio 2:1 ... and includes eight sounds, hence also the name it takes of diocto or diapason -- since the citharas of the ancients had eight strings this consonance, including as it does all sounds, is called diapason (literally, through all).1

"Octave" (also "fourth" and "fifth") is used in translations of the (pseudo-)Aristotlian Problemata (ca. 300 B.C.E. -- 600 C.E.), but it's unclear whether these are used by the translator as terms of convenience, or whether they reflect a numerical usage in the original.

Why is the octave the finest concord? Is it because the ratios are between terms that are wholes, while those of the others are not between wholes? ... for the fifth, which is hemiolic, is not of whole numbers ... the case is similar with the fourth....2

1Oliver Strunk, Source Readings in Music History: From Classical Antiquity through the Romantic Era (1950, W. W. Norton and Company), page 89. The passage is from Cassiodorus's Institutiones, believed to have been written between 543 and 562 C.E. (combining dates giving in Wikipedia and Strunk). In a footnote, Strunk explains that Cassiodorus's statement is, in fact, incorrect. I include it here, because of its connection to the notion of eight pitches.
2 Andrew Barker (ed.), Greek Musical Writings: Volume II -- Harmonic and
Acoustic Theory (1989, Cambridge University Press), page 93.
Answer: Lots of repeatable things (or cyclic) are named as a closed interval. There are 7 notes in the Western scale but early theorists liked to include the closing note (giving 7 intervals) A-B-C-D-E-F-G-A. Compare with some Spanish dialects calling a week "ocho días."
Another reason comes from the old Greek theory of tetrachords; these are 4-note patterns (like ABCD or CDEF or EFGA) which can be abutted to make a scale. Two 4-note objects seem to have been called 8-notes (even though the overlap means only 7 different notes.) Combining CDEF with GABC yields 8 notes but octave equivalence means the first and last notes have the same name.
The acoustical almost-equivalence of frequency doubling leads to the term "octave" meaning "frequency doubling."
It's like starting counting with 0 or 1; each may make sense in the context used.
Comment: My issue doesn't have to do with 7 notes and counting methods. It has to do with the chronology of a 12 semi-tone system related to the term octave. In my question I assume that the 12 tone system preceeds the octave, as the later seems to refers to an already ordered sub-set of a 12 tone system and is related to scales, which indicate development of some level of music theory. The interesting part of your answer is that you point out that in Greek music theory we already had a reason for an 8 note system, possibly preceeding a 12-note system, proving me wrong in my assumptions


Set up ns1, ns2 name servers at google cloud from a registered name server

Question: I have regestered ns1.grant-fullen.com and ns2.grant-fullen.com and (Proper IPS) at namecheap.com
I am using google cloud dns.
I have set up A records at google cloud dns.
ns1.grant-fullen.com.   A   300 220.127.116.11
ns2.grant-fullen.com.   A   300 126.96.36.199
Problem I am haveing is with CWP7 web panel.
Can not start the DNS BIND service
.Warning for this is
<code>Mar 31 22:26:38 centos7 bash[3667]: zone nf1j.com/IN: loaded serial 2019033167
Mar 31 22:26:38 centos7 bash[3667]: zone grantfullen.com/IN: loaded serial 2019033168
Mar 31 22:26:38 centos7 bash[3667]: zone grant-fullen.com/IN: NS 'ns1.grant-fullen.com' has no address records (A or AAAA)
Mar 31 22:26:38 centos7 bash[3667]: zone grant-fullen.com/IN: NS 'ns2.grant-fullen.com' has no address records (A or AAAA)
Mar 31 22:26:38 centos7 bash[3667]: zone grant-fullen.com/IN: not loaded due to errors.
Mar 31 22:26:38 centos7 bash[3667]: _default/grant-fullen.com/IN: bad zone
Mar 31 22:26:38 centos7 systemd[1]: named.service: control process exited, code=exited status=1
Mar 31 22:26:38 centos7 systemd[1]: Failed to start Berkeley Internet Name Domain (DNS).
Mar 31 22:26:38 centos7 systemd[1]: Unit named.service entered failed state.
Mar 31 22:26:38 centos7 systemd[1]: named.service failed.
</code>
Question:= DO I have something configured wrong in the a records at google cloud dns ?
Comment: The logs you posted tell you what the problem is and exactly how to fix it.
Comment: Your zone file has syntax errors.  You can check syntax with `named-checkzone example.com /path/to/example.com/zonefile`
Comment: I have a records for the ns1, ns2. I do not know if this is correct     grant-fullen.com. A 300
188.8.131.52
grant-fullen.com. NS 21600
ns-cloud-d1.googledomains.com.
ns-cloud-d2.googledomains.com.
ns-cloud-d3.googledomains.com.
ns-cloud-d4.googledomains.com.
grant-fullen.com. SOA 21600
ns-cloud-d1.googledomains.com. cloud-dns-hostmaster.google.com. 1 21600 3600 259200 300
ns1.grant-fullen.com. A 300
220.127.116.11
ns2.grant-fullen.com. A 300
184.108.40.206
srv1.grant-fullen.com. A 300
184.108.40.206
www.grant-fullen.com. CNAME 300
grant-fullen.com.
Answer: Verifying the IPs, you don't have any problem with google cloud DNS configuration.
Your domains are resolving with the correct IP as you configured.
----------------------
dig ns1.grant-fullen.com
; <<>> DiG 9.10.3-P4-Ubuntu <<>> ns1.grant-fullen.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 58018
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;ns1.grant-fullen.com.          IN      A
;; ANSWER SECTION:
ns1.grant-fullen.com.   299     IN      A       18.104.22.168
;; Query time: 28 msec
;; SERVER: 169.254.169.254#53(169.254.169.254)
;; WHEN: Tue Apr 02 21:10:13 UTC 2019
;; MSG SIZE  rcvd: 65
----------------------
dig ns2.grant-fullen.com
; <<>> DiG 9.10.3-P4-Ubuntu <<>> ns2.grant-fullen.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 7204
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;ns2.grant-fullen.com.          IN      A
;; ANSWER SECTION:
ns2.grant-fullen.com.   299     IN      A       184.108.40.206
;; Query time: 166 msec
;; SERVER: 169.254.169.254#53(169.254.169.254)
;; WHEN: Tue Apr 02 21:10:28 UTC 2019
;; MSG SIZE  rcvd: 65
Also you cant try with the IP (188.8.131.52) itself at a web browser and this will take you to the CWP7 web panel.
The logs you posted are related to to the DNS BIND service running at centos7, and it's telling you that you need to add a record (A or AAAA) for both domains (ns1.grant-fullen.com and ns2.grant-fullen.com)
and that there is a problem with the zone you configured.
I found this guide that maybe can be useful for you (https://www.linuxtechi.com/install-configure-cwp-centos-web-panel-on-centos-7/)
Comment: Thanks for the help. I got the bind server going.


Why is $\frac{\cos(\alpha + \beta) + \cos(-\alpha)}{\sin(\alpha + \beta) + \sin(-\alpha)}$ independent of $\alpha$?

Question: By accident I found (numerically) that the expression
$$\frac{\cos(\alpha + \beta) + \cos(-\alpha)}{\sin(\alpha + \beta) + \sin(-\alpha)}$$
only depends on $\beta$. This looks like it shouldn't be hard to prove, but I didn't manage. Can someone think of a nice proof?
Additionally, I would be interested in any geometric interpretation of this result.
Comment: I don't believe that this is true. If $\alpha=0$ and $\beta=\pi/2$, then the expression is $1$. If $\alpha=\pi/2$ and $\beta=0$, then the expression is $0$.
Comment: Did you try using https://en.wikipedia.org/wiki/List_of_trigonometric_identities#Product-to-sum_and_sum-to-product_identities
Comment: @JoshB. I think you misread
Comment: You're absolutely right, I did misread. Sorry for the confusion.
Comment: http://mathworld.wolfram.com/ProsthaphaeresisFormulas.html
Answer: $$\cos(\alpha+\beta)+\cos(-\alpha)=2\cos{\frac{\alpha+\alpha+\beta}{2}}\cos{\frac{\alpha+\beta-\alpha}{2}}=2\cos{\frac{\beta}{2}}\cos\left(\alpha+\frac{\beta}{2}\right)$$
$$\sin(\alpha+\beta)+\sin(-\alpha)=2\sin{\frac{\alpha+\beta-\alpha}{2}}\cos{\frac{\alpha+\beta-(-\alpha)}{2}}=2\sin{\frac{\beta}{2}}\cos\left(\alpha+\frac{\beta}{2}\right)$$
Comment: I think you should put parentheses around $\alpha + \frac \beta 2$


CiviCRM report by address

Question: Is there a way to pull a CiviCRM report that compiles all donations from matching addresses?
Whether or not the people at the matching addresses are formally part of a household -- kind of like the mailing option that merges matching addresses for a mailing export to prevent double mailings.
Answer: If I understand you correctly the  Aggregate Household Contribution Report is what you are looking for.  If that is not sufficient, it may provide a good basis for a custom report.
Comment: Thanks, it's not exactly but I may try to use it as a basis for a modification.
Answer: This Display Related Contributions extension might also be of interest.

CiviCRM report by address


In Mercurial, why we cannot backout a commit when there are other modified files?

Question: Yesterday I committed a file and then wanted to hg backout, but Mercurial says cannot backout because I have other modified files in the project…
That's a little bit strange… it is not atomic level on each file?  Commit 1 file and then backout 1 file?
Second, I can save a copy of those modified files A, B, C, to tmp files, hg revert them, and then backout, and then copy those tmp files back to A, B, C, and isn't that the same as just hg backout that last commit but just more work?
Answer: In general, doing a backout implies doing a merge. When merging, the working copy is used as a scratch space: merge conflicts show up as changes to the files in your working coyp, and you resolve them by editing the files in your working copy. This is the reason why Mercurial insists on you having a clean working copy before you merge or backout: there is really no other good place for Mercurial to store the files when it needs you to resolve conflicts.
Personally, I've never run into this problem. I never have modified files lying around -- I either commit them or I stash them in a MQ patch. If you don't want to use MQ, then a simple
<code>hg diff > tmp
hg revert --all
# working directory is now clean, do your merge/backout/...
hg import --no-commit tmp
</code>
is enough to deal with your case. This has of course been wrapped into easier commands by the nice people who write extensions: see the attic extension for an example.
Answer: Nope. Mercurial is not a file-revision tool, it's changeset-revision. A changeset includes all the files affected by particular change, not individual files.
Yes, theoretically doing revert on all open files, backout and then editing those files again will achieve the same effect as doing a backout of the individual file. However, in practice the history for the repo does not contain separate entries for each file, so you can't roll back only one of the files.
Comment: This isn't actually true.  Mercurial keeps a separate version history for each file and uses the manifest to tie together all the versions for a given changeset.  The reason `backout` is tricky in the case the OP describes are a lot more subtle.


Using jdk 1.6 and jdk 1.7 for different eclipse program

Question: i have two different Eclipse(Java EE and android) and two jdk(jdk6,jdk7)
i have confuse how to set java EE eclipse in jdk6 and android eclipse in jdk7
is this possible?
Comment: I could appreciate the confusion if you had to setup multiple versions of java in one instance of Eclipse. I can't in your case. Could you please explain what is it that you've tried which has not worked?
Answer: You could set them in the preferences.
Window --> Preferences --> Java --> Installed JREs

In this, you can add the JREs you want to use for the eclipse. Thus in your case, for Java EE eclipse, add the JDK 1.6 and for Android eclipse, add the JDK 1.7.
Answer: Continuing the answer of @R.J I would like to add that even if you don't have two separate eclipses.
You can use project specific settings and use different different JRE for different projects.

Right click on Project --> Libraries ---> Remove JRE you dont want
  ---> Add other JRE
Answer: Windows -> Preferences
Then simply type jdk in the search box. Window is shown below. You can add your JDK here.


Does $d(x+u, y + v) \le d(x, y) + d(u,v)$ holds for every metric?

Question: The title said it, I want to prove that
$$
 d(x+u, y + v) \le d(x, y) + d(u,v)
$$
for every metric $d$. If the metric is induced by a norm, i.e. $d(x,y) := ||x-y||$, then this is easy.
\begin{align*}
 d(x+u, y+v) & = ||x+u - (y+v)|| \\
             & = ||x-y + u - v|| \\
             & \le ||x-y||+||u-v|| \\
             & = d(x,y) + d(u,v)
\end{align*}
But in the general case I have no idea how to get rid of the sums...
Comment: $x+u$ isn't meaningful in metric spaces in general; are you working specifically in $\Bbb R^n$?
Comment: What is the underlying space here?
Answer: It isn't even true in $\Bbb R$. The function
$$d:\Bbb R^2\to\Bbb R:\langle x,y\rangle\mapsto\left|\tan^{-1}x-\tan^{-1}y\right|$$
is a metric on $\Bbb R$. In this metric we have $d(-1,1)=\frac{\pi}2$, but $$\lim_{x\to\infty}d(x-1,x+1)=\lim_{x\to\infty}\left|\tan^{-1}(x-1)-\tan^{-1}(x+1)\right|=0\;,$$
even though $d(x,x)=0$ for all $x$.
More generally, suppose that it were true. Then you'd have $d(x+u,y+u)\le d(x,y)$ for all $x,y,u$, and hence $d(x,y)\le d\big((x+u)+(-u),(y+u)+(-u)\big)\le d(x+u,y+u)$ for all $x,y$, and $d$ would be translation-invariant. Clearly not all metrics on $\Bbb R^n$ are translation-invariant.
Comment: in what manner does your limit for $x\to \infty$ said that $d(x-1,x+1) \le d(x,x) + d(-1,1)$ could not hold?
Comment: @Stefan: It doesn't: it shows that for sufficiently large $x$ the inequality $$d\big((x-1)+(-x),(x+1)+(-x)\big)\le d(x-1,x+1)+d(-x,-x)$$ cannot hold.
Answer: If I'm not mistaken, you can also take the pullback of the standard metric on $ℝ$ by $x ↦ x^3$, i.e. the metric $ℝ × ℝ → ℝ,\; (x,y) ↦ |x^3 - y^3|$, and choose $x=u=1$ and $y=v=-1$. Then the left hand side of the title inequality is $16$ and the right hand side is $2 + 2 = 4$.