Display Suite: Panel layouts in doesn't appear in "Manage fields"

Question: I can select panel layouts using display suite in the manage display tab, but only display suite layouts are available in the manage fields tab but none of the panels layouts are.
Can you please help me with this problem?
Answer: The Manage Fields tab is used for arranging fields for the Node Add/Edit form, as well as to Add/Edit/Remove fields to the Node/Entity.
If you want to use Panels for the layout of your Node Add/Edit forms, then you would do this through the Panels Interface by enabling and editing the Node add/edit form Panel that comes included when you install Panels. You would create variants in this Panel to handle the layouts for each content type you have. Hope that can help.


Optimize performance of custom pre-built option list to webform

Question: I am looking to add a pre-built options list, based on a query. I crafted the function nicely with the below code
<code>function mitacan_webform_select_options_info() {
    $items = [];
    if (function_exists('basliklariAl')) {
        $items['addresses'] = array(
            'title' => 'Stok Kodları',
            'options callback' => 'basliklariAl'
        );
    }
    return $items;
}

function basliklariAl($component, $flat, $arguments) {
    $nodes = [];
    $select = db_select('node','n')
        ->fields('n',[
            'nid',
            'title'
        ])
        ->condition('type','urun')
        ->execute()
        ->fetchAll();
    foreach($select as $n) {
        $nodes[$n->nid] = $n->title;
    }
    return $nodes;
}
</code>
This is very slow, mostly because there are about 10k records. What can I do to optimise the process?
Comment: How often do you expect the query results to change ? Why don't you use cache_set and cache_get ?
Comment: I consume a web service to generate the nodes once a day, but expect the results to change rarely.
Answer: You can always cache the results as seen in the official documentation
<code>  if ($cache = cache_get('my_module_cache') && REQUEST_TIME < $cache->expire) {
    $data = $cache->data;
  }
  else {
    $data = 'xxxxxxx'; //do all your time taking complex calculations here
    cache_set('my_module_cache', $data, 'cache',  REQUEST_TIME  + (3600 * 24 * 30 * 6)); //stores in cache table and expires after 6 months
  }
</code>
More about cache_set and cache_get
Comment: I added the cache_set but the cache looks like
`+---------------+------+--------+------------+------------+
| cid           | data | expire | created    | serialized |
+---------------+------+--------+------------+------------+
| mitacan_cache | N;   |  86400 | 1520589086 |          1 |
+---------------+------+--------+------------+------------+`. What did I do wrong?
Comment: Sorry the code was untested as I was just trying to give you a headstart ... I updated my answer with the official documentation example now that should probably work better ... but again its untested


Should I somewhat normalize/scale data less than 1 when squared

Question: I'm using a simplification algorithm for Geo-points where internally a squared distance between points is calculated. I have the feeling that the outcome is somehow strange and it might be because it makes a big difference whether the distance of two points is less than or greater than 1 Meter. The whole algorithm seems to struggle, because small distances get even much smaller squared distances while other become much greater.
This problem should occur quite often in statistical calculations, since many very basic formulae or algorithms calculate squares quite often.
Is it generally necessary or advisable to scale data before calculations, e.g. use cm instead of m? Does this usually have any effect? Maybe in some cases this effect is even desired?!
Background:
Unfortunately I don't have an environment where I could use R or Matlab. It's running in the browser hand-crafted with JavaScript. But I'm asking not only for this special case, but generally, because I'm self-teaching statistics and R. It's a really big universe you're in, compared to computer programming which seems like a small village to me.
BTW I'm using http://mourner.github.io/simplify-js/ for simplification.
Comment: Depends on which methods you are using. With scale-invariant methods, using m or cm would not affect the results.
Answer: I think what you're concerned about – correct me if I'm wrong – is that if $x > 1$, $x^2 > x$, whereas if $x < 1$, $x^2 < x$.
I don't know of a method where this in itself would be an issue.
The reason is: you don't ever compare $x^2$ and $x$. They have different units. Yes, it feels different to square a small number, but if you just look at a plot of $y = x^2$, there's nothing different about $x=1$. The algorithm doesn't care.
There are two main ways in which scaling can matter:

If you have multiple variables, scaling changes the relative importance between them. Imagine you have data points that include both a location and a time, and you compute distances between those data points according to the standard Euclidean distance. If you measure the location in nanometers and the time in years, the difference in location is going to be numerically much larger and it'll dominate the distance. If you measure location in parsecs and time in milliseconds, it'll be the other way around.
Numerical issues. If the numbers you're using are very small, the limited-accuracy floating point data types our programs usually use start causing more and more issues. The issue @Lennart brought up is one of these. In practice, this typically really matters only when your numbers are quite small, when they vary over many orders of magnitude, or (for some algorithms) when the implementation is naive.

That said, using squared distances does absolutely magnify the importance of large distances. Sometimes this is what you want; sometimes it's not, especially when there's a reasonable chance of outliers. Exactly what to do about that, if that's a problem, depends a lot on what algorithm you're using. One example is to use "Huberized" functions, which are quadratic out to a certain value and then become linear (wikipedia).
Scaling doesn't affect this problem. If the issue is that $y^2$ is much bigger than $x^2$, note that $\frac{(a y)^2}{(ax)^2}=\frac{y^2}{x^2}$, so their relative sizes are unchanged.
Answer: This might be because of singular (or nearly singular) matrices. It may also be because the condition number is large. But if you calculate it in Matlab it shouldn't be a problem because it QR-factorizes the matrices by default, thus, the condition number won't be as large. What program are you calculating the algorithm in?
Comment: Thanks. I edited the question. Can I understand "factorize" like some kind of scaling?
Comment: It's a scalar as in A = QR  where Q is the (under) orthogonal matrix and R the upper triangular matrix. You can calculate the euclidean distance in matlab using X=[Geo-points] with the command D = pdist(X) or D = pdist(X,distance).


Positive sums of small quantities at low resolution

Question: Many measured continuous quantities are in fact sums of discrete events measured with insufficient resolution (e.g. electric current) and thus conveniently modeled by continuous probability distributions, such as the normal distribution. In many cases these quantities are also essentially positive (e.g. chemical quantities that are sums of molecules), which warrants the use of log-normal distribution, often with good results. The underlying quantity is however a sum rather than a product, so using log-normal distribution seems fundamentally wrong. Is there a theoretical result justifying it?
Added later
Additional motivation for using log-normal distribution: it is a long tailed distribution, which makes it less sensitive to outliers than the normal one.
Comment: Not necessarily; if a distribution has the property that convolutions are in the same distribution family, it might make sense (or when convolutions can be well approximated by another distribution in the same family)
Comment: Your reasoning $-$ that it being positive is sufficient of itself to specifically warrant a choice of the lognormal, rather than some other distribution on $\mathbb{R}^+$ $-$ seems flawed. Why would you expect a theoretical result justify such a seemingly arbitrary choice? Why not say, gamma, or any number of other possibilities?
Comment: Log-normal is just an example: you have the same problem with any other distribution defined on the positive half-axis.
Comment: Does your argument imply that every time we model a real phenomenon with a continuous distribution we are making a mistake because reality is discrete?
Comment: Every time we model a discrete quantity by a continuous distribution, we make an approximation, that is our results are applicable only in certain limit. We also make an approximation when we model a strictly positive quantity by a normal distribution. The questions is: under what conditioyn we can approximate a sum by a continuous distribution that is not normal.
Comment: I agree with you that modeling a variable with support on the positive reals as something with support on the whole real line leaves a bad aftertaste. But the support of the log-normal _is_ the positive reals. I don't see the problem you're describing in this particular case?
Comment: The variable is a positive sum. Normal distribution models a sum... but it is not positive. Log-normal models a positive variable... which is not a sum: we replace sum by product, mean by geometric mean, etc. When is such an approximation justified, and when could it produce errenous results?
Answer: A necessary condition for the limiting distrbution was given by Gnedenko in 1972: the Laplace transform $\Psi$ of its cumulative distribution function must be of the form
$$\Psi(s)=\frac{1}{1+Cs^\gamma}$$
with $C>0$ and $0<\gamma\leq1$. See

Gnedenko: "Limit theorems for sums of a random number of positive independent random variables." Proceedings of the Sixth Berkeley Symposium on Mathematical Statistics and Probability, 1972.
Answer: In practice this situation arises when we are dealing with fluctuations that are small compared to the mean of the quantity of interest: $|\delta x|/x \ll 1$. This justifies the use of the normal distribution (via the central limit theorem), but introduces a mathematical inconvenience of permitting negative values. This is a mathematical artifact: such big fluctuations had to be already disallowed in order to get to the normal limit.
Log-normal distribution in this case behaves as normal, since $\log (x + \delta x) \approx \log x + \delta x/x$, but has the mathematical convenience of never getting negative.
Thus, one can use normal and log-normal distributions interchangeably, as long as one avoids making any the claims about large fluctuations. This reasoning also applies to using other distributions defined on positive semi-axis.


Why if a real function has a derivative with a positive lower bound, it must be surjective

Question:
Let $f$ be differentiable on $\Bbb R$ and suppose that $f'(x)\ge c >0$ for all $x$. Show that for each $y\in \Bbb R$, there is an unique $x$ such that $f(x)=y$.

By assumption and mean value theorem, $f$ is strictly increasing on $\Bbb R$. If I can prove $\lim \limits_{x\to \infty}f(x)=\infty$ and $\lim \limits_{x\to -\infty}f(x)=-\infty$. Then by definition, Given $y>0$, there exist $t_0$ and $t_1$ such that $f(t_0)>y$ and $f(t_1)<-y<y$. By intermediate value theorem, there exists $z$ between $t_0$ and $t_1$ such that $f(z)=y$, and since $f$ is strictly increasing, this $z$ is unique. We can do it for any $y\in \Bbb R$, so we are done.
I want to ask how to prove $\lim \limits_{x\to \infty}f(x)=\infty$ and $\lim \limits_{x\to -\infty}f(x)=-\infty$?
Answer: For $x >0$ we have $f(x)-f(0)=xf'(t)$ for some $t$ between $0$ and $x$.Hence $f(x) \geq f(0)+cx \to \infty$ as $x \to \infty$.
Similarly. $f(0)-f(-x)=xf'(s)$ for some $s$ between $0$ and $-x$ and this gives $f(-x) \to -\infty$ as $ x \to \infty$.
Comment: You mean $f(x)\ge f(0)+cx\to\infty$.


Java - Executing jar fails because of Prohibited package name: java.sql

Question: I am making a multiple choice quiz that makes use of the sqlite-jdbc-3.21.0.jar driver. You can find it here:
https://bitbucket.org/xerial/sqlite-jdbc/downloads/
I've made a class called Database to handle everything relating to SQLite:
<code>   package quizpack;
    import java.sql.Connection;
    import java.sql.DriverManager;
    import java.sql.ResultSet;
    import java.sql.Statement;

    public class Database {
    Console cnsl = new Console();
    ResultSet rs = null;
    Connection connection = null;
    Statement stmt = null;

    public Connection connect() {
        try {
            connection = DriverManager.getConnection("jdbc:sqlite:./data/data.db");
            Class.forName("org.sqlite.JDBC");
        } catch (Exception e) {
            cnsl.println("connect() error: " + e.getMessage());
        }
        return connection;
    }
}
</code>
When i run my quiz in Eclipse it doesn't give any errors. When i compile it it doesn't give any errors (packaged required libraries). As soon as i launch the jar file in commandprompt i get the message: Prohibited package name: java.sql.
That would be: java.lang.SecurityException: Prohibited package name: java.sql
This is the stacktrace of the connect() error:
<code>connect() error: Prohibited package name: java.sql
java.lang.SecurityException: Prohibited package name: java.sql
    at java.base/java.lang.ClassLoader.preDefineClass(Unknown Source)
    at java.base/java.lang.ClassLoader.defineClass(Unknown Source)
    at java.base/java.security.SecureClassLoader.defineClass(Unknown Source)

    at java.base/java.net.URLClassLoader.defineClass(Unknown Source)
    at java.base/java.net.URLClassLoader.access$100(Unknown Source)
    at java.base/java.net.URLClassLoader$1.run(Unknown Source)
    at java.base/java.net.URLClassLoader$1.run(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Native Method)
    at java.base/java.net.URLClassLoader.findClass(Unknown Source)
    at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
    at java.base/java.lang.ClassLoader.loadClass(Unknown Source)
    at quiz.Database.connect(Database.java:21)
    at quiz.Database.buildQuery(Database.java:51)
    at quiz.Quiz.<init>(Quiz.java:22)
    at quiz.Main.main(Main.java:13)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Nativ
e Method)
        at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknow
n Source)
        at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Un
known Source)
        at java.base/java.lang.reflect.Method.invoke(Unknown Source)
        at org.eclipse.jdt.internal.jarinjarloader.JarRsrcLoader.main(JarRsrcLoa
der.java:58)
</code>
What i tried:
Changing the package name.
Changing the sequence of my buildpath.
Tried several placings of where i put the driver jar in my source folder.
Signing my exported jar.
Added the jar to my classpathvariables:
database connection not working in jar, but does work in eclipse
Now i'm a beginning Java programmer, i might have done something wrong from the above list. But i'm hoping someone can shed light on what is actually causing this error to happen.
Comment: Check that your project doesn't have a package with name `java`. Change it for `quadrivics` or something else.
Comment: I checked an my project doesn't have a package name with java in it. I changed it to 'quizpack' already.
Answer: This seems like a repeat of Prohibited package name: java, but you said you changed your package name.
If you didn't change the package name from java to something else, try changing that. Else, delete your jar file and rebuild.
Comment: I would suggest you also delete all the compiled .class files, i.e. the bin or target folder.
Comment: I've rebuild my entire project multiple times in different workspaces and new projects and that doesn't solve the problem either. I've checked out the link and that refers to something i've tried already aswell.


Converting List into Dictionary of Sorted Tuples

Question: I've used the following approach many times to generate a list of tuples from the contents of a dictionary:
dispositions = list(dispositions.items())

In this case, the keys are different types of ways a patient can leave the emergency department, and the values are counts of those types. Now, I wanted to sort this data based on the second item in each of the tuples, so I tried this:
dispositions = list(dispositions.items()).sort(key=lambda x: x[1])

To my surprise, when I ran the code, I found that dispositions had been set to None. I tried breaking it into two parts, as follows:
dispositions = list(dispositions.items())
dispositions.sort(key=lambda x: x[1])

This works! I got my list of sorted tuples. So, I've already solved my problem, but I want to know why the first option didn't work so that I can be a better person (better programmers are better people). Can anyone help me out here?
Comment: Hello and welcome to StackOverflow. Although your questions is answered below, please note that StackOverflow is for posting non-working code/seeking help with the solution. For the code that works, but you would like an improvement or additional explanation, please use CodeReview website https://codereview.stackexchange.com/ which is also part of StackExchange network. Cheers
Answer: list.sort does not return anything. So this:
dispositions = list(dispositions.items()).sort(key=lambda x: x[1])

sets dispositions to None.
sorted on the other hand returns a new list. So you would use:
dispositions = sorted(dispositions.items(), key=lambda x: x[1])

Which will set dispositions to a sorted list of tuples.
Comment: That makes perfect sense. Thank you.
Answer: The sort function doesn't work like you might think. It does not return a sorted list, it directly modifies the list so it's sorted.
For instance, say you have this code:
a = [0, 2, 1]
a.sort()

a will now be changed [0, 1, 2]. Had I used a = a.sort() rather than just a.sort(), it would have been set to None.
This:
dispositions = list(dispositions.items()).sort(key=lambda x: x[1])

functions the same as this:
dispositions = list(dispositions.items())
dispositions = dispositions.sort(key=lambda x: x[1])

Which sets dispositions to the returned value from sort, which is None.
On the other hand, this:
dispositions = list(dispositions.items())
dispositions.sort(key=lambda x: x[1])

is not setting dispositions to the value of sort, it's simply calling the sort function on dispositions, which causes the list to be sorted as intended.
Comment: That also makes sense. Thank you also.


Xamarin Visual Studio iOS Portable Class Library rebuild process

Question: I have a PCL in my Xamarin iOS project.  Working from VS, I am finding that to get a change to the PCL reflected in the iOS app, I have to do all of the following:

Kill the app from VS
Quit the app in the simulator
Delete the app from the simulator
Rebuild the PCL in VS
Finally, build and run the iOS project.

Can I simplify this workflow?  I do have a build dependency from the iOS project to the PCL project.  But it doesn't seem to help.
Comment: This looks pretty much like some bug with how we track dependencies.  A change in one of the referenced projects should really trigger a recompilation.
Comment: Entirely possible.  My experience with dependencies in native iOS (i.e. Xcode, no Xamarin) has been that dependencies have a lot of non-obvious behavior, especially nested dependencies.  If A links to B and B links to C, it does not follow that A links to C.  I can imagine that it gets that much more confusing when you have VS on top of it.
Comment: Are you using the Xamarin Mac Pairing then? I've had issues where the pairing breaks WITHOUT warning during a build and the changes aren't reflected. However I just make sure the pair is complete every-time I start working on my project again.
Comment: Yes, over WiFi.  But the problem happens every time.  So I don't think it's some flaky-connection type of problem.
Answer: Have you checked your build configuration? I had this same issue a few weeks ago and it was because certain projects were not being built in the active configuration. My PCL libraries were not being built by default.
Build menu -> build configuration


Show that $\inf\{s\geq 0\mid |M_s|\geq d\}$ is a stopping time.

Question:
Let $(M_t)$ be a martingale and $(\mathcal F_t)_t$ an adapted filtration. Show that $$T=\inf\{s\geq 0\mid |M_s|\geq d\}$$ is a stopping time.

So I must show that $\{T\leq t\}\in \mathcal F_t$. We have that $$\{\omega \mid T\leq t\}=\{\omega \mid \forall u\in [0,T], |M_u(\omega )|<d \},$$
but how can I continue ?
Comment: Any assumption on the regularity of the sample paths (continuous/cadlag/....)?
Comment: @saz: No, sorry.
Comment: Well, this is strange. Do you assume that the filtration is complete?
Comment: @saz: I don't know what is a complete filtration.
Comment: By the way, the equation $$\{\omega; T \leq t\} = \{\omega; \forall u \in [0,T]: |M_u(\omega)|<d\}$$ is not correct; it should read $$\{\omega, T(\omega) \leq t\} = \{\omega; \exists u \in [0,t]: |M_u(\omega)| \geq d\}.$$
Answer: Without any additional assumptions on the regularity of the sample paths (continuity, càdlàg,...) or the filtration (completeness), the assumption does, in general, not hold true.
Counterexample Denote by $V \subseteq [0,1]$ the Vitali set (this is an uncountable set which is not contained in the Borel-$\sigma$-algebra $\mathcal{B}(\mathbb{R})$ generated by the Euclidean metric). Define a stochastic process on $\Omega := [0,1]$ endowed with the Lebesgue measure by
$$M_t(\omega) := \begin{cases} 1_{\{t\}}(\omega), & t \in V, \\ 0, &t \notin V. \end{cases}$$
Then $(M_t)_{t \geq 0}$ is a martingale with respect to the canonical filtration $$\mathcal{F}_t := \sigma(M_s; s \leq t)$$ since $M_t = 0$ almost surely for any $t \geq 0$. Note that each $M_t$ is Borel-measurable for $t \geq 0$, and therefore $\mathcal{F}_t \subseteq \mathcal{B}(\mathbb{R})$ for all $t \geq 0$. However, if we define
$$T := \inf\{s \geq 0; |M_s| \geq 1\}$$
then
$$\{T \leq 1\} = V \notin \mathcal{B}(\mathbb{R})$$
hence, $\{T \leq 1\} \notin \mathcal{F}_1$. This means that $T$ is not a stopping time with respect to $(\mathcal{F}_t)_t$.


Is the name of an interval between two notes unique and absolute?

Question: Given two notes, is the name of the interval based only on the number of semitones between them (absolute) or can the same exact interval have different names related to the key/scale we're talking about at the time (relative)?
(I'm not going to get into whether D♯ and E♭ are the same note, etc, for the purposes of the question, because I don't know enough - hopefully a good answer can make that clear too!)
Comment: Augmented fourth and diminished fifth?
Answer: Intervals are not based just on semitones. They are a combination of distance in semitones and distance in letter name. So as much as you want to avoid the idea that D♯ and E♭ is the same note, you cannot when talking about intervals.
The letter name distance determines the type of interval (unison, second, third, etc.) and the distance in semitones determines the quality. Any A to any E is a 5th and any A to any D is a 4th so while D♯ and E♭ are enharmonic equivalents and may be the same note in some instruments, they indicate different intervals.
Because of this, how things are spelled defines the name of the interval. If a key/scale/chord uses the same spelling of intervals it will have the same name.
Let's compare two chords: Cm (C E♭ G) and C7♯9 (C E G B♭ D♯). Since C to D is a 2nd (or 9th since it's an octave above) and C to E is a 3rd, C to D♯ and C to E♭ are two distinct intervals: an augmented 2nd (augmented 9th) and a minor 3rd.
Answer: If the notes are from C to D# it's an augmented second. If it's from C to Eb it's a minor third. Is that what you are asking? Even though the notes are enharmonic (same pitch but different names) the name for the interval is different. They will sound the same though so those two intervals are also said to be enharmonic intervals.
Answer: This may at first sound strange, but the number of semitones is determined by the name of the interval but not the other way around. In non-equal-temperament, there may be no enharmonics, D# may (or may not) be identical to Eb (they will be close though.)
In equal temperament, (or by counting piano keys), each semitone is considered to have the same ratio. Often, in some post-Romantic music theory, notes and intervals are identified by semitone count. However, in most Common Practice Period music (and most earlier and lots of modern music), each key is represented by 7 letters (A,B,C,D,E,F,G) and intervals main name are determined by counting this way. So A to C and C to E are both called a third; as the two intervals have different semitone counts, A-C is termed a minor third and C-E is termed a major third.
As music was (and mostly still is) written, naming intervals by note name (rather than semitone difference) carries more information. For example, in the key of C, the interval D-F is a minor third and D-F# is a major third; this naming indicates that for the purposes of the piece being considered, the composer (and performers) should think of F# as a modified F rather than an independent object. (Of course, this is a convention, in the key of D, F# would be the "normal" note and F the modified note.)
One point is that in general (everything is always "in general" or "usually") sharpened notes tend to be followed by a higher pitched note and flattened notes tend to be followed by lower tones. Note that in the same piece, things like dm-G-C and D-G-C chords (ii-V-I and II-V-I or V/V-V-I in Roman Numerals) may both be used to end phrases. Root movements are the same, the only difference is that the D chord appears in two forms. One could even have a d-diminished chord consisting of the notes D,F, and Ab . All these are basically a type of D chord, a G chord, then a C chord even though the intervals may be different.
Another historical relic is that in non-equal-temperament (for example "just tuning"), the ratio of D to C is 9/8 and of E to D is 10/9; this causes the just third C to E to have the ratio 5/4. Equal size whole tones give the C to E ratio as either 81/64 or 100/81. (Thus one has the choice of which intervals should be out-of-tune.)
Music is named because composers write as though intervals may have different sized, but the compromise of equal-temperament means that one is always off (but by the same amount no matter what key.)
Answer: It cannot be absolute or unique, due to the fact that any interval name relies on two factors. Like it or not, the D♯/E♭ conundrum must be part of the equation!
The letter name distance gives the number of the interval. C>D is a second. C>D♭ is a second. C>D♯ is a second. C>E is a third. C>E♭ is a third. C>E♯ is a third.
BUT those seconds (C>some D) all have different names - and that's due to the number of semitones between the notes concerned (as you thought).
C>D is called major 2nd. C>D♭ is smaller, so called minor 2nd. C>D♯ is larger, so is called augmented 2nd.
C>E is M3. C>E♭ is smaller, so m3. C>E♯ is larger, so augmented 3rd. If you want more (or less!) C>E♭♭ is a diminished 3rd.
The only intervals with no major/minr name are P4, P5 and P8. When they are smaller by one semitone, they are called diminished; larger by the same, augmented. Same number (4, 5, 8) different word, to signify different number of semitones between them.
To underline all this - when two notes are heard, it is impossible to state what the interval is between them. It may well be a simple 'major 3rd', or 'minor 7th',and context will obviously help, but just two notes in isolation, heard, no. Written down, the interval is obvious every time!
Answer: A tone is a frequency distribution with one dominant frequency and many lesser frequencies.  A tone is never a pure single "note" in isolation, it is a composition of many frequencies, the strongest one and dominant one being the "name" of the note.  This is like calling a city by the name of the tallest skyscraper.  It's not calling it Dubai, it's Burj Kalifa.  Even though we know the area is actually more detailed and fine-grained, Dubai being huge, when we call a complex frequency distribution a note we are calling this entire province by the name of the tallest building.
Alright, so that's a tone.  What's an interval?  Interval is the ratio of two tone frequencies.  For a perfect fifth the ratio is 3:2 and this is always true no matter what the octave.  If we start at A=432 then a perfect fifth up is f*(3/2) or 648Hz.
When we play 432 and 648 together we get a Perfect Fifth two-tone overlap.  This is fundamentally what an "interval" represents.
Pythagoras was confronted with a challenge, how to represent this amazing doubling effect in frequency for every octave.  If you have 100Hz and double it to 200Hz you get an "octave higher" sound -- the note is the same but it sounds higher.  Meaning we have a rainbow of sounds in each Octave that are repeating, slightly higher slightly lower, we may even think of them as brighter or more saturated in the more resonant octaves closer to the human range and reign of our ear.
Pythagoras found an amazing approximation.  By creating 12 equally sized pie pieces on the wheel of the Octave, we can have the beautiful 3:2 and the important 4:3 (Perfect Fourth) represented by two distinct keys.  The 12-tone system is the most convenient representation that accurately (within a few decimal spots) represents a perfect fourth and perfect fifth with regularity up and down the octaves.  The fundamental basis of all modern music theory is the striving to keep 3:2 and 4:3 convenient to play, which is why almost every instrument has 12 buttons per octave.
Today, we can challenge this digitally by returning to the mathematical basis for music, the whole number ratio between tones.  Also known as "intervals."
Answer: In the same way that you have enharmonic notes (D# / Eb), you can have enharmonic intervals (dimished 5th / augmented 4th or minor 3rd / augmented 2nd). Does this answer your question?
Comment: Don't be quicker - be more explanatory.
Comment: What's the added value of your answer compared to the already existing ones?
Comment: What about this [one](https://music.stackexchange.com/a/89747/40510)?
Comment: Probably not. The concise answer is 'no'. However, on this site, answers that explain why are always graded as better. Add some explanation to stem the dvs!
Comment: Conciseness. I find that the other answers go off on relatively long tangents
Comment: That one's a bit less concise than mine, but still quite concise.
Comment: Funny, because in other SE sites I had a question downvoted for going off on a tangent...
Comment: I think the problem is that your answer came much later than the others and that there's nothing in your answer which hasn't been covered already.
Comment: Understood. Will try to be quicker next time


Find $P(2 \leq |X| + |Y| \leq 3)$ where $X, Y \sim N(0, 4)$ are independent and normally distributed

Question: Suppose that $X, Y \sim N(0, 4)$ are independent and normally distributed random variables.
My question is how to find $P(2 \leq |X| + |Y| \leq 3)$?
Probably, the first step is to try to solve a more general task and find the distribution of $Z := |X| + |Y|$, i.e. find $F_Z(t) = P(Z \leq t) = P(|X| + |Y| \leq t)$ for $t > 0$.
The straightforward way would be to compute the integral:
$$\int\limits_{|x| + |y| \leq t} \dfrac{1}{8\pi} e^{-(x^2 + y^2)/4}dxdy$$
This task seems to be non-trivial because the resulting integrals end up being hard to calculate. Assuming the function $\Phi(t) = \int\limits_{-\infty}^{t} \dfrac{1}{\sqrt{2\pi}}e^{-x^2/2}dx$ is known, the integral above requires computing something like $\int\limits_{0}^{t}e^{-x^2/4}\Phi(x) dx$ which I'm not sure how to compute with simple calculus tools that I know.
Maybe it is easier than I think or maybe there is just a different better way of solving this.
Any help would be greatly appreciated.
Comment: The distribution of the absolute value of a normal random value is a half-normal distribution. Have a look here: https://math.stackexchange.com/questions/428781/sum-of-independent-folded-normal-distributions
Comment: ok, I will try to write it (in an answer)
Comment: @hgmath Thank you for the reference! But in this answer https://math.stackexchange.com/a/428790/251704 I haven't quite understood the point about circular symmetry. That would great if you could kindly elaborate, why can we just use the rotated square instead of the original one?
Answer: As asked for in a comment I'll try to elaborate on the "circular symmetry" argument given in this answer.

Basically we are given two normally distributed, independent random variables $X,Y \sim N(0,4)$ and want to find the distribution function of $|X|+|Y|$. I.e. for $a>0$ we want to calculate
$$F_{|X|+|Y|}(a) = P(|X|+|Y|\leq a) $$
This means that we want to find the probability of $(X,Y)$ to lie within the set
$$A = \{(x,y)\in\mathbb{R}^2 \mid |x|+|y|\leq a\} .$$
Geometrically $A$ is a square with corners at $(-a, 0)$, $(0, -a)$, $(a, 0)$ and $(0, a)$. For example, with $a=10$:

Now, because $X$ and $Y$ are independent, the random vector $(X,Y)$ is jointly normal-distributed with covariance matrix $\begin{pmatrix}4&0\\0&4\end{pmatrix}$.
This means that it is rotationally invariant: for every angle $\alpha$, the rotated vector
$$\begin{pmatrix}
\cos \alpha& -\sin \alpha \\
\sin \alpha & \cos \alpha \\
\end{pmatrix}\begin{pmatrix}X\\Y\end{pmatrix}$$
has the same distribution as the vector $(X,Y)$ itself. (This can be checked using how a multivariate normal distribution changes under a linear transformation; note that the rotation matrix is orthogonal.) The symmetry can also be seen geometrically by plotting the density:

Hence, denoting the rotation by $\alpha$ as $R_\alpha$,
$$P((X,Y) \in A) = P(R_{-\alpha}(X,Y) \in A) = P((X,Y) \in R_\alpha(A)) .$$
We can thus equivalently compute the probability of $(X,Y)$ lying in the rotated square $A'$. Now choose $\alpha=45^\circ$; rotating the square by $45^\circ$ yields a square with axis parallel sides (the side lengths remains the same: $\sqrt{2}a$)

And now
$$P((X,Y) \in A') = P\left(|X|\leq \frac{\sqrt{2}a}{2}, |Y|\leq \frac{\sqrt{2}a}{2}\right) = \left(F_{N(0,4)}\left(\frac{\sqrt{2}a}{2}\right) - F_{N(0,4)}\left(-\frac{\sqrt{2}a}{2}\right)\right)^2 .$$
Comment: That's so cool! Thank you!


Derivative over the function itself

Question: I am new to calculus. Let $f(X)$ be continuous and differentiable over a set of variables $X$ where $x \in X$ and $x \in (0,\infty)$. Is there any general solution or rules to solve $\frac{f'(X)}{f(X)}$?
Comment: "Where $x\in X$ and $x \in (0,\infty)$" so $X=(0,\infty)$? Also do you mean $f(x)$?
Comment: What do you mean "solve $\frac{f'(X)}{f(X)}$"? This is not an equation, so I don't see what would constitute a solution.
Comment: If this is a probability density function, go ahead and add that tag.
Comment: $f$ is a function over multiple variables $x_1,x_2,\dots,x_i,\dots,x_n$ where $x_i \in X$. Sorry that I did not mean to solve $\frac{f'(X)}{f(X)}$. The question is "is there a general solution to $\frac{f'(X)}{f(X)}$"?
Answer: Of course if you can differentiate $f(x)$ you can immediately write $\frac{f'(x)}{f(x)}$ by just dividing.  For example, if
$$
f(x) = x^3 + 5 \\
f'(x) = 3x^2 \\
\frac{f'(x)}{f(x)} = \frac{3x^2}{x^3+5}
$$
But I suspect what your professor or teacher is getting at is that it is sometimes easier if you realize that
$$
\frac{d(\log(f(x))}{dx} = \frac{f'(x)}{f(x)}
$$
For example, if
$$
f(x) = e^{\sin x}\\ \frac{f'(x)}{f(x)} = \cos x
$$
without much work, since $\log\left( e^{\sin x} \right)= \sin x$.
Comment: A typo: **since $\log\left( e^{\sin x} \right)= \cos x$** should read **since $\log\left( e^{\sin x} \right)= \sin x$**
Comment: Is there a general solution to this problem? By the way is there a term for the expression $\frac{f'(X)}{f(X)}$?

Derivative over the function itself


How to forward a mail server without MX records?

Question: My company is switching from an old clunky dedicated email server (which we can't maintain anymore) to Google Apps email, and we'd like to start using the Google email now, as the old server regularly loses emails.
The problem is that we're waiting on the MX records to change, and the guy before me (who's no longer with the company) set the TTL to a ridiculously high number (like a week) thinking that it would improve server performance.
While we wait on the MX change to propagate, I was wondering if there's any way I can set the old server to just forward all connections to google instead.
Is there any way to do that?
EDIT
I'm using Postfix/Dovecot on a Ubuntu 12.04 LTS server (The last guy upgraded the server before he left, but it's still not working well and we don't have anyone with email server experience to maintain it.)
Comment: `Is there any way to do that?` - Yes.  Now, that you have your answer, perhaps you would like to add some more details about your existing mail setup so someone could give you more useful information.  For example, what is your current mail server?
Comment: If it's losing email, why do you think using it to forward email will be somehow more resilient?
Comment: @Zoredache I've edited with some details. Do I need to put anything else?
Comment: @mfinni I don't really know. Misguided optimism I suppose. This was really more of an administration decision than an IT one.
Comment: I am not familiar with postfix.  But I would start looking at the documents for setting up a relay.  http://www.postfix.org/BASIC_CONFIGURATION_README.html  You basically need to switch from your current setup over to a relay.  You want to relay only for your domain, and you want to your domain to be relayed to Google.
Comment: Also see the routing section in the Google Apps Docs.  It will have the information about addresses and such to route to.  https://support.google.com/a/topic/2921034?hl=en&ref_topic=14867
Answer: Set up the old box to be a secondary MX server, flush the DNS records on your old box (so that when you do a 'host -t MX your domain' you see google with a lower MX value than your old box).  Now your old email box may merrily be a secondary MX server and relay email to google.
http://en.wikipedia.org/wiki/MX_record#The_backup_MX
Comment: But won't those MX Records take just as long to propagate?
Comment: Simply adding an MX record won't change a mail server that is currently configured to accept all mail for a given domain over to relaying mail for that domain.  Also in this case the external people are all ready getting to the old MX record which is presumably his existing postfix box.  He doesn't have to add another MX record for the messages to get to the postfix box.  He just needs to get the messages from his postfix box over to Google.
Answer: Just forward port 25 on the (retired) mailserver to Google.
Answer: You can get a postfix server to forward all email to another server with the line:
relayhost = googlehostname.google.com
To answer the specific question that was asked "How to send email to an address and not an MX record", you can edit the /etc/postfix/transport file to over email locations for a domain.
Something like:
example.com smtp:googlehostname.google.com:587
Then rebuilding the file with
  postmap hash:/etc/postfix/transport
and restarting postfix
will cause your postfix server to forward all email for example.com to googlehostname.google.com on port 587 without doing an MX lookup. This is how you can build internal processing servers without having to muck with fake DNS.


$\mathbb{R}[X]$ is an integral extension of $\mathbb{R}[X^2-1]$

Question: I am trying to prove that every polynomial of $\mathbb{R}[X]$ satisfies a monic polynomial equation with coeffients in $\mathbb{R}[X^2-1]$ that is every polynomial $b(x)= x^m+b_{m-1}x^m-1+...+b_{0}$ satisfies
that there exits an $ n\in N$  such that $b(x)^n+a_{n-1}(x^2-1)b(x)^{n-1}+...+b_{0}$=0 is satisfied being $a_{i}(x^2-1)$ a polynomial in $\mathbb{R}[X^2-1]$ .
I have tried to distinguish the polynomials $b(X)$ depending of its degree so that I can choose $a_{i}(x^2-1)$ that satisfies the equation but I don't know if I am in the correct path.
Thank you.
Comment: It is $R[X]$ which is an integral extension of $R[x^2-1]$.
Comment: @VeganMaths Why do you want to find explicit polynomials? To check that it is an integral extension, you just need to show that $X \in R[X]$ is integral over $R[X^2 - 1]$. Remember that sums an products of integral elements are integral.
Answer: Hint:
$\mathbf R[X^2-1]$ contains $X^2$, hence $\mathbf R[X^2]$.
Comment: Can I affirm that $\mathbb{R}[X^2]=\mathbb{R}[X^2-1]$
Comment: How can I show the inclusion?
Comment: The inclusion of $X^2$ or of $R[X^2-1]$?
Comment: I asked for which inclusion you wanted details.
Comment: Ues, the reverse inclusion is obvious since $X^2-1=\dots$, well $(X^2)-1$.
Comment: And how can I find a monic polynomia such that it is integral any element of $\mathbb{R}[X]$
Comment: That is  another problem. Maybe writing any polynomial as $P(X^2)+Q(X^2)X first?
Comment: But , the main aim is to find such polynomial in order to affirm that $\mathbb{R}[x] $ is an integral extension right?
Comment: You have other non explicit ways, using general properties of integral extensions, e.g. $\mathbf R[X]$ is an $\mathbf R[X^2]$-module of finite type.
Answer: Note that for a ring extension $A \subseteq B$, the elements of $B$ that are integral over $A$ form a ring (this is a standard theorem and many proofs are available online).
Clearly every element of $\mathbb{R}$ is integral over $\mathbb{R}[X^2 - 1]$.
Also, $X$ is a root of the monic polynomial $f(t) = t^2 - (X^2 - 1) - 1 \in \mathbb{R}[X^2 -1][t]$, so $X$ is integral over $\mathbb{R}[X^2 -1]$.
Since $\mathbb{R}[X]$ is generated as a ring by $\mathbb{R}$ and $X$, the result follows from the fact in the first paragraph.


Proftpd port-forwarding failing

Question: I'm setting up proftpd on an ec2 Instance running Ubuntu 10.04
I've gone through all the forums and tried every suggestion but still can't seem to get it working.  I know the problem is with the passive ports but everything I've tried has failed.
The filezilla log shows:
Status: Resolving address of ec2-50-110-20-81.us-west-2.compute.amazonaws.com
Status: Connecting to 220.127.116.11:21...
Status: Connection established, waiting for welcome message...
Response:   220 ProFTPD 1.3.2c Server (Michaels Main) [220.127.116.11]
Command:    USER cube
Response:   331 Password required for cube
Command:    PASS *******
Response:   230 User cube logged in
Command:    OPTS UTF8 ON
Response:   200 UTF8 set to on
Status: Connected
Status: Retrieving directory listing...
Command:    PWD
Response:   257 "/home/cube" is the current directory
Command:    TYPE I
Response:   200 Type set to I
Command:    PASV
Error:  Disconnected from server: ECONNABORTED - Connection aborted
Error:  Failed to retrieve directory listing

In my proftpd.conf file I have the following lines for setting up the passive ports:
ServerType                      inetd
PassivePorts                    60000 60200
MasqueradeAddress               184.108.40.206

My iptables -L -v looks like this:
4475 370K ACCEPT all -- any any anywhere anywhere state RELATED,ESTABLISHED
   0    0 ACCEPT tcp -- any any anywhere anywhere tcp dpt:ftp-data
  13  676 ACCEPT tcp -- any any anywhere anywhere tcp dpt:ftp
   1   40 ACCEPT tcp -- any any anywhere anywhere tcp dpts:60000:60200
   0    0 ACCEPT tcp -- any any anywhere anywhere tcp dpt:ssh

netstat --vatn:
tcp        0      0 0.0.0.0:21              0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        0      0 10.252.45.220:22        220.127.116.11:18169     ESTABLISHED
tcp6       0      0 :::22                   :::*                    LISTEN

/proc/sys/net/ipv4/ip_forward is set to 1.
I've uncommented the net.ipv4.ip_forward=1 line in /etc/sysctl.conf
This has my head fried, any ideas?  If I've left anything out please let me know.
Thanks for your help, cheers!
Comment: This is EC2, so did you set up the Security Group for this instance to allow the passive port traffic?
Comment: Ports 60000 - 60200 are open in my Security Group
Answer: Did you open ports 60000 to 60200 in your EC2 security group ?
Comment: Ports 60000 to 60200 are open in my ec2 security group.  Thanks for the suggestion though.

Proftpd port-forwarding failing


.NET How to change Control's Location and Width at once?

Question: Edit: Assume a TextBox as the control for the example - where height is not an issue
So I am using the mouse to change a control's width and location at runtime (through grabbing a handle with a mouse, much the same way that you can change it at design time).  However, I am noticing some resizing issues, which I thought would be fixed by calling
<panel>.SuspendLayout
<control>.location = new Point(x, y)
<control>.width = newWidth
<panel>.ResumeLayout

Now both the location and width change correctly, but because the location changes first - you see a blur of the textbox changing width after it moves.  Now reading through Suspend and ResumeLayout, I guess they are supposed to be called before the controls are constructed.  With that being the case: how do I make sure the location and width change at once to avoid the blur?
Edit: Solved - The following code allowed me to suspend drawing the control before the properties were set, then resume afterward.  As opposed to suspending the layout*
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Integer, _
                                                                ByVal wMsg As Integer, _
                                                                ByVal wParam As Integer,
                                                                ByVal lParam As Integer) As Integer

Private Const WM_SETREDRAW As Integer = 11

' Extension methods for Control
<Extension()>
Public Sub ResumeDrawing(ByVal Target As Control, ByVal Redraw As Boolean)
  SendMessage(Target.Handle, WM_SETREDRAW, 1, 0)
  If Redraw Then
    Target.Refresh()
  End If
End Sub

<Extension()>
Public Sub SuspendDrawing(ByVal Target As Control)
  SendMessage(Target.Handle, WM_SETREDRAW, 0, 0)
End Sub

<Extension()>
Public Sub ResumeDrawing(ByVal Target As Control)
  ResumeDrawing(Target, True)
End Sub

Answer: An appropriate solution to preventing this type of flickering to occur wouldn't be changing both of the values at once, as one will always be set before the other, but setting the form to use double buffering.  This way, your changes are drawn off screen before being copied onto your visible region.  You can find this property on your form.
MSDN: For additional information on the DoubleBuffered control property.
Comment: I'm a little confused.  I've set the following settings for the panel.

        **Me.SetStyle** (ControlStyles.AllPaintingInWmPaint Or _
                    ControlStyles.UserPaint Or _
                    ControlStyles.DoubleBuffer, True)
        \n **Me.UpdateStyles** ()
        \n **Me.DoubleBuffered** = True.  None of this helps the jitter.
Answer: Instead of panel.SuspendLayout(), do this.SuspendLayout(). Suspend and Resume are guaranteed to traverse down the actual object tree, but I've never had luck with it trickling down the container tree.
Comment: I've tried this.  Out of curiosity I also tried suspending the form layout.  None of them worked.
Comment: Hmm, the only other way I've tried is by sending a WM_REDRAW command via Win32. Here's one way to do it: http://stackoverflow.com/questions/487661/how-do-i-suspend-painting-for-a-control-and-its-children/487757#487757. It'd be pretty easy to turn these into extension methods on `Control` so you can use it in multiple places.
Comment: I've just spent the last hour trying to hold off the WM_PAINT message, but oddly enough, neither the panel nor the textbox actually controls the painting of border of the textbox.  The resizing still works, just no filler in the panel, or white (including the inner text) in the textbox.  I will check out WM_REDRAW - thanks for the suggestion.
Comment: Good to hear. Don't you just love how .NET doesn't give you direct access to important functionality like this?
Comment: Yeah, I don't have much experience programming, but the I did become fond of java.  .NET annoys me quite often haha.  Again though, that's just in my small experience.


How to integrate $\int_{0}^{1}\ln\left(\, x\,\right)\,{\rm d}x$?

Question: I encountered this integral in the quantum field theory calculation. Can I do this:
$$
\left. \int_{0}^{1}\ln\left(\, x\,\right)\,{\rm d}x
=x\ln\left(\, x\,\right)\right\vert_{0}^{1}
-\int_{0}^{1}\,{\rm d}x
=\left. x\ln\left(\, x\,\right)\right\vert_{\, x\ =\ 0}\ -\ 1
$$
So the first term looks divergent. But Mathematica gives finite result and the integral is $-1$. Why isn't the first term divergent ?.
Comment: I changed the tags because the previous ones where not related to the question.
Comment: *the first term looks divergent* - Appearances can be deceiving.
Answer: Use L'Hopital's Rule to resolve the indeterminate form: $$\lim_{x\to 0^+}x\ln x=\lim_{x\to 0^+}{\ln x\over x^{-1}}=\lim_{x\to 0^+}{x^{-1}\over -x^{-2}}=\lim_{x\to 0^+}(-x)=0$$
Comment: They're both correct, but your method won't really help you find the limit.
Comment: Uh, I tried L'Hopital's Rule, but used it this way $\lim_{x\rightarrow 0}\frac{x}{1/\ln x}=-\lim_{x\rightarrow 0}x\ln^2x$... Which one is correct?
Answer: interpret $\int_0^1 \ln x dx$ as the signed area of the region bounded by $x = 0, y= \ln(x)$ and $y = 0$ this is the negative of the area of the region bounded by $x = e^y, y = 0$ and $x = 0$(interchange $x$ and $y$ in the previous boundary). the area of latter region is $\int_{-\infty}^0 e^y dy = 1.$  so $\int_0^1 \ln(x) dx = -1.$
another way to think of the same thing is in the first area computation you have the infinitesimal rectangles parallel to the $y$-axis in the latter the infinitesimal rectangles parallel to $x$-axis.
Answer: Hint: Use L'Hopital's rule to evaluate $\lim_{x\to0^+}x\ln x$.
Answer: Or alternatively, use the substitution $x=e^y$.
Comment: L'Hopita's rule extends to $\pm\infty$ by noticing $\lim_{x\to\infty}f(x)=\lim_{x\to0^+}f(x^{-1}).$
Comment: Thanks. I tried this before posting and using integration by part, got one term looks like $ye^y|_{y\rightarrow -\infty}$ then stuck.
Comment: Yeah fair, that's another situation where you would use L'Hopital's rule.
Comment: Oh yes! I didn't try because $-\infty\notin\mathbb R$. But it works formally.
Answer: We have
$$\begin{gathered}
  \int\limits_0^1 {\ln xdx}  = \mathop {\lim }\limits_{\varepsilon  \to {0^ + }} \int\limits_\varepsilon ^1 {\ln xdx}  = \mathop {\lim }\limits_{\varepsilon  \to {0^ + }} \left( {\left. {\left( {x\ln x} \right)} \right|_{x = \varepsilon }^{x = 1} - \int\limits_\varepsilon ^1 {dx} } \right) = \mathop {\lim }\limits_{\varepsilon  \to {0^ + }} \left( { - \varepsilon \ln \varepsilon  - 1 + \varepsilon } \right) \hfill \\
   =  - \mathop {\lim }\limits_{\varepsilon  \to {0^ + }} \varepsilon \ln \varepsilon  - 1. \hfill \\
\end{gathered}$$
On the other hand, by the L'Hospital rule, we have
$$\mathop {\lim }\limits_{\varepsilon  \to {0^ + }} \varepsilon \ln \varepsilon  = \mathop {\lim }\limits_{\varepsilon  \to {0^ + }} \frac{{\ln \varepsilon }}
{{\frac{1}
{\varepsilon }}} = \mathop {\lim }\limits_{\varepsilon  \to {0^ + }} \frac{{\frac{1}
{\varepsilon }}}
{{ - \frac{1}
{{{\varepsilon ^2}}}}} = \mathop {\lim }\limits_{\varepsilon  \to {0^ + }} \left( { - \varepsilon } \right) = 0.$$
So
$$\int\limits_0^1 {\ln xdx}  =  - 1.$$
Answer: Consider the general log integral, $$I_n=\int_0^1\log^n(x)\ dx$$
note that we are after $I_1$ and define the exponential generating function $G(t)$,
$$G(t)=\sum_{n=0}^\infty\frac{I_n}{n!}t^n=\int_0^1\sum_{n=0}^\infty\frac{(t\log(x))^n}{n!}\ dx=\int_0^1x^t\ dx=\frac{1}{1+t}$$
for $t>-1$ and expanding the result as a geometric series in the same region,
$$\frac{1}{1+t}=\sum_{n=0}^\infty(-1)^nt^n=\sum_{n=0}^\infty\frac{(-1)^nn!}{n!}t^n$$
comparing coefficients,
$$I_n=(-1)^nn!.$$
The first four non-zero log integrals are,
$$\begin{align*}
&\int_0^1\log(x)\ dx=-1,\quad\int_0^1\log^2(x)\ dx=2 \\
&\int_0^1\log^3(x)\ dx=-6,\quad\int_0^1\log^4(x)\ dx=24.
\end{align*}$$


SQL SSIS - Moving certain number of files

Question: I am looking for a way to move files from one folder to another using SSIS.
I have a foreach loop with an empty data flow and a file system task in the foreach loop.
I want to specify a certain number of files to be moved using a variable. Increments of 1000 files at a time.
Please Help
Comment: Do you just want to move the files without importing them or anything?  Or do you want to import them to the DB then move them?
Comment: The first step to doing this is to open SQL Server Data Tools and try something.
Answer: If you are looking to move files from directories to another one using variables all you need is a Execute File System Task inside a Foreach Loop container of type file enumerator. There are many articles found on the internet that describe the whole process step-by-step.

For Each Loop with File System Task
Move Multiple files using File System Task in SSIS

If want to exclude some directories or files then you should use a Script Task or an Expression Task to apply filter, you can check my answers on:

Exclude specific Sub Folders
WildCards in SSIS Collection {not include} name xlsx


In football is it possible for a team to change team formation during a match?

Question: In football:

Is it allowed by the rules to change the team formation during a match?
Does it happen often when a coach decides to swap players between positions?
Does it happen often when a coach decides to change team formation?
Comment: That is something in which football (soccer) is different from football (of the "american" kind). There are no fixed positions - except maybe goalkeeper - so there is no concern about a "tight-end" swapping position with a "running back" or a "wide receiver" with the "quarter back"
Answer: The rules actually don't say anything about formations. The only thing they say is that there are 11 players per side - one of which is designated a goalkeeper, and that if a team drops below 7 players the match cannot start/continue (source: IFAB Law 3: The Players.)
Formations are all about strategy. If the team is playing an attacking strategy, they will play more players up - formations like 4-3-3 or 4-5-1. A more defensive formation would be something like 5-3-2 or 4-1-4-1. These would put more players in the backfield.
However, there's nothing that restricts players to certain areas of the field based on their formation. You'll almost always see one or more midfielders help out on attacks, but you will sometimes see defenders come up to help as well. Defenders can be playing higher than midfielders (or even forwards) for a time, though they will usually return to the backfield - not because the rules say they have to but because in a formation it's good to be where you're supposed to be so your teammates can be where they're supposed to be.
So, to answer your specific questions:

Yes, since formations aren't mentioned at all in the rules, they can be adjusted.
Sometimes when making a substitution, a coach will sub in a defender for an attacker/midfielder if the team is ahead and wants to protect their lead. The opposite can happen too. But it all depends on the situation of the game.
Again, it all depends on the layout of the game. I'd say the most likely time when a formation change would happen is probably halftime, so the coach can discuss the new strategy in depth with the players, but it could happen at any point.

EDIT: I've known people to ask about the formation that the sportscasters usually announce before the game, so here are some notes on that. I do not have citations for these, they're just what I believe to be true.
Although a formation is not required by the rules, it is often possible to tell what a formation will look like by examining the players that will be on the field. Some players are generally attackers, some defenders, and some midfielders. You can also sometimes tell based on knowledge about the coach - what formations has s/he used in the past in different situations.
Lastly, I believe that coaches sometimes will mention the formation they're using when announcing the starting line-up. This is not required, though.
Best source I have for this is another stackexchange post.
Comment: "a coach will sub in a defender for an attacker/midfielder" - you mean - they would swap their positions? Or an attacker go to the bench and the player with more defensive play style would replace him?
Comment: The latter - notice it says "...when making a substitution..." I don't think a coach would generally swap a defender on the field with an attacker on the field, though it's not impossible.
Comment: I have a source you may be interested in adding that supports that coaches submit the lineup. In the Australian national league, the Hyundai A-League, coaches submit the formation along with the team sheet, so it can be passed onto broadcasters and published by the league. [This tweet from Sydney FC](https://twitter.com/SydneyFC/status/693332504577593344) shows a completed team sheet, containing each team's formation. I imagine other national leagues could possibly do something similar.
Comment: @Duncan, so you meant the coach substitutes an attacking-style player with defensive-style player on the same position on the field, right?
Comment: "Positions" doesn't have a meaning in the official rules, so it's tough to pin down. But in the sense of where they play in the formation, it's possible for the coach to sub a defensive-minded player into the same position in the formation as an attack-minded player. But if they wanted to shift to a defensive mindset, they often will change the formation as well. For example, they're playing in a 4-3-3 formation, but are up by a goal and want to protect it. They take out an attacker, sub in a defender and play a 5-3-2. Or sub in a midfielder for the attacker and play a 4-4-2.
Answer: Players can change formations/positions at any time, mostly at the coaches discretion. For example, if you are winning you may want to play more defensively to protect your lead and if you are losing then you many want to be more attacking minded.
Changing positions/formations happens quite often but it all depends on the opposition.


NPE on javafx applications on MAC

Question: This is quite an annoying bug that was - supposed to be - fixed already ( I did some research), but the problem persists on my mac.
I have a simple javaFX application with a button that when clicked on should print hello world. The button itself has some text in it. However, when the application runs, it gives this error:
Caused by: java.lang.NullPointerException
at com.sun.javafx.font.MacFontFinder.populateFontFileNameMap(MacFontFinder.java:99)

(full exception here: http://pastebin.com/YdAgMfPs)
How could this be solved? Mac is on most recent version ( OS X el capitan) and java aswell. I'm using netbeans IDE, but can be reproduced on other IDE's aswell, so I think the problem lies with my machine
Answer: I've found a solution to this problem. I opened the font book app and restored standard fonts. That did the trick.
Source : https://bugs.openjdk.java.net/browse/JDK-8089900
Answer: I had the same problem (OSX 10.11.6) when using the mvn speedment:tool, which also makes use of JavaFX. Restoring standard fonts made the NPE go away. I later installed latest version (2.37) of DejaVuSansMono.ttf which I use in my Terminal, and the problem did not come back.

NPE on javafx applications on MAC


λP2, the Calculus of Constructions, and quantifying over propositions

Question: In $\lambda P2$, we can write polymorphic functions like $\Lambda A. \lambda x. x: \Pi A. A \to A$. By Curry–Howard, this corresponds to the proposition "for all propositions $A$, $A$ implies $A$". From my understanding, the quantification here is predicative, i.e. "for all propositions" includes the proposition "for all propositions $A$, $A$ implies $A$" itself. Hence, $\lambda P2$ allows quantifying over arbitrary propositions.
If so, then I'm wondering about the difference between $\lambda P2$ and COC. From my understanding, the logical difference between $\lambda P2$ and COC is that COC allows predicates over propositions. Supposedly, $\lambda P2$ logically corresponds to second-order predicate calculus, while COC is higher-order predicate calculus.
But why is $\lambda P2$ only second-order? Isn't a statement like "for all propositions $A$, $A$ implies $A$" already a higher-order statement, because it not only quantifies first-order statements, but also second-order statements, etc.? If not, how does adding predicates over propositions make COC higher-order? What's an example of a higher-order proposition we can make in COC that we can't in $\lambda P2$?
Comment: λP2 and COC are different in terms of [Lambda Cube](https://en.wikipedia.org/wiki/Lambda_cube). COC has all the three dimension rules while  λP2 is missing (binding) type operators rule (type families).
Comment: Yes. I think my question was why adding type operators turn it into a higher-order logic? Was it not already a higher-order logic?
Comment: It gives more powerful type system for CoC compared to λP2. Your propositions (as types) may have different kinds of types, like simple types, algebraic types, termed types, dependent types, and typed types (type families). CoC can abstract over all above kinds of types, while λP2 is missing typed types.
Comment: I understand that. The question is about naming. Why do we call it "higher-order" if we can abstract over all kinds of types? In λP2, couldn't we not already abstract over types, and if so, why do we just call it "second-order"? Why does allowing abstracting over type families turn it into "higher-order"?
Comment: In your example "for all propositions A, A implies  A" per Curry–Howard, strictly speaking you can only map proposition to intuitionistic proposition/formula. System F (λ2) adds abstraction over polymorphic types (term dependent on type) which is second order. λP2 is also second order by further adds dependent types. However, CoC is higher order since it allows abstraction over types of types (like ranging over sets of sets in 3rd order logic). Induction is not derivable in λP2 (see [here](https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.26.957&rep=rep1&type=pdf)), so it's rarely used
Answer: The reason is that quantifying over propositions isn't considered higher-order merely because propositions can contain second-order quantifiers.
In logic, 'order' is measuring to what extent subsets or relations are realized as objects within the logic. In first order logic, only individuals of the domain of discourse are objects. In second order logic, relations on/subsets (of products) of the domain of discourse are objects. Third order logic allows subsets of subsets. And higher order logic is like the limit of this, where any finite iteration of subsets/relations are available as objects.
The propositions in second order logic are allowed to have second order quantifiers. So, in general, the relations/subsets being quantified over may in principle be defined in terms of the collection of 'all' relations. This doesn't make the logic higher order. You could restrict the semantics of the logic more, but it would be a restriction (it would be related to "predicativity"). It's not really different than a first order theory that allows you to specify individuals via formulae that contain first order quantifiers. Such a theory isn't considered higher order because of that.
$λP2$ is second order in this sense because you can quantify over relations via types like $ℕ → ℕ → *$. However, the type of predicates-on-relations would be $(ℕ → ℕ → *) →*$, which is disallowed. But, the calculus of constructions allows this, and further finite iterations, which is the sense in which it matches higher order logic. Quantifying over propositions/$*$ is like quantifying over a 0 arity relation in this sense.


exponential random variables of monitors

Question:
You have three computer monitors, and their lifetimes $T_{i}$ are exponential random variables with parameters$ \lambda_{i}=i,$ for i = 1,2,3 respectively.
  We switch on all monitors at time zero.

Find
(a) the mean time you have to wait until monitors three burns out
(b) the variance of the above time,
(c) P(at least one monitor is burnt out at time t)
(d) the mean time you have to wait until at least one of the monitors burns out
(e) the mean time you have to wait until all of the monitors burn out.
(f) P(exactly two monitors are burnt out at time t)
for part a I think it should be $\frac{1}{\lambda}$ which is 1/3
For part b it should by the definition
part c is 1-p(0) but I don't know what should I do next.
part e is it E(first)+E(second)+E(third)=1+0.5+1/3=11/6
part f is it since they are independent so var(three burns out)=var(1)+var(2)+var(3)
The else I got no idea to do
Answer:
a) $\mathbb ET_3$
b) $\text{Var}T_3$
c) $\Pr(\min(T_1,T_2,T_3)<t)$
d) $\mathbb E\min(T_1,T_2,T_3)$
e) $\mathbb E\max(T_1,T_2,T_3)$
f) $\Pr(T_1\leq t, T_2\leq t, T_3>t)+\Pr(T_1\leq t, T_2>t, T_3\leq t)+\Pr(T_1>t, T_2\leq t, T_3\leq t)$

For c) and d) it can be used that here also $\min(T_1,T_2,T_3)$ has exponential distribution.
For f) make use of independency.
Comment: part c is  it equal to 1-exp(($\lambda1$+$\lambda2$+$\lambda3$)t)?
Comment: also i cant quite understand the f part


How to select a logical expressions in SQL Server

Question: I simply want to select a boolean value that indicates something like the following ...
select name , age > 18 from tbl_user ;

it gives an error on the expression  age > 18
Can anyone just tell me how can I add expressions in the select query ...
Answer: select name, case when age > 18
                  then 'ok'
                  else 'not ok'
             end as age_ok
from tbl_user

Instead of ok and not ok you can use 1 and 0 for boolean values if you like
Answer: select name , case when age>18 then 1 else 0 end from tbl_user ;

Answer: declare @t table (
    Name varchar(max),
    Age int
)

insert @t(Name, Age)
    values ('David', 27),
    ('Anna', 52),
    ('Joseph', 17)

select Name, Age, case when Age > 18 then 1 else 0 end from @t


Propensity score matching after imputation in R with mice

Question: 9I have a dataset (500 rows) with missing values in different variables for a propensity score analysis. First I created the propensity score matching by omitting the rows with missing values (about 100 rows) in the variables I used for propensity score calculation, but now I would like to try to impute the missing values with the mice package.
In a first step I imputed the data like this:
impute <- mice(mydata, method =
  methods, predictorMatrix =
  predictormatrix, m = 5, maxit =
   3)
mydata <- complete(impute)

So - as far as I understand - "mydata" now is a new data frame with the imputed values, but it is the first out of 5 different attempts of imputation (because the first attempt is used by default).
Now, as "mydata" is a data frame, I have my "full" data available and can continue with my propensity score matching code:
# matching
match <- matchit(treatment ~ independent1 + independet2 + independent3, data = mydata, method = "nearest")
matched_data <- match.data(match)

# model for outcome by treatment
model <- glm(outcome ~ treatment, data = matched_data, family = binomial(link = "logit"))
publish(model)

So this obviously works if I'm fine with using only the first out of 5 possible imputed datasets (as far as I now "complete" uses the first dataset by default).
Now my question is: I read about the "pool" function, but it seems that in the end I need a regression formula (like seen here https://rdrr.io/cran/mice/man/pool.html at the end of the page > "Example").
My favorite result of the imputed data would be a completed dataset with the same number of rows as before the imputation process (5oo rows) but with imputed values (by all 5 datasets) instead of NAs.
For example:
final_imputed_data <- complete(impute) # don't use the first imputed dataset (out of 5) but all 5

Or do I misunderstand the sense of multiple imputation?
Comment: Is the end goal of this analysis to estimate the propensity scores, or are you going to use the propensity scores as one step in a further analysis?
Comment: After propensity score matching I would like to do further analyses with the matched dataset...
Answer: To do multiple imputation with propensity score matching, you should use the MatchThem package, which was designed specifically for this purpose. You need to do the following steps:

Multiply impute the data, creating M (e.g., 5) separate datasets with the missing values filled in by estimates of the missing values. mice does this and stores the output in a mids object (which you have called impute). You should use way more than 5 (e.g., 50) imputations, as more is always better.
Estimate propensity scores within each imputed dataset and then perform the matching within each imputed dataset. MatchThem does this using the matchthem() function, which uses the same sytnax as matchit() but takes in a mids object instead of a data frame.
Assess balance on the matched multiply imputed data. The cobalt package works with matchthem objects (called mimids objects) to assess balance across and within imputed datasets.
If balance is achieved, estimate the effect within the imputed datasets. The MatchThem functions with() and pool() (which work similarly to the corresponding functions in mice) do this, correctly incorporating the weights, matching structure, and correction for multiple imputation.

All this is described in the MatchThem paper and documentation. Remember that propensity score matching and multiple imputation are advanced statistical techniques and should only be used by someone with advanced statistical training using these methods.
Comment: What about the problem made you want to use propensity scores?  And why use a matching algorithm that discards valid data?
Comment: Hi Noah, thank you for your answer! I read the MatchThem paper you linked here, but I've still got the question, if there is a possibility, to get back a data frame after multiple imputation for further analyses similar to the match.data function, which gives back a full data frame after using matchit().
Comment: Use the `complete()` function in `MatchThem`.
Comment: Hi Noah, thank you again for your response. Could you maybe help me with a code snippet, how to create a "cross section dataset"? If I use complete() with default parameters the FIRST dataset of the 5 will be selected. Is there a way to create a cross section of the different datasets? Does that make sense?
Comment: I mean, I have 5 different datasets - how do I decide, which of them to use for my subsequent analyses?
Comment: You have to perform the same analysis in all of them and then combine the results using formulas commonly referred to as "Rubin's Rules", which are implemented in `mice::pool()` and `MatchThem::pool()`. Read the documentation for `complete()`; you will see ways to extract more than one dataset.
Comment: Hi Noah! Thanks for your help! Do you mean this documentation https://www.rdocumentation.org/packages/tidyft/versions/0.4.5/topics/complete ? Or the "complete" section in this document: https://cran.r-project.org/web/packages/MatchThem/MatchThem.pdf (page 3) ?
Comment: The latter (`?MatchThem::complete`). You should always read a function's documentation if the default arguments aren't doing what you want.
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/129623/discussion-between-mdstat-and-noah).


Slug e Post/Get em uma mesma Route - Laravel

Question: # PÁGINA DE PRODUTO - RELACIONADA AO CARRINHO
Route::get('produtos/{slug?}', 'ProdutoController@getIndex');
Route::controller('produtos', 'ProdutoController');

Meu código atual é o acima e está funcionando. Eu fiz isso pelo fato de que, se eu deixar apenas a linha de baixo ele não encontra o Controller na seguinte URL com slug - localhost/site/public/produtos/meu-slug-produto. Então eu defini uma Route apenas para quanto tiver um slug.
Nesse Controller eu também tenho um postPagina(). Por isso eu fiz a Route da linha de baixo. Mas não sei se é a melhor maneira. Tem como fazer isso em apenas uma Route ?
No meu ProdutoController tem:
public function getIndex($slug = null)
public function postInsertProduto()

Comment: Use o stacksnippet apenas para reproduzir problemas com css, html e js e que possam ser executados.
Answer: Resolvido.
Route::any('produtos/{slug?}', 'ProdutoController');
E no ProdutoController.php fiz:
public function anyIndex($slug){

}

http://laravel.com/docs/4.2/routing#basic-routing


An URL that is all parameters

Question: I'm building a website related to videogames. There's a view that shows all videogames catalogued in the website, using taxonomy terms as arguments, that is:
mysite.com/games/genre/platform
The problem is that the "games" part in the URL is unnecesary: everything is games. For SEO reasons we want to remove this part, so, for example, this...
mysite.com/games/strategy/android
becomes this...
mysite.com/strategy/android
That is, a view with no fixed part in the path, just the parameters. How can I get this working?
Comment: If using the same view to drive the home page is an option you may be able to get away with changing the path to ``
Comment: You can´t use  in a views path.
Answer: You can go directly in your View's settings, in "Page settings" bloc, configure the path manually. Just remove the game part of the path.
For your information:
I suggest you to take a look at Pathauto module that allows you to define URL patterns very precisely for all the default pages of your site (but not views apparently): https://www.drupal.org/project/pathauto

The Pathauto module automatically generates URL/path aliases for
  various kinds of content (nodes, taxonomy terms, users) without
  requiring the user to manually specify the path alias. This allows you
  to have URL aliases like /category/my-node-title instead of /node/123.
  The aliases are based upon a "pattern" system that uses tokens which
  the administrator can change.

Maybe it will be helpful for other cases.
Comment: Thanks, but this is not the problem. The problem is that my URLS have more than one dimension, that is:

mysite.com/[taxonomy-genre]/[taxonomy-platform]
Comment: So you have 1 view per taxonomy-genre/taxonomy-platform? Are they built through the Views UI or in code?
Comment: Built on Views. I tried using Taxonomy Views to link the default taxonomy page to a view, so there are aliased URLs for the first parameter already:

misite.com/strategy/[parameter]

But this [parameter] doesn't reach the view, Drupal just gives me a 404.

An URL that is all parameters


Why is the Proper Sarum mode notated differently than it sounds (in the Yattendon hymnal)?

Question: For context, image 1 is where I found this tune in another hymnal, and it looks like a sort of free-flowing attempt at notating (in standard notation) how a choir or congregation would sing. Images 2 and 3 are the same tune in the Yattendon hymnal.

In listening to music of this type, and reading as best I can what is given here in image 2, I would expect to hear something very close to image 1. However, I am confused at how the editor came to the conclusion to notate the way he did in image 3, as it seems at odds with image 1.
So, in short: for s as short and l as long, why notate it roughly as sssssssl ' sssssssl in the one case, but llllllsl ' llllllsl in the other?
There is an explanation of sorts in the back of the hymnal, but it is quite long. It is quoted here. I believe I understood most of the explanation, but what I don't understand is why it's translated to the kind of rhythm shown in image 3.

Tune,—assigned in most of the choral books, from 12th cent. onwards, to the hymn at Lauds on Sundays, Aeterne rerum Conditor; and in many to the hymns on Ferias also, of which Splendor Paternae is one. It is found in the Sarum & Hereford antiphoners, but not in those of York. It is not set to either of these hymns in the Ambrosian books. [P.] About the date of these early plain-song melodies there is much uncertainty. There is very great probability that some of them are as old as the words: and we may be singing now the very notes which ravished the ears of S. Augustin in the Milan basilica in the year 386. But in the absence of contemporary musical record, one must regretfully admit the untrustworthy nature of the oral tradition of music, which is subject to constant modification by the singers, in accordance with prevailing fashion. Hence, though the age of a plain-song melody may be judged in some measure by its intrinsic character, experts are chary of committing themselves to any decided opinion. Being thus reduced to the external evidence, the facts are, as far as I can gather, much as follows. The old latin breviaries of the western church contained a cycle of hymns for the year. These breviaries varied in minor details, according to local use, such as the saints chosen for commemoration; and the hymns varied: but all the various hymn-cycles had a common nucleus, which was formed between the first general introduction of hymns, due to the influence of the rule of S. Benedict, about the 6th century, and the liturgical expansion of the 10th century: and there can be little doubt that the melodies had a corresponding variation, though there is not the same early MS. authority for the music as there is for the words.       Little more, therefore, can be safely affirmed than this, namely, that when a melody is found in the old books in connection with only one hymn, and in use over a wide area, then it is almost certainly the original melody of that hymn, or an altered form of it (the absence of local modification being of great value), and it may be as old as the words. With less of such evidence, there is of course less probability of antiquity.
The Sarum Hymnal, which was the one in most general use in England, draws the greater part, both of its hymns and melodies, from the common storehouse; but in some instances the melodies have forms which are peculiar to this use. These are of extreme interest; for if they should not be of more ancient authority than others, their form must be the expression of national musical taste at a time when there is little other record of it; and to which it may be said that they do great credit, and for that reason should be jealously guarded from the invasion of foreign and inferior forms. Most of the plain-song melodies in this book are therefore taken from the old Sarum version, the text being that of the Rev. W. H. Frere's 'Hymn Melodies and Sequences,' &c., Plain-song and Mediaeval Musical Society, 1896.
In order to write out for singers a part-setting of a plain-song melody, one must either use the modern notation with its significance of strict time-values (in which case it is impossible to avoid the error of giving one strict interpretation to a melody which is of its nature elastic), or, on the other hand, one may set all the usual time-meaning of modern notation aside, and use symbols which have no strict time-significance, but which, fixing only the sequence and pitch of the notes, will allow the singers freedom of rhythm. This last is the course which I have adopted, and the justification of the method can only be this, that it makes it easy to sing the music properly. Before attempting the four-part singing of any of these tunes, the melody must be known to the singers, and its rhythm understood or agreed upon. This is always advisable, though the simplest tunes in this book (and this No. 29 is one) fall naturally into modern bars, and might be read off fluently enough; but in these simplest melodies it is important not to allow the feeling of bars to equalise the value of the notes, and so cut up the melody into unyielding blocks. After these remarks, the notation adopted will be readily understood with the following explanation:

The notes (semibreve, minim, and crotchet) have not their proper relative values. As a rule the notes in ligature are of less time-value than the notes which are not in ligature.

When a semibreve, not final, occurs in one of the under parts, this means only that it has two or more notes in ligature passing above it.

The notes in ligature are represented by minims printed closely together.

When an accidental occurs in a ligature, the sharp or flat sign is printed on its proper line or space before the whole ligature, not immediately before the affected note. This is done merely to avoid separating the notes of the ligature.
Comment: I tried to use the spoiler tag to "hide" the quotation to save vertical screen space, but it didn't accomplish that end. My apologies. If there is another way to provide the information without being a massive truckload of text on screen, please let me know.
Comment: Did you get the notation from here? https://books.google.com/books?id=c7n0AAAAMAAJ It looks like the same printing, but I don't see the editor's text in the Google book.
Comment: Got it from here: https://imslp.org/wiki/The_Yattendon_Hymnal_(Various)
Comment: Ah! IMSLP is 1899 edition, Google is 1905.
Comment: This particular notation seems somewhat inconsistent with the other plainsong "rhythmic" transcriptions in the hymnal, so I don't know that there appears to be a specific reason having to do with the *chant notation*. If I had to guess (this is a guess, hence the comment rather than an answer), it has something to do with the bit in the commentary about not having "unyielding blocks" of rhythm, and the fact that the English translation is pretty consistently in iambic tetrameter (not the original Latin), making this a short syllable and justifying some variety with a shorter rhythmic value.
Answer: My understanding is that old plainsong was deliberately non-metered. According to a book I have about hymnody the purpose was to distinguish it from secular, metered music.
The quote from the book seems to reinforce that idea by promoting a flexible approach to rhythm: "...allow the singers freedom of rhythm..." He also says the various notes used don't have their normal relative values. Which I understand to mean that a crotchet (quarter note) is not necessarily half the duration of a minim (half note.) Certainly that makes trouble for comparing the rhythm of the three examples!
I think the main thing to notice about rhythm is all three are notated with equal value notes until the seventh note for the syllable -ry of "glory". From that perspective they are all the same and only the notation of the phrase endings differ.

EDIT
Why is a short note used in example #3 on syllable -ry?
I figure it is a hint about avoiding a strong metrical placement, but I'm not really sure I understand the intention. #1 and #3 start with "oh" and that could be treated like an anacrusis. #2 doesn't have that potential anacrusis syllable. This would give note value count groupings like so...

#1 seems to fall into a clear implied duple meter.
#2 combines a mix of 2 and 3 and so avoids a metrical feel.
#3 starts with a duple feel, but it seems to me the relative short value on syllable -ry is a signal to avoid a clear duple, metrical feel, because the result of the short value is a mix of note value counts.
I think the difference between #1 and #3 is about avoiding meter in #3 for a more authentic plainsong rhythm.
Comment: I gathered that, in theory, note values are basically ignored, but what still eludes me is why the editor specifically differentiated the second-to-last note of the phrase from the others. Differentiating the _last_ note would make sense, as in image 1, which suggests to singers to _actually_ sing the last note a little longer than the others; and differentiating _none_ of them would make sense, as in image 2, which suggests to singers to _make up your mind_, collectively, as how to sing it. It's the 3rd image that is confusing: why differentiate _that_ note if it has no special significance?
Comment: @Neal I made an edit, because my thought on this were a bit complicated. My knowledge on this topic is limited, so I'm not sure I'm correct. I'm only applying what I've read. I hope you get a more authoritative answer.
Comment: I appreciate the reply and edit. I seem to have made a bad habit of asking obscure and esoteric questions.


Motive behind preserving variance

Question: Dimensionality reduction techniques preserve some properties of the data. I was wondering how preserving variance (as PCA does) can be helpful?
Precisely speaking, PCA takes the covariance matrix and a number $k$, which denotes the dimensionality of the mapped space. It decomposes the co-variance matrix and selects the $k$ eigenvectors as the new dimension, such that the variance is preserved, as much as possible. I wanted to know how preserving variance is useful? or in other words, what is the motive behind preserving variance?
Comment: This question needs some improvement: it is not at all clear what you are asking. You can edit your answer to improve it (and prevent it from being closed) by clicking the "edit" button in the lower left.
Comment: This might be a mis-characterization of PCA. If one wanted truly to "preserve" variance, it would be a simple matter of multiplying the retained eigenvectors by a constant value (usually slightly greater than $1$). That this is not done signals that PCA has different aims. Perhaps you could clarify what you mean by "preserving variance"?
Answer: First of all, I'd say that there is no single dimensionality reduction technique that is always useful: PCA for dimensionality and/or noise reduction is a heuristic that is useful if you can sensibly assume that your data has roughly the following structure:
The data covers a not too large number ($n$) of "interesting" effects that cause relatively large variance, and in addition unrelated "noise" (and/or uninteresting influencing effects), which, however, has much lower magnitude (variance).
In such a situation, PCA will capture the interesting factors in the first few PCs which are kept for further analysis, while noise will tend to appear in the higher PCs and is removed.
One conclusion from that is that PCA is e.g. not the method of choice if you know e.g. that certain confounding factors lead to large variance compared to the variation due to the effects of interest.
Also PCA produces linear combinations of the original variates. So if you'd e.g. expect your data to consist of few interesting channels among lots of noise-only channels then a dimensionality reduction based on hard feature selection could be more suitable.
Answer: Suppose you deal with a linear regression $y=X\beta$, where a common estimator is $\hat\beta=(X'X)^{-1}y'X$. The variance (uncertainty) $\hat\sigma_\beta$ of the estimator $\hat\beta$ is inversely proportional to the variance of the data $\Omega_X=X'X/n$.
So, if you replace the variables with PCA factors $F=AX$, then you would like to preserve the variance because: a) if you decrease the variance, then you increase the variance of the estimators $\hat\beta_F$, on the other hand b) if you increase the variance, it is only through artificial noise amplification, and the increased precision of the estimator $\beta_F$ is not real, i.e. you'll be underestimating the uncertainty of the coefficients.
Answer: Roughly speaking, variance is the amount of information contained in your data. The variables that have small variances provide little information about the data and can be removed from the analysis. For example, suppose you have a study of hospitalized dementia patients in which their demographics and health history were recorded. The patients may have different characteristics such as gender or different medication usage. But they are all elderly patients with age > 70. In this case, you cannot answer any question related to the age effect since all subjects are old.
On the other hand, you may find 50% of your subjects are males. You should keep gender variable as it allows you to answer questions such as whether there is a difference between male and female patients.
Comment: "Small" and "large" variances within "data" (or just the independent variables) are *meaningless* assessments. Among other things, the variance depends on the units of measurement, which in most applications are arbitrary.
Comment: @whuber I partially agree with you and this is one of the criticism of PCA.
Comment: (-1) Variance of each individual variable has *nothing to do* with the "amount of information" contained in it (especially in your example with age and gender), because it simply depends on the units of measurement, as @whuber wrote.

Motive behind preserving variance


Prevent WYSIWYG inline images from showing in Teaser Display

Question: Is there an easy way to stop inline images placed through the WYSIWYG editor from showing on a teaser display? Obviously if I use the summary field the problem is solved, but the client may not be conscious enough to always do that. I am currently outputting a featured image through an image field on the teaser display, so when the inline image also shows up it not only blocks the teaser text, it looks pretty weird.
Answer: Perhaps you could try https://drupal.org/project/advanced_text or https://drupal.org/project/smart_trim?
I think they both have the ability to strip html from teasers.
Comment: Smart trim is close, but an embeded video, for example, leaves a trail of gibberish characters where the link was.
Comment: Smart Trim worked great with inline images inserted with Media WYSIWYG. There was only the label of the file left. Removed that one as well by removing the title section in file_entity.tpl.php.
Answer: Check you own page code, but something like the following in your css will work:
<code>body.front div.field-item img {
  display: none;
}
</code>
This will allow the teaser to include the inserted image, and suppress the image display on the front page.
Comment: Thx. Unfortunately, because the image comes before the text in the wysiwyg, it blocks the first paragraph from coming through on the teaser display. So if I just hide it, I have no teaser, basically.
Comment: The above css ***only*** blocks the img – no text blocked. So why would your first paragraph get blocked?
Comment: The summary is set to be trimmed at a certain length. Inline image tags are just another sequence of characters. If they appear before the text, than the text might not display because it comes after the cut-off point.
Answer: body.front img[data-entity-type="file"]
{
    display:none;
}
Or maybe more specific for the teasers only:
.view-mode-teaser img[data-entity-type="file"]
{
    display:none;
}
This should solve the problem with the text in the WYSIWYG.
The field-items are still being displayed, including the text inside the p-tag. Only the inline images are not displayed.


error 500: Premature end of script headers: index.php

Question: Everything works except the /node/[nr]/edit page of only one content type page. And it's not for every page of this specific content type. Only one.
So let's say I have a content type "product" and created 5 nodes with that content type. Editing 4 of them works but for one the error 500 Premature end of script headers: index.php occurs.
I tried increasing the memory limit in the php.ini all the way up to memory_limit = 1024M (and restarted apache after that) but this changes nothing. Btw I'm using Acquia DevDesktop and the PHP version is 7.0.15. I also tried downgrading the PHP version (and there also increased the memory limit) but this won't do anything either.
Please help me, I'm incredibly thankful for every answer I can get!
Comment: @elterr1ble were you able to find the solutions, I'm having same issue with my site as well.
Comment: If this is only happening for one node, my guess would be that the content of this node causes a recursion and you run out of memory.
Comment: Hm no, it doesn't seem to do that.
Comment: @SukhjinderSingh see Nookeen's answer below. This did it for me!
Answer: @mcaleaa answer helped me on an acquia based site. To fix it I commented out the following lines in development.services.yml.
parameters:
  http.response.debug_cacheability_headers: true

Comment: You could also change from true to false.
Comment: This issue can happen on any site, and as far as I know is not related specifically to acquia in any way.
Answer: In case this helps anyone: I encountered this error on my local site's front page, just after following the instructions here https://www.drupal.org/node/2598914 (Disable Drupal 8 caching during development)
When I once again commented out this line in my settings.local.php, the 500 error went away:
# $settings['container_yamls'][] = DRUPAL_ROOT . '/sites/development.services.yml';

I suspect that my site's front page is heavily dependent on the cache entries, and when I switch to the null cache, the page is simply having trouble getting built. That's my guess.
UPDATE 2022-02-16
There is a issue on drupal.org dealing with this problem: https://www.drupal.org/node/2844620
We have been using the patch from that issue for a couple of years now, to deal with this error message during local development:
Premature end of script headers: index.php

Comment: This was not the case in my case, so hope for more answers.
Comment: I've found that adding `$settings['php_storage']['twig']['directory'] = '/path/to/writable/tmp/sites-caching/php';` directory cleared the error too, in addition to  the above.
Answer: This is not "solve it all" answer, but it may help those who use Acquia. The problem went away after switching from Fast CGI (mod_fcgid) to Apache module (mod_php) in Acquia DevDesktop->Preferences->Config.
Just some env notes for future debugging:
Acquia DevDesktop 2 rev:39801a8
PHP version 7.2.9
Answer: I am using drupalVm and was able to make the switch to using nginx. This was helpful for us cause our site is hosted by pantheon which uses nginx. You'll need these values set in your extra parameters: fastcgi_buffers and fastcgi_buffer_size. My config.yml looks like this:
drupalvm_webserver: nginx
...
nginx_hosts:
  - server_name: "{{ drupal_domain }} www.{{ drupal_domain }}"
  ...
  extra_parameters: |
    ...
    fastcgi_buffers 16 16k;
    fastcgi_buffer_size 32k;

Answer: In my case, SVG files in my blocks are causing the error. The error went away after replacing them.
Comment: Can you please provide a little bit more detail how these SVG got placed there, how you removed them and what these SVG looked like?


Find an injective map from $\{\frac{i}{2^n}:i\in\Bbb Z,n\in\Bbb N\}$ to $\Bbb N$

Question: Set: $A=\left\{\dfrac{i}{2^n} : i∈\Bbb Z, n∈\Bbb N\right\}$
Prove that A is countable by giving an example of an injective (one to one) map $f:A \to \Bbb N$
How do you find such an injective map?
Comment: Have you ever seen an example of an injection or bijection from $\Bbb N^2$ to $\Bbb N$?  Can you adapt one of those examples to work for your case?
Comment: "invective"? (in the title)
Comment: Welcome to MSE. Please use MathJax. A basic [tutorial](https://math.meta.stackexchange.com/questions/5020/mathjax-basic-tutorial-and-quick-reference)
Answer: Hint: (leading to one of the more common expected answers)
Every integer can be written uniquely as a power of two times an odd number.
For example $25 = 2^0\times (25)$ and $12 = 2^2\times (3)$

Further hint:
Without loss of generality, any fraction we select from our set we may assume appears in simplest form.  That is to say, your set $A=\{\frac{i}{2^n}~:~i\in\Bbb Z,n\in\Bbb N\}$ we could have rewritten out of convenience as $A=\{\frac{i}{2^n}~:~i\in(2\Bbb Z+1),n\in\Bbb N\}$ where $i$ is allowed to range only over odd integers.
This allows us to avoid having to be overly careful about having $\frac{4}{2^9},\frac{2}{2^8}$ and $\frac{1}{2^7}$ all mapping to potentially different values despite being equal.


Is it possible with NT Backup (or MS Backup) to restore all of the latest files from a certain folder out of an incremental backup file?

Question: I am using MS Backup on a Windows Server 2003 to backup our key folders at my work.  The backup is set up as an incremental backup job where it only backs up any files that have changed since the last time the backup was run.  Periodically I have to restore some files out of it, and it has been a royal pain to find the date where that file was last modified and exists in the backup.
My question is two-fold:

Is it possible to somehow specify that I want the "latest" edition of a particular file in the backup file when restoring?  If so, how?
Is it possible to get the "latest" edition of an entire folder in the backup file?  If so, how?

Thank you so much for your responses.
Answer: NTBackup is pretty plain-vanilla. There's no functionality to view the catalogs of multiple backup sets in a single amalgamated catalog, which is what it sounds like you're looking for.
If you can't get another tool that has the functionality you're looking for you might try:

Writing out "full" logs (<code>/l:f</code> command-line argument) when your backups run and searching these logs for the files you're looking for. At least, with logs, you can use command-line tools to search for strings.
Switching to differential backups. At least then the file will be on the latest backup set if it's been modified since the full. Obviously, this'll require more disk space to store the backup sets.
Comment: What is "another tool" that might have that functionality?
Comment: Symantec Backup Exec, for example, will let you search all the catalog files (albeit, unless they've done something different in the most recent version, the performance is terrible).