Python Regular Expression matching multiple lines (re.DOTALL)

Question: I'm trying to parse a string with multiple lines.
Suppose it is:
text = '''
Section1
stuff belonging to section1
stuff belonging to section1
stuff belonging to section1
Section2
stuff belonging to section2
stuff belonging to section2
stuff belonging to section2
'''

I want to use the finditer method of the re module to get a dictionary like:
{'section': 'Section1', 'section_data': 'stuff belonging to section1\nstuff belonging to section1\nstuff belonging to section1\n'}
{'section': 'Section2', 'section_data': 'stuff belonging to section2\nstuff belonging to section2\nstuff belonging to section2\n'}

I tried the following:
import re
re_sections=re.compile(r"(?P
Section\d)\s*(?P<section_data>.+)", re.DOTALL)
sections_it = re_sections.finditer(text)

for m in sections_it:
    print m.groupdict()

But this results in:
{'section': 'Section1', 'section_data': 'stuff belonging to section1\nstuff belonging to    section1\nstuff belonging to section1\nSection2\nstuff belonging to section2\nstuff belonging to section2\nstuff belonging to section2\n'}

So the section_data also matches Section2.
I also tried to tell the second group to match all but the first one. But this leads to no output at all.
re_sections=re.compile(r"(?P
Section\d)\s+(?P<section_data>^(?P=section))", re.DOTALL)

I know I could use the following re, but I'm looking for a version, where I do not have to tell what the second group looks like.
re_sections=re.compile(r"(?P
Section\d)\s+(?P<section_data>[a-z12\s]+)", re.DOTALL)

Thank you very much!
Comment: have you tried to match all occurrences `r"(?:(?PSection\d)\s*(?P.+?))+"` ?
Comment: Yes, it's not working. Output: {'section': 'Section1', 'section_data': 's'}
{'section': 'Section2', 'section_data': 's'}
Answer: Use a look-ahead to match everything up to the next section header, or the end of the string:
re_sections=re.compile(r"(?P
Section\d)\s*(?P<section_data>.+?)(?=(?:Section\d|$))", re.DOTALL)

Note that this needs a non-greedy .+? as well, otherwise it'll still match all the way to the end first.
Demo:
>>> re_sections=re.compile(r"(?P
Section\d)\s*(?P<section_data>.+?)(?=(?:Section\d|$))", re.DOTALL)
>>> for m in re_sections.finditer(text): print m.groupdict()
...
{'section': 'Section1', 'section_data': 'stuff belonging to section1\nstuff belonging to section1\nstuff belonging to section1\n'}
{'section': 'Section2', 'section_data': 'stuff belonging to section2\nstuff belonging to section2\nstuff belonging to section2'}

Comment: Already tried, leads to: {'section': 'Section1', 'section_data': 's'}
{'section': 'Section2', 'section_data': 's'}
Comment: @user2221323: Yeah, noticed that too; a look-ahead is needed, updated the answer.
Comment: Great! This is working! Is it possible not to mention Section\d again in the last part of the re (?=(?:Section\d|$)) and to use a reference like (?=(?:(?P=section)|$)). This trial results in the same output like in the Question :/ I looked up the Positive lookahead assertion. As far as I understood, it succeeds if the re matches at the current location and the whole re is tried again at the current location? But I don't understand why the |$ is needed?
Comment: No, you can't reuse the `section` match, because it'll only match again if it has the *same section number*, so the exact same literal text.
Comment: @user2221323: The look-ahead acts as an anchor, text before it matches if the position for the look-ahead matches the `Section\d` part next. The `|$` part is needed to match the *last* entry in your text; either there is a *next* section or we are at the end of the string.


Check to determine if user is member of any group of specific type

Question: Our website has three types of groups: area groups, support groups and member organized groups.
While a member can join several or none of the support groups and member-organized groups, we do want each member to be a part of one (and only one) area group.
I'd like to find a way to use rules to check to see if a member is a member of an area group and if not, display a warning/help message to them to encourage them to join an area group. Ideally, I would like to do this several times shortly after they join and then occasionally after the first couple weeks (some people who are in the process of moving to the area may not want to join a group right away and I don't want the messages to get overwhelming for that small minority).
I've been playing around in the rules module to see what I can do, but I'm not sure exactly how to check to see if they are a member of any group of the area group type -- can anyone help me with determining what conditions I have to apply to get it to check this for me? Also can I put a limit (as suggested above) on the amount of times the message shows?
Or in lieu of that, is there an easier way to accomplish this goal of ensuring that all of our members make it into one area group?
Thanks
Heather
Answer: I don't think Rules alone will do what you want. You'll want something like
<code>// This hook fires whenever a user account is saved.
// If you want to do it at other times, you'll want another hook.
function mymodule_user_presave(&$edit, $account, $category) {
    // This is an organic groups API function for finding out what group a user is in.
    $user_groups = og_get_groups_by_user($account, 'my_group_type');
    if ( [check for group membership] ) { ... }
}
</code>


Probability of No One Born on Day $j$

Question: Consider $n$ people in a room.
On an arbitrarily chosen day $j$, what is the probability no one was born?
$\textbf{My Question}$: Is my thought process correct?
Assuming the probability of any individual born on any given day is independent, consider two individuals, James and Sarah.
$P$(No one was born on day $j$)=$P$("James not born on day $j$")$P$("Sarah not born on day $j$").
On day $j$, the probability of a person being born is $\frac{1}{365}$.
Thus, $P$(No one was born on day $j$)=$(1-\frac{1}{365})$$(1-\frac{1}{365})$=$(\frac{364}{365})^2$.
For $n$, $P$(No one was born on day $j$)=$(\frac{364}{365})^n$.
Reference:
Blitzstein, J. K., & Hwang, J. (2014). $\textit{Introduction to probability.}$
Comment: Yeah, this is how I would do it too.
Comment: It's not clear that "day" refers to the day of the year, as opposed to a specific day (e.g., June 25, 2019). Also, keep in mind you may wish to handle leap years as well. In addition, you should state the assumption that all days are equally likely for a person to be born. Otherwise, as Matti P. wrote, I would also handle the problem basically as you're doing.
Comment: You should check out the Birthday Paradox
Answer: Absolutely correct.
A more advanced question would be "What's the minimum number of people in the room for the probability of two of them having the same birthday to be larger than 50%?".  You will find an interesting answer.  Have fun!
Comment: thanks for the response!

Probability of No One Born on Day $j$


Limit LDAP request to AD

Question: Is there a way to limit requests from a specific user to the AD such that he can only ask if a username or an email address exists or not? The user should not be able to request other data from the AD.
Answer: You can modify the default permissions in Active Directory (AD) to accommodate this requirement, but it won't be particularly easy or "clean". The default permissions in AD are, arguably, very "open".
To accomplish what you're looking for you're going to need to enable List Object Mode in your Active Directory (to limit object visibility). You should use a group (rather than a "specific user") to be named in permissions to grant the rights to read email addresses. I think you'll have to do some experimenting to get things to work how you want. (I don't have a scratch AD laying around right now that I'm willing to use to give you step-by-step instructions.)

Limit LDAP request to AD


Should pre-intervention outcome variable Y0 be excluded from counterfactual model based on causal diagram?

Question: Based on the causal diagram below, where:

Y1 is the outcome in the post-intervention period,
Y0 is the pre-intervention outcome,
X is a Yes/No healthcare intervention, and
Z1 & Z2 represent various confounder variables (diagnoses, geography, etc.).

Shouldn't Y0 be excluded from the counterfactual model estimating the effect of X on Y1 given it is both a collider and mediator variable?
Is there any reason not to exclude Y0 from the study?
Comment: Are the Zs observed?
Comment: @dimitriy Yes they are
Answer: $Y_0$ is not a mediator; it is a confounder. You must adjust for it. If $Z_1$ and $Z_2$ were not observed, this would induce what's sometimes called "butterfly bias"; but if you can adjust for them, then all confounding is removed. The sole minimally sufficient adjustment set is $Y_0$, $Z_1$, and $Z_2$.
Comment: If you adjust for $Z_1$ and $Z_2$, then even if $Y_0$ is a collider and not a confounder, adjusting for it would not bias the treatment effect. Because it would not open any backdoor paths. Instead of thinking about classifying each variable into a causal "type", think about its role in the DAG and the consequences of adjusting for it while adjusting for others. Yes $Y_0$ is a mediator and a collider, but adjusting for it is necessary. The rule "don't adjust for colliders" is too coarse to apply to this more complicated scenario.
Comment: That's correct. For your second question, check out [this article](https://osf.io/5zdme).
Comment: (+1) Wouldn't also be sensible to point out that $Y_0$ is not a mediator as there is no mediated effect between the independent variable $X$ causing $Y_0$ causing the dependent variable $Y_1$?
Comment: Thanks Noah - my initial thoughts were Y0 is a mediator lying on the paths between Z1, Z2, and Y1. And Y0 could also be a collider since two causal arrows from Z1 and Z2 converge on Y0.
Comment: If the X <- Y0 -> Y1 path didn't exist, then Y0 would be a collider that ought to be excluded since it blocks the Y1 <- Z2 -> Y0 <- Z1 -> X path. But the Y1 <- Y0 -> X path complicates things.
Comment: Think I see - if Y0 is a collider & not a confounder, conditioning on Y0 opens the Y1 <- Z2 -> Y0 <- Z1 -> X backdoor path, but controlling for Z1 then closes the path right?
Comment: Another issue we're struggling with at work are regression to the mean effects when including pre-intervention variables like Y0 in our model. It's not really a "causal" effect of Y0 on Y1, but a real concern when the Y0 distributions are significantly different in the treatment and control populations. Maybe a separate question!


Joint Probability Mass

Question: Consider a die rolled 10 times and $A$ represents number of times '1' occur and $B$ represent number of times '3' occur.
I'm not able to get the joint Probability Mass function.
My best effort :
$P_{A,B} (i,j) = {10\choose i} {{10-i}\choose j} p^{i+j}$
I'm not getting how to calculate $p$ for both points $i$ and $j$ and I don't know if the combination expression is right either. So, could someone please help?
Answer: I would divide this into cases because the analysis should vary.

Case 1, $P(0,0)$ is the easiest: $\left(\frac{4}{6}\right)^{10}$.

Case 2, $P(i,j)$ where only $i=0$ (similarly for $j$):
Normalize the following by $6^{10}$: ${10\choose j}\times 4^{10-j}$. You pick $j$ positions for the $3$'s. For the remaining, you pick any of the $4$ valid options ($1$ is not allowed).

Case 3, where neither $i$ nor $j$ is $0$ but $(i+j)\leq10$:
Normalize the following by $6^{10}$: ${10\choose j}\times {{10-j}\choose{i}} \times 4^{10-j-i}$.  You could do $10\choose i$ first and the answer would be the same.

Case 4, when $i+j>10$, again easy because then $P(i,j)=0$.

You may note that Case 3 actually subsumes Case 2 but I think it's easier to break it down this way. I've assumed a fair die, an unfair die could make it a bit messy.
Comment: For some i, j: could it be like: Choosing i places from 10, j places from 10-i, and for other 10-i-j places, we have, 4 alternatives for each place and the sample space is 6 raised to 10. So, like (10ci) (10-icj) (4^10-i-j) whole divided by 6^10?
Comment: Correct, that is Case 3 in my answer.
Comment: (10ci) (10-icj) (4^10-i-j) whole divided by 6^10?
Comment: Whoops, I switched the positions. let me fix that, good catch.
Comment: Oh, so did you mean divide by 6^10 when you said "Normalize"?
Comment: Yes, I'm sorry if that wasn't obvious. Typically in cases like this I like to count the explicit number of cases because that's just easier when you have a uniform distribution (like in a fair die). The total number of outcomes is just the size of the sample space so you divide by that.
Comment: Yeah, got it! Thanks!
Comment: Don't forget to accept the answer so that the question may be marked closed!

Joint Probability Mass


Sum of Linear Subspaces

Question: Let $V$ be a vector space over $K$ and $S,U,W \subset V$ linear subspaces of $V$. $U+W$ is defined as $\{ u+w | u \in U, w \in W \}$. Is it true, that
a) $U+W = \{ u-w | u \in U, w \in W \}$
b) $S \cap (U + W) = (S \cap U) + (S \cap W)$?
My thoughts for a) so far had been that due to $-1 \in K$, $-w$ also has to be in $W$ if $w \in W$.
Comment: If $w\in W$ is $-w\in W$?
Comment: @DougM OP already mentioned that
Comment: Well, that takes care of part (a): $\{u - w: u \in U, w \in W\} = \{u + (-w): u \in U, -w \in W\} = U + W$. As for part (b), what have you tried there, OP?
Comment: @bounceback I was thinking about rewriting it like $S \cap \{ u + w | u \in U, w \in W \} = \{ u + w | u \in (U \cap S), w \in (W \cap S) \} = (S \cap U) + (S \cap W)$ but I am not sure if this is a valid operation.
Comment: No, your first equality is false - see Bernard's answer below for the counterexample
Answer: For $a)$ it's fine, as $w\in W\iff -w\in W$.
For $b)$, a counter-example: take $V=K^2$ ($K$ is the base field)$, $U={(x,0),\;x\in K}, $\;W=\{(0,x),\;x\in K\}$ and $\;S=\{(x,x),\;x\in K\}$.
Then $U+W=V$, so $S\cap(U+W)=S$, but $S\cap U=\{0\}=S\cap W$,  so $\;S\cap U+S\cap W=\{0\}$.

Sum of Linear Subspaces


Equipartition of energy in $n$ dimensions

Question: Let $u \in C^2(\mathbb R^n \times [0, \infty))$ be a real solution of the wave equation
$$\begin{cases} \partial_t^2 u - \Delta_x u = 0 & \text{in } \mathbb R^n \times (0, \infty) \\ u(x, 0) = f(x), \quad u_t(x, 0) = g(x) & \text{in } x \in \mathbb R^n, f \in C_c^2(\mathbb R^n), g \in C_c^1(\mathbb R^n) \end{cases}$$
We define $k(t) := \frac 1 2 u_t(x, t)^2 d x$ as the kinetic energy, $p(t) := \frac 1 2 |\nabla_x u(x, t)^2| d x$ as the potential energy, and $e(t) := p(t) + k(t)$ as the total energy. I now want to show that $e(t)$ is constant on $[0, \infty)$.
Now I did find some threads like this one where this question is explored and answered for the case $n = 1$, but I'm not sure if the argument carries over the same for higher dimensions. Like in the answer given there, I would start with $\frac d{dt} e(t)$ and then use the Leibniz rule/differential rule for parameter integrals to pull the $\frac d{dt}$ into the integral, i.e.
$$\frac d{dt} e(t) = \frac 1 2 \int_{\mathbb R^n} \frac d{dt} \left( u_t(x, t)^2 d x + |\nabla_x u(x, t)|^2 \right) d x$$
which would get me
$$= \frac 1 2 \int_{\mathbb R^n} \left( 2 u_t u_{t t} d x + \frac d{dt} |\nabla_x u(x, t)|^2 \right) d x  $$
but my problem is, how do I now handle the $\frac d{dt} |\nabla_x u(x, t)|^2$-term? Unlike in the other answer where $x$ has only one component, I'm not sure where to go from here or what to make of it.
What confuses me is that I'm also given the hint that I might first want to show: for any $t_0 > 0$, there exists a compact set $K \subseteq \mathbb R^n$ so that $\mathrm{supp} u(\cdot, t) \subseteq K$ for all $t \in [0, t_0]$. But I'm not sure what for I would actually need this.
Comment: To compute the derivative, write $|\nabla u|^2=\sum_{j=1}^n (\partial_{x_j} u)^2$. Concerning the compactness of the support, who told you that the integral is finite, in the first place? And in the second place, compactly supported functions make for easier integration by parts, since boundary terms vanish.
Comment: @GiuseppeNegro Thank you. Ok I see, showing the fact regarding the compactness of $\mathrm{supp} u(\cdot, t)$ gives me the existence of the integral. How could I go about showing that (the compactness of this support) if I may ask?
Comment: That's a basic property of the wave equation, called *finite speed of propagation*.
Answer: The correct replacement for $(u^2_x)_t = 2u_xu_{xt}$ is $$ \partial_t |\nabla u|^2 = 2\nabla u\cdot\nabla u_t $$
In fact this follows from the 1D rule because for any vector valued function $f=(f_1(t),\dots,f_n(t))$
$$ \partial_t |f|^2 =\partial_t \sum_{i}f_i^2 = \sum_i \partial_t (f_i^2)=2∑f_i\partial_tf_i = 2f\cdot\partial_t f$$
One concludes what you want by integration by parts, since $\int_{ℝ^n} \nabla a \cdot \vec{b} = -\int_{ℝ^n} a\nabla\cdot \vec{b}$.


Why does a B major scale work against an A major chord?

Question: I can hear that soloing over an A major chord using a B major scale "works" but I am curious as to the musical theory why it works?
I know the C# and E contained in the B major acale are the 3rd and 5th of A major so that makes sense but there is no A in B major.
The G# and A# notes in the B major scale flirt just below the A and just above the A and suggest some type of unresolved tension...?
I suspect this is a large part of the reason why this "works" but I was wondering what is the real music theory behind why you can solo in a major scale a whole step above a major chord?
Comment: Have you found something that does NOT work? :) For me personally, playing completely random notes does not work even if all the notes come from a supposedly "correct" scale. It is still nonsensical noise. Random notes from any scale don't work over any chord. There has to be some kind of a musical idea that you do with the notes. In that sense, the fact that notes were selected from a particular scale is not a sufficient reason for the notes to "work".
Comment: Actually, I tried to say, it would be a more meaningful question if you asked, _what_ it is that certain notes played in a certain way over an A major chord _do_. Scales by themselves don't "work", because it is possible to construct rubbish from the notes of the C major scale that does not "work", even over a C major chord. For something to "work", there is always an assumption of some sort of an artist or designer who uses discretion and artistic choice, and it's the discretion and artistic choice which make things work, not the ingredients as such.
Comment: Funnily enough, using notes from key G major work over an A chord too, in quite a Bluesy way.
Comment: By "work", do you mean that it sounds like you're playing outside (the established chord progression) but it still sounds fine, or do you mean that it still sounds like you're playing over the correct chord?
Answer: The B major scale contains B, C#, E, F#, which happen to be all the notes of A major pentatonic, minus the root. The G# is the 7th of A, playing might give the chord an Amaj7 feel. The D# (#11) and the A# (b9) definitely provide some tension, with the former providing a lydian feel, which is common enough in some genres.
My guess is it sounds good because it is A major pentatonic with some added chomatic tensions (but not too many), and is never going to truly resolve back down to A until you switch the scale that you're using
Comment: All you have to do is stop playing, and the backing track will provide the resolution to A! :) The total combination of sounding notes will contain an A note because of the backing track. In that sense, it's not even possible to play B major scale over A major, unless you can somehow suck all the A notes out of the backing track. But then it wouldn't be A major anymore.
Comment: As a fairly inexperienced amateur, I notice the "too many roots" problem when soloing. That is, I end up playing the root of my chord in places where I don't necessarily want my phrase to end, and I don't find that too sonically pleasing. Soloing using notes from a pentatonic/majors scale a whole step above the root seems like a good idea. I'll have to try it next time I'm around my instrument
Answer:
...soloing over an A major chord using a B major scale "works"...

Define "works." Anything can "work."
A major and B major scale only differ by two sharps, D and A sharp.
Common tones are B C# E F# G# - which superficially looks like an E major pentatonic scale. That set of tones over both an A major or B major chord give flavorings of maj7, add6, and add9.

...but there is no A in B major...

Right. The A is A#.
By typical chord/scale matching a B major scale to a A major chord does not really work.
A lot of things "working" can be explained in terms of modal flavoring or altered tones. For example, a lowered seventh scale degree can give a mixolydian modal flavor, or raising/lowering the ninth or fifth of a dominant ninth chord makes it altered. There is also something called a chromatic cross relationship, but that is usually seen with the leading tone or third of a scale. In the case of an A major chord with a B major scale, the root or the chord is "altered" by the scale. It doesn't really "work" by the conventional means of introducing chromatic tones.
This is where describing something as "works" is too vague. At least too vague to call music theory. To the extent that A# doesn't "work" you might be better off playing E major to get an A natural. The only differing tone will be the D# which will give a lydian flavor to the A major chord.
If the A# is handled carefully, you can mitigate the dissonance. Play it less, shorter durations, in metrically weak positions, and it will lessen the mismatch.
If "works" means polytonality, then it's a completely different ball game. You then embrace the clash of hearing A major and B major simultaneously and sound like a modern, someone like Darius Milhaud, or Stravinsky.
Answer: I was listening to a musical cadence of A maj to F# maj. The melody run in the A measures sounded intriguing to me and I knew there was something "different" about it so I transcribed it. (Wanted to include the transcription in this comment but doesn't seem as though attachments are allowed.) Basically it started on low C#, went all the way up to a high G# before it came back and ended on a C# an octave above the starting C#. When I examined it, I was very surprised to see, (except for a "G" passing tone in a "F#,G,G#"), sequence, it was simply a melodic run in B maj. It was a perfect melodic sequence over A maj that lead naturally to the F# maj cadence where of course continuing the B maj melodic scale worked just fine modally. For the A maj part of the cadence I can certainly understand how starting and ending on the C# (3rd of A) works and I can also feel how "bookending" the A with a G# and A# but never actually playing the A teases the ear with A without ever really resolving to it.  I myself just never would have thought to use B maj over the A maj. Just wondering if I finally discovered something Bach already did 350 years ago....


Cannot convert type 'System.Attribute' to generic argument 'T' - why?

Question: I'm trying to compile my desktop .NET dll to WinRT platform (Target Windows 8.1). It worked fine on desktop but in WinRT project I have that compiler error in the code:
internal static T[] CreateRuntime<T>(MemberInfo member, bool inherit)
{
    return member.GetCustomAttributes(typeof(T), inherit).Select(attr => (T)attr).ToArray();
}

I can't cast Attribute attr  to generic argument T... but why only on WinRT? Are there any differences in the language or what may cause this?
Comment: Did you put the constraint `where T : Attribute` ? The definition of `T` would be useful to see
Comment: This may also be useful: http://www.minddriven.de/index.php/technology/dot-net/net-winrt-get-custom-attributes-from-enum-value
Comment: @Rob thanks but my question is about compiler differences - not code review ;) btw when I put `T : Attribute` the error goes away.
Answer: This is a consequence of the type conversion rules in C#. From the C# 5.0 specification:

6.2.7 Explicit conversions involving type parameters
  The following explicit conversions exist for a given type parameter T:
  •   From the effective base class C of T to T and from any base class of C to T. At run-time, if T is a value type, the conversion is executed as an unboxing conversion. Otherwise, the conversion is executed as an explicit reference conversion or identity conversion.
[…there are three other bullet points, but none apply here…]
  The above rules do not permit a direct explicit conversion from an unconstrained type parameter to a non-interface type, which might be surprising. The reason for this rule is to prevent confusion and make the semantics of such conversions clear.

Unconstrained, the only known base class of T is System.Object. But in Winrt, the GetCustomAttributes() method is implemented as an extension method, returning IEnumerable<Attribute> instead of the object[] that is returned in the .NET API. Thus the variable attr has the type Attribute, and not object.
So when you are using the .NET API, you can cast from the base class object to T, but when you are using Winrt, you cannot cast from the non-base-class Attribute to T.
You can change the known base class of T by adding a constraint to the method declaration:
internal static T[] CreateRuntime<T>(MemberInfo member, bool inherit)
    where T : Attribute
{
    return member.GetCustomAttributes(typeof(T), inherit).Select(attr => (T)attr).ToArray();
}

With the base class of T now being declared as Attribute, you can now cast from Attribute to T.

Note that this is not a difference in language implementation between .NET and Winrt. It's the same exact C# rules. It's simply that you are actually dealing with different implementations of GetCustomeAttributes(), where the return values are different, making the type of your variable attr different, and thus producing different results in each case.

See related questions:
Cannot convert type 'System.Windows.Forms.Control' to 'T'
C# Problem with Generics
Casting to generic type fails in c#
I was disappointed that none of these otherwise-relevant questions and answers addressed the core of the issue, which is why C# makes this requirement. I've tried to do so above. However, they do all cover similar scenarios, showing how the same exact thing can happen in the context of non-Winrt code. They also illustrate the two basic solutions:

Use a constraint on the generic parameter (as I suggest here)
Cast to object before casting to T. This bypasses the generic conversion, removing context so that the compiler permits the cast. IMHO this is much less preferable; but if you cannot add the constraint for some reason (such as you're dealing with a special case that doesn't apply to all possible T…however undesirable such implementations are), this will work.


Probability - Limits of integration for Z=X+Y, with bivariate density f(x,y)

Question: It is given that
$$f(x,y)=\begin{cases}
   864(2x-y)(y-x), & x \le y\le 2x, x+y \le 1\\
   0,              & \text{otherwise}
\end{cases}$$
Find the density $f_z(z)$ for $Z=X+Y$
I have used the formula for convolution that says
$$f_z(z)=\int_{-\infty}^\infty f(x,x-z) \, dx$$
The problem is i have no idea which limits to use on the integral. According to the solution, we have that $ z/3\leq x\leq z/2$ and $z \in [0,1]$
Anyone who could explain to me how these limits are found?
Comment: you should have $$f_Z(z) = \int_\mathbb{R} f(x,z-x) dx$$
Comment: You should have $f_Z(z)$, not $f_z(z)$. ${}\qquad{}$
Answer: You need $\displaystyle f_Z(z)=\int_{-\infty}^\infty f_{X,Y}(x,z-x) \, dx$, not the version with $x-z$. The point here is that in the expression $(x,z-x)$ the sum of the $x$ and $y$ components should be $z$, so the point $(x,y)$ moves along the line $x+y=z$ with $z$ constant.
For any fixed value of $z$, consider the line $x+y=z$.  This line has slope $-1$ in the $(x,y)$-plane.  It intersects the line $y=2x$ at $(x,y)=(z/3,\,2z/3)$ and it intersects the line $y=x$ at $(x,y)=(z/2,\,z/2)$.
Comment: I was using the right integral, just misswrote in my question, my bad!

How exactly do you determine where z intersects with y?
Comment: Say for example $z=5$.  Then the line $x+y=z$ is the line $x+y=5$.  You need the intersection of $x+y=5$ with $y=2x$.  If $y=2x$ then $2x$ can be put in place of $y$ in the other equation, getting $x+2x=5$.  That gives us $3x=5$, so $x=5/3$.  If $x=5/3$ then $y=2x=10/3$.  With some other number $z$ rather than $5$, instead of $5/3$ we have $z/3$.  Similarly for the intersection of $y=x$ with $x+y=5$. ${}\qquad{}$


How to chage the page suffix?

Question: My page is starting from 0,and I want to start with1.
As follows:

Can implemented in Drupal?
Answer: Yes. Sort of.
The ?page=X query parameter in views pages is the offset from the SQL results (if you have the views admin section displaying generated SQL you can see this by the OFFSET X clause).
Hence, if you adjust your Pager options such that the Offset (normally 0) is set to opposite (e.g. -5) of the number in the Items per Page (e.g. 5) it will produce the effect of /my-views-page?page=1 containing the first results of your query.
However, it will also produce the side effect of the first offset page (i.e. /my-views-page and /my-views-page?page=0) of having no results. You could probably mitigate this through some URL rewriting, but it's a bit of work for something that has very little value (how many people browse the web thinking about numbered results vs. index offsetting?).

How to chage the page suffix?


Get define value in preprocessor time in c

Question: I want to create a define using macro expansion. The crated define shall hold the value of an other define. :)
Example:
<code>#define ONE            1
#define TWO            2
#define MACRO(x, y)    ...
...
#define MACRO_1_2      3
</code>
My question is: how can I resolve / use the value of a define in macro expansion?
I have tried to use
<code>#define TEST_MACRO_V2(x, y)      TEST_MACRO_V2_"x"_"y"
</code>
, but I get the following error:

main.c:18:34: error: 'TEST_MACRO_V2_' undeclared (first use in this function)
   #define TEST_MACRO_V2(x, y)      TEST_MACRO_V2_"x"_"y"

My test code:
<code>#include <stdio.h>

#define ONE   1
#define TWO   2

#define TEST_MACRO_V1(x, y)      TEST_MACRO_V1_##x##_##y
#define TEST_MACRO_V1_ONE_TWO    3

//#define TEST_MACRO_V2(x, y)    TEST_MACRO_V2_##('x')##_##('y')  -> this version does not work
#define TEST_MACRO_V2(x, y)      TEST_MACRO_V2_"x"_"y"
#define TEST_MACRO_V2_1_2        4

int main()
{
    printf("Test Macro V1: %d\n", TEST_MACRO_V1(ONE, TWO));
    printf("Test Macro V2: %d\n", TEST_MACRO_V2(ONE, TWO));

    return 0;
}
</code>

Note: TEST_MACRO_V1 works fine. I need TEST_MACRO_V2.
Comment: What do you need to do with V2 that you can't do with V1?
Comment: :) The solution shall be independent from the name of macro argument. It means, the user can use other define name, but this defines have always the same value, like 0,1,2 …
So, in the "end define" I need the values of the defines used in the macro call.
Comment: It's not clear what you are asking. Please post exactly what the expected expansion of `TEST_MACRO_V2(ONE, TWO)` should be, or what the expected output is of the program you posted
Comment: Also explain what is the point of `MACRO_1_2` , `TEST_MACRO_V1_ONE_TWO` and `TEST_MACRO_V2_1_2` ?
Answer: I tried this on ideone.com:
<code>#include <stdio.h>

#define ONE   1
#define TWO   2

#define TEST_MACRO_HELPER(x, y) TEST_MACRO_##x##_##y
#define TEST_MACRO(x, y)        TEST_MACRO_HELPER(x, y)
#define TEST_MACRO_1_2          4

int main()
{
    printf("Test Macro: %d\n", TEST_MACRO(ONE, TWO));
    return 0;
}
</code>
Output:
<code>Test Macro: 4
</code>


Additional reasons why perfect 5th is forbidden in contrapuntal writing (other than voice independence)

Question: When textbooks explain why parallel (consecutive) fifths are forbidden, they always say that it undermines the voice independence.
I disagree with this, though.
If voice dependence is the reason for not using parallel fifths, then why composers never use parallel fifth even if the music is NOT contrapuntal? Composers always double different parts in octaves, NEVER in fifth, even though both intervals destroy voice independence.
There MUST be some other reasons why parallel fifths are banned. Could anyone suggest other reasons?
Comment: @Dekkadeci That's not applicable, because the music you describe isn't following any classical rules anyway.
Comment: Power chord spamming doubles music at the fifth all the time.
Comment: @MaJoad: But the effect of parallel power chords works well precisely because the parallel fifths accentuate the feel of a "single voice" moving together, rather than two independent ones.  It's a standard example of why you might not want to follow the parallel fifth prohibition, if you want a different sort of effect.
Comment: You are misquoting the rule it is parallel fifths that are the problem, not perfect fifths.
Comment: Parellel fifths come from *organum*. They are clasiscaly banned in both four-part harmony and counterpoint.
Comment: It might have been a counter revolutionary movement to the time of  organum. (s.  my answers) And the classical composers may have followed this rules blindly as they lived in an absolutistic era. And in our days we may think: it's time for a revolution!
Answer: As brought up in comments, there are plenty of examples of music styles where parallel fifths are appropriate.  Parallel chords and even naked parallel fifths are used to great effect in a number of popular styles (and some music around the world) to create precisely the effect of a single "voice" moving in a mass, rather than independent voices.
I gather the OP is more concerned with the fact that the so-called "classical style" seems to contain few parallel fifths to give a sense of voice "doubling," while parallel octaves are used all the time for voice doubling.
First, it should be noted that prohibitions against parallel fifths go back to late medieval vocal polyphony, where octave doubling in parallel was rare.  Both parallel octaves and parallel fifths were eventually prohibited in that style to create independence.  By the time we get to early renaissance music (mid-15th century), parallel fifths had become quite rare in the notated styles of the time.  Historically, the rationale against parallel fifths definitely was rooted in independent voices.
The reason why later composers who adopted octave doubling didn't also adopt "fifth doubling" is probably because perfect fifths have a more distinctive sound.  Composers who had been trained in the traditional method of avoiding parallel fifths (and the specific sound it created) were thus less likely to make deliberate use of them except for effect.  (Basstickler's observation that parallel fifths for doubling could result in more dissonance/clashes with other voices, whereas octave doubling does not, is another reason they didn't become regularly used.  One limits the consonant harmonic possibilities a lot more by trying to double fifths than by doubling octaves.)
And composers certainly did make use of them for effect.  Parallel fifths show up here and there in romantic period music and later, often to evoke "folk" or "rustic" styles of music (where parallel fifths were presumably common, as they continue to be in many popular styles today; unfortunately a lot of this music was likely not written down).  Later, they came to denote other "exotic" music styles, from medieval to "Eastern" musics.  While octave doubling was accepted as a practical technique for allowing different instruments to play the same melody, the more unique sound of fifth doubling was instead employed to evoke specific styles (often those which would not be considered a "learned" contrapuntal style).
Lastly, I'd just note that the prohibition of parallel fifths in classical style is not absolute (pace music theory textbooks that oversimplify things).  Brahms was known to carry a notebook around of examples from the standard repertoire.  One can find sporadic examples of parallel fifths in Bach, for example.  The standard uses tend to occur around cadential formulas, where two voices are both doing standard cadential melodic gestures, but because of rhythmic displacements ("non-harmonic tones") the motions sometimes happen to line up and create parallel fifths.  These are not generally noticeable, and Bach wasn't usually concerned about them, because the voices were all following standard cadential melodic gestures that dictated the drive toward the cadential resolution.  All other voice-leading concerns were generally subservient to the cadential formulas.  (Overzealous editors who were trained in harmonic rather than melodic formulations of cadential progressions sometimes have "edited out" these parallel fifths in Bach, so they're perhaps not seen as often as Bach actually wrote them.)
There is, however, one example of classical usage that could be marshaled to argue for a potential place for "fifth doubling," i.e., in the resolution of the German augmented sixth chord, where some 18th-century composers and many 19th-century composers tended to employ fifths moving in parallel with the bass.  (These are sometimes called "Mozart fifths," though I don't know Mozart used them more than other composers.) One could argue that the strong resolution of the augmented sixth interval draws the listener's attention, thus "excusing" the parallel fifths, as the voice-leading of the augmented sixth takes precedence.  But it's also true that the parallel fifths reinforce the bass descending semitone motion that is so essential to the augmented sixth chord.  (I'm not going to go so far as to claim the German augmented sixth resolved this way was the 18th-century version of a "power chord," but... well, it sort of was.)  Composers could only get away with it because the distinctive sound of parallel fifths was obscured in this case by a stronger intervallic resolution occurring at the same time.
But perhaps rather than "excusing" so-called "Mozart fifths," we might question why composers felt the need to use them at all, given the strong prohibition elsewhere.  I think it's likely some of the reason why they were deemed acceptable was precisely because of the use of the augmented sixth for very strong half cadences, and the parallel fifths were a sort of "doubling" that made the bass resolution feel even stronger (i.e., not independent voices).
Comment: @Basstickler - well, "Mozart fifths" in this sense are a [thing](https://en.wikipedia.org/wiki/Consecutive_fifths#Mozart_fifths). I'm actually somewhat curious about the repeated assertions everywhere (including that Wikipedia entry) that composers resolve the German+6 "almost always" to the cadential 6/4.  I wonder if anyone has actually done a statistical analysis of this, or whether (like the overzealous editors who have "corrected" Bach's parallel 5ths) one just *assumes* that composers "almost always" avoided the fifths by going to a 6/4.
Comment: Interesting, when I was learning about the G+6, I don't recall hearing much about this approach.  They may have taught it and I forgot but either way, I don't intend to say that you're incorrect or anything like that.  We were just taught to have a cadential 64 preceding the actual dominant to avoid the parallel fifths.
Comment: Medieval prohibition against parallel fifths? Organum _is_ from the Medieval period.
Comment: Resolving a German augmented sixth directly with parallel fifths doesn't seem to be a effort to introduce parallel fifths. It's just abandoning the concern for a rule from an old style that no longer applies. (Or even more obviously, simply not wanting the sound of a cadential 6/4. Why be forced to use it if you don't want it.) At any rate, when tastes changed, composer just used parallel fifths with absolutely no concerns for old church style. Liszt and Debussy provide good examples of those changes in taste
Comment: @MichaelCurtis: Point taken, but I wasn't really claiming it was a positive effort to introduce parallel fifths. Instead, perhaps composers didn't mind them as much because they may have actually reinforced the strong bass motion (but were hidden enough by the other intervals going on to be "excused"). And there are alternatives to the cadential 6/4: in many cases, composers staggered the resolution of the voices (perhaps to avoid the parallels), but we have plenty examples of fairly "rule-following" composers who still use parallel fifths in this instance. It's just an interesting aberration.
Comment: @MichaelCurtis: Regarding history, the first explicit prohibitions of parallel fifths show up around the year 1300, which (as far as I know) is usually called the "medieval era."
Comment: @MichaelCurtis: I realize that paragraph was a bit unclear and could be interpreted a couple different ways, so I cleaned it up a bit.
Answer: Voice leading and voice independence are not specific to contrapuntal music.  Homophonic music of the Classical genre continued to use the voice leading rules of the contrapuntal music that preceded it to preserve voice independence because it provided fuller sounding harmonies.  The voices in homophonic music are not thought of as independent melodies, like contrapuntal music, so I can see how one might not think of them in the same manner.
Take a look at some of the Classical repertoire, particularly the Classical era, and notice how often the harmonies are just I-IV-V, yet the harmonies feel rich and full, providing strong support to the melodies.  This is in large part due to the voice leading.  If you were to take a piece or section that primarily uses I-IV-V harmony, then arrange this to be played on a guitar, utilizing on barre chords (which contain lots of parallel fifths and octaves), you would find that the harmonies are not quite as satisfying, or rich and full sounding.
Speaking to your thoughts on doubling, the idea there is that the doubled line is not considered its own voice; it is just additional texture added to the fundamental voice.  Depending on how the harmony and melody interact, doubling with fifths could add a lot more dissonance.  Fifths also have a different affect on the harmony, where they can make things feel thick (for lack of a better word), particularly in lower registers.  This can make things feel cluttered or dense, where octaves have a more pure sound to them, less likely to add that feeling of clutter.
Modern popular music largely ignores these voice leading rules, which creates a different sort of texture.  The consistent use of parallel perfect intervals from chord to chord creates a different sort of accompaniment, often having that more dense feeling I reference above.  Heavier rock music (grunge, metal, etc.) often uses power chords (root, 5, octave), entirely omitting the third from the harmony.  This creates a very thick, dense sound, helping to create the heavy feeling they are going for.
Even though we tend to find that modern popular music doesn't utilize traditional voice leading, it still comes up sometimes, particularly when any sort of orchestration is added.  I was arranging some orchestration for a pop rock song and found myself wondering why the harmonies didn't feel right at one particular moment and I realized it was because of a parallel perfect intervals, which were not present before or after that moment.  The rest of the arrangement (guitar, bass, keys) were not concerned with traditional voice leading, using lots of parallel perfect intervals, yet the orchestration basically required it.
In short, homophonic music of the Classical genre tends to stick to the voice leading rules of counterpoint to provide richer, fuller harmonies, and doubling of voices is very much concerned with how the overall texture will be affected and what sort of dissonance(s) it may create.
Comment: "you would find that the harmonies are not quite as satisfying, or rich and full sounding" – many a guitarist would disagree...
Comment: @leftaroundabout - Perhaps that's not the best way to describe what I'm trying to say.  I think the difference between barre chord accompaniment, or other harmonies with parallel perfect intervals, is rather profound.  Barre chords are not bad or dissatisfying and don't fail to provide a functional harmonic accompaniment, it's more so that use of Classical voice leading seems to have a richer, fuller sound.  If you gather what I am getting at, would you have another way to describe this that may be less subjective?
Answer:
If voice dependence is the reason for not using parallel fifths, then why composers never use parallel fifth even if the music is NOT contrapuntal?

I think you need to describe music more specifically than: "is NOT contrapuntal."
The matter isn't really about whether something is or is not contrapuntal per se, like is the music a fugue, but whether the harmonic style is based on the old counterpoint style. Early Mozart isn't normally considered contrapuntal, but the harmony did follow the old counterpoint voice leading conventions. Parallel fifths weren't the norm for that early classical style as the style's harmony was still rooted in counterpoint. Move ahead in time to something like Debussy's impressionism and the harmony severed the link back to the old counterpoint style. You can see counterpoint (linear independence) on display in some impressionistic works, but you don't see the prohibition against parallel fifths. That change in taste for parallelism wasn't a matter of linear independence, it was about abandoning an old harmonic style.

Composers always double different parts in octaves, NEVER in fifth, even though both intervals destroy voice independence.

Again, the matter isn't about voice independence. Doubling of parts in octaves versus some other interval is a harmonic matter.
If you double in octaves, nothing changes harmonically.
Double a part in (I assume you mean parallel) fifths, and you quickly run into harmony issues where the extra part brings in new tones. That isn't necessarily a problem, but doubling in octaves and doubling in perfect fifths are in no way harmonically interchangeable.

There MUST be some other reasons why parallel fifths are banned. Could anyone suggest other reasons?

You might rephrase the question as: "why do parallel fifth destroy voice independence, but not parallel thirds?"
I would give two reasons.
The first is pure theory. Thirds come in two varieties major and minor, but perfect fifths are only one interval quality. Parallel thirds more properly should be called similar motion thirds which by definition are more independent than parallel perfect fifths.
But I don't that is the really important reason for the prohibition against parallel fifths. For a long time parallel fifths were perfectly fine... in medieval organum. When the contrapuntal styles evolved I think it wasn't a logical, theoretical concern to avoid parallel fifths, but the desire to not sound like parallel organum that was the reason to prohibit parallel fifths.
Comment: I've always related the avoidance of parallel perfect intervals to the overtone series.  Since the fifth and octave are so closely related to the fundamental, they more easily blend with it to be obscured.  Thirds are far enough removed from the fundamental that even parallel thirds of the same quality, eg, parallel major thirds, are unlikely to blend into the fundamental.  I'd also note that the move to just and equal temperament would further separate thirds from the fundamental as a result of them being further removed from the natural overtones, where fifths were either exact or very close
Comment: @Basstickler, I didn't mean to say voice independence is a myth. On a purely technical level parallel fifths are less independent than parallel thirds.
Comment: Honestly, the _first_ way I was introduced to the parallel fifths prohibition was simply: "parallel fifths are prohibited." The more sophisticated teaching about voice independence feels like a rationalization for the old style. It's a nice way to rise above blind adherence to a rule. But it's so much simpler to just admit it's a matter of taste. In some styles parallel fifths are essential, in other antithetical. No logical or theoretical explanation is necessary.
Comment: @MichaelCurtis Taste may be more important than we generally say, however, the voice independence is not just a myth.  I've experienced it in my own writing, as mentioned in my answer. I have long criticized the academic approach to teaching theory, where all too many people walk away from those classes thinking of everything as rules, particularly without specification that those rules are specifically for the style of music they are studying.  So many questions on here where you can tell the OP wasn't taught about this distinction.
Comment: I've found the passage on page 26ff in **Studies of Harmony** and I've posted a second answer with the original translation.
Comment: That's it: *For a long time parallel fifths were perfectly fine... in medieval organum. When the contrapuntal styles evolved I think it wasn't a logical, theoretical concern to avoid parallel fifths, but the desire to not sound like parallel organum that was the reason to prohibit parallel fifths.* you  say with clear words in one sentence what I've meant in my answer! Do you remember a source , Michael, or are this your own thoughts?
Comment: @AlbrechtHügli, that was my own thought on the topic. But it does come in part from researching treatises from the 18th century where they often judged "good taste" in music.
Answer: I have asked this question in the same intention right a year ago (my very first question on SE) and I thought to have given the answer I had read in De la Mottes " " Harmony". Well it seems I have posted it elsewhere. But I can't find it here nor the source.
I know that he says (in other words) concerning forbidden parallel fifths in respect to the organum of fifths:
*Why should suddenly be forbidden what had been for  hundreds of years in use  - and obviously the only "rule" of voicing two separate parts: the voice leading in parallel fifths of the middle age organon?"
And the answer was ( - apart of the independence of the voices):
"The composers of Ars nova and the following periods wanted to demonstrate that their music was something really new and different as the precedent aera."
So in this revolutionary  motivation lies  the will or desire to avoid parallels of fifths.
Add:
I've found another one quoting de la Motte:
A look at de la Motte's theory of harmony helps:

The argument of the vibration relationships is nonsensical, because why are quart parallels (2: 3) allowed and quint parallels (2: 3) prohibited?
The bad sound argument is illogical since the fifth is one of the most consonant intervals, the octave anyway.  Before Bach, parallel fifths in the organas of Leonin and Perotin were the non plus ultra, after Bach the parallel octaves and later the parallel fifths are found again in music, particularly quickly in instrumental music.
The independence of the voices is not an argument either, because the voice is no less independent when it runs in fifths than when it runs in permitted parallel thirds.
In the end, de la Motte justifies the most important dogma of music with a very flat explanation, but it is at least logical: the ban on parallelism as a reactionary movement, indeed as a deliberate loss and dissociation from the previous one.  That's exactly why they found their way back into music.

https://www.clavio.de/threads/offene-quintparallelen-am-ende-von-bwv-564-2.16798/
Answer: Here are the arguments and the original text by Diether de la Motte and a link to his book:
https://www.scribd.com/document/400639867/The-Study-of-Harmony-Diether-de-la-Motte-pdf
.... parallelisms that actually occur in the music of the great composers.
There are two usual explanations for the prohibition of parallel perfect octaves and fifths between any two voices:
1) The octave has a simple ratio of 1:2 between the frequencies of its lower and upper notes (for example: if the frequency of the lower pitch is 100 Hz., then the frequency of the upper pitch will be 200 Hz.). Because of this acoustical phenomenon, the two tones of the octave are often perceived as a single unified sonority. Similarly, the perfect fifth, which has thenext most simple ratio (2:3) between its upper and lower tones, is also frequently perceived to be a strong unified sonority. Therefore, two voices which move in parallel octaves or perfect fifths will tend to lose some of their own melodic individuality and independence.
*2) Parallel perfect octaves and perfect fifths simply sound "bad."
Both of these traditional explanations are somewhat troublesome. In explanation 1), why are we not also cautioned against the use of parallel perfect fourths the next most simple ratio (3:4)?
and De la Motte argues:
In explanation 2), why is it claimed that parallel perfect octaves and fifths sound "bad," when, as shown in Ex. 1:26, such structures abound in the music of the Middle Ages? (Furthermore, in the style of Medieval parallel organum, the parallelisms in question are said to have a particularly "good" sound.) Example 1:26 Excerpt from a Thirteenth-Century Conductus * Parallel perfect octaves and fifths, broken by rests or cadences, were also generally pemitted and cmployed im later musical styles.
All technical arguments which attempt to explain why parallel perfect octaves and fifths should be avoided create problems that cannot be resolved. For that reason, I shall attempt to explain the origin of this rule a different way. The major triad is a basic harmonic element that was common to Western music during a period of some 500 years (from Dufay to Reger). It also plays a vital role in twentieth-century music, especiallyinthe works of Hindemith and Stravinsky. Dominant-seventh and diminished- seventh chords, which are newer structures than the major triad, are quite rare in twentieth- century music literature, however. This is because both of these sonorities are associated with the kind of dominant-function harmony that is particuarly characteristic of the Classical and Romantic periods. By 1925, many composers refused to employ dominant- or diminished- seventh chords in their works because these sonorities evoked musical styles and aesthetics that were no longer in vogue. In short, harmonies which had played such an important part in the music of the past were simply rejected as old-fashioned by composers of a newer age. Parallel perfect octaves, unisons, and perfect fifths were first considered errors of composi- tional technique in the fourteenth century.
In many ways, compositions of this era also manifest
an aversion to earlier musical expressions.
Since composers of the fourteenth century considered the music ofthe previous era to be primitive, it is possible that disdain for and avoidance of earlier techniques helped establish the rule that: parallel perfect consonances are musically incorrect.

Composers always double different parts in octaves, NEVER in fifth, even though both intervals destroy voice independence.

There MUST be some other reasons why parallel fifths are banned. Could anyone suggest other reasons?
Well, as you see, your question provoked some good answers, but eventually not in the sense of your last point!
As  now rereading your question I have to say: Never say never!
Answer:
If voice dependence is the reason for not using parallel fifths, then why composers never use parallel fifth even if the music is NOT contrapuntal?

Try playing this example.

This is not contrapuntal writing at all. It's homophonic two-part harmony that you could hear in pop music, e.g., a vocal duet. In the first bar, I hear it as though there were two voices, and then suddenly one of the voices went away. It's arguably unpleasant and distracting. It feels like the texture changed suddenly. If the effect the composer wanted wasn't the effect of having one voice disappear suddenly, then this could be considered a mistake or bad writing.
In the second bar, I personally don't hear the disappearing-voice effect anywhere near as strongly when I play it on the piano at a slow tempo, but the same sort of thing can happen with a fifth as with an octave.
All of this can be an issue even if you had no intention at all of writing in a contrapuntal style and didn't care about having a texture of independent voices for its own sake. You create a texture, which creates an expectation on the part of the listener. Then you violate that expectation.

Composers always double different parts in octaves, NEVER in fifth, even though both intervals destroy voice independence.

Doubling parts in octaves is just considered a thickening of the texture. The ear-brain system so closely identifies notes that differ by an octave that they tend to meld together into the same sensation of tone.
The sound of parallel fifths (as opposed to just direct fifths) is different. It's very distinctive and creates, e.g., the effect of monks singing a chant. If that wasn't the effect you wanted, and it was the effect you produced, then it's a mistake or bad writing. But I don't think this effect really stands out to the listener if it's just inner voices or only a couple of fifths in a row.
Answer: Here is an interesting idea that I came up with that I have not seen elsewhere. It involves knowing something about the harmonic series, and also a little bit of signals/electronics theory. It doesn't quite answer the question, but might throw some light on it.
First the harmonic series. If we take the note C1 as root (that's pretty low but it's just to make the numbers easy - things work just the same starting from any note):
5 x F = E3 (F=frequency)
4 x F = C3
3 x F = G2
2 x F = C2
1 x F = C1
So a perfect fifth is 2F and 3F.
Now in signals theory there is something interesting - if we mix two frequencies F1 and F2 through a non-linear element (don't worry what that really means, basically any element that has some distortion will do this a bit) we get out F1, F2 and also sum and difference F1 + F2 and F1 - F2
So when we "mix" our perfect fifth we get
2F = C2
3F = G2
2F + 3F = 5F = E3
3f - 2F = 1F = C1
So the perfect fifth can do something special - it can produce extra overtones that "imply" a full major chord. In fact you can hear this when you hear an electric guitarist play a power 5th through distortion - the "extra" major 3rd above the chord.
Now let's say this happens at low, hard to hear but subtle levels on a piano (try it and see if you can hear the extra notes). You will subtly imply notes that are not in the major/minor scale, which might not sound "quite right".
Of course this doesn't quite explain the "parallel" part of the rule, but I do wonder if it has some bearing on why 5ths are considered a bit "special" in traditional harmony.
Comment: This is an interesting answer explaining the overlapping overtones. I've just edited the first column of the frequencies (like you meant it) as they were in a row ... and defined F= freq.
Answer: If you are doubling at the octave then they are not independent voices.  It's just the same voice, at a different octave.
It's not true to say that composers never use parallel 5ths.  There are plenty in music - some intentional (Puccini), some  not.  I even found one in Beethoven once, but can't remember where sorry.  At a certain point, most composers gave up caring about such rules.
However, for centuries, composers didn't like the hollow, weak sound of consecutive 5ths and tried hard to avoid them.
Comment: The first sentence could be made just as well for fifths, or even any other exact interval, no?
Comment: double fifths potential bring in a new pitch class, that changes the harmony, doubled octaves doesn't do that
Answer: There is a divergence of opinions on the matter, power chords are indeed parallel fifths but they should not be considered as such. The power chord is just a simple chord on the guitar, that when played in the lower registers, give a sound that sounds mean, they should not be considered chords in the traditional sense of the word, they are just a fifth played low that gives a sound that appeals to some.
In the case of power chords on the guitar there exist a fundamental choice in guitar players live of is his playing going to be power-chord based or is he going to use the fuller harmonic texture of a barre chord.
If you are playing in a harmonically complex band then barre chords will serve you well, if you are playing in an aggro thrash band you may enjoy the aggressiveness of a power-chord. Neither is better than the other, it is just a choice.
As for the parallel octaves, you may find in piano music this again should not be considered as such. It is one of the stylistic points of the piano as an instrument that the sound it produces has a quick decay and limited senority.
This just means that in effect the pianist has to constantly be playing a lot of notes to get a good sound, what you would see as parallel octaves is just two notes played together as an effect to make a better sound.
And then lastly, you must know the basic rules of harmony is just a guideline, I don't like to think of them as rules. It is just an introduction to the basics of voice leading, you are free to change or bend the rules as you wish. You may find that these rules are not there to stifle your creativity but is just a realisation trough the centuries of musical discovery into what makes good music.


What is the best way to remember the difference between sensitivity, specificity, precision, accuracy, and recall?

Question: Despite having seen these terms 502847894789 times, I cannot for the life of me remember the difference between sensitivity, specificity, precision, accuracy, and recall.  They're pretty simple concepts, but the names are highly unintuitive to me, so I keep getting them confused with each other.  What is a good way to think about these concepts so the names start making sense?
Put another way, why were these names chosen for these concepts, as opposed to some other names?
Comment: The best way to remember is to recall a real life study where this or that characteristic was in the focus. I.e. contextual flesh helps.
Comment: Recall is sensitivity, there you have one fewer to deal with. :)
Comment: For me, the best way to remember these concepts is through the 2×2 contingency table within the [Wikipedia link](http://en.wikipedia.org/wiki/Sensitivity_and_specificity).
Comment: @ttnphns: "contextual flesh" is a great typo!
Comment: Just to keep it here, this post offers a nice explanation: https://uberpython.wordpress.com/2012/01/01/precision-recall-sensitivity-and-specificity/
Comment: I come from the future (soon to be the past)! I don't think this question is about learning the definitions so much as remembering them.
Comment: See also [Origins of terms "sensitivity"and "specificity"](https://stats.stackexchange.com/q/510654).
Answer: For precision and recall, each is the true positive (TP) as the numerator divided by a different denominator.

Precision: TP / Predicted positive
Recall: TP / Real positive
Comment: TP/TN/FN/FP are well-named, self-explanatory if you remember that True/False refers to the correctness and Positive/Negative is the real world truth.
Comment: Nice and clean. Thank you!
Answer: Personally I remember the difference between precision and recall (a.k.a. sensitivity) by thinking about information retrieval:

Recall is the fraction of the documents that are relevant to the query that are successfully retrieved, hence its name (in English recall = the action of remembering something).
Precision is the fraction of the documents retrieved that are relevant to the user's information need. Somehow you take a few shots and if most of them got their target (relevant documents) then you have a high precision, regardless of how many shots you fired (number of documents that got retrieved).
Comment: When you say "regardless of how many shots you fired (number of documents that got retrieved)", it seems that the precision is independant of the number of total positive prediction, but : Precision=TP/Predicted Positive.
Answer: Mnemonics neatly eliminate man's only nemesis: insufficient cerebral storage.
There is SNOUT SPIN:

A Sensitive test, when Negative rules OUT disease
A Specific test, when Positive, rules IN a disease.

I imagine a pig spinning around in a centrifuge, perhaps in preparation for going into space, to help me remember this mnemonic. Humming the theme to Tail Spin with the words appropriately changed can help the musically inclined from a certain generation.
I am not aware of any others.
Comment: The SNOUT and SPIN rules are deceptively simple. You really ought to have good estimates of sensitivity, specificity, and prevalence before putting your trust in a positive or negative test result, no matter how sensitive or specific the test is. Check out this website: https://kennis-research.shinyapps.io/Bayes-App/. For example, entering a prevalence of 5 per 1,000. sensitivity = .90, specificity = .99 produces (via Bayes Rule) a relatively low positive predictive value of .2857.
Answer: I agree that the terms are very non-intuitive and hard to correspond to their formulas. Here are some diagrams with the mnemonic tricks that I have developed, and now I have them all solidly memorized.
Classification matrix
First, here are the mnemonics summarized in two common variations of the classification matrix (also called confusion matrix). My mnemonics work for either variation, so just focus on the variation of the matrix with which you are more familiar.

Note:

TP = true positives
TN = true negatives
FP = false positives
FN = false negatives

Short version of mnemonics
Here is the short form of my mnemonics; the details below explain the logic underlying them, which should help in memorizing what they mean:

Accuracy: correct predictions divided by all predictions: TP+TN/(TP+FP+FP+FN)
Precision and Recall: focus on true positives

PREcision is TP divided by PREdicted positive: TP/(TP+FP)
REcAll is TP divided by REAl positive: TP/(TP+FN)

Sensitivity and Specificity: focus on correct predictions

SNIP (SeNsitivity Is Positive): TP/(TP+FN)
SPIN (SPecificity Is Negative): TN/(TN+FP)

Detailed explanation of logic underlying the mnemonics, corresponding to their intrinsic meaning
Accuracy: overall results
Accuracy is actually quite intuitive and usually presents no difficulty in memorization. It is simply the correct (true) predictions divided by all predictions, whether true or false.
$$
Accuracy = \frac{correct\:predictions}{all\:predictions} = \frac{TP + TN}{TP + TN + FP + FN}
$$
Precision and Recall: focus on true positives
The essence of precision and recall is that they both consider the proportion of true positive results; that is, they are two different ways of measuring how many times the model correctly guessed the class of interest (that is, the positive class). So, TP is always the numerator. The difference between them is in the denominator: whereas precision considers all the values that were predicted to be positive (whether correctly or not), recall considers all the values that actually are positive (whether correctly predicted or not).
Precision is the proportion of positive predictions that were correct:
$$
Precision = \frac{true\:positive}{\pmb P\pmb R\pmb E dicted\:positive} = \frac{TP}{TP + FP}
$$
Recall is the proportion of real or actual positives that were predicted correctly:
$$
Recall = \frac{true\:positive}{\pmb R\pmb E\pmb A l\:positive} = \frac{TP}{TP + FN}
$$
To differentiate them, you can remember:

PREcision is TP divided by PREdicted positive
REcAll is TP divided by REAl positive

Sensitivity and Specificity: focus on correct predictions
The essence of sensitivity and specificity is that they both focus on the proportion of correct predictions. So, the numerator is always a measure of true predictions and the denominator is always all the total of corresponding predictions of that class. Whereas sensitivity measures the proportion of correctly predicted positives out of all actual positive values, specificity measures the proportion of correctly predicted negatives out of all actual negative values.
Sensitivity is the proportion of actual positives that were correctly predicted:
$$
Sensitivity = \frac{true\:\pmb Positive}{real\:\pmb Positive} = \frac{TP}{TP + FN}
$$
(Note that the although the formulas for Recall and Sensitivity are mathematically identical, when recall is paired with precision and sensitivity is paired with specificity, the interpretations and applications of the two measures are rather different.)
Specificity is the proportion of actual negatives that were correctly predicted:
$$
Specificity = \frac{true\:\pmb Negative}{real\:\pmb Negative} = \frac{TN}{TN + FP}
$$
To remember which is which, remember "snip and spin", but note that the letters P and N are swapped (that is, they spin around and the ends of the long names are snipped):

SNIP (SeNsitivity Is Positive)
SPIN (SPecificity Is Negative)
Answer: In the context of binary classification:
Accuracy - How many instances did the model label correctly?
Recall - How often was the model able to find positives?
Precision - How believable the model is when it says an instance is a positive?
Answer: The following article helps me a lot
https://medium.com/swlh/how-to-remember-all-these-classification-concepts-forever-761c065be33

accuracy: Double-A rule
precision: Triple-P rule
Comment: Helpful but might be more helpful to explain where "double A" and "triple P" come from
Answer: I created an interactive confusion table to help me understand the difference between these terms: http://zyxue.github.io/2018/05/15/on-the-p-value.html#interactive-confusion-table. I post the link here in case someone may find it helpful, too.
Answer: I had a similar problem and came across Andrew Ng's slide, which I found helpful, although there are good answers here as well.
As highlighted by other answers the key is remembering the confusion matrix.

Positives are on the first row and negatives are on the bottom row.
Andrew Ng Explanation:
For both precision and recall, True Positive is on top of the division symbol (i.e. numerator). For the Prescison we divide this by Predicted positive (which is the first row) and for reCAll, we divide this by ACtual positive (which is the first column)
High precision would mean that if a diagnosis of patients
have that rare disease, probably the patient does have it and it's an
accurate diagnosis. High recall means that if there's a patient with
that rare disease, probably the algorithm
will correctly identify that they do
have that disease.

Microsoft explanation:
Precision is the ability of a model to avoid labeling negative samples as positive (by looking at the above eq, precision formula, we need the false positive to be zero meaning do not tell people that they have the rare disease)
Recall is the ability of a model to detect all positive samples (by looking at the above eq, recall formula, we need the false negative to be zero meaning do not miss patients who have the rare disease)
Answer: I'll try and explain how I remember what recall is.
Definition:
Recall = True positives/All real world positives. OR
Recall = True positives/True Positives and False Negatives.
Imagine an automobile company that wants to recall some of its cars for a manufacturing defect (hard to imagine, right?). This company obviously wants to get in all the cars that have the issue. That's our denominator. The total number of faulty cars.
It may indeed get hold of all of them, by calling every single car it ever manufactured. So here, it's recall would be perfect, a value of 1. There cannot be a false negative (part two of the denominator) since we labelled everything as positive!
In this case, the owner is obviously a multi-billionaire who doesn't care about the cost of the *recall exercise.
But what if a corporate entity  wanted to cut costs (again, just go with me on this) by getting only the faulty cars in. Well, then, they would want to figure out something like, let's only call in cars that were manufactured in January this year as they have the maximum chances of this problem.
This creates our false negatives, that is, cars that have the problem but do not meet the January criterion. Therefore the second part of the denominator (FN) now becomes non-zero, which then reduces the overall fraction.
Key takeaways - it is the false negatives that fiddle with the recall metric.
The mnemonic, if you really need it, is that cars get recalled.
Hope this helps, somewhat.
Answer: I use the word TARP to remember the difference between accuracy and precision.
TARP: True=Accuracy, Relative=Precision.
Accuracy measures how close a measurement is to the TRUE value, as the standard/accepted value is the TRUTH.
Precision measures how close measurements are RELATIVE to each other, or how low the spread between various measurements is.
Accuracy is truth, precision is relativity.
Hope this helps.
Answer: Specificity tackles false positive. High specificity means a low false-positive rate. (Specificity = 1 - false-positive rate)
Sensitivity tackles false negative. High sensitivity means a low false-negative rate. (Sensitivity = 1 - false-negative rate)
That's why specificity is also called true negative rate, and sensitivity is also called true positive rate. The reason why we don't call them these ways is probably because the term "true negative rate" can be misleading to laymen as the denominator can be confusing. true negative rate = true negatives/actual negatives, NOT predicted negatives. The same goes for "true positive rate".
P.S. The answer above is tightly connected with the mnemonics "spout" and "spin", but I think it makes the mnemonics more understandable, plus I don't need to remember two extra words.


How can I improve my classical guitar vibrato technique

Question: I've been teaching myself to play some classical pieces on my nylon string guitar and want to improve my vibrato technique; specifically when holding several notes.
I'm referring to the technique of applying vibrato by stretching the string along its length rather than side to side.
I've been using the piece "Romance" (AKA 'Romanza' or 'Romance d'amour', etc), from Book 2 of Ben Bolt's '39 progressive solos for classical guitar', as a study for this purpose. Here it is played beautifully by Peo Kindgren ->

In the sections where there are arpeggios on open strings with melody played on the first string I can apply the vibrato quite nicely, but in the trickier sections I struggle to achieve any vibrato at all.
I've had some success by thinking in terms of shaking my thumb on the back of the neck as opposed to shaking my fingers, but it doesn't come naturally.
So I'm looking for general advice on technique and/or specific exercises to help develop this aspect of my playing.
Conclusion: I have accepted the answer from @amalgamate for the insight that the movement should originate from the arm muscles. This is exactly the information i was looking for.
Comment: Can you mention which book or edition the piece is from? "Romanza" could be anything! ... oh wait "sections where there are arpeggios on open strings with melody played on the first string" -- ok. I know what it is. Carry on.
Comment: @luser - good idea, I have added a reference to the book and a video by one of my favorite guitarists.
Answer: Start by giving yourself the most advantage:

Location on a string: Start with all your fingers fretting notes on the same string in the middle of the neck. The closer to the 12th fret you are, the more it is possible to move the note.
String selection: Start with a string where you can get a good grip on the string (a wound string). I recommend the 4th string, so that you don't have to reach more than necessary.
Use all your fingers at first: for example put your first finger on the 7th fret, your second on the eighth fret, your third on the ninth fret, your fourth on the tenth fret of the same string. Push and pull with all fingers gripping the string.

Now move your hand towards the bridge and the nut, back and fourth with the goal of grabbing the string and pushing and pulling it with all your fingers working as a team. In other words: move your arm which moves your hand which moves your fingers which stretches and relaxes the string tension. You should be able to produce a quite pronounced vibrato effect where the pitch moves both higher and lower than the true fretted pitch. You will be able to discern a pitch change without a tuner. As you get more and more comfortable with this technique, try it with less and less fingers, and in less ideal conditions (Such as on an unwound string, or closer to the nut). I commonly contrive to use two fingers, even though mastering the use of the single index finger is quite possible. In actual performance, I continue to take advantage of using more than one finger, when the fingering suggests using a finger that is not my first as the optimal choice.
Note that this vibrato technique often looks just like the improper technique of simply rolling your finger. If you play a stringed instrument such as the violin, that is exactly how to do vibrato, but this does not work on fretted instruments.
Also, you can get a quite pronounced effect with this technique. Sometimes the desired effect is more subtle, so once you master the technique in practice, understand that you often can and sometimes should do less in performance.
Also, the clarity of effect seems to be less pronounced on older strings for what ever reason.
Comment: I will definitely try this approach, although i can already get quite a good vibrato with a single finger I suspect that maybe I am doing something of rocking motion rather than a pure push/pull motion.       practicing with multiple fingers on the same string, as you suggest, would probable also help with my main problem which is persuading my hand to make this motion while holding several notes..
Comment: While it can look the same to an observer, it is different than what Tim suggests. It is a movement that should be coming from your arm, and it may be awkward to do quickly at first, start off slow. It is awkward because this technique uses bigger muscles that are not used to doing fine movements, but it is more than possible to work this up into a powerful technique that has a measurable pitch changing effect that Tim's suggestion lacks. Note it is not necessary to have a firm grip with your thumb, in fact it can get in the way if you grip too hard.
Comment: Think of it as a tug of war.
Comment: Too much tension and reluctance to work on what feels awkward are probably at the root of my problem. one tends to forget that everything you do on the guitar felt awkward / impossible at one time
Answer: Since asking the question I have discovered an excellent series of tutorials on classical guitar vibrato technique by Douglas Niedt.  Here is a link to the first video.
One technique he describes (which I did not know was possible) is adding vibrato on open strings and harmonics by fretting the same note, maybe in a lower octave, on another string and applying the vibrato to that but without sounding it.
Answer: This vibrato is rolling the finger along the length of the string on a particular fret. Don't try to slide it. To do it effectively, the fingertip will move from back to front of the fret space. With the thumb tight on the back of the neck, it restricts movement, so it's best to free the thumb off. I tend to bring the thumb out level with the fingers quite often. To me, the sound changes in tone rather than pitch - try it with a tuner - there's very little if any pitch change. Pull the guitar body in with the right elbow, and bend the fretting fingers so that the left arm can pull against the guitar neck a little.
Comment: The pitch should change, you are not doing proper classical guitar vibrato. On a fretted instrument you need to grip the string, and push and pull to get proper classical style vibrato that both moves the pitch higher and lower.
Comment: If the pitch changes, it's extremely subtle in comparison to the sideways bend. Try with a tuner, please, to check. It's not so much a grip and pull than a rolling motion along the string within the fret. I'm sticking with what I said !
Answer: You can always start to do vibrato exercises. Do your scales with vibrato. You can do them with the three main vibrato techniques.

The cocking of the wrist movement.
The vibrato in the left hand fingers bending the notes up and down
and the vibrato in the left hand finger bending the notes right to
left (Along the neck)

Mastery is achieved when you can achieve all three without any problems. They do very similar things but at certain times you may want to use on over the other.
The one that uses the wrist as pivot is in my experience best for a wide vibrato but it takes a lot of left hand motion to achieve so it is not always appropriate.
The finger vibrato along the neck is best for a softer gentle vibrato
And the vibrato that uses the fingers in an up and down motion is the better all purpose vibrato.
Comment: Didn't think classical guitarists use the same up and down vibrato that electric players use, if that's what you meant in the last para.
Comment: On classical guitar you get very little result by bending the strings (because of the low string tension?) except for the G string (for some reason) which can be bent to reasonably good effect, but stretchinbg along the length of the string creates a nice musical effect which adds a lot of expressive power to slow passages. It's nothing like as deep as the vibrato you get by bending a steel string side to side.
Comment: I like the idea of practicing scales with vibrato though. - I'd vote you up but the system won't allow it.
Comment: Your no.3. How can a string be bent while moving a finger longitudinally along the string? Can you expand, please?
Answer: The technique I have used and the technique that is taught by guitar teacher Tom Hess is to break the technique down into 3 parts and practice each in isolation.  These parts are: pitch, tempo and contour.
Practicing pitch refers to consistently bending (vibrato is a slight bend) to a higher pitch and then back to the original pitch.  Bending up a half step and back again makes for a wide vibrato but allows you an easy way to check that your pitch changes are in tune and consistent.
Practicing tempo trains you to have a consistent rather than erratic vibrato.  Try practicing your vibrato to a metronome as 1/8, 1/16 and 1/16th note triplets.
Practicing the contour refers to how you are raising the pitch and returning.  This is not the same as tempo, because you may gradually move to a pitch and back or wait until the last instant before bending and still be in time.  Practice doing vibrato gradually and smoothly (imagine a wave form) and also faster and sharper (^^^^^).  They both have applications.


CodeIgniter htaccess + awstats password protected collision

Question: I've searched the web for a while and couldn't find the correct answer for the following problem:
I have a working .htaccess for codeigniter app (index.php removed ) which looks like this:
RewriteEngine On

RewriteCond %{HTTP_HOST} !^www\.mydomain\.com [NC]
RewriteRule ^(.*)$ http://www.domain.com/$1 [R=301,L]

RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

And the /awstats/.htaccess has the following rules:
Options +ExecCGI
AddHandler cgi-script pl
DirectoryIndex awstats.pl

AuthUserFile /home/MY_USER/domains/mydomain.com/public_html/awstats/.htpasswd
AuthType Basic
AuthName "AwStats Protection"

<LIMIT GET POST>
require valid-user
</LIMIT>

When I did not use awstats with password protection -> everything worked just fine.
After enabling password protection for awstats -> CI shows a 404 error when I try to access mydomain/awstats. how can that be fixed?
Note: mydomain.com / MY_USER is just for the sake of the example :-)
Comment: You should see your logs firstly, access and error log
Answer: Instead of this:
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

You can do this:
RewriteCond $1 !^(index\.php|favicon\.ico|favicon\.png|crossdomain\.xml|robots\.txt|images|css|js|awstats)
RewriteRule ^(.*)$ /index.php/$1 [L]

So you can explicitly grant access to anything that doesn't need to go through CI's front controller. This is a safer technique, but requires that you explicitly add every file and directory (e.g. images, css, etc).
Comment: Hmmm..still gives me a conflict with CodeIgniter, codeigniter thinks it's a controller and gives me a 404.


O que é opinionated software?

Question: O termo é usado em algumas discussões de programação. Eu nem sei a tradução dele.
Qual é a importância para programadores?
Comment: _Opinionated_ eu consumo traduzir como ter uma opinião forte sobre alguma coisa. _"My grandfather is an opinionated man"._
Answer: Geralmente está se falando de alguma característica que o software impõe ao usuário, e se for para um programador, que ele não deixa você programar de forma diferente.
Como exemplo, é a filosofia oficial de Python que diz que só tem uma maneira de fazer as coisas. Este não é um bom exemplo porque na prática tem várias formas de fazer, mas teoricamente eles dizem que querem que só tenha uma.
O termo é bastante usando em ORMs e outros frameworks, onde alguns dizem que sabem o que é melhor para você e só deixam fazer daquele jeito, você não tem flexibilidade de mudar, pelo menos em certas partes.
Então ele pode dizer que você tem que usar code first em vez de database first para gerar os modelos (geralmente tem alguma ferramenta que faz importação do banco de dados para gerar código se form necessário).
Outro exemplo seria um software de wiki que impõe a forma de trabalhar sem dar muita margem de como mexer nisso.
A Apple é um exemplo de empresa que costuma fazer softwares bastante opinativos por isso as pessoas costumam dizer que você não compra o software deles, porque mesmo depois de pagar, eles ainda dizem o que você pode ou não fazer.
Não sei se a falta de opção é ser opinativo. Por exemplo, a maioria dos bancos de dados possuem apenas um engine de storage, mas o MySQL permite você escolher e até personalizar algum. Isso é ser não opinativo?

Eu acho que algo não é 100% opinativo ou não, tem certas características que são. Pode até ter um caso com todas as características, mas em programação deve ser algo bem ruim de usar.
Algumas pessoas podem dizer que Java é opinativo quando não deixa criar um operador personalizado. O que faria virtualmente todo software ser opinativo em algum ponto. Fica difícil traçar uma linha do que é opinião sobre como fazer algo ou falta de alguma característica.
Eu não sei dizer como costuma ser interpretado quando há "convenção sobre configuração", que é tem um default considerado opinativo, mas você pode mudar. Nunca vi uma definição canônica que diz claramente o que o termo é. É daqueles casos do termo nascer informalmente e cada um pode interpretar como achar melhor.
Já vi algumas pessoas dizendo sobre o software ser aberto (não só o código) para a comunidade participar ou recriar, o que faria dele não opinativo, mas eu tenho dúvidas se isso se encaixa bem.
Alguns dizem que ele faz você não poder sair dele (lock-in). Também não acho uma boa definição, esta seria outra questão, até porque quase qualquer software te obriga ficar nele se não fizer grande esforço para sair.
O que parece ser mais certo, que ele estabelece "boas práticas" e obriga você usar daquela forma.
Dar muita flexibilidade torna o software mais difícil de desenvolver e mater e torna ele mais difícil de usar (exceto se usar convention over configuration).
Algumas pessoas falam que ele escolhe qual é o "caminho dourado", mas pode deixar você seguir outros caminhos. Se a escolha for ruim você passa longe do produto.
Então ele facilita fazer o que o criador achou que é melhor para você, mas dificulta ou impossibilita fazer algo diferente disto. Provavelmente é um termo de usabilidade.
Quando a pessoa não domina muito o assunto parece que ele é bom. Um software é mais opinativo quanto mais for feito para leigos, pelo menos deveria ser assim.
Costuma-se alegar que eles são mais produtivos que os mais flexíveis.
Me parece que esses softwares tendem durar menos. Fazendo uma análise histórica, se eles não mudam de filosofia, a adoção tende a declinar em favor de um concorrente, mesmo indiretamente, mais moderno, com melhores "opiniões". E nem sempre é fácil mudar a filosofia de algo opinativo. Em alguns casos pode ser mais fácil, justamente por ser mais simples. Mas irá contra sua própria opinião.
Softwares mais opinativos tendem ser mais nichados. Eles sobrevivem bem onde as pessoas possuem poucas exigências.
Para tudo pode ter exceção, exceto os softwares opinativos.
Parece que o balanço até onde deve ser opinativo é importante. Todo mundo quer o fácil, até que ele não atenda sua demanda e aí quer a flexibilidade.
O que eu mais notei é que as pessoas não conseguem concordar muito quais softwares são opinativos ou não. E eu mesmo não classificaria algum exemplo da pessoa usando o critério dela. Por isso é um bom termo para ajudar definir algo, mas ele não consegue universalizar tudo, é altamente opinativo na hora de usar o termo. Ah... a ironia.
Gostei deste diagrama:

O termo em Português provavelmente é o que eu usei por todo o texto, o literal, até porque sem uma explicação ele não quer dizer muito, é um termo técnico, não deveria ser completamente intuitivo, apenas dar uma ideia do que seja.
Tentei fazer a resposta não ser opinativa :P
Coloquei no GitHub para referência futura.
Comment: +1 Não sei ao certo, mas a primeira vez que eu ouvi falar no termo foi quando estudei sobre o framework Ruby on Rails. Não sei se foi o framework que criou o termo ou se já existia, mas sempre faço a ligação desse termo com tal ferramenta do Ruby.
Comment: Sei que ele é um dos mais citados quando usa o termo. Eu tenho dúvidas se ele é tão opinativo assim, talvez usaram isso como marketing um pouco. Há quem use de forma positiva e há quem use como negativo. De fato deve ser um pouco, por isso as pessoas estão abandonando ele, conforme o que eu respondi :)

O que é opinionated software?