How to create a view showing the products from a user's company?

Question: I'm trying to create a relationship between a field on a user profile and a field on a content type.
User Profile
Company Name - This is an entity reference that pulls names from a Company content type.
Product - contains a field company which also pulls from a Company content type.
I'm trying to create a view which will show a user products his company carries.  So the view is a user view.  Contextual filter is the UID of the logged in user. Now trying to create the relationship to pull in fields from the product content type.
Basically, I'm trying to create a query that will show products where the product.company is equal to the user.companyname.
Answer: To achieve it with the current content architecture:

Create view of users.
Add a relationship Entity Reference: Referenced Entity. Mark it as required. This will make a connection between the user and the company.
Add another relationship Entity Reference: Referencing entity. Before saving add the value of the Relationship select list and select the relationship created in step #2. Mark this relationship as required too. This will make the connection between user company and the product.
You should now get the fields of products you could add to the view using the relationship you have built at step #3
Comment: Thanks.  Selecting the relationship was the part I kept missing.   Perfect.
Comment: Glad to help :-)
Comment: http://drupal.stackexchange.com/questions/159526/helping-with-a-view-users-taxonomy-and-relationships  -- in case you have an opinion on this one.
Answer: The tutorial about Using Entity Reference in Views is about using Entity Reference in Views, primarily how to use with Views relationships. Some of the topics covered are:

Entity references available as a relationship.
Entity references available as a reverse relationship.
Using relationships will give you duplicate rows – because that is how relationships work.
Use entity references as contextual filters.
When Entity API is enabled, you can choose the "show" setting entity, in addition to fields and content.
...


Parent element not getting child function call arguments

Question: I'm almost there, missing just one simple thing. I'm modyfing state of parent with a child that has the function passed. The problem is that when the child calls the function passed from parent with an argument, that argument is not being catched in the parent's method.
Parent:
export default class GameList extends Component {
  constructor({ navigation }) {
    super();
    this.navigation = navigation;
    this.ds = new ListView.DataSource({ rowHasChanged: (r1, r2) => r1 !== r2 });
    this.state = {
      test: 0,
    }

  updateState(filteredResults) {
    this.setState((prevState) => ({
      dataSource: this.ds.cloneWithRows(filteredResults),
    }));
  }
  render() {
    return (
      <View style={styles.background}>
         { this.updateState() }} dataSet={this.dataSet} />
      </View >
    )
  }

};

Child:
import React, { Component } from 'react';
import { View, TextInput } from 'react-native';

import styles from './styles';

class Header extends Component {
  render() {
    return (
      <View style={styles.container}>
        <TextInput
          style={styles.input}
          placeholder="Search..."
          onChangeText={(text) => {
            const filteredResults = this.filterRows(text, this.props.dataSet);
            debugger;
            this.props.updateState(filteredResults);
          }}
        />
      </View>
    );
  }

  filterRows(searchText, dataSet) {
    return dataSet.filter((record) => record.title.includes(searchText));
  }
}

export default Header;

'filteredResults' in parent is undefined.
Answer:

You create a new function and don't pass the param to the inner function each time.
 this.updateState(filteredResults)} dataSet={this.dataSet} />

But that's pointless. Just go with the first way.
Comment: You're right about why it's not working mate, just I don't think the 2nd option is pointless as it allows you to keep the context in the child without the binding (see 1st answer). Thanks tho!
Answer: Reason is you are calling that method with no arguments:
updateState={() => { this.updateState() }} //here

Instead of that write it like this:
updateState={this.updateState}

And use updateState function like this:
updateState = (filteredResults) =>  {
     this.setState((prevState) => ({
        dataSource: this.ds.cloneWithRows(filteredResults),
     }));
 }

Or another alternative is just define the binding in the constructor:
this.updateState = this.updateState.bind(this);

then use that function like this:
updateState={this.updateState}

updateState(filteredResults) {
     this.setState((prevState) => ({
        dataSource: this.ds.cloneWithRows(filteredResults),
     }));
 }

Comment: It works perfectly mate, I just don't get why updateState = () => {} works, and regular updateState() {} doesn't ? That's the last thing in that subject I don't get
Comment: when you write `updateState={this.updateState}` means you are passing the reference of that `function` and actual function will get called from child component with parameter, and `arrow function` is used to maintain the context, it will work without `arrow function` also but in that case you will no be able to use `this` inside that function. To test that remove `arrow` and remove the `this.setState` simply do `console.log(parameter);` it will print the proper parameter passed from child.
Comment: Got it! I understand now, thank you! Answer accepted :)


Somehow forum's got associated to wrong taxonomy vocabulary. Need help

Question: I am using Advanced Forum 2.6 and I noticed that some of the views were set to pull the wrong vocabulary instead of the forum vocabulary. I set them all to pull the correct vocabulary but when I go to /forum the page title is still for the incorrect vocabulary and any change I make at admin/structure/forum also affects the terms in the previously connected vocabulary. It seems that the database is confused and I'm not sure how to reset things.
I am also getting a pair of the following errors for every term:

Notice: Undefined property: stdClass::$num_topics in
  mothership_preprocess_forum_list() (line 49 of
  /Users/seankennedy/Documents/_IWS/drupal/sites/all/themes/mothership/mothership/functions/forum.php).
Notice: Undefined property: stdClass::$num_topics in
  mothership_preprocess_forum_list() (line 60 of
  /Users/seankennedy/Documents/_IWS/drupal/sites/all/themes/mothership/mothership/functions/forum.php).

I am mostly a front end guy so I have little experience with messing around in the database directly but not afraid to have a go if that's what it will take to fix it.
Answer: Option 1
Go to the Forum Topic manage fields and click edit in the forums field.
Check that the vocabulary is set to Forums
If it's not, delete the forum field and add the term reference field again.

Option 2
Have u posted content already to the forum? or do you care about the forum content? if not, disabling and uninstalling both Forum and Advanced Forum would be an option you could try and then enable them again.
Comment: Tried both options with no luck.

steps I took.
1. deleted term reference from forum topic
2. Created new term reference pointing to forum taxonomy
3. Disabled and Uninstalled both forum and advanced forum modules and cleared cache.
4. Re installed both modules and flushed cache.

Result was no default forum taxonomy and Forum Topic content type pointing to the same incorrect taxonomy vocabulary as before. Same errors as above returned. One pair for each taxonomy term. The list of forums  has the default general forum but also has a mirror of the terms from the wrong taxonomy vocabulary.
Comment: Next I tried disable/uninstall and delete both forum and other tax vocabs. Now there is no config screen for Advanced forum and get error when going to a topic page

Notice: Array to string conversion in include() (line 36 of /Users/seankennedy/Documents/_IWS/drupal/sites/all/modules/contrib/advanced_forum/styles/naked/advanced-forum.naked.forums.tpl.php).


I want to write XPath for below HTML code

Question: This is an HTML code I need help to write XPath for this. I have tried to write x-path but it does not hit the system correctly?

    <button class="vh79eN" type="submit" data-reactid="18">
    <svg width="20px" height="20px" viewBox="0 0 17 18" class="" xmlns="http://www.w3.org/2000/svg" data-reactid="19">
    <g fill="#2874F1" fill-rule="evenodd" data-reactid="20">
    <path class="_2BhAHa" d="m11.618 9.897l4.225 4.212c.092.092.101.232.02.313l-1.465 1.46c-.081.081-.221.072-.314-.02l-4.216-4.203" data-reactid="21">
    </path>
    <path class="_2BhAHa" d="m6.486 10.901c-2.42 0-4.381-1.956-4.381-4.368 0-2.413 1.961-4.369 4.381-4.369 2.42 0 4.381 1.956 4.381 4.369 0 2.413-1.961 4.368-4.381 4.368m0-10.835c-3.582 0-6.486 2.895-6.486 6.467 0 3.572 2.904 6.467 6.486 6.467 3.582 0 6.486-2.895 6.486-6.467 0-3.572-2.904-6.467-6.486-6.467" data-reactid="22">
    </path>
    </g>
    </svg>
    </button>

Please, help me to write correct XPath I have tried with:
driver.findElement(By.xpath("//div[@class='col-1-12']//button[@class='vh79eN']")).click();

but it does not work.
Comment: Try to use `@type` instead of `@class`: `//div[@class='col-1-12']/button[@type='submit']`
Comment:
Comment: getting any error or what ?
Comment: Drop one of the slashes in the middle - `//div[@class='col-1-12']/button[@class='vh79eN']`
Comment: Possible duplicate of [Selenium WebDriver \[Java\]: How to Click on elements within an SVG using XPath](https://stackoverflow.com/questions/41829000/selenium-webdriver-java-how-to-click-on-elements-within-an-svg-using-xpath)
Comment: @Andersson I tried but getting below issue:
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@Type='col-1-12']/button[@type='submit']"}
  (Session info: chrome=64.0.3282.186)
Comment: @suyash_sunny , try to use [ExplicitWait](https://www.seleniumhq.org/docs/04_webdriver_advanced.jsp#explicit-waits)
Comment: @DawoodibnKareem : I tried you solution also but below error:
org.openqa.selenium.NoSuchElementException: no such element: Unable to locate element: {"method":"xpath","selector":"//div[@Type='col-1-12']/button[@class='vh79eN']"}
  (Session info: chrome=64.0.3282.186)
Comment: @NarendraR :yes I got error written in the comment above
Comment: If that's the error you got, then you did _not_ try my solution.
Comment: @suyash_sunny, the xpath you are giving is written by you manually or it is generated by inspecting element?
Comment: @suyash_sunny, did you try my answer?
Comment: @RabiaAsif: I am trying to create by myself.
Comment: @suyash_sunny Ok then I would recommend you to inspect the element on browser and get the xpath which is already driven. If you have no idea about inspecting and getting xpath this way do tell me.
Answer: If data-reactid is consistent every time page is visited, you could try: //button[@data-reactid='18']
Note: If the element is inside of an iframe, you will have to switch to the iframe, then try to click.
Answer: The following XPath can be tried :
//div/button[@class='vh79eN'][@type='submit']

So the function will be:
driver.findElement(By.xpath("//div/button[@class='vh79eN'][@type='submit']")).click().


Change textarea length when post submit

Question: I have set textarea value is
1
2
3

and when print to var_dump is
string(5) "a b c"

But, I try post submit. and let's take a $_POST value and print var_dump
string(7) "a b c"

I think the new line is problem.
How can i make the number of letters the same?
Comment: This _might_ be an issue with line break sequences differing between different operating systems. Unixoid systems use `\n`, whilst MS-Windows based systems use `\r\n`. Older Apple systems used `\n\r` :-) You could replace that using a regular expression.
Comment: thank you good info. i didn't know `\n\r`
Answer: Try using trim () function to remove unnecessary symbols
trim ()
Or consider this function
str_replace ()
Comment: I try `str_replace('\n', '', $value)`

But, i should `str_replace("\n", "", $value)`

It was a matter of single quotes and double quotes.
Comment: The output examples do _not_ show any additional white space characters left and right of the printable characters...

Change textarea length when post submit


Is Cronbach's alpha a parametric or non-parametric test?

Question: Is Cronbach's alpha a parametric or non-parametric test? I need to know more specific details about it.
Comment: Welcome to our site! At the moment it is somewhat unclear what you are asking - could you explain what you mean by " I need to know more specific details about it"? What in particular do you need to know? I'm also a little confused by the reference to a hypothesis test. Could you explain what hypothesis you are seeking to test?
Comment: Although this question proceeds from false premises, it can be answered. (Ie, those misunderstandings can be cleared up.) This doesn't need to be closed, IMO.
Answer: Chronbach's alpha is not a test at all, it's a measure of reliability of test scores, looking at (in a particular sense) their internal consistency.
It is responsive to the correlation between items -- as the items become more highly correlated, Chronbach's alpha will generally increase.
Sometimes people may require that Chronbach's alpha achieve some arbitrary minimum threshold value, but that's not a test in the statistical sense.
Comment: @MohamedLoayDahhan What is okay depends on who you ask! The linked Wikipedia article discusses thresholds in more detail than I could (giving several criteria), but in any case an in depth discussion of what would make it acceptable lies outside the statistical issues, and I don't really think arbitrary cut offs on it have all that much to do with science either. Just naming a precise threshold to blindly apply in every situation may be comforting (or perhaps disconcerting) but not necessarily scientifically relevant -- in some situations it may be more like astrology than it is like astronomy
Comment: All thanks to clarify the point, what is the value at which the value of Chronbach's alpha is acceptable, I found the values 0.6 and 0.7 are used as the threshold to accept it. and What is the scientific justification for the selection of the threshold value at which we are accepted.


Inverse cubic function

Question: I'm looking for a way to find the inverse of a function that resembles something like this, ${f(x)=x^{3}+4x+2}$. So one of the "form" $f(x)=x^{3}+ax+b$.
I am told that it has an inverse function, $ $ $ f^{-1}(x)$ , and that $f(0)=2$.
Can someone point me in the right direction?
Comment: You were told that $f(0)=2$? The expression for $f$ is $f(x)=x^3+4x+2$ and you need that someone tells you that $f(0)=2$?
Comment: @JoséCarlosSantos :) I have no idea. I was asked to help with this question by a friend of mine who's doing undergrad calculus.. The question also formulated the funny statement: "$f(0)=2$ ..
Comment: @Kristian Then I strongly suspect that the problem that your friend was supposed to solve was to compute $(f^{-1})'(2)$. Am I right?
Comment: @JoséCarlosSantos Yeah you are. Is it easier to evaluate at a single point?
I know that $f(f^{-1}(x))$ should give $x$ itself, right?
Comment: @Kristian I posted an answer to the question.
Answer: The problem, as you told me in the comments, consists in computing $(f^{-1})'(2)$. Since $f(0)=2$, $f^{-1}(2)=0$, and therefore$$(f^{-1})'(2)=\frac1{f'\bigl(f^{-1}(2)\bigr)}=\frac1{f'(0)}=\frac14.$$You don't have to determine $f^{-1}(x)$ for every $x$ in order to do this.

Inverse cubic function


cannot access proftpd installation from outside server

Question: I have a digitalocean droplet running ubuntu 18 with Apache. I installed proftpd on there and when I log in to the droplet via ssh and run ftp myservertld  or telnet myservertld 21 I can access the proftpd instance properly. However when I try to connect to it from my pc via filezilla, terminal or browser, or even from another separate droplet, I cannot connect to the ftp server, the connection simply times out. On filezilla I am getting this:
Status: Resolving address of myservertld
Status: Connecting to IP:21...
Error:  Connection timed out after 20 seconds of inactivity
Error:  Could not connect to server

Answer: I simply forgot to open the port in firewall
ufw allow 21/tcp


What does it mean when the same note with the same length is on the same stem for the same instrument?

Question: In Ravel's "Bolero" the violas play a repeated pattern in pizzicato that grows more and more complex. The second form, however, beginning at m. 21, has a notation that puzzles me. The middle notes show the same note being played at the same time with the same length. Like so:

The notation implies one voice only and the length shows it's not a note that carries over the next, which would be more or less meaningless for pizzicato anyway. I cannot seem to find anything about it when searching online. My best guess is that the same two notes should be played on different strings to achieve a double layer of that note, but it's only a guess and I'd like to know for sure.
While I have not read many orchestral scores I've read quit a lot of notes and it's the first time I've come across it. My searches have given me info on notes of different lengths for the piano, notation of same notes for different voices for vocals, but nothing that explains this.
Answer: The first chord is on the open C and G strings. The second chord is G on the C string, open G on the G string, and the octave G on the D string. So yes, three strings total.


What am I doing wrong solving $\sqrt{x^2+1}- 2x+1>0$?

Question: First, I started looking at where $\sqrt{x^2+1}$ is defined: $\sqrt{x^2+1}>0$ is defined everywhere. Next I
$\sqrt{x^2+1}- 2x+1>0$
$\sqrt{x^2+1}> 2x-1$
$0> 3x^2-4x$
$0> x(3x-4)$ and I solve this for $x\in (0,\frac{4}{3}]$.
I know that this solution is wrong, because I went and drew this graph. The correct result is $x\in (-\infty,\frac{4}{3}]$.
I'm totally confused on how to solve irrational inequalities now, because the official solving in my textbook looks like this:
$\sqrt{x^2+1}> 2x-1$. This inequality is fulfilled , if the right side is negative, therefore $x<\frac{1}{2}$. If $x\geq\frac{1}{2}$, the right side is positive or equals to $0$ and we get $0> 3x^2-4x$ which is true for $x\in (0,\frac{4}{3}]$. Now with previous condition $x\geq\frac{1}{2}$ we get the solution $[\frac{1}{2},\frac{4}{3})$.The complete solution set is $x\in (-\infty,\frac{4}{3}]$.
I never solved this type of inequality in this way, because it's messy- Why would I look at the conditions $x<\frac{1}{2}$ and $x\geq\frac{1}{2}$ when I can immediately tell where irrational part is defined and where not?
In the end, this textbook solution process only confused me. Could anyone please explain it why the correct solution is $(-\infty,\frac{4}{3}]$ or more concretely: Where did I miss the part of the solution $(-\infty,0]$?
Comment: It appears that you are confusing the logical "or" ($\lor$) with logical "and" ($\land$) in the assertion $$\sqrt A>B\iff ((A\ge 0\land B<0)\lor(A\ge 0\land A>B^2\land B\ge 0))$$
Answer: You seem to believe that$$\sqrt{x^2+1}>2x-1\iff x^2+1>(2x-1)^2.\tag1$$This is false. The inequality $\sqrt{x^2+1}>2x-1$ holds automatically if $2x-1\leqslant0\left(\iff x\leqslant\frac12\right)$. Otherwise (that is, if $x>\frac12$) then, yes, the equivalence $(1)$ holds.
Answer: What you've overlooked is that it's not true that, assuming you know that $t \geq 0, \text{ then } \sqrt{t} \geq y \iff t \geq y^2$.  What is true is that $\sqrt{t} \geq y \iff t \geq y^2 \lor y \lt 0$.
So you need to account for the possibility that $2x-1 \lt 0$.
Answer: When $A \geq 0,$ it is always true that $B > A$ is equivalent to $B^2 > A^2.$
But this is not always true when $A < 0.$
For example, if $A = -2$ and $B = -1,$
then $B > A$ is true but $B^2 > A^2$ is false.
The step where you squared both sides of $\sqrt{x^2+1}> 2x-1$
is only valid when $2x-1 \geq 0,$ that is, when $x \geq \frac12.$
For every other value of $x$ you have to use a different method.
One method that works for $x<\frac12$ is to notice that the right side of
$\sqrt{x^2+1}> 2x-1$ is always negative while but the left side is never negative, therefore the left side is always greater than the right.
Answer: First of all, we should check for $x \ge \frac{1}{2}$ and $x < \frac{1}{2}$ because in this step:
$$\sqrt{x^2+1}> 2x-1$$
we are squaring both sides. So sign of $2x-1$ may change the direction of inequality (precisely when $|2x-1| > \sqrt{x^2+1}$).
Now, for the case where $x < \frac{1}{2}$, we also have a solution for
$$x^2+1 <4x^2-4x+1 \implies 3x^2-4x > 0 \implies x < 0 \lor x > \frac{4}{3}$$
but $x > \frac{4}{3}$ doesn't satisfy our first assumption $x < \frac{1}{2}$. Therefore, we get a solution $x < 0$ here.
Answer: If $A,B\in \Bbb R$,$$\sqrt A>B\iff \begin{cases}A\ge 0\\ B<0\end{cases}\lor\begin{cases}A\ge 0\\ B\ge 0\\ A>B^2\end{cases}$$ In this instance $A=x^2+1$, $B=2x-1$ $$\begin{cases}x^2+1\ge 0\\ 2x-1<0\end{cases}\lor\begin{cases}x^2+1\ge 0\\ 2x-1\ge 0\\ x^2+1>4x^2-4x+1\end{cases}\iff x<\frac12\lor\begin{cases}x\ge \frac12\\ x(3x-4)<0\end{cases}\iff\\ \iff x<\frac12\lor \begin{cases}x\ge\frac12\\ 0<x<\frac43\end{cases}\iff x<\frac12\lor \frac12\le x<\frac43\iff x<\frac43$$
Answer: I'll try to explain in somewhat simpler terms than the other valid answers.
Also, I assume you really meant the strict inequality "$>$" and not "$\geq$".
The problem is in the squaring step, of course, and comes from the fact that the valid inequality $$1 > -1$$ does not imply the nonsensical squared inequality $$1^2 > (-1)^2.$$
Your task was to find all $x$ for which the original inequality holds, but you only found some because you missed the possibility that $\sqrt{x^2 + 1}$ is less positive than $(2x - 1)$ is negative (or equal), i.e. the case that
$$
\sqrt{x^2 + 1} \leq -(2x - 1)
.
$$
The borderline case happens when
$$
\sqrt{x^2 + 1} = |2x - 1|,
$$
which has the two solutions you identified, $x_1 = 0$ and $x_2 = \frac{4}{3}$.
By inspection, $\sqrt{x^2 + 1}$ is less positive than $(2x - 1)$ is negative (or equal) for all $x \leq 0$.
Together with the part that you found, we have the solution set
$$
(-\infty, \frac43).
$$
If you meant "$\geq$" in the problem setup then the solution set is $(-\infty, \frac43]$.
Hope that makes sense.
Answer: The OP mentioned the solution given in the book, so here we express that logic.
$\quad \{ x \in \Bbb R \, | \, \sqrt{x^2+1} - 2x+ 1 \gt 0\} =$
$\quad\quad\quad \{ x \in (-\infty, \frac{1}{2}] \; | \; \sqrt{x^2+1} - 2x+ 1 \gt 0\} \;  \bigcup $
$\quad\quad\quad\{ x \in [\frac{1}{2},\frac{4}{3}] \; | \; \sqrt{x^2+1} - 2x+ 1 \gt 0\} \; \;\;\;\;\,\bigcup$
$\quad\quad\quad \{ x \in [\frac{4}{3},+\infty) \; | \; \sqrt{x^2+1} - 2x+ 1 \gt 0\} \;=$
$\quad\quad\quad(-\infty, \frac{1}{2}] \;  \bigcup \; [\frac{1}{2} , \frac{4}{3}) \;  \bigcup \; \emptyset = (-\infty, \frac{4}{3})  $
Answer: You must consider:
$$\sqrt{x^2+1}> 2x-1 \iff \\
1) \ \sqrt{x^2+1}> 2x-1\color{red}{\ge 0} \ \ \text{or} \ \ 2) \ \sqrt{x^2+1}\ge \color{red}{0>} 2x-1$$
You square in $1)$, because both terms are nonnegative.
However, you must not square in $2)$, because you don't know how far away the LHS and RHS are from $0$ and you would impose an additional constraint. Moreover, once $0>2x-1$ holds, it automatically implies $\sqrt{x^2+1}>2x-1$. So:
$$\sqrt{x^2+1}\ge \color{red}{0>} 2x-1 \iff \color{red}{0>}2x-1.$$
Hence, solution must be:
$$x^2+1>(2x-1)^2 \ \ \text{or} \ \ 0>2x-1 \Rightarrow \\
x\in (0,\frac43] \ \ \text{or} \ \ x\in (-\infty,\frac12) \Rightarrow \\
x\in (-\infty,\frac43].$$


How to improve intuitive feeling for rhythm

Question: I'm playing for around 10 years now and I'm definitely not a beginner. Still, my intuitive understanding of new rhythms is very poor.
I can learn to play nearly every rhythm if I have enough time. This is a very analytical process like breaking everything down in small blocks, practice them super slow and connect them.
Even this works it's not a useful approach if someone shows you a new song and ask you to play a backing for a singer. It doesn't has to be perfect but it should catch the idea of the rhythm of the song. Very often I must respond with: Sorry, I have to practice this first.
Other musicians in my circle of acquaintances don't have this problem. They don't care a lot about the theory behind it, they just start playing and it sounds good.
How do I reach this point? Of course I asked them but I never got a satisfying answer, they just do it without thinking about it.
I'm already doing a lot of these classic rhythm exercises like pyramid, shifting accents, syncopation, ... with a metronome. And of course this helps but this alone does not take me to point where I want to go.
Any tips?
Comment: Does this answer your question? [Exercises to get beter at rhythm (piano)](https://music.stackexchange.com/questions/109578/exercises-to-get-beter-at-rhythm-piano). And numerous other questions on leaning rhythm.
Comment: Note that "playing for 10 years" is not *that much*. It depends on how those 10 years were spent in studying and education. It would help to know how you approached playing, if you ever had any theory course (with/without teacher, in a class or individually), how your instrument training evolved along with the theoretical comprehension (and I don't mean about the "rules" and pure notions of music theory) and, not less important, at what age you started. Most of the times, this kind of problems are caused by inappropriate education in early years, failing to address primary elements of music »
Comment: Do you already have straight 8th notes and straight quarter notes down intuitively? How about running dotted 8th -> 16th note patterns?
Comment: Actually, how often have you done those sight reading clapping ear test exercises? They're standard fare in piano lessons or at least preparing for Royal Conservatory of Music (RCM) exams. (They had me sight reading and clapping 8th-note triplets and regular 8th notes in the same exercise by Grade 10.)
Comment: @Dekkadeci Straight notes are not a problem. I have a bunch of dotted patterns in my repertoire but not very single possible one. If I encounter a new  one most times I have to spent some hours to get it right.
Comment: @Dekkadeci I've done them in different levels. But still its just learning patterns. I dont have the feeling it helps me that much with understanding new stuff.
Comment: » learning, such as ear training, inner ear, rhythmic/tonal abstraction, time/interval relations etc. All that is often (and with good reasons) done through use of the voice, which is the most intuitive and autonomic way we have to approach music. So, the first question would be: when you have difficulties understanding a rhythm, before trying on the instrument, are you able to "replay" it with your voice? If you are, then you're probably half-way, as it means that you don't actually have issues in understanding the rhythm, but only in "connecting" the part of your brain that actually plays.
Comment: I started with age of 20 and play on average ~2-3h a day (but not all time is practice). I'm mainly self taught, but had done also some lessons. I have a solid knowledge of music theory and this helps a lot with identifying harmonic context, notes, chords... but not so much with feeling a rhythm.
Comment: If I have a tricky rhythm I can't deal with then it doesn't matter if I try to strum it, knock it on the table or sing it.
Comment: I'm curious what kind of answer you're looking for. I myself do not have an intuitive understanding of rhythms but I've learned enough of the most popular rhythms that I can pick up new rhythms and feel them quite quickly. I've never done rhythm exercises so I don't know if those help, but I'm a little skeptical. Learning rhythms will help you with understanding rhythms.
Comment: Can you dance to any random tune? Not very well necessarily, but well enough so you feel you're moving to the music? Or can you tap along to a song while driving a car? Doing these kinds of things might help you develop a more intuitive sense for rhythm on guitar.
Answer: There are no shortcuts:

Practice sight reading rhythms. There are books and web sites available for sight reading practice.
Learn a lot of rhythms. Do a web search for something like "rhythms every drummer should know" and learn to strum the results on guitar. You'll have to count and subdivide and use a metronome to get them right before you can just feel them.
Listen to a lot of music that has percussion and popular rhythms in it. The previous web search should also lead you to examples and names of rhythms to search for.

Be aware that if you don't recognize a rhythm on the page you'll have to sight read it to hear it and then get in the groove of it. Until or unless you can audiate a rhythm before you play (sight reading practice will help with this), you'll have to get the groove from the first few times you play it and try to settle in as fast as possible.
Comment: @flappix Part 2 of his answer is to learn patterns. Part 1, sight reading is not about memorizing, it is about reacting and having to play something you don't know on the spot, which ultimately helps in recognizing and playing unfamiliar rhythms quickly. As for part 3, I would add transcribing things you haven't played before. I would also suggest listening to and playing along with recordings you like. Since you don't have the ability to do it without thinking about it like your acquaintances your best choice is to work hard to know exactly what you're doing.
Comment: @flappix ok, read it as "there are no magic ways."    The more you practice as many rhythms as possible (with a metronome, preferably), the more those rhythms will be ingrained.   Same as learning scales and arpeggios.
Comment: Thanks for your answer but I'm not looking for shortcuts, I'm looking for a different (additional) approach. Like I said, I know multiple musicians which are not able to sight read at all nor do any rhythm exercise on a regular base but can still adapt rhythms super fast. So there has to be another way of doing this.
Comment: @flappix Ok if you don't like my answer that's fine. I'm a guitarist who can just look at some chords and get the rhythm and play and sing and direct the rest of the band all at the same time and this is how I learned to do all that so I thought maybe it would help you. Have you tried asking these other people how they learned to do it?
Comment: Yes, like I wrote in the initial post. They tell me something like "Dont think about it, dont count it, just feel it." Unfortunately I dont feel it.
Comment: @flappix I hope someone else posts an answer you like. The advice to "don't think about it" is one of the shortcuts I was saying there isn't. I wasn't suggesting you are looking for a shortcut.
Comment: @flappix regarding your first comment, the first thing Todd says is "There are no Shortcuts." He then gives you 3 good ideas to work on. Do you know how to read music or much about theory?
Comment: @JohnBelzaguy Yes, I do. I've already done these exercises (and still working on them). The basic strategy behind all this is to learn as much patterns as possible to lower the risk of encounter new patterns. It's valid, it's working in many cases, but it is not flexible. This is not a bad answer but it's not the answer to my question.
Comment: @flappix "The basic strategy behind all this is to learn as much patterns as possible to lower the risk of encounter new patterns" That is a good summary of how we learn **everything**. There is literally no other way that I've ever known to learn things. This is how we learn languages, mathematics, science, music, etc. I think you might have left something out though: Once we learn enough patterns, we can encounter a new pattern that is *similar* (but not identical) to *one or more* patterns that we have already learned and then we can quickly synthesize the new pattern from what we know.
Comment: Not wishing to disagree with you, but I do. As a young 11yo, learning guitar, I knew nothing about the technicality of rhythms, or the theory behind them, and certainly didn't learn as many patterns as I could. It just happened. No-one taught me how to do it. Serendipity? Maybe. Now, knowing a bit of theory, I can understand what I do, but in the moment, never think about it. Problem is, I can't come up with an answer to OP's question!
Comment: @Tim Clearly it didn't just happen for the asker or they wouldn't be asking. It doesn't always just happen. When it doesn't, the only way I've ever found to make it happen is to do the work.


Whats the difference between "Content Type" and "Content Types" on a block configuration form?

Question: Whats the difference between these two tabs? There is no help text here. One has "negate" the condition but the other does not.
Comment: See https://www.drupal.org/node/1932810 for the issue that would add that generic implementation to core, deprecate the old one and then we will need to remove it from ctools
Comment: One is from Ctools, which adds this for bundles of all entity types and so you get this for nodes twice.
Answer: "Content type" comes from CTools and "Content types" comes from core.
Use "Content types".
Simplified summary
"Content types" comes from core and is the preferred condition to use. The "negate" option is also present in core, but it is suppressed by the block module (source). In contrast to core CTools provides this condition not just for nodes but for any entity type (taxonomy terms, custom entities etc.). That's the reason why in case of nodes there is a duplicate set of entity bundle conditions.
Issues on drupal.org
Now there's this core issue Duplicate node type setting in block visibility which was closed as "works as designed". The problem shall be fixed by CTools (as in remove the duplicate entry).
This leads us to this CTools issue Duplicate node type visibility condition in block settings which was put on hold until core itself replaces CTools functionality to provide block visibility settings for any entity type (not just for nodes) including the "negate" option.
Which finally brings us to this core issue Add entity bundles condition plugin for entities with bundles where the progress to move CTools functionality to core to replace the current node type core condition is being tracked.
Comment: 2 years and still not fixed.
Comment: Think this is one of those UX issues then. "Works as designed" but for end users, should it be there?
Comment: @Kevin – Of course no, it shouldn't be there. Let's hope that we can get that fixed soon.
Comment: @KevinFinkenbinder hello from 2021 where this is still a thing!


Carregar mais não funciona corretamente

Question: Tenho uma section onde recebe alguns posts e tem um botão de carregar mais. Na minha section o primeiro post exibe corretamente, mas quando eu clico no botão de carregar mais, não executa o segundo post q era para aparecer.

Minha section | complemento/section-um.php   = Local que fica minha section
Meu botão | complemento/section.botao.php = Local que fica meu botão
Meu javascript | complemento/carregar_mais_js.js = Local que fica meu botão

//Carrega um conteúdo inicial ao carregar a página
$(document).ready(function(){

   $.ajax({
        url: 'complemento/section-um.php',
        data: {PG:1},
        type: 'GET',

        success: function(response){

            $('#Section_index_NV').html(response);
        }
   });
});

//Carrega um conteúdo ao clicar no botão
$(document).ready(function(){

    $('#CarregarNVs').click(function(){

        let proxima_pagina = $(this).attr('data-ref');

        $.ajax({
            url: 'complemento/section-um.php',
            data: {PG:proxima_pagina},
            type: 'GET',

            success: function(response){

                console.log(response);
                $('#Section_index_NV').append(response);
            },

            complete: function(){

                $('#CarregarNVs').attr('data-ref', parseInt(proxima_pagina) + 1);
            }
       });
    });
});

Página do meu botão:

            <button id="CarregarNVs" title="Carregar mais" class="CarregarNVs" data-ref="2">Carregar mais</button>

Comment: voce esta enviado um `data` em um `GET`, nao seria `POST`?
Comment: Sim era isso msm, estava como GET mudei para o POST e funcionou. Obrigado.
Comment: O que acontece, tem algum erro no console? Cai no callback de erro do ajax, nao renderiza na tela..?
Comment: o console não retorna nenhum erro, mas agora q eu dei uma olhada, quando eu clico no botão ele executa apenas a parte do titulo do minha section (Ou seja ele duplica o inicio da section, mas n aparece outro post).
Answer: Você está enviando a propriedade data no Ajax do jQuery com um método GET. Como o end-point é um post, altere para type: 'POST'.

Carregar mais não funciona corretamente


Sharing AWS AMI Images Between Accounts Not Working - Image not visible

Question: The initial motivation for the activity below was the need to move my Wordpress site (based on Bitnami) from one AWS account to another. In order to do that I have found the following tutorial: https://www.youtube.com/watch?v=aITdIDIkkao
I am doing all the steps as described in the tutorial until 7:11, where shared AMI Image needs to appear in another account. Unfortunately, this is not happening - I can't see the image on my second account.
Can anyone please help?
And is this the right approach to move my wordpress site from one AWS account to another?
Thank you!
Answer: Found it - apparently I need to look in the same region.


For $z \in \mathbb{C}$, if $(z^a,z^c,z^b \bar{z}^d,z^{b+d})=(1,1,1,1)$, then $z=1$ under certain gcd conditions for $a,b,c,d$.

Question:
Let $z \in \mathbb{C}$. I would like to show that if $(z^a,z^c,z^b \bar{z}^d,z^{b+d})=(1,1,1,1)$ and gcd$(a,b,c,d)=1$ and gcd$(a^2-c^2,b^2-d^2)=4$, then $z=1$.

Note that I am not sure whether this is true or not, but I believe it is. My argument starts as follows:
Assume that $z$ is a primitive $n$th root of unity, that is, $z^n=1$ and $n$ is the smallest such positive integer. Then
$z^a=1 \implies n |a$
$z^c=1 \implies n |c$
$z^b \bar{z}^d=1 \implies z^b=z^d \implies n |(b-d)$
$z^{b+d}=1 \implies n|(b+d)$.
Using the division conditions that n divides $b-d$ and $b+d$ it follows that $n|2b$ and $n|2d$. Moreover, since $n$ divides $a$ and $n$ divides $c$ it follows that $n$ divides $2a, 2b,2c$ and $2d$. Hence $n=1$ or $n=2$ because gcd$(2a,2b,2c,2d)=2$. If $n=2$ then since $2|a$ and $2|c$, then $4$ divides $a^2-c^2$. Also, since $2$ divides $(b-d)$ and $(b+d)$, we have that $4$ divides $b^2-d^2$.

Now, this does not seem to give me a contradiction, so I am stuck.
Answer: The given condition is false. Take $z = -1$, and $a=4,c=2$, with $b=3,d=1$. Then, of course $\mbox{gcd}(a,b,c,d) = 1$, and $a^2-c^2 = 12$ with $b^2-d^2 = 8$ whose $\gcd$ is $4$. Furthermore, $\bar z = z$, so $z^a = z^c= 1$ and $z^b\bar z^d = z^bz^d=z^{b+d} = z^4=1$.


Amazon ECS MissingAuthenticationTokenException

Question: I follow this instruction http://docs.aws.amazon.com/AmazonECS/latest/developerguide/ECS_GetStarted.html
and here's what I got:
<code>$ aws ecs list-clusters

{
    "clusterArns": [
        "arn:aws:ecs:us-east-1:xxx:cluster/MyCluster",
        "arn:aws:ecs:us-east-1:xxx:cluster/default"
    ]
}
</code>
and on the EC2 instance:
<code>$ cat /var/log/ecs/ecs-agent.log

t=2015-02-02T18:31:45+0000 lvl=info msg="Starting Agent" module=main stack=    [agent/agent.go:32]
t=2015-02-02T18:31:45+0000 lvl=info msg="Loading configuration" module=main stack=[agent/agent.go:34]
t=2015-02-02T18:31:45+0000 lvl=info msg="Connecting to docker daemon" module=main stack=[agent/agent.go:41]
t=2015-02-02T18:31:45+0000 lvl=info msg="Connected to docker daemon" module=main stack=[agent/agent.go:43]
t=2015-02-02T18:31:45+0000 lvl=info msg="Registering Instance with ECS" module=main stack=[agent/agent.go:50]
t=2015-02-02T18:31:45+0000 lvl=crit msg="Could not register" module="api client" err="{\"__type\":\"MissingAuthenticationTokenException\",\"message\":\"Missing Authentication Token\"}" stack="[github.com/aws/amazon-ecs-agent/agent/api/api_client.go:175 agent/agent.go:51]"
t=2015-02-02T18:31:45+0000 lvl=eror msg="Error registering" module=main err="{\"__type\":\"MissingAuthenticationTokenException\",\"message\":\"Missing Authentication Token\"}" stack=[agent/agent.go:53]

cat /var/log/ecs/ecs-init.log

ecs-init [Mon Feb  2 18:31:43 UTC 2015]: pre-start
ecs-init [Mon Feb  2 18:31:43 UTC 2015]: Loading Amazon EC2 Container Service Agent from file /var/cache/ecs/ecs-agent.tar
ecs-init [Mon Feb  2 18:31:44 UTC 2015]: start
ecs-init [Mon Feb  2 18:31:44 UTC 2015]: Starting Amazon EC2 Container Service Agent
ecs-init [Mon Feb  2 18:31:45 UTC 2015]: Exited 1
</code>
So where Authentication Token should be set ?
Answer: Authentication tokens should be set by the IAM role that you use to launch your container instance.
Did you set up an IAM role for Amazon ECS with this procedure: http://docs.aws.amazon.com/AmazonECS/latest/developerguide/get-set-up-for-amazon-ecs.html#create-an-iam-role
Also, you need to launch your container instance with that IAM role.
Hope this helps.


Very small Cramer's V and moderate Odds Ratio?

Question: I'm running a Chi Sq test with 2 binary variables. The data are large (>1 million rows) and not balanced (rare event). The test is statistically significant (p < .0001) and the Cramer's V is very small (.006). I took this to mean there is no relationship and the p value is due to such a large sample size/power. However, the odds ratio is 4.4.
I'm trying to understand how one effect size (Cramer's V) can be so unlike another (Odds Ratio)? Is the Cramer's V sensitive to data imbalance?
Answer: I happened to come across this interesting question, and wanted to provide my 2 cents, expanding on the answer already given. I will assume that the provided data meet the requirement for the chi2 test.
What I would like to point out is that Cramer's V, as well as other coefficients such as Phi, C, and even Goodman-Kruskal's lambda, is sensitive to both the magnitude of the association AND to the marginal distribution.
In the dataset provided by the user, the marginals are pretty unbalanced (skewed). It is not by chance, in fact, that V proves pretty small (0.006383) while the OR is indeed not "tiny" (4.44).
The imbalance in the marginal sums, which does not affect the OR, would indeed account for the small value of V. Some scholarly sources suggest to control for the imbalance by computing the coefficient on the standardised table. As matter of fact, V (computed on the standardised version of the user's table) turns out to be 0.356. For a 2x2 table, it could be interpreted as an association of medium strength (according to the Cohen's thresholds), and is more "in line" with the magnitude of the association as measured by the OR.
What do I mean by "standardised table"? A standardised table is a table where we re-express the counts so to achieve predetermined sets of marginal sums. This is done via Iterative Proportional Fitting (IPF). For instance, the row and column marginals can be equal to fractions out of 100. Or, one can retain the table's grand total and set the row (and column) marginals to the grand total divided by the number of rows (and columns).
Using this last approach, the standardised version of the table provided by the user would be:

Note that we are "re-expressing" the counts, keeping the association structure is unaltered (OR 4.44). The marginals are not unbalanced.
Essentially, the way I see the issue is: given the observed V, is it what it is (e.g., "small", like in the example provided by the user) because the association is indeed "tiny" or also because the imbalance in the marginal distribution is "getting in the way"? For one thing, the discrepancy between V and the OR should ring as a warning bell. One might wonder whether in such contexts (i.e., in a table with such a marginal imbalance) measures that are sensitive to  imbalances in the marginal sums should not be used, and more "resistant" measures should be preferred instead. Or, on the other hand, we could still stick to V "but" controlling for the marginal skewed distribution.
The issue becomes even more cogent when comparing Vs across tables, for example.
There is a nice section on the effect of marginal distribution on nominal association coefficients, and on table's standardisation, in the following book: Reynolds, H. T. (1977). The Analysis of Cross-Classifications. The Free Press. ISBN 0029263905.
Also, the seminal Agresti's book on Categorical Data Analysis features a paragraph on tables standardisation via IPF.
Comment: I have edited my answer in order to address your comment.
Comment: What do you call the standardized table?
Comment: Thanks, I see. +1 for the explanation and the reference. However, as you largely altered the data and the resulting Cramér's V, I find it dubious that you can compare it to Cohen's rules of thumb, which are based on non-altered calculations (but maybe there's something justifying it in the reference you mention?). Anyway, Cohen's rules of thumb are themselves are subject to criticism, and ultimately may not be useful at all to judge the relevance (or the "strength") of an effect size relative to the context of a given study.
Comment: (cont'd) In addition, in this specific case of a 2x2 table, I find that your solution introduces an unnecessary complication to try to correct a known issue with Cramér's V (or phi) in 2x2 tables (see https://stats.stackexchange.com/a/632240/164936). When phi is inadequate for the question we want to answer, the odds ratio (or the risk ratio) is a simpler and more intuitive solution.
Comment: (cont'd) Also, I wonder about the properties of the altered Cramér's V you suggest: what kind of inference can we make from it? Can we compute reliable confidence intervals around it? etc.
Comment: Thanks for your comments. I do see your points. I do not totally agree with the expression "altering". We are "re-expressing" the counts, keeping the association structure unchanged as indicated by the OR. Ultimately, one is controlling for the marginal unbalances that are "affecting" V (as well as phi, C, and lambda for instance). Regarding Cohen's thresholds, I do know that their are field-specific and "subjective". I merely mentioned them just as a sort of tentative frame of reference. There is more literature on the IPF and standardised tables. There was also a short paragraph....
Comment: ....in Agresti's book on Categorical Data Analysis.
Comment: @NewATGis The standardization you describe seems related to the change one might make to create a Binomial Effect Size Display.  Am I right?  https://stats.stackexchange.com/questions/24067/is-the-binomial-effect-size-display-besd-a-misleading-representation-of-effect
Answer: This is a good question with a few moving pieces, so my answer may be a bit circuitous. But given your setup, I think it's important to hit all the relevant stops along the way.
There are boundaries that we have to first establish as to what these tests can and cannot tell us. First off, class imbalance alone has no impact your chi-square test results. Try to artificially create imbalance in your "flag class" ranging from 1:2 to 1:35 to 1:1000, etc. and you could hypothetically create 2x2 matrices with chi-square statistics close to zero (likely unassociated). This in mind, I'm looking at your data, and not actually too worried about the class imbalance per se. That won't "drive" anything here.
What will matter is your actual overall sample size (your n) and the number of columns/rows you have. Jumping ahead, this will determine whether your should be relying more on the OR or Cramer's V.
Chi-square statistics tell you nothing about the effect size (strength of association), only of the association occurring by chance. Big differences between classes (i.e. white and black) in matrices with low overall sample sizes can produce non-significant chi-square results. And in large sample sizes, even the smallest differences between groups can generate significant chi-square results, with p-values well below 0.0001. This is because the p-value indicates how likely you will obtain the chi-square statistic by chance. Higher sample sizes makes it extremely unlikely, and so differences between groups becomes more sensitive.
Whereas Chi-Square provides indication of an association, Cramer's V and Odds Ratio provide an estimate of the strength of the association. However, which to use depends on a few things:

Generally, OR is best used on 2x2 contingency tables. Cramer's V can conveniently provide effect size estimates on tables of multiple dimensions with a "correction" for large sample sizes. But this has the effect of producing low correlation measures, even for highly significant results.

Cramer's V also assumes that both columns (i.e. black/white and flag/no flag) can be thought of as independent variables. It is a symmetrical test, meaning V(x,y)=V(y,x). I don't believe this to be true in your setup, as you're trying to describe one as having a dependent effect on the other, or the odds of some kind of success in the flag group vs. odds of success in the non-flag group.

Cramer's V is also sensitive to large sample sizes, which you have, regardless of the class imbalance that is also present in your dataset. Contrary to the chi-square statistic, larger group differences in smaller samples will show larger associations (as they should), and smaller group differences within larger samples will show smaller associations (as they should). This is why your Cramer's is low (0.0064) while your Chi-Square is high (60.08, p-value <0.001).

Therefore, I would tend to summarize your results using the OR and Chi-Square statistics, and put less emphasis on the Cramer's V for the reasons mentioned above. Your 95% CI limits also look good for the OR.
However, I would also stress that OR assumes the underlying distribution of your data is normal, and that this sample of observations you've selected is also random (Berkson's Fallacy). You can't make inferences on entire populations using restricted observation samples.


Is there a name for raising the v chord to a dominant V

Question: From what I've understood from other questions, the dominant chord is always major. So in a minor key, the v chord is not considered dominant.
Considering that, is there a name for when we're in a minor key, and a v chord is raised to a dominant V? When a iii/III chord is changed from major to minor or vice versa, it's called a chromatic mediant, so why is there seemingly no name for when it's the v chord? It's also chromatic, using a note not in the original scale.
I get that V to v is extremely rare, but v to V is very common, I would have expected it to have a name. I'm not satisfied with just saying "to use the dominant chord" because it's "normal" in a major key (it's just the V chord), but it's a chromatic change when done in a minor key.

For example, in Bad Romance the chorus uses both, raising it to a dominant in the second half:

F G Em Am
F G E Am
Comment: "So in a minor key, the v chord is not considered dominant": that depends on who you ask. "the dominant chord is always major": some people would say that, but not all. The defining characteristic is being built on the fifth degree of the scale. In functional harmony of the so called "common practice," it's true, but not necessarily in other musical styles, and there's no reason to avoid calling `v` the "minor dominant."  The dominant is always major like potato chips always have salt -- it's the natural order of things, but taking away the salt doesn't stop it from being a potato chip.
Comment: @phoog Fair, but note that my question still stands even if there is such a thing as a "minor dominant". Saying dominants are always major just narrows it down a bit.
Answer: The dominant chord is so called because the fifth degree of the scale.  Normally, in traditional functional harmony, it's major.  This arises because of conventions of chromatic alteration that were established long before harmonic theory was developed.
Some people therefore think that a minor chord built on the fifth degree of the scale can't be called "dominant," but there's no reason why it shouldn't be.

When a iii/III chord is changed from major to minor or vice versa, it's called a chromatic mediant

There similarly isn't total agreement on precisely what chords should be defined as chromatic mediants.  If we take C major as our example, though, it's clear that of the major and minor chords built on E and E♭ the only one that doesn't involve chromatic alteration is E minor.
But it's silly to call the major chord built on the dominant scale degree of a minor key the "chromatic dominant" because the chromatic alteration that makes it major is the default state of that chord.  So much so, in fact, that the minor chord built on that degree of the scale has to be the chord that is qualified.  We can't call it the "chromatic dominant," though, so we may call it the "minor dominant" or even analyze it in relation to the temporary tonicization of a different scale degree.
In a chord progression that isn't in the common practice style, therefore, I'd use the terms "minor dominant" and "dominant" for the v and V chords, respectively.
The process of modifying the seventh scale degree, the third of the dominant chord, is generally "chromatic alteration," or, more specifically, "raising [or lowering] the leading tone."
Comment: I wouldn't call the non-raised 7th degree a leading tone at all. It's a "subtonic" or something. https://en.wikipedia.org/wiki/Subtonic
Answer: When I first encountered 'theory' in the 1950s, the basic minor scale was the Harmonic Minor, with its sharpened 7th note.  V HAD to be major, otherwise how could there be a V-I cadence, the cornerstone of Common Practice harmony?   When determining whether a piece with two flats in the key signature was in B♭ major or G minor we were taught to 'spot the sharpened 7th'. If there were a sprinkling of F♯ accidentals,  it's G minor!   We knew about the Melodic Minor and Natural Minor scales, but Harmonic Minor was the norm.  Harmonic Minor IS the 'original scale'.
Latterly, Natural Minor seems to have taken over as the One True Minor Scale, particularly in 'Jazz Theory'.   But not all jazz is 'modal'.  There are plenty of major dominants still being played.
The sharpened 7th requires an accidental.  We could call it a 'chromatic alteration'.  I don't know any special name for that particular chromatic alteration.
Answer: I'll gloss over a description of how common practice minor key harmony works vis a vis the dominant triad and just say that in such a context I would probably distinguish the two chords by name using:

functional dominant for the major triad, and...
minor dominant for the minor triad

So, in a passage like i v6 iv6 V, I might say something like: "the minor tonic moves to the minor dominant in first inversion, then to the minor subdominant in first inversion, for a phrygian cadence type progression to the functional dominant in root position." I don't always load up a description with theory terms like that, but it I wanted to say it in a way to avoid confusion, I might say something like that.
Along with "functional" terms like "raised" or "leading tone" are other was to describe the "major triad rooted on the dominant."
Answer: There is no special name for swapping between major and minor V chords. The reason chromatic mediants have a special name is that they come from neither the parallel major or minor of the current key; whereas, major and minor V do. That is, v/V can be attributed to modal interchange, but III cannot. (I'm not aware of an instance where iii would be considered a chromatic mediant, as it can always be explained in terms of the major key.)


DNS resolve failing for specific domains. Domains work with nslookup

Question: What I want to happen: Pass the method a domain as a string and have it return true if the domain resolves. False if it does not. The underlying goal is to see if a domain exists.
What happens: Most valid domain strings return true. Some, however, return false despite resolving with nslookup.
I don't understand why certain domains are failing to resolve when they look fine when using command prompt nslookup and nslookup sites. (I've used https://centralops.net/ , http://www.kloth.net/services/nslookup.php , and http://network-tools.com/nslook/)
Method (C#):
    //no blank domains
    public bool CheckDomain(string sDomain)
    {
        if (string.IsNullOrWhiteSpace(sDomain)) return false;
        for (int i = 1; i <= mQueryRetry; i++)
        {
            try
            {
                System.Net.IPAddress dnsCli = System.Net.IPAddress.Parse("220.127.116.11")
                DnsClient myClient = new DnsClient(dnsCli);
                DnsMessage dnsMessage = myClient.Resolve(ARSoft.Tools.Net.DomainName.Parse(sDomain), RecordType.A);
                if ((dnsMessage == null) || ((dnsMessage.ReturnCode != ReturnCode.NoError) && (dnsMessage.ReturnCode != ReturnCode.NxDomain)))
                {
                    throw new Exception("DNS request failed");
                }
                else
                {
                    foreach (DnsRecordBase dnsRecord in dnsMessage.AnswerRecords)
                    {
                        ARecord aRecord = dnsRecord as ARecord;
                        if (aRecord != null)
                        {
                            return true;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                // Back off and try again after 1 seconds
                if (i != mQueryRetry)
                {
                    System.Threading.Thread.Sleep(1000);
                }
                else
                {
                    System.Diagnostics.Trace.WriteLine(string.Format("Domain: {0} error: {1}", sDomain, ex.Message));
                }
            }
        }
        System.Diagnostics.Trace.Flush();
        return false;
    }

If you plan to test it, I suggest replacing the dnsCli IPAddress with one of these. I've left the IP for the google DNS server in there as an example but I am using my company's DNS server in my production code. I've found that changing the DNS server in no way impacts the method's behavior.
I am using the latest version of Arsoft.Tools.Net (2.2.8) for the DnsClient, DnsMessage, DomainName, DnsRecordBase, and ARecord,  classes/objects. We had the same problem with an older version (1.8.1).
Some of the domains that are failing to resolve are:
appraisallinks-amc.com
resurgenstech.com
orpheusvr.com
trovvit.com

Additional info: I've tried some ludicrously long query timeout limits, upwards of 5 minutes, and they made no difference. Therefore, I am certain that this is not a timeout issue.
Comment: you can try and use a different library, the DnsClient (nuget) instead, see http://dnsclient.michaco.net. The domain names in question seem to work just fine
Comment: ***Plus One***, a DNS question with code.
Answer: "you can try and use a different library, the DnsClient (nuget) instead, see dnsclient.michaco.net. The domain names in question seem to work just fine " -
  @MichaC
The problem was in fact the Arsoft.Tools.Net library I was using. Switching to DnsClient.Net fixed the problem.


Botões não mudam a cor

Question: Os botões eram para ficar azuis de acordo com o .rounded-button.blue, mas estão pretos e apenas a borda funciona. O que tem de errado?

.client-buttons {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 100;
}

.client-buttons button {
  -webkit-box-shadow: 0 0 0 2px rgba(0, 0, 0, .2);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .2);
  display: block;
  float: left;
  padding: 7px;
  min-width: 34px;
  height: 34px;
  font-size: 12px;
  margin-right: 10px;
  line-height: normal;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .2);
}

button,
html input[type=button],
input[type=reset],
input[type=submit] {
  -webkit-appearance: button;
  cursor: pointer;
}

button {
  -webkit-appearance: button;
  -webkit-writing-mode: horizontal-tb !important;
  text-rendering: auto;
  color: buttontext;
  letter-spacing: normal;
  word-spacing: normal;
  text-transform: none;
  text-indent: 0px;
  text-shadow: none;
  display: inline-block;
  text-align: center;
  align-items: flex-start;
  cursor: default;
  background-color: buttonface;
  box-sizing: border-box;
  margin: 0em;
  font: 400 13.3333px Arial;
  padding: 1px 6px;
  border-width: 2px;
  border-style: outset;
  border-color: buttonface;
  border-image: initial;
}

.rounded-button {
  background-color: transparent;
  -webkit-border-radius: 48px;
  -moz-border-radius: 48px;
  border-radius: 48px;
  padding: 11px 24px;
  display: inline-block;
  text-decoration: none;
  font-family: montserrat, Arial, sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: #333;
  text-transform: uppercase;
  border: 2px solid #333;
  cursor: pointer;
  height: 47px;
  line-height: 21px;
  text-shadow: none;
  text-align: center;
  -webkit-transition: background-color .2s, color .2s;
  transition: background-color .2s, color .2s;
}

.rounded-button.plain {
  -webkit-transition: opacity .2s;
  transition: opacity .2s
}

.rounded-button {
  opacity: .85
}

.rounded-button:hover {
  opacity: 1
}

.rounded-button.plain,
.rounded-button:not(.plain):hover {
  color: #2d74a6
}

.rounded-button.blue {
  color: #138cc8;
  border-color: #138cc8;
}

.rounded-button.blue:not([disabled]):not(.no-hover):hover,
.rounded-button.blue.plain {
  background-color: #138cc8;
  color: #fff;
}

.rounded-button:not(.white):not([disabled]):not(.no-hover):hover,
.rounded-button:not(.white).plain {
  background-color: #333;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .2);
}

.rounded-button.blue {
  color: #138cc8;
  border-color: #138cc8;
}

.client-buttons button .client-icon {
  -webkit-filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.3));
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.3));
  display: inline-block;
  font-style: normal;
  float: left
}

.client-buttons button .client-icon.client-close-icon {
  background-image: url(../images/favicon-white.png?3);
  background-size: 16px 16px;
  width: 16px;
  height: 16px
}

.client-buttons button .client-icon.client-fullscreen-icon,
#hotel-container .client-buttons button .client-icon.client-fullscreen-icon-back {
  background-image: url(../images/web/fullscreen-icon.png);
  background-position: 0 -14px;
  width: 14px;
  height: 14px;
  margin: 1px
}

.client-buttons button .client-icon.client-fullscreen-icon-back {
  background-position: 0 0
}

.client-buttons button .client-icon.hidden {
  display: none
}

.client-buttons button.client-close .client-close-expand {
  float: left;
  overflow: hidden;
  width: 0;
  text-align: left;
  -webkit-transition: width .15s ease-out 0s;
  transition: width .15s ease-out 0s
}

.client-buttons button.client-close .client-close-expand span {
  padding: 1px 0 0 8px;
  display: inline-block
}

.client-buttons button.client-close:hover .client-close-expand {
  width: 50px
}

.client-buttons button.client-players {
  cursor: default
}

.client-buttons button.client-players .client-icon.client-players-icon {
  background-image: url(../images/web/players-icon.png);
  background-size: 16px 16px;
  width: 16px;
  height: 16px
}

.client-buttons button.client-players .client-players-count {
  float: left;
  text-align: left;
  padding: 0 2px 0 6px;
  font-size: 14px;
  position: relative;
  top: -1px;
  display: inline-block
}

.client-frame {
  background-color: #000;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  display: block;
  border: 0
}

  <button class="client-close rounded-button blue plain">

    Início
    </button>
  <button class="client-fullscreen rounded-button blue plain">

    </button>
  <button class="client-count rounded-button blue plain">
     1,802 </button>
  <button class="client-radio rounded-button blue plain">
    <audio controls="controls" id="stream" autoplay="autoplay" preload="none" style="display:none" src="http://yoda.habblet.in:9999/;">

    <source id="source_mpeg" type="audio/mpeg" src="http://yoda.habblet.in:9999/;type=mp3">
    <source id="source_ogg" type="audio/ogg" src="http://yoda.habblet.in:9999/;type=ogg">
    <source id="source_aacplus" src="http://yoda.habblet.in:9999/;type=aacplus">
    <source id="source_wav" type="audio/wav" src="http://yoda.habblet.in:9999/;type=wav">
    </audio>

    .Canabis
     .Canabis

    </button>

Comment: Na regra `.rounded-button:not(.white).plain` você define a cor de fundo `#333`. Os seus botões possuem a classe `.rounded-button`, não possuem a classe `.white` e possui a classe `.plain`, ou seja, satisfaz a regra, portanto devem ficar cinza.
Comment: Era isso mesmo, muito obrigado!
Comment: @AndersonCarlosWoss responde no lugar certo uai ;)
Answer: Para entender o que está acontecendo com o seu elemento você pode (e deve) utilizar as ferramentas que o navegador lhe oferece. Basta você clicar com o mouse com o botão direito sobre o elemento e ir em Inspecionar.

Na ferramenta será listados todos os estilos que estão sendo aplicados ao elemento e, principalmente, na ordem que estão sendo aplicados.

Perceba que o último estilo aplicado foi
.rounded-button:not(.white):not([disabled]):not(.no-hover):hover,
.rounded-button:not(.white).plain {
  background-color: #333;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .2);
}

Onde você explicitamente fez o fundo ser cinza (#333). Se os botões deveriam ser azuis, ou esta regra está errada, ou você precisa rever a ordem que está aplicando os estilos no elemento.
Answer: Isso ocorre porque você tem algum conflito de classes em um mesmo elemento, ou seja, alguma outra classe está aplicando a cor ao fundo depois, sobrescrevendo a cor azul que você deseja, como solução rápida, coloquei um '!important' nas cores da classe desejada. Lembrando que isso não é a maneira correta, o correto seria você procura a classe que está conflitando e verificar se realmente necessita fazer o uso de ambas, caso necessite utilizar as duas no mesmo elemento, por conta das propriedades empregadas em ambas, é aconselhável você dividir essas propriedades em mais classes, em ultimo caso, se isso não for possível, utilize o '!important' como eu fiz, que ele irá forçar o seu elemento utilizar a propriedade marcada da classe.

.client-buttons {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 100;
}

.client-buttons button {
  -webkit-box-shadow: 0 0 0 2px rgba(0, 0, 0, .2);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .2);
  display: block;
  float: left;
  padding: 7px;
  min-width: 34px;
  height: 34px;
  font-size: 12px;
  margin-right: 10px;
  line-height: normal;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .2);
}

button,
html input[type=button],
input[type=reset],
input[type=submit] {
  -webkit-appearance: button;
  cursor: pointer;
}

button {
  -webkit-appearance: button;
  -webkit-writing-mode: horizontal-tb !important;
  text-rendering: auto;
  color: buttontext;
  letter-spacing: normal;
  word-spacing: normal;
  text-transform: none;
  text-indent: 0px;
  text-shadow: none;
  display: inline-block;
  text-align: center;
  align-items: flex-start;
  cursor: default;
  background-color: buttonface;
  box-sizing: border-box;
  margin: 0em;
  font: 400 13.3333px Arial;
  padding: 1px 6px;
  border-width: 2px;
  border-style: outset;
  border-color: buttonface;
  border-image: initial;
}

.rounded-button {
  background-color: transparent;
  -webkit-border-radius: 48px;
  -moz-border-radius: 48px;
  border-radius: 48px;
  padding: 11px 24px;
  display: inline-block;
  text-decoration: none;
  font-family: montserrat, Arial, sans-serif;
  font-weight: 600;
  font-size: 14px;
  color: #333;
  text-transform: uppercase;
  border: 2px solid #333;
  cursor: pointer;
  height: 47px;
  line-height: 21px;
  text-shadow: none;
  text-align: center;
  -webkit-transition: background-color .2s, color .2s;
  transition: background-color .2s, color .2s;
}

.rounded-button.plain {
  -webkit-transition: opacity .2s;
  transition: opacity .2s
}

.rounded-button {
  opacity: .85
}

.rounded-button:hover {
  opacity: 1
}

.rounded-button.plain,
.rounded-button:not(.plain):hover {
  color: #2d74a6
}

.rounded-button.blue {
  color: #138cc8 !important;
  border-color: #138cc8 !important;
}

.rounded-button.blue:not([disabled]):not(.no-hover):hover,
.rounded-button.blue.plain {
  background-color: #138cc8 !important;
  color: #fff !important;
}

.rounded-button:not(.white):not([disabled]):not(.no-hover):hover,
.rounded-button:not(.white).plain {
  background-color: #333;
  color: #fff;
  text-shadow: 0 1px 0 rgba(0, 0, 0, .2);
}

.rounded-button.blue {
  color: #138cc8 !important;
  border-color: #138cc8 !important;
}

.client-buttons button .client-icon {
  -webkit-filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.3));
  filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.3));
  display: inline-block;
  font-style: normal;
  float: left
}

.client-buttons button .client-icon.client-close-icon {
  background-image: url(../images/favicon-white.png?3);
  background-size: 16px 16px;
  width: 16px;
  height: 16px
}

.client-buttons button .client-icon.client-fullscreen-icon,
#hotel-container .client-buttons button .client-icon.client-fullscreen-icon-back {
  background-image: url(../images/web/fullscreen-icon.png);
  background-position: 0 -14px;
  width: 14px;
  height: 14px;
  margin: 1px
}

.client-buttons button .client-icon.client-fullscreen-icon-back {
  background-position: 0 0
}

.client-buttons button .client-icon.hidden {
  display: none
}

.client-buttons button.client-close .client-close-expand {
  float: left;
  overflow: hidden;
  width: 0;
  text-align: left;
  -webkit-transition: width .15s ease-out 0s;
  transition: width .15s ease-out 0s
}

.client-buttons button.client-close .client-close-expand span {
  padding: 1px 0 0 8px;
  display: inline-block
}

.client-buttons button.client-close:hover .client-close-expand {
  width: 50px
}

.client-buttons button.client-players {
  cursor: default
}

.client-buttons button.client-players .client-icon.client-players-icon {
  background-image: url(../images/web/players-icon.png);
  background-size: 16px 16px;
  width: 16px;
  height: 16px
}

.client-buttons button.client-players .client-players-count {
  float: left;
  text-align: left;
  padding: 0 2px 0 6px;
  font-size: 14px;
  position: relative;
  top: -1px;
  display: inline-block
}

.client-frame {
  background-color: #000;
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  z-index: 0;
  display: block;
  border: 0
}

  <button class="client-close rounded-button blue plain">

    Início
    </button>
  <button class="client-fullscreen rounded-button blue plain">

    </button>
  <button class="client-count rounded-button blue plain">
     1,802 </button>
  <button class="client-radio rounded-button blue plain">
    <audio controls="controls" id="stream" autoplay="autoplay" preload="none" style="display:none" src="http://yoda.habblet.in:9999/;">

    <source id="source_mpeg" type="audio/mpeg" src="http://yoda.habblet.in:9999/;type=mp3">
    <source id="source_ogg" type="audio/ogg" src="http://yoda.habblet.in:9999/;type=ogg">
    <source id="source_aacplus" src="http://yoda.habblet.in:9999/;type=aacplus">
    <source id="source_wav" type="audio/wav" src="http://yoda.habblet.in:9999/;type=wav">
    </audio>

    .Canabis
     .Canabis

    </button>

Comment: Eu votei -1 porque não vejo justificativas para utilizar `!important` neste caso. É uma "solução rápida", mas em tempo de desenvolvimento eu vejo como mais recomendado resolver o problema do que apenas contorná-lo. Sinceramente, eu acho que o CSS seria muito melhor se o `!important` não existisse.
Comment: !important é jogar a sujeira para debaixo do tapete
Comment: Ok, obrigado pelo comentário. Atualizei o post.

Botões não mudam a cor


What test to compare community composition?

Question: Hope this newbie question is the right question for this site:
Suppose I would like to compare the composition of ecological communities at two sites A, B. I know all three sites have dogs, cats, cows, and birds, so I sample their abundances at each site (I don't really have an "expected" abundance for each animal at each site).
If I count, say, five of each animal at each site, then the A and B are very "similar" (in fact, they're the "same").
But if I find 100 dogs, 5 cats, 2 cows, and 3 birds at site A. 5 dogs, 3 cats, 75 cows, and 2 birds at site B. Then I would say that the sites A and B are "dissimilar", even though they have the exact same species composition.
(I read up on the Sorensen's and Bray-Curtis indices, but looks like they only consider absence/presence of the dogs, cats, etc., and not their abundances.)
Is there a statistical test to determine this?
Comment: Bray-Curtis dissimilarity may do the job... A great ressource is the book 'Numerical Ecology' by Legendre & Legendre (1998).
Comment: All the answers so far have been very useful, and I really appreciate all the reference material you provided. I wish I could mark more than one answer! Thanks for everyone's help.
Answer: I will concur with what has been mentioned that Bray-Curtis can handle abundance as well as presence/absence, also to add another good book to the mix: Analysis of Ecological Communities by McCune and Grace.
There are a lot of factors to consider as you compare ecological communities and I don't think there is a single test that will do the job.  The appropriateness of the test will depend a lot on the type of question you are asking about the communities and the nature of your dataset.  Common approaches include ordination techniques, which array sites within a multidimensional taxon-space.  However if you truly only have 2 sites then this is not likely to work.  Mantel tests correlate a the distance matrix based on composition (e.g., the pairwise Bray-Curtis distance across all sites) with a distance matrix based on other potential factors of influence.  The simplest case can be just the euclidean distance between the sites in space.  Cluster analysis groups sites with respect to their community composition.
In general I would take the approach of using a subset of the many statistical tools described in any of the above books to provide a statistical description of the differences between the communities in question.  There is no single measure of the difference in community composition so the stats are used to synthesize multidimensional data into a more easily interpretable form.
EDIT: I also just thought of this paper which lays out many of the different options pretty clearly and thoroughly.
Anderson, M. J. et al. 2011. Navigating the multiple meanings of Beta diversity: a roadmap for the practicing ecologist.  Ecology Letters 14:19-28
Answer: If you want to test this hyothesis, you can use an Analysis of Similarity (based on Bray Curtis or other available ones), there is a procedure named ANOSIM wich is implemented in PRIMER software. You can do One way, nested or Two-way analysis. Another (better) option is to run a multiple permutational analysis of variances, a nice procedure is avalaible in the routine PERMANOVA (available at http://www.stat.auckland.ac.nz/~mja/Programs.htm)
Once you have test for signficant differences among sites, you can follow up in order to know which species are responsable for the observed differences (IndVal routine, or SIMPER routine). hope it helps
Answer: Since you mention Sorensen index, it seems you need a dissimilarity score rather than a dissimilarity test. (A score will give a numerical value indicating how different they are. A test will tell you whether the difference is significant with a given probability.)
You can represent species abundance at each location by a histogram. This histogram can be normalized if you just care about relative abundance (e.g. that cats are twice as abundant as dogs), or unnormalized if you care about absolute numbers as well.
There are many ways to measure dissimilarity of histograms. Some of the popular ones are:

Chi-squared statistic
L2 distance
Histogram intersection distance
Answer: Bray-Curtis and other similar indices do incorporate differences in species abundance.  In addition to Legendre and Legendre, I would also recommend Charles Krebs' book, Ecological Methology (1999).


confidence interval with logistic regression

Question: I have data which consist of 0,1,-1 values somethink like this.
    x:{1,1,1,-1,-1,0,0,0,0,0,1,1,1,1,1,1,1,1 ......}
    y:{1,1,1,0,0,0,1,1 ......}

I need to confirm that data(x and y) match with formula.I mean those data generate a formula same as or almost same as the below formula.
How can I achive that.
Formula:
y = -0,398ln(x) + 1,2694

Comment: I don't understand your question. To start with, correlation is an relationship between two vectors or two variables, not between a vector and a function. Perhaps you're misusing the terms "correlation" and "confidence interval".
Comment: I am sorry ,seems u are right.wait..
Comment: I'm afraid I don't know what it means for a vector to have a relation with a formula with 90% confidence, either.
Comment: I'm guessing you want to assess the goodness of fit of your model. Where did it come from? If the outcome is 0/1, we usually use logistic regression. Your formula clearly isn't LR. It strikes me as almost certainly inappropriate, but I'm not sure how to check it since I don't know what it is or where it came from. Your x-variable has 3 peculiar levels, is it a continuous variable, an ordinal one, or a categorical variable?
Comment: @gung may be it is my stupidness as I am not statistician.I am getting data when drawing number on surface.at the beginning, data was the surface coordinate of the number(pixel based).Later I applyed filter that when x axis increase ,I represent the 1 ,no changes 0 and decrease -1.after that I implemet LR and get this formula :).thinking each number should have and equation representation.if u have any good idea,let me know.
Answer: A simple way to quantify how well the formula describes the data is with root mean squared error (RMSE). For each $i$, compute $(-0.398 \ln x_i + 1.2694 - y_i)^2$, then take the square root of the mean of these all these squares. The smaller the RMSE, the better the formula describes the data.


Forecasting with arimax model including xtransf

Question: I am trying to forecast with an arimax model including the xtransf argument. I used the example given in chapter 11 of the book Time Series Analysis With Applications in R, Jonathan D. Cryer & Kung-Sik Chan, 2nd ed.
So this is basically an intervention Model. I just did not include the xreg argument, so the Additive outliers are not included for the moment. Here are the codes and the Error I got.
>library(TSA)
>data(airmiles)
 >air.m1=arimax(log(airmiles),order=c(0,1,1),seasonal=list(order=c(0,1,1),period=12),xtransf=data.frame(I911=1*(seq(airmiles)==69),
I911=1*(seq(airmiles)==69)),transfer=list(c(0,0),c(1,0)),method="ML")
> air.m1

Call:
arimax(x = log(airmiles), order = c(0, 1, 1), seasonal = list(order = c(0, 1,
    1), period = 12), method = "ML", xtransf = data.frame(I911 = 1 * (seq(airmiles) ==
    69), I911 = 1 * (seq(airmiles) == 69)), transfer = list(c(0, 0), c(1, 0)))

Coefficients:
          ma1     sma1  I911-MA0  I911.1-AR1  I911.1-MA0
      -0.5379  -0.7644   -0.1290      0.8901     -0.2419
s.e.   0.0854   0.1532    0.0606      0.1239      0.0513

sigma^2 estimated as 0.0009739:  log likelihood = 199.42,  aic = -388.84

>predict(air.m1,n.ahead=20)
Error in dim(data) <- dim : attempt to set an attribute on NULL

Any idea where my mistake is?
Answer: The TSA package provides no predict method for arimax models. Strange but true.
Comment: I will send this to the author of TSA package. BTW, your "forecast" package is really helpful. Thanks.


Does $\lim_{n\to\infty}\frac{1}{n}\sum_{j=1}^{\lceil n/2\rceil}\frac{1}{j}$ exist?

Question: Does $$\lim_{n\to\infty}\frac{1}{n}\sum_{j=1}^{\lceil n/2\rceil}\frac{1}{j}$$ exist?
To show this, consider $$0\leq \lim_{n\to\infty}\frac{1}{n}\sum_{j=1}^{\lceil n/2\rceil}\frac{1}{j}\leq \lim_{n\to\infty}\frac{1}{n}\sum_{j=1}^{n}\frac{1}{j}.$$ Does $$\lim_{n\to\infty}\frac{1}{n}\sum_{j=1}^{n}\frac{1}{j}$$ equal to 0?
Comment: As another approach, notice $\lim_{n \to \infty} \frac{1}{n} \sum_{j = 1}^n \frac{1}{j}$ is a [Cesàro Mean](https://en.wikipedia.org/wiki/Ces%C3%A0ro_summation) and thus converges to the same thing as $\lim_{n \to \infty} \frac{1}{n}$ (which is, of course, $0$).
Comment: Hint: $$
\sum\limits_{j = 1}^n {\frac{1}{j}}  < 1 + \sum\limits_{j = 2}^n {\int_{j - 1}^j {\frac{{dx}}{x}} }  = 1 + \int_1^n {\frac{{dx}}{x}}  = \log n + 1.
$$ In fact, much more is know: $$
\sum\limits_{j = 1}^n {\frac{1}{j}}  \sim \log n + \gamma  + \frac{1}{{2n}} - \frac{1}{{12n^2 }} +  \cdots
$$ for large $n$, where $\gamma=0.5772\ldots$ is the Euler$-$Mascheroni constant. Look up https://en.wikipedia.org/wiki/Harmonic_number for other interesting stuff.
Answer: Cesàro Mean. If $a_n\to a$, then $\frac{1}{n}(a_1+\cdots+a_n)\to a$.
So $\frac{1}{n}\to 0$ and hence $\frac{1}{n}\sum_{j=1}^n\frac{1}{j}\to 0$.  Since
$$
0<\frac{1}{n}\sum_{j=1}^{[n/2]}\frac{1}{j}<\frac{1}{n}\sum_{j=1}^n\frac{1}{j}
$$
then
$$
\frac{1}{n}\sum_{j=1}^{[n/2]}\frac{1}{j}\to 0,
$$
as well.
Answer: Hint:
$$1+\frac12+\frac13+\frac14+\frac15+\frac16+\frac17+\cdots<1+\frac12+\frac12+\frac14+\frac14+\frac14+\frac14+\cdots$$
shows that the sum of the $2^m-1$ first terms is bounded by $m$.
With $n=2^m-1$, you can conclude.
Comment: I think I misunderstood your answer
Comment: this assumes the sequence is convergent
Comment: @AdityaDwivedi: no, the property is true for the $2^m-1$ first terms. That's enough.


How to add a confirmation form upon submission of user profile form

Question: I have previously added a confirmation dialog to my own forms using a technique like http://blog.purdy.info/2014/04/how-to-work-with-confirmform-in-drupal-7.html.  However this assumes that you have control of the form builder and submit functions.  I now want to add a confirmation to the user profile form which is of course defined in the user module.
Any suggestions ?
Thx
Answer: You can add your own submit handler in front the of the predefined submit handler using hook_form_alter().
The #submit property is an array of submit handlers and it allows multiple values. Use array_unshift() to put your handler in front of the predefined handler.
Your code will look something like this:
/**
 * Implements hook_form_alter().
 */
function mymodule_form_alter(&$form, &$form_state, $form_id){
  if ($form_id = 'target_form') { // make sure it's the right form
    // add my handler
    array_unshift($form['#submit'], 'my_submit');
  }
}

function my_submit( $form, &$form_state ) {
}

When the form is submitted, it will run my_submit() before the predefined submit handler.
Comment: The strategy for delivering the confirmation form requires modifying both the submit handler ( as you have suggested ) AND the function defining the form itself so that it returns a different form if a flag is set.  So unfortunately your answer is not a complete solution.


Joi conditional based on value of it's key (self-reference)

Question: I have an existing schema like this
exports.updateSchema = Joi.object({
  class_id: Joi.string().guid({ version: 'uuidv4' }).required(),
});

Existing only allow uid value, but now I also wanna allow specific string like general.
So I need a schema that has conditional based on it's value, if try many ways using ref like this
exports.updateSchema = Joi.object({
  class_id: Joi.string().when(
    Joi.ref('.class_id'), {
      not: Joi.string().guid({ version: 'uuidv4' }),
      then: Joi.string().valid('general').required(),
      otherwise: Joi.string().guid({ version: 'uuidv4' }).required(),
    },
  ),
});

but no one works well.
And also tried this one
exports.updateGradeParamsSchema = Joi.object({
  class_id: Joi.string(),
}).when(Joi.object({ class_id: 'general' }).unknown(), {
  then: Joi.object({
    class_id: Joi.string().valid('general').required()
  }),
  otherwise: Joi.object({
    class_id: Joi.string().guid({ version: 'uuidv4' }).required()
  }),

but the error message is confusing, when I input 'john-doe', it's return

""class_id" must be a valid GUID"

instead of "class_id\" must be [general]
Is anyone ever do self-reference in Joi or is there another solutions for this?

UPDATE

Best approach
exports.updateSchema = Joi.object({
    class_id: Joi.alternatives().conditional('class_id', {
      not: Joi.string().guid({ version: 'uuidv4' }),
      then: Joi.string().valid('general').required(),
      otherwise: Joi.string().guid({ version: 'uuidv4' }).required()
    })
});

based on docs here it said this will use the first matching schema, ignoring other conditional statements
cons:

If I input uuid v1, it will match the first schema because the uuid is treat as string, and return \"class_id\" must be [general] instead of \"class_id\" must be a valid GUID
Answer: Try this:
exports.updateSchema = Joi.object({
  grade_id: Joi.alternatives().try(
    Joi.string().guid({ version: 'uuidv4' }),
    Joi.string().valid('general')
  ).required()
});

This uses the alternatives method to try both guid validation for UUIDs and valid validation for the string "general". The required method is used to ensure that grade_id is present in the data.
I hope this helps!
If you want to return custom message:
exports.updateSchema = Joi.object({
  grade_id: Joi.string().when(
    Joi.ref('.grade_id'), {
      not: Joi.string().guid({ version: 'uuidv4' }),
      then: Joi.string().valid('general').required()
        .message('Grade ID must be a UUID or the string "general"'),
      otherwise: Joi.string().guid({ version: 'uuidv4' }).required()
        .message('Grade ID must be a UUID'),
    },
  ),
});

Comment: This one works exactly like my second sample, yours more simple and easier to understand. But the issue is the error message, is it possible to custom message if I use yours?
Comment: I've tried the custom message, but it can't run and return error `Cannot apply rules to empty ruleset or the last rule added does not support rule properties`. I've tried to use `messages({})` instead. But the problem is that the validation not working as I expect. Consider I remove the custom message, if I input `john-doe`, it will return `\"class_id\" must be a valid GUID` which I think ther right one should be `"class_id\" must be [general]`
Comment: I've update the post, added the best approach I can do for now. May be there's another suggestion from you


For what values of $k$ is the following matrix diagonalizable?

Question: The matrix is:
$$\begin{bmatrix}k&1\\0&k^2\end{bmatrix}$$

I am aware that a square matrix is diagonalizable if there exists a matrix $P$ such that $D = P^{-1 }* A * P$ is a diagonal matrix.
Comment: matrices with distinct eigenvalues are diagonalisable.
Comment: It's $P^{-1}$, not $P^2$.
Comment: Do you have a textbook or lecture notes to consult ? If so, do they give any other necessary or sufficient conditions for diagonalizability ?
Comment: **Hint:** There are exactly two values $k$ for which this matrix is not diagonalizable.
Comment: @Mindlack I am so sorry about that, it was unintentional.
Comment: @Simon this is the information available to me.
Comment: Do you know anything about the Jordan form of a matrix?
Comment: @RobertoFaedda Sorry, I don't.
Comment: @hardmath I couldn't figure it out even with taking this information into consideration.
Answer: You can see that the set of the eigenvalues of the matrix is $\{k,k^2\}$.
If $k=k^2$ (that is, if $k=1$ or $k=0$) then our matrix coincides with his Jordan form. Since a matrix is diagonalizable if and only if his Jordan form is diagonal, you can conclude that our matrix is not diagonalizable.
If $k \neq k^2$, on the other hand, the matrix has distinct eigenvalues and as such is diagonalizable.
Edit: This problem is gonna be very difficult if you approach it using only the definition. You need to know a bit about eigenvalues and eigenspaces to solve it quite easily. It's a bit of theory  that isn't very hard but can't be all put in the space of an answer. You can find it in any book on basic linear algebra, though (disregard the observation on the Jordan form, you don't need it to solve this).
Sorry, I'm not able to give you a simpler answer that's not very long. Hope someone else can help you in a better way. In the meantime, notice that there are real values of $k$ such that the matrix (which I'll call $A$) is diagonalizable.
Take $k=2$ and:
$$P =\begin{pmatrix}
1 & 1\\
0 & 2
\end{pmatrix}
$$
I'll leave it to you to check that:
$$\begin{pmatrix}
2 & 0 \\
0 & 4
\end{pmatrix} = P^{-1}AP $$
Comment: @hardmath I edited the answer. I couldn't answer shortly using only his knowledge, but I tried to point to him where to indipendently find the solution.
Comment: Thanks for the edits.  It should be more accessible now for the OP and similar (no pun intended) future Readers.


Do the notes of a chord form parallel octaves, even when they are not played simultaneously?

Question: Here is an example of what I'm trying to say
The sample below is in Bb major.

Do the notes of the bass and the alto form parallel octaves?

On the alto voice I'm using delayed resolution.
On the bass voice, C is a passing tone.

So, the D of the bass and the D of the alto aren't being played at the same time, but I'm not sure if I can avoid the parallel octaves like this. Is this an error or not?
 I know that the C of the bass and the D of the alto are dissonant, but let's avoid that mistake for the sake of the question
Comment: These aren't parallel octaves, because your voices don't make **simultaneous** steps separated by an octave (the bass moves to e flat before the alto does). There are, however, parallel *ninths*.
Comment: Why is your vi chord in second inversion? Second inversion chords are used only for very special chord progressions. Why are you using one here?
Comment: And just btw your notation is incorrect the Sub Mediant chord in Bb Minor is not a Major chord as you indicate. (G-Bb-D = minor chord)
Answer: There are some aspects of your example that go a little beyond the norms of 18th-century common practice such as the 9th chord and the move to a second inversion vi chord, but that's more complicated to assess than merely "mistake" or "not mistake." The passing tone in the bass at the same time as the 9–8 resolution in the alto (turning it into a highly unlikely 9–9 move) is also unusually harsh for common practice. The doubling of the chordal seventh on beat two is fairly unambiguously an error in this style.
However, ignoring those issues, using a suspension to offset what would otherwise be parallel 8ves is generally ok in the style. It's more common (and arguably more effective) to offset parallel fifths in this manner, using 6–5 resolutions, because the baldness of 9–8 resolutions doesn't mask the underlying motion as well. In this case though, the doubled chordal seventh tendency tone highlights the similarity of function, and a move like this would probably be avoided by most composers of the era.
Answer: Not parallel octaves, but just by the skin of its teeth.
The second inversion of vi isn't that at all: it's I6 under a suspended 7th and 9th, which both resolve normally, but D in the bass has already moved on to a passing note C. Nonharmonic tones coinciding with a resolution are not that uncommon, but, as has been noted, the similar motion produces parallel ninths. Parallel ninths are, as Pat Muchmore noted, unusual and a bit rough in common practice harmony. The similar motion between the outer voices here, with E♭-D in both the alto and bass, is making life very difficult for you.
So I'll read between the lines, and answer the question you are really asking: how to handle a double suspension in parallel thirds.
Chains of parallel thirds used in suspension are tricky. Normally, at least one voice needs to be in contrary motion, and you need to ensure that, when you arrive at fifths and octaves by similar motion, they are direct, rather than parallel, fifths and octaves, with preferably at least one voice in the alto or tenor (i.e., avoiding direct octaves and fifths between the outer voices). You will find that you occasionally need to use leaps in one or more of the remaining voices. For example:

There is an instance of direct octaves here, A/F going to B♭/B♭ in the tenor and bass voices in m.2, and a hidden instance of the same direct octave (A/F -> B♭/B♭) at the end of m.3 / start of m.4. There is a strongly implied chain of fifths between the alto and tenor in the first 3 measures (F/B♭ -> E♭/A -> D/G). It is, however, not the least bit dodgy because of the diminished fifth separating the two perfect fifths (and the fact that the fifths are in the alto and tenor). There is a direct fifth between alto and bass in m.3 (D/C -> C/F).
The tenor B♭ in m.1 (marked "+") is an anticipation. I could have used a passing C instead, or just held the D for a full minim, but the suggestion of the tonic major 7th in first inversion seemed tastier. I've marked out all the suspensions and resolutions using figured bass notation. The start of m.3 can be taken as a kind of gapped eleventh of C minor, but I prefer to look at it as the simultaneous application of two very common suspensions.
Note that, as I suggested above, the direct fifths and octaves all involve at least one inner voice. Note also that a) the outer voices are essentially forming a wedge, and b) the F in the bass at the start of m.2 is being treated as a chord tone (which, as the root of the chord, it is). That is where your example started to come a cropper: you were treating the root of the ninth as if it needed to resolve by step downwards. Note that, except for giving myself more room to move by dropping the bass an octave, I'm using the same suspension and voice order as you.
When you are dealing with tricky dissonance handling, simplify your voice leading to the essentials (just the suspensions with the underlying root movements), look for the spots where you will need to place the octaves and/or fifths, work out how you can get to them with contrary or direct movement, and then start elaborating the voices when you have something that makes sense.
Answer: You do not directly form chords with the voice notes, but melodies/voices that live in the "scope" of a chord. Think when you find chords for the main melody, you don't create a new chord for each changing note in the melody, but you find a chord that fits the dominant part of the melody sequence. A voice melody often starts on a note in the chord, and has a movement that leads into and resolves/lands on a note in the next chord.
This is not absolute rules, and the most important is that it sounds good. If you create something that lives on the edge or even breaks standard "rules", it can end up sounding interesting and thus you have created something unique that makes your music stand out.
This is a difficult thing to balance, because it can tip over from sounding interresting to sounding like it was a mistake.
Notes in a chord can be played in a sequence that is not simultanously, but are components in the same chord. Think of playing guitar by finger plucking where each string is plucked after the other, but all is part of the same chord.
Whether a sequence of notes are considered to be in the same chord or not, is somethimes  difficult to know, but again - it is important to hear how it sounds like, and let that define the chord.
Comment: This is nice insight in the scope of harmony, but I'm not sure if this is a yes or a no on the 'parallel octaves'


What is the best size for video which can fit for all mobile screens?

Question: What would be the best size or scale of height and width for video which can fit for all mobile screens properly.
Answer: For mobile the best size is for all smartphones is 1080X1090 pixels.For 1080X1090 pixels in height and width is 3.6 X 3.63 Inches OR 91.44 X 92.29 Millimeters this is for 300 resolution


Correcting experiment results

Question: We have performed a microarray screening of about 200 samples. In each sample we measure about 100 different variables. For technical reasons the screening of these 200 samples was divided into two batches with a couple of weeks interval between them. When all the data has been collected, I have performed principle component analysis (PCA) on the 200 x 100 table.
When we look on linear projection of first 4 components (responsible for ~70% of the variability), we see a clear division between the two experiment batches. An illustration to what I have can be seen here: http://img594.imageshack.us/img594/3687/pca.png
What are the accepted techniques to address this issue?
Answer: How did you normalise your microarray data? Standard ways are:

Robust Multichip Average (RMA)
Genechip RMA - this can be a bit slow for lots of samples.

This presentation gives a good overview of the two techniques.

There are two R microarray tutorial papers which may also help:

A microarray analysis for differential gene expression in the soybean genome using Bioconductor and R (link to paper)
Analysing yeast time course microarray data using Bioconductor (link to paper).

Both these papers provide the data and R commands.
Competing interest: I'm a author on the second paper.
Answer: I would think that the first step would be to examine the component loadings and the actual variables to see if you can identify why the two batches yielded discernible differences. Depending on the reasons for the differences you may or may not be able to use a statistical control to "correct" the results.
However, if you have every reason to believe samples were randomly assigned to batches, that the your testing methods have not reached floors or ceilings in their ability to assess the variables of interest, and the actual scores themselves are not of interest but only their relative position, perhaps you could standardize scores along each variable by batch.
Edit:  It looks like csgillespie understands your research area and has provided you some good links.  All I was suggesting was that for each batch you could calculate a Z score for each observed variable.  This would have the effect of eliminating batch differences since for each variable in each batch the mean would be the same (0) and the standard deviation would be the same (1).
Comment: Would you please give a link or two to explanation of data standardization?
Answer: Using PCA only to analyze your gene expression data can lead to (possibly) wrong conclusions. The fundamental assumption behind PCA is equal genewise variation and this may NOT be justified almost always. The links to the paper to analyze time course data by csgillespie point to better ways.

Correcting experiment results