Finger independence exercises - quality or quantity?

Question: I have some exercises for finger independence (for left hand); however, I cannot even start to do some of them correctly.
The most difficult exercise is:

Start with a hand and all fingers in a straight line; then, flex the
fingers repeatedly, each time only one finger, so that the others
don't move.
After flexing each finger, straighten it back before flexing the next one.

I cannot flex the 2nd and 4th finger correctly - other fingers move significantly when I try to do it.
So, my question is: should I try to do this exercise anyway, or should I leave it for now, and try it in future, when I master other (presumably easier) ones?
Answer: My answer is coming from a pianist, not a guitarist. Take my advice with a grain of salt, as our needs regarding our hand strength and flexibility are vastly different.
My recollection of hand physiology is kind of hazy, but there are tendons linking your fingers together; this is why it's necessary to practice independent finger motion. For piano, a number of teachers would suggest stretching fingers backwards one at a time to loosen up that bond, especially between the ring and middle fingers. Other students have described other exercises to me, but I've never heard of the one you describe. In any case, I was advised by my piano teacher to not worry about those exercises, and I've found that my independence of motion is fine for my purposes.
So my advice to you is that unless you're having a specific issue with hand flexibility, don't stress over the stretches. I suspect that you'll develop your flexibility by simply playing the instrument.
Answer: Starting with the low E string play first fret first finger, then second fret second finger, third fret third finger, fourth fret fourth finger then proceed to the next string. You will be ascending in notes. Then try descending starting with the pinky. You may try combinations like first, third, second, fourth finger in that order on the string. Steve Vai used this technique and it work well for me too.
Your fingers will eventually become independent. It is a process that will take time and practice. But don't get discouraged.
Comment: I agree this is a very good exercise, but I was talking about the "dry" ones that you can do without a guitar
Answer: I'm not really a fan of "lifting" fingers independently. Its not really a natural motion nor is it really useful when playing guitar. You're better off doing chromatic 4 note per string scales on the guitar, playing in position and moving vertically up/down strings. Doing this slowly and accurately to a metronome, and slowly increasing in tempo.
Steve Vai has published a similar type "workout" which involves changing the starting finger for each string. I personally found that quite useful. Also watch to ensure that your fretting pressure doesnt come from a "pinch" motion in your hand, but instead pull backwards against the neck using your forearm, your thumb acting only as a pivot and not applying pressure. This will help the tendons in your arm to carry less tension, making it easier to get separation of motion.


Only one of my site node's doesn't print it's alias

Question: I use the latest version of the famous Pathauto module and my site pages have Automatic alias that are shown well in the URL navigation bar of the browser... All of these pages are in Hebrew, But one of the pages which is in English, doesn't show it's alias and only node/20 is being printed...
For example you could go on all main-menu links and see it, instead of that one...
Here is a live example in my site.
What can cause it? Thanks!
Comment: What is the url alias pattern? (admin/config/search/path/patterns)
Answer: assuming you are using Pathauto to accomplish this, try:

check the settings under /admin/config/search/path/settings and make sure the Update action is set to Create a new alias, Delete the old alias
edit the node, and make sure the 'generate automatic URL alias' is checked and save the node again - this should reset the alias for the node
Comment: I assume the english page is of the same content type as the others? is it only one page in english - if so, you could manually create an alias and change the menu entry so at least from a UI standpoint it worked, but if it's a gateway to other pages that don't alias properly that's not useful. I'm not sure what else to suggest, sorry
Comment: You are assuming right Geoff (edited the question) and indeed "Create a new..." is what check-marked in /admin/config/search/path/settings, and indeed, "Generate automatic..." is also check-marked in the node.
Comment: ok - check admin/config/search/path to see if that node already has an alias assigned to it - it could be that it's not checking and deleting an old alias and won't create the new one - I have had this happen a couple of times. If an alias already exists, delete it, and then resave the node
Comment: also, try running the bulk update for content
Comment: Actually there was an alias at the Aliases' list\log. Deleted it and resaved the node - didn't help. Afterwards I've tried to update the alias balk - also didn't help... Flush all caches after all of this was done btw, but I'm guessing it's yet another annoying RTLization problem...
Comment: please either accept this answer or create a new answer with that information and accept that so the question does not remain listed as unanswered
Comment: I'm sorry, I was wrong, using the alias itself in the menu-link item didn't help because this alias seems to not to be created (it appears in the aliases list\bulk but seem not the be recognized as an address in the site).
Comment: it sounds like a problem with the language. I did a search for 'Drupal 7 alias not working' and got a few pages with a lot of info on issues related to multi-language sites. I would look into that next
Answer: See comments - I don't know what was the problem but re-creating the page (took about 40 seconds) fixed the problem.
Comment: that is really weird behaviour, but glad you finally got it to work


RVO is expected, but not happening

Question: I have the following rudimentary implementation of a connection pool. At a very high level, it provides a safe way for a client to get an open connection from a pool, or open a new one if all the connections are currently in use. The Connection struct is the low level implementation of a connection. The ClientConnection struct is a wrapper around the Connection so that the client has only limited access to the Connection object as well as providing a safe way for the Connection object to be returned to the pool using RAII. When calling Pool::getNewConnection(), I expect NRVO to occur, but it does not and I cannot for the life of me figure out why. I expect only a single call to the destructor, since I create the ClientConnection in main() and then it gets destroyed. However, what happens is an instance is created in Pool::getNewConnection(), then moved into the object's memory in main(), thus 2 destructors are called.
Built using g++ -std=c++17 -O0 -g -o main main2.cpp and g++ -std=c++17 -O3 -g -o main main2.cpp
Output is:
$ ./main
Opening connection
Pool::getNewConnection() -- Address of newClientConnection: 0x7ffe3d29c290
ClientConnection(ClientConnection&&) -- old: 0x7ffe3d29c290 new: 0x7ffe3d29c320
ClientConnection::~ClientConnection() -- Returning this connection back to pool: 0x7ffe3d29c290
Pool::returnConnection() -- Returned connection: 0x7ffe3d29c290
Writing
ClientConnection::~ClientConnection() -- Returning this connection back to pool: 0x7ffe3d29c320
Pool::returnConnection() -- Returned connection: 0x7ffe3d29c320

#include <iostream>
#include <memory>
#include <vector>

struct Connection {
  bool open(std::string /* ip */, std::uint16_t /* port */) {
    std::cout << "Opening connection\n";
    return true;
  }
  bool close() {
    std::cout << "Closing connection\n";
    return true;
  }
  bool write(const char*) { return true; }
  bool read(const char*) { return true; }
};

struct ClientConnection;

struct Pool {
  ClientConnection getNewConnection();
  void returnConnection(ClientConnection& clientConnection);

private:
  friend class ClientConnection;

  std::vector<std::unique_ptr<Connection>> m_connections;
};

struct ClientConnection {
  ClientConnection()                        = delete;
  ClientConnection(const ClientConnection&) = delete;
  ClientConnection(ClientConnection&& rhs) noexcept : m_pool(rhs.m_pool), m_connection(std::move(rhs.m_connection)) {
    std::cout << "ClientConnection(ClientConnection&&) -- old: " << std::addressof(rhs) << " new: " << this
              << std::endl;
  }

  ClientConnection& operator=(const ClientConnection&) = delete;
  ClientConnection& operator=(ClientConnection&&) = delete;
  ~ClientConnection() noexcept {
    std::cout << "ClientConnection::~ClientConnection() -- Returning this connection back to pool: " << this
              << std::endl;
    m_pool.returnConnection(*this);
  }

  bool write(const char*) {
    std::cout << "Writing\n";
    if (!m_connection->write(nullptr)) {
      m_connectionValid = false;
    }
    return m_connectionValid;
  }

  bool read(const char*) {
    if (!m_connection->read(nullptr)) {
      m_connectionValid = false;
    }
    return m_connectionValid;
  }

private:
  friend class Pool;

  ClientConnection(Pool& pool, std::unique_ptr<Connection> connection)
      : m_pool(pool), m_connection(std::move(connection)) {}

private:
  bool m_connectionValid = true;
  Pool& m_pool;
  std::unique_ptr<Connection> m_connection;
};

ClientConnection Pool::getNewConnection() {
  if (m_connections.empty()) {
    auto conn = std::make_unique<Connection>();
    conn->open("", 0);
    auto newClientConnection = ClientConnection(*this, std::move(conn));
    std::cout << "Pool::getNewConnection() -- Address of newClientConnection: " << std::addressof(newClientConnection)
              << std::endl;
    return newClientConnection;
  } else {
    auto newClientConnection = ClientConnection(*this, std::move(m_connections.back()));
    m_connections.erase(std::prev(m_connections.end(), 1));
    return newClientConnection;
  }
}

void Pool::returnConnection(ClientConnection& clientConnection) {
  if (clientConnection.m_connectionValid) {
    m_connections.push_back(std::move(clientConnection.m_connection));
    std::cout << "Pool::returnConnection() -- Returned connection: " << std::addressof(clientConnection) << std::endl;
  } else {
    clientConnection.m_connection->close();
  }
}

int main() {
  Pool p;
  auto conn = p.getNewConnection();
  conn.write(nullptr);
  return 0;
}

Comment: NRVO is not guaranty, `return {*this, std::move(conn)}` should allow copy elision.
Comment: I expect that to be because there are two potential return paths from `Pool::getNewConnection()` - the compiler isn't able to optimize this. If you were to consolidate it in to a single return statement then you would get RVO
Comment: @user283471 I'd agree with you if the compiler didn't know which object to place in the caller's stack frame, but object creation happens after the branch. See: https://shaharmike.com/cpp/rvo/#when-rvo-doesn-t-can-t-happen
Comment: @Jarod42 You're right, that does elide the move.
Comment: `-O0` Why are you expecting optimisation, when you've disabled optimisation?
Comment: @eerorika Tried with `-O0` thru `-O3`
Answer: NRVO is not guaranteed. Compiler might miss the opportunity to use it.
Alternative to ensure copy-elision is to use alternative form which are guaranteed.
Something like the following:
ClientConnection Pool::getNewConnection()
{
    if (m_connections.empty()) {
        auto conn = std::make_unique<Connection>();
        conn->open("", 0);
        // Skip (problematic) debug display which introduces name for ClientConnection
        return {*this, std::move(conn)};
    } else {
        struct OnScopeEnd // You might have equivalent util class
        {
            std::vector<std::unique_ptr<Connection>>& m_connections;
            ~OnScopeEnd() { m_connections.pop_back(); }
        } onScopeEnd{m_connections};
        return {*this, std::move(m_connections.back())};
    }
}

RVO is expected, but not happening


Less-rails and twitter-bootswatch-rails @imported styles not causing a LESS/CSS recompile

Question: I'm using less-rails and twitter-bootswatch-rails gems with a brand new Rails 4 app.
This sets up an app/assets/stylesheets/cosmo/loader.css.less which contains @import to all of the bootstrap less files.
application.css contains a  *= require cosmo/loader, which correctly loads all the styles.
However, when I save one of the files that are @imported the CSS changes are not reflected when I refresh the page; I have to edit and save loader.css.less for the changes to come through.
What am I doing wrong?
Comment: I've had the same problem with `lessphp` so my guess is the gem/compiler only watch for modifications of the main LESS file (has the timestamp changed?) and won't care about imported files by this LESS file. One solution would be to `touch` this LESS file before calling the LESS compiler, forcing a recompilation each and every time the compiler get called (each refresh I guess?). Hope sb else has a better solution ;)
Comment: This doesn't make sense, since the `less-rails` gem readme.md states Any @import to a .less file will automatically declare that file as a sprockets dependency to the file importing it. This means that you can edit imported framework files and see changes reflected in the parent during development. : https://github.com/metaskills/less-rails/#import-hooks
Answer: Should be resolved in the latest https://github.com/scottvrosenthal/twitter-bootswatch-rails gem release.


How to use FFMPEG with java?

Question: I'm using the following command to convert sequence of images to a video.
ffmpeg -r 1 -i sample%d.png -s 320x240 -aspect 4:3 output.flv

This works fine for me!
Now i'm trying to use the above command to run through java code.
How can i run the ffmpeg command using Runtime.getRuntime() from my java code.
Please share your thoughts..
Answer: Runtime.getRuntime().exec("ffmpeg -r 1 -i sample%d.png -s 320x240 -aspect 4:3 output.flv");

How to use FFMPEG with java?


yarn deploy sets gh-pages to static create-react-app page instead of what is on my branch

Question: I have deployed my app at https://hudsonbasso.com/ and it is just showing the readme instead of what is showing on my branch when run locally. I suspect is something with the build folder or gh-pages not recognizing my index.js in the src folder. Link to repo https://github.com/hbasso/wherecaniwatch
enter image description here
Comment: Change the subdirectory in your repo settings [in the same place as in this answer](https://stackoverflow.com/questions/74580095/gh-pages-page-is-showing-blank-page) and add a [nojekyll file](https://github.blog/2009-12-29-bypassing-jekyll-on-github-pages/).
Comment: So the new root of the gh-pages branch should be the build directory? Or I am just one directory to high in my repo? So I think what I currently have is this @ZacAnger

```
wherecaniwatch
  - build
  -public
  -src
package.json
index.js
yarn.lock
```
Comment: I think I'll try deleting my github pages branch and trying this https://jiafulow.github.io/blog/2020/07/09/create-gh-pages-branch-in-existing-repo/
Answer: I ended up solving this by adding a .nojekyll file and following some of the instructions here https://jiafulow.github.io/blog/2020/07/09/create-gh-pages-branch-in-existing-repo/ to create an empty branch called 'gh-pages' and then my yarn deploy worked!


gcloud sql databases list operation consistently fails for certain cloud SQL instances

Question: I running the following gcloud command, where myinstance1 is a MySQL instance.
gcloud sql databases list --instance=myinstance1 --format="value(name)"

However I consistently get one of the following two  errors , is this an issue with gcloud (as this is still in beta) or with the MySQL instances ?
ERROR: (gcloud.sql.databases.list) HTTPError 503: Service temporarily unavailable. This is most likely a transient error. Please retry.

ERROR: (gcloud.sql.databases.list) HTTPError 400: This operation isn"t valid for this instance.

Answer: I found out that these instances that were failing for the API call were in a stopped state.


JSON returning null values using WCF Services

Question: Hi all I am new in JSON and WCF Services. I am trying to call wcf service using JSON and my paramater is one of my data contract class.
Here is my Data Contract Class.
namespace Employee.Services.DataContracts
{
    using System;
    using System.Runtime.Serialization;

    [DataContract]
    public class ReqDataContract
    {
[DataMember]
        public long Type { get; set; }
[DataMember]
        public string ID { get; set; }
[DataMember]
        public DateTime? FDate { get; set; }
[DataMember]
public long? UserID { get; set; }
 }
}

Here is myWCF Service function
public void SaveRequ(ReqDataContract request)
        {
            var req=request;
        }

Here is Interface Implementation
[OperationContract]
        [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.Wrapped, ResponseFormat = WebMessageFormat.Json)]
        [return: MessageParameter(Name = "ReqData")]
void SaveRequ(ReqDataContract request);

.js File (AJAX Call)
var selection = "{ \"Type\": 55,\"ID\":'email@example.com' ,\"FDate\":" + null + " ,\"UserID\": 'ASDAS'}";
searchData = searchData + (searchData != '' ? "," : "") + selection;
    if (searchData != null) {
        searchData = "[" + searchData + "]";
    }
var searchJSON = jQuery.toJSON(eval("(" + searchData + ")"));
    var strJSON = searchJSON.toString();

    params = '{\"request\":' + strJSON + '}';
    $.ajax({
        async: false, //To perform synchronize operation to get status
        type: "POST",
        url: servicePath + "SaveRequ",
        dataType: "json",
        contentType: "application/json; charset=utf-8",
        data: params,
        processData: true,
        success: function (data) {
          //  alert(data.ReqData);
        },
        error: function (xhr, result, id) { alert(xhr.responseText); }
    });

Everything works fine but the problem is i ma getting all the value null in request parameter....Am i missing something?? Please help me in this.
Comment: Check this http://stackoverflow.com/questions/10110805/jquery-post-json-object-to-a-server to pass an object to server in Json format.
Answer: Did this get resolved?  If not, for fdate try a valid value instead of NULL and see if that works.  JSON.NET might be a better solution for processing null from JSON into objects.


Pointwise limit of a sequence of functions defined recursively as integrals.

Question:
Problem: Let $g$ be a continuous function from $[0,\dfrac{1}{2}]$ to $\mathbb{R}$. Consider the sequence of functions $\{g_n\}$ defined on $[0,\dfrac{1}{2}]$ to $\mathbb{R}$ with $g_1=g$ and $$g_{n+1}(t)=\int_{0}^{t} g_n(s)ds$$ for all $t\in [0,\dfrac{1}{2}]$. Show that $ \lim_{n \to \infty} n!g_{n}(t) =0$. for all  $t \in [0,\dfrac{1}{2}]$.

I tried some examples of such functions but I don't know how to prove it in general. Any hint please regarding how to start a proof? Thank you.
Comment: See https://math.stackexchange.com/a/109564/42969.
Answer: The function $g$ is bounded, say $|g(t)|\leq M$ for all $t\in [0,1/2]$. This means that
$$
|g_{2}(t)|= \left|\int_0^t g_1(s)\,ds\right|\leq \int_0^t|g_1(s)|ds\leq \int_0^t M\,ds= tM
$$
This gives us:
$$
|g_3(t)| = \left|\int_0^tg_2(s)\,ds\right|\leq \int_0^t|g_2(s)|ds\leq\int_0^t sM\,ds = \frac12t^2M
$$
Now generalize the pattern and finish with a proof, say by induction.


Is there a better IIS 7 bindings dialog?

Question: Some of my sites in IIS have 20-30 bindings and the bindings dialog box in IIS 7 is 4 lines, which makes editing bindings a real pain. Are there any replacements/upgrades for the dialog specifically? I realize behind the scenes it is just updating an XML file, but I would prefer not to directly edit the XML file or start writing a separate management application, if possible.
Answer: I can't see anything on Google but this code should be helpful in building a C# Forms App that does it the way that you want - this has the advantage of connecting directly to IIS so it would work for any machine (as opposed to hacking the XML directly).
Comment: Definitely would be better than editing the XML file directly.


Will android/bitmap.h increase performance in image processing

Question: I am making an image processing APP in Android. Originally, I use Java to do the pixel computing, it is extremely slow. Then I change to C++ native code, it's much faster, but not enough.
I just pass the pixels integer array to C++, and do the computing. Recently, I noticed the android/bitmap.h library, but I am not sure whether it will increase performance. It seems like the difference is just passing an integer array or a bitmap. If I still need to do the same computations, how could it be faster?
Comment: Hey there! Did you possibly need more help with your question? You haven't marked this question as answered so I figured I'd reach out.
Comment: Why is java extremely slow ? Can you share some code ?
Answer: I should preface that I have never written code using the NDK or the Bitmap library, but I did take a look at the documentation for it.
The Bitmap.h documentation looks like it's only used for meta information about the Java Bitmap object. It only provides a single struct that tells you basic information about the bitmap (width, height, etc), its format, and other similar data. The library also only contains functions for performing locks on the data or getting the aforementioned information.
Therefore, I would conclude that using the Bitmap library in the NDK is only useful if you are writing Java and C++ code in parallel and you use Bitmap objects in the Java code, in which case you might want to use the library to interact with them easily. There will be no performance gains, and it might not even make sense, to use the bitmap library otherwise.
Take a look here for an example on the usage of the Bitmap library: https://github.com/googlesamples/android-ndk/tree/master/bitmap-plasma.
Notice how the Bitmaps are created in the Java code and then only processed in the C++ code.


I need to read x and y values from .txt file in C

Question: I need to read x and y coordinates from a text file then use them for polynomial regression. I can do the regression part but I can't read the values from the file. Data points are
5,10,15,20,25,30,35,40,45,50
17,24,31,33,37,37,40,40,42,41
First row is x and second row is y, and they're exactly written like this in the txt file.
From another question I managed to read all the numbers into a single x array of 20 but I really need for them in seperate arrays as x and y. How can I do this?
Here's my current code:
#include <stdio.h>
#include <stdlib.h>

int main()
{
FILE *data;
data = fopen("data.txt", "r");

int x[20];
int i=0;

for(i=0; i<20; i++)
    fscanf(data, "%d,", &x[i]);

for(i=0; i<20; i++)
printf("x are: %d\n", x[i]);

fclose(data);
return 0;
}

Thanks in advance.
Comment: Why not use a similar loop with another array: `int y[20]; for(i=0; i<20; i++) fscanf(data, "%d,", &y[i]);`? You also need to think what happens if there are fewer or more numbers in each line and add error checking etc.
Comment: is it always 10 elements in each row?
Answer: If you always have 10 int in one line and 10 more int in another line as you stated in your question, you can use one more array int y[10]; to store y values. And use two for loops - one for reading 10 x values, and another for reading 10 y values. And both your arrays just need to store only 10 elements.
    int x[10];
    int y[10];  // Array to store y values
    int i=0;

    for(i=0; i<10; i++) // Read first 10 values to x array
            fscanf(data, "%d,", &x[i]);

    for(i=0; i<10; i++) // Read next 10 values to y array
            fscanf(data, "%d,", &y[i]);

    for(i=0; i<10; i++)
            printf("x are: %d\n", x[i]);

    for(i=0; i<10; i++)
            printf("y are: %d\n", y[i]);

However if there is a chance that there may be different number of integers  - more or less than 10 - in those lines then you will need to do more checks.
Answer: check exist the comma
int x[20], y[20];
int i, n;
char tail;

for(i = 0; i < 20 && 2 == fscanf(data, "%d%c", &x[i], &tail); i++){
    if(tail != ',')
        break;
}
n = i+1;//if(n > 20){ puts("bad format!"); return -1;}

for(i = 0; i < n; i++)
    fscanf(data, "%d,", &y[i]);

fclose(data);

for(i = 0; i < n; i++)
    printf("(%d, %d)\n", x[i], y[i]);

Answer: First off all i advice you to write your x and y values by pairs (seems more logical, so it is simpler to implement). For example:
1 2
3 4
5 6

So fscanf(FILE* fp, char* format,...) :

FILE* fp - pointer to stream you want to  read data from (which can be even standard stdin which makes fscanf() work as scanf());
char* format - format string (for example: "%d%s%d");
... -  addresses of variables and / or areas in memory that will receive inputted data. Number of variables are specified by char* format.

You use fscanf(data, "%d,", &x[i]); instead of using fscanf(data, "%d%d", &x[i],&y[i]); forgetting that you get as much data as you specify in char* format.
Also note, that fscanf() as well as scanf() returns number of successfully inputted data, meaning that you can do something like this:
while(fscanf(data,"%d%d",&x[i],&y[i]) == 2) {
    // do something, or don't
}

You can leave while empty. In the end, you will get your x and y points stored in separate arrays. What happens is that fscanf() tries to read two integer values. if he manages to do this, he returns number of successfully inputted data, meaning 2. Else he returns 1 (if you missed x or y in pair) or 0 (if it is end of file).


Is this a valid method to adjust for multiple testing?

Question: Assuming I have 100 variables and I do a t-test for each of them without adjusting the p-values, and get 8 significant p-values out of the 100 tests. If my alpha is 5% can I just say that since I expect by chance 5% of p-values to be under 0.05, the 5 highest p-values for those 8 significant tests are due to random chance (since 5 is the expected 5% of 100. And then say that the 3 lowest p-values are the true rejections of the null hypothesis and are adjusted for multiple testing (and therefore my analysis adjusts for multiple tetsing)?
Answer: No, you do not control the familywise type one error rate this way, with sufficiently many tests you end up rejecting at least one null hypothesis about half of the time under the global null hypothesis (50% type 1 error rate rather than 5%). This procedure also has the odd property that you can never reject all null hypotheses no matter how strong your evidence is.


How to enable/disable fancy comparison signs in JetBrains IDEs

Question: My PyCharm changes the appearance of comparison symbols as I type them.
For example, if I type ">=", it turns it into the way you'd write it in a math notebook, like so:

I couldn't find where in PyCharm's setting that is so I could disable it, or enable it in friends' installations where it doesn't work that way (the sign just remains >=).
Where's the setting to disable this special rendering of comparison operators?
I tried googling for the answer in several different phrasings and didn't find anything useful.
This question should also apply to other JetBrains IDEs such as IntelliJ IDEA and CLion.
Comment: Welcome! Can you [edit] to share _what_ you googled for? That way, people in the future who are trying to google for those phrasings have a chance at finding this Q&A post.
Answer: This called a ligature. Go look at what font your IDE is using. It's probably JetBrains Mono, which supports many ligatures for programming operators and such.
To disable it, go to the font settings, and uncheck the box that says "Enable font ligatures".
Or alternatively, you can switch to a font that doesn't have ligatures in it.


Indicator for proportional correlation?

Question: The data shown in the graph below seems to be linearly correlated, but not proportional. How can I show that it is not proportionally correlated?
It seems so simple, but none of my ideas so far come close to satisfying:

Fitting y' = m*x and then measuring the relative difference |y'-y| / y. However, the difference is actually quite low for this example (20%). It would only make sense if it would be compared to the correlation between y and a straight line.
Fitting y' = m*x+b and using |b| as an indicator. But that just seems silly
In an old stats.stackoverflow thread the usage of the Spearman coefficient was proposed. However, in my understanding this checks for monotonicity correlations and not proportionality - Which test to use: hypothesis that a variable is proportional to another variable (not necessarily linear)
Google showed some rather recent papers such as "Proportionality: A Valid Alternative to Correlation for Relative Data", but those seem like an overkill.

Is there any simple indicator such as the Pearson correlation coefficient? Thanks very much in advance.
~Edit: A new idea was to use the p-values for m and b in a linear fit y=mx+b. If there is a linear correlation (Pearson) and the p-value for b is high, it seems to indicate proportional relation. However, if the p-value is low, it seems that I cannot infer anyhting. For example, assume the second, very noisy graph below, created using a quadratic function and a lot of noise. The p-values for m is 0, the p-value for b is 0.004. I understand it the way, that m is most likely nonzero, hence there is a linear correlation (?). However, the Pearson correlation coefficient is only 0.79, which indicates otherwise and aligns with the ground truth. Concluding, this does not seem to help. In summary, this does not seem to be an extremely helpful indicator for this situation either...
Answer: If you are interested in proportionality then the simplest thing to do is to plot the logarithm of the two variables and conduct a regression on the logged data, using the model:
$$\log Y_i = \beta_0 + \beta_0 \log X_i + \varepsilon_i.$$
When $\beta_1=1$ you have $\log Y = \beta_0 + \log X$, which can be written as $Y = \exp(\beta_0) \cdot X \propto X.$  Hence, proportionality occurs in the case where $\beta_1 = 1$.  So if you want to test the hypothesis of proportionality of your variables, all you need to do is fit this regression, and then do a T-test for this hypothesis using the estimated coefficient and its standard error.  This is just like the regular test in the regression output, expect that you want to test the null hypothesis $\beta_1=1$ instead of the null hypothesis $\beta_1=0$.

Indicator for proportional correlation?


How to extract all the hyperlinks and their text strings from HTML?

Question: I have a big text file in html with a bunch of hyperlinks, e.g.:
"Hello I want to talk about Google and Facebook."

I'm looking for a way to extract all of these from the txt file, such that I have a big Google Sheet with the following list:

www.google.com — Google
www.facebook.com — Facebook

And so on...
However, I have basically zero coding knowledge, so am looking for a really simple explanation on how to do this (e.g. if you think I should use a Python script, I'll need to know how to do this, what to download, etc.).
Would really appreciate a helpful answer here!
Comment: This question is too broad for Stack Overflow. Questions really need to be specific and technical. I'd suggest reading about regular expressions. There are examples on the internet which will match hyperlinks
Comment: Where is a good place on the internet for me to ask these broad questions though?
Comment: There are plenty of good programming forums, r/learnprogramming is a good place to ask.
Answer: Install python on your computer
Download here
How to install python video tutorial
On your command line write pip install linkGrabber:

After that write the following commands:
python
import re
import linkGrabber
link = linkGrabber.Links('your url')
grab = link.find(limit=4, duplicates=False, pretty=True)
#Change the value limit as needed.

The results should be printed on the screen:
Answer: "A big text file" is a bit ambiguous. But you could try this:
1.) Open a blank Google Sheet.
2.) Copy and Paste the entire "big text file" into cell A1. If you want it to look less messy after it's in, click the cell and choose from the menu Format > Text wrapping > Clip.
3.) Place the following array formula into, say, cell C1:
=ArrayFormula(QUERY(SPLIT(QUERY(SPLIT(TRANSPOSE(SPLIT(A1,"",0)),"href="&CHAR(34),0),"Select Col2"),CHAR(34)&">",0),"Select * Where Col2 Is Not Null"))

If this gives you the desired result, you can then hard-copy those results in place by selecting Column C in its entirety, hitting Ctrl-C to copy to clipboard, and then (with the column still selected) hitting Ctrl-Alt-V to Paste Special. A small clipboard icon will appear lower right on the visible screen. Click it and choose "Paste values only."
This solution is based on what you provided in the example text in your post. It also assumes that your "big text file" does not have paragraph breaks that would separate it out to different cells once pasted into Google Sheets. If it DOES break into separate cells going down Column A when pasted, you'll need to perform a couple intermediate steps:
a.) To "un-mess" Column A, select the entire column before applying Format > Text wrapping > Clip.
b.) Place the following formula into B1: =JOIN(,A:A)
c.) Change the A1 in the formula I provided above to B1.
And if all of this doesn't work, consider pasting your "big text file" contents into A1 in the sheet and then sharing the link to that sheet here, being sure to set sharing permission on the link to "Anyone with the link can edit." Then I or others here can see for ourselves what you're working with and make adjustments.


Select List value in an If statement - Computed Field

Question: I have created a select list field in my Entity Form.
Select List : none||none and AM||AM and PM||PM

In my computed field, I want to know what did the user chose by using IF STATEMENT
example:
if($halfday == 'AM')
{
//action
}

I tried to use array_pop (example code :
$halfday = array_pop(field_get_items($entity_type,$entity,'field_halfday'));)
but it does not work for me. What PHP code should I use? Any suggestions?
Answer: Write the following code under Computed Code (PHP) texarea in computed filed settings
$calc =  $entity-> field_sample['und'][0]['value'];

if($calc == 'AM')
{
 //action
$entity_field[0]['value'] = 'After Meridian';
}

elseif($calc == 'PM')
{
//action
$entity_field[0]['value'] = 'Prime Meridian';
}

This is a sample tested code which prints the selected item at output of computed field.
Note: replace filed_sample with your select list field machine name.


Injecting Angular components into FullCalendar event entries

Question: PrimeNG 7 introduced a
 component that wraps the FullCalendar 4.0 library as an Angular component. E.g.

The FullCalendar options include the eventRender option to specify a function to customise how events are rendered in the calendar. I've used it in the example below, but it generates DOM Elements using standard Javascript and therefore can't contain any other Angular components such as the Material design-styled button in the example (it still creates a basic unstyled button since the standard <button> is used).
I've tried looking into options such as using Angular's [innerHTML],  ViewContainerRef with ComponentFactoryResolver or Angular's runtime JIT compiler, but I don't understand enough to get any of these approaches to work or to know which is best for this use case. How can I inject Angular components into the FullCalendar event entries?
It doesn't need to be fully dynamic, e.g. having hidden components that already exist on the page but are shown in the right location, or having ng-templates that are merely instantiated differently would possibly be fine so long as it displays and acts like a proper entry on the calendar.
import { Component, OnInit } from '@angular/core';

@Component({
  selector: 'app-calendar',
  templateUrl: './calendar.component.html',
  styleUrls: ['./calendar.component.scss']
})
export class CalendarComponent implements OnInit {

  options: any;
  events: any[];

  constructor() { }

  ngOnInit() {
    this.events = [
        {
            "title": "All Day Event",
            "start": "2019-02-01"
        },
        {
            "title": "Long Event",
            "start": "2019-02-07",
            "end": "2019-02-10"
        },
        {
            "title": "Repeating Event",
            "start": "2019-02-09T16:00:00"
        },
        {
            "title": "Repeating Event",
            "start": "2019-02-16T16:00:00",
            'color': 'rgb(72,101,144)',
            'textColor': 'black',
        },
        {
            "title": "Conference",
            "start": "2019-02-11",
            "end": "2019-02-13"
        },
        {
            "title": "John Smith",
            "start": "2019-02-01T10:00:00"
        },
        {
          "title": "Appointment",
          "start": "2019-02-01T16:00:00"
        },
    ];

    this.refreshOptions();
  }

  refreshOptions() {
    this.options = { eventRender: this.onRender };
  }

  onRender(info: any) {
    let title = info.event.title;
    let start = info.event.start;
    let end = info.event.end;
    if (!info.event.allDay) {
      return createElementFromHTML(
        '' +
        '
' +
        '    ' + event.title + '' +
        '    <button mat-raised-button>Button</button>'+
        '
'+
        '');
    }
  }

}

// Use Javascript to generate DOM Elements
function createElementFromHTML(htmlString) {
  var div = document.createElement('div');
  div.innerHTML = htmlString.trim();

  // Change this to div.childNodes to support multiple top-level nodes
  return div.firstChild;
}

Answer: This might be related to what I came into just months ago. You can check out the answer I outlined here.
Using Angular's DomPortalHost, I was able to inject components into the anywhere in the DOM easily
EDIT: This is a sample snippet
import { ComponentFactoryResolver, ApplicationRef } from '@angular/core';
import { ComponentPortal, DomPortalHost } from '@angular/cdk/portal';

import { TheComponentThatIWantToAppend } from '../path-to-component-that-i-want-to-append';

constructor(
    protected componentFactoryResolver: ComponentFactoryResolver,
    protected appRef: ApplicationRef,
    protected injector: Injector
) {}
...

myfunction (): void {
    let myElementContainer = new DomPortalHost(
      eventRenderInfo.el.querySelector('.my-element-container'), // Target the element where you wish to append your component
      this.componentFactoryResolver,
      this.appRef,
      this.injector);

      myElementContainer.attach(new ComponentPortal(TheComponentThatIWantToAppend)); // This does the trick
}

Comment: Could you not report the answer into this post for this specific problem ?
Comment: It's just a click away, and it bugs me to repeat my answer, but yeah, sure. See my update


How did Rameau's Treatise on Harmony (1722) influence the mass production of musical instruments?

Question: Rameau's Treatise on Harmony (1722) initiated a revolution in music theory but in what ways did that translate into popularizing music ... particularly the mass production of musical instruments?
The question means if his work made music more accessible to the public and therefore greater demand to produce less expensive instruments -- perhaps with metal instead of gut, such as frets, using less materials, etc.
Comment: Are you referring to a specific article that's arguing that the Treatise did so? Can you link it?
Comment: @LSM07 No, I'm actually asking if it did and should've used clearly phrasing.
Answer: How did Rameau affect mass production?  Not at all.  His Treatise was published in 1722, but there was no mass production (of anything!) until 80 years later.
The biggest influences on instrument manufacturing were the development of the tubular valve for brass instruments (by Stölzel in 1818), the Boehm key system (in 1847), and the invention of various plastics in the early 20th century (for mass-market clarinet bodies, single reed mouthpieces, etc.).  Plus the advances in technology that aided manufacturers of anything, like part standardization - that happened in the early 1800s to manufacture pulleys for sailing vessels.
Comment: I don't think it had an effect on the choices of materials.  Metal strings were used in keyboard instruments and as windings for gut strings before Rameau; steel strings didn't replace gut until the 19th century.  Instruments that had gut frets like the lute didn't use metal frets until the mid 20th century (and most still use gut today!)
Answer: This first quotation doesn't properly answer your question, but it contains an interesting hint:
Jean-Philippe Rameau, the leading French composer of the 18th century, also contributed much to the development of orchestration. Rameau, like Handel, was principally famous as an opera composer, and the overtures and dances of his operas represent the most advanced uses of instruments during that period. Rameau was probably the first composer to treat each instrument of the orchestra as a separate entity, and he introduced interesting and unexpected passages for flutes, oboes, and bassoons.
https://www.britannica.com/art/instrumentation-music/Percussion-instrumentation#ref530172
The Traité was immediately recognized as a profound advance in musical theory, however, and it established Rameau's reputation as a theorist. His book was the first to codify those principles of tonality that were to dominate the music of the West for almost two centuries. Even today the theories of Rameau remain the basis for the study of harmony.

The question means if his work made music more accessible to the public and therefore greater demand to produce less expensive instruments -- perhaps with metal instead of gut, such as frets, using less materials, etc.

I'd rather say that no!
The points you are mentioning might have been more an impact of the French revolution in general when the music culture baceme not only a pleasure and privilege of for the nobility (apart of the travelling artists in the cities) but for all citizens - at least for the bourgoisie, as before the French nobility (French: la noblesse) was a privileged social class in France during the Middle Ages and the Early Modern period to the revolution in 1790.
Comment: "His book was the first to codify those principles of tonality that were to dominate the music of the West for almost two centuries. Even today the theories of Rameau remain the basis for the study of harmony."

So why focus on what happened in France?
Comment: The french revolution has been spread to whole europe and till moscow. Isn't it that till today some people think classical music were a  privilege of the higher classes? In the same year (1722) the first part of Bachs WTC was published. I didn't notice this coincidence before ...


Use of Music Theory in Composition

Question: I've been told by many people that music theory is not normative; it doesn't tell you what to write or do in music to create something beautiful that sounds good.  I've been told that it's strictly descriptive; that is, it describes a set of observed patterns in music that (someone) thinks sounds good, or that is frequently written.
So with that in mind, I want to ask about theory and composition.  How is theory supposed to inform composition?  Some musicians seem to have a deep theoretical knowledge, and regardless of what they would say their mental process is, this seems to affect the way that they compose, since they can't "un-learn" certain patterns.   On the other hand, there are untutored musicians who know nothing about theory, and who in some sense are more "free to break the rules", being unaware of what the rules are.
EDIT - This question has already gotten a lot of attention, and several good answers.  I'm starting to think the original question is a bit flawed; here are three big things I've gleaned:

Several answers point out that people who don't know any formal theory still adhere to many patterns described by formal theory, in the way that a child who speaks English knows sentence grammar without knowing the terms of academic structure of grammar.  In this way perhaps, they're "using theory" without having a conscious awareness of rules and terminology like chromatic mediants, modulation, etc.
Another perspective here is that focusing on the connection between theory and composition is the wrong focus, because what matters is whether the result is good, pleasing, unexpected (pick your descriptive term).   If it is, then it doesn't matter what the theory connection was.  If it isn't, then clearly it also doesn't matter what the theory connection was.
There's a fair amount of concern about the interplay between theory and creativity.  Does knowing theory make you more creative, or less creative?   There's no consensus, it appears the answer is "both, depending on who you talk to".
Comment: I used to think that, in C keys, a D chord before a G chord sounded absolutely amazing, but I had no idea why. Additionally, I wasn't even sure whether anyone agreed with me on this. Then I learned about the theory behind secondary dominants, which taught me *why* this sounds good, and how I can reach a similar sound in many other ways. I never thought music theory was very useful until that moment.
Comment: Your first paragraph is true, except in cases of modern protestant liturgical hymns... once you know a few basic chord progressions, you will know every Christian worship hymn ever :-D
Comment: Only if you know the rules, you can conciously break them.
Comment: Music theory prevents you from re-inventing the wheel, which is a time-consuming process which will be recognized by your peers as clichés.
Comment: ""using theory" without having a conscious awareness of rules" -- this is a common guess. But conforming to a descriptive theory isn't necessarily *using* it, any more than a rock is "using the theory of gravity" to fall ;-) In such cases the theory is an approximate representation of what happens, it isn't what happens.
Comment: @SteveJessop I think we're just equivocating on what "using theory" means here.  I'd absolutely say that a 5 year old child is using English grammar, although they don't know anything about sentence construction.  If you play major chords C, F, G, I think you're probably using diatonic theory whether or not you can read a note.
Comment: Don't think of breaking rules, but of extending them.
Answer: On a practical level, knowing some theory can be useful to a composer in certain circumstances.
First is when a composition is not as interesting as the composer would like it to be. He/she would like to evoke something different than whatever the music inspires at that stage of composition. Examining the melody for how it conforms to standard scales, examining the harmony to detect whether or not it is feeling hidebound to predictable patterns and progressions, then contemplating how to mix it up with shifts in key feel, introducing certain accidentals - all this can be useful, and I can attest to it from personal experience.
Second is when one has composed a passage, and the harmony is not obvious. Analyzing the relationship between a melodic passage and all the possible ways it can be harmonized (Does it lie in a standard triad? Could it be an accidental?) can be interestingly informed by theoretical knowledge.
I like to think of theory and composition having a similar relationship to that between the composition of poetry on one hand and rhyme, meter or other craft-centered knowledge on the other: It can be a limitation, sending the composer down a well worn channel to a banal destination, or it can be a spur to creativity that lifts one out of a rut.
Of course, it can never substitute for the inventiveness that composition demands of its practitioners. That is why composers of tremendous accomplishment have done without such knowledge, and yet excelled.
Comment: I meant to go into this in my own answer; well said, +1.  Related Q/A: [Does following musical forms suppress creativity?](http://music.stackexchange.com/a/4908/28)
Answer: It's rather like language.  Treating the rules as prescriptive allows you to always be generally understood (or compose something non-irritating).  You need to understand the rules in order to know when it is OK to break them, even though you could accidentally break them and still make a comprehensible sentence (or pleasing melody) without knowing why.
Because the rules are in fact descriptive and often involve natural laws (i.e., the math behind the music), music can come quite naturally to people.  Like the other answers say, composers who have little knowledge of theory are still unknowingly following many rules.  (Or, more accurately, the rules describe them already.)
Whether you arrive at your composition "naturally" or from some laid-out process doesn't really matter if you/others like it.  (Of course, it's totally valid to purposefully compose unpleasant works as well.)  Both are effective methods for different people, but neither stands alone.  Following the rules only works in combination with some sort of melody or desired sound already, since otherwise you'd just churn out the same thing every time.  Conversely, you can't compose without any rules because many of them are already built into your brain, and our brains are what defines "music" in the first place.
Comment: I appreciate your response, and I'm really not trying to give you a hard time; but the question was "How is theory supposed to inform composition?" - your points are well-taken, maybe the process doesn't matter as long as the result is good.  So are you basically saying that there isn't a connection between the two, or that if there is, it doesn't matter "as long as the result is good"?
Comment: @FrobberOfBits Maybe I am not totally sure what you mean by "supposed" -- "intended" or "able".  Whether theory *should* inform composition is up to you, and what I'm trying to get at in my answer.  If you meant how *can* theory inform composition, I would recommend memphisslim's answer; at this point I don't feel comfortable going back and adding what he said to my own answer.
Answer: First off, the notion that you can write more freely if you "don't know the rules" is an unfortunate fallacy.  When I hear guitar players saying that they eschew learning theory or how to read sheet music because it will "stifle their creativity" I think, "lads, you're trying to run a marathon with a boat anchor strapped to your ankle."
Functional harmony (western music theory) was constructed empirically, by recognizing the patterns that everyone gravitated towards and capturing those in a descriptive semantics.
When you compose having a background in music theory, you possess the tools to compose "with intent."  The theory essentially describes patterns of tension and release, and patterns of consonance/dissonance.  Music theory is not there to make it "sound nice," it's there to provide you with a tool to achieve specific intent.
All that said, it's obvious that there are many songwriters who have no formal training to speak of who come up with wonderful music.  The reason they make wonderful music comes out of their wonderful mind, not out of their ignorance.  They actually DO use theory, but it's born of their own sensibilities and listening.
Answer: Theory is both descriptive, and, to the extent that it gives an accurate description, also a bit prescriptive (but only to that extent). It might be correct to say that theory doesn't provide rules so much as rules-of-thumb. What theory does is provide a set of tested solutions to common problems. If, in a piece written in common practice tonality, you find yourself at V/vi needing to get back to I, chances are good that your theory courses have taught you some very serviceable progressions to use to do so. If, in a twelve-tone piece, you need to accompany some voices written using one row form with voices using another row form without incurring any unisons or octaves, well, you look up combinatorial rows - the matter is quite simple.
The problem with trying to use theory for much more than that lies in two spots:

Theory covers commonality, what happens the majority of times in a given situation, which is fine if you aren't attempting much more than Gebrauchsmusik or musique d'ameublement. If you like setting challenges for yourself, you'll frequently find yourself in spots where the "rules" no longer apply nearly so well. In fact, most of the rules came about when someone had to write something extraordinary, something that was outside of common practice, in such a way as to make it intelligible to the audiences of the day - in other words, to make such a departure from the rules compatible with the spirit of the existing musical language, to make such departures normative. (This is a good description of so much of Haydn's output.)
Because of that, theory is reductive. Because of the emphasis on commonality, theory is sometimes obliged to ignore a lot of what particularises a specific well-made work. Sonata form is a case in point: sonata was not so much a form as a way of working in a language that expected a move to a dominant region, and a resolution of that move, as part of its normal syntax. Yes, you can often find first and (sometimes "feminine") second themes, transitions, full recapitulations, discursive "development sections", but it was only when the language changed so that dominant polarisation lost its force that the "form" ossified into what we find in textbooks now. (See Charles Rosen, "The Classical Style", "The Romantic Generation" and "Sonata Forms". Rosen's writing on the subject is marvellous.)

Some musicians seem to have a deep theoretical knowledge, and regardless of what they would say their mental process is, this seems to affect the way that they compose, since they can't "un-learn" certain patterns. On the other hand, there are untutored musicians who know nothing about theory, and who in some sense are more "free to break the rules", being unaware of what the rules are.

The former is true to the extent that these musicians see theory as a panacea, a kind of "silver bullet" to slay the complexity encountered when composing music. If you are interested in drawing out the implications of your musical ideas, and doing so in a language that is intelligible, you will frequently find yourself feeling your way forward, and these all-encompassing theoretical frameworks become, at best, guidance, and, at worst, detriments. Personally, I find that the older I get, the less I know for sure, the more contigent my ideas regarding theory become.
As for untutored musicians, they frequently succeed to the extent that they have internalised the prevailing musical language, since they don't live in a musical vacuum. However, when you have an autodidact like Mussorgsky, who was attempting a synthesis of classical and Russian folk traditions while eschewing "book learning", you can sometimes find such a person having occasional problems adequately conveying his ideas (and, in Mussorgsky's case, it led to a lot of people, rightly or wrongly, feeling a strong need to edit his work). A knowledge of theory sometimes allows you to find solutions to the specific problems immediately at hand by analogy to existing solutions to common problems.
Comment: @Rockin Cowboy, they're not completely mutually exclusive. Let me put it another way: theory is useful for telling you how something can be done to the precise extent that it is successful at describing how something has been done in the past.
Comment: Thanks!  This is a great answer.  I think what I'm coming around to is that my question is based on a set of assumptions about what theory is and what its relationship to good music is, that I need to revise.  I appreciate you taking the time to write this.
Comment: @Patrx2 I agree - very well put.  But don't you think prescriptive is the opposite of descriptive.  I did not quite understand what you meant to say in your first sentence.
Answer: In math, you are supposed to know 1+1 = 2. You do not need to know math in a formal way to know when you have two apples. As math becomes more technical, common knowledge is less equivalent, even while it is still relevant (What is the thrust required to leave the surface of the planet, or what is the compound interest of your account over the next 6 years?)
I know music is not math, but it is similar in this way: You do not need to know music theory to write a simple piece of music that follows the rules. You do need to know the rules in order to achieve a complex musical work that connects to the common musical grammar. The good news is that simple music can often sound really good. That does not negate the riches to be found in deeper study of music theory.
Some can also internalize many of the rules of music in common use, by listening. This is equivalent to grammar. A person can follow the rules of common use in grammar without ever going to an English class, and without even thinking about it consciously. This does not mean that attending an English class is useless, what it does mean is that it is possible for some to follow the rules without it.
Understanding music theory gives you the opportunity to discuss the rules in a forum like this, and study and research them further and find answers to questions. It gives you a larger deeper world to draw from and a view to standards that have already been set.
Its harder to break the rules if you do not know what they are. When I was young I wrote pieces that were meant to break the rules, but since I did not know the rules, no rules that I meant to break were actually broken.
I don't think you would learn unbreakable patterns that stick with you forever, unless it turns out that you like said patterns and want to continue with them on some level. Win : Win.
Answer: You can use theory to form a framework which underpins your composition. The framework provides a basic structure that guides the composition, but the details of the composition distinguish it from other compositions, even those that use the same framework.
Answer: As other's have suggested, it is not necessary to know any theory at all to create great musical compositions.  Music follows some basic laws of nature that are innate not only to humans, but some studies have even suggested plants can respond in predictable ways to music.  Theory is merely an attempt to logically explain why some music sounds good and some notes sound good together, while others do not.
That being said, theory can indeed be used effectively to, as you say, inform composition, should one have a desire to use it in this way.  For example, theory tells us which notes blend well together to make music that is pleasing to the human ear.  So if we are composing a piece in C Major, we know from theory, which notes are available to us if we want to remain within the safe harbor of tried and tested theory about which notes blend well together in that particular key.   Knowing which notes will work in our melody also tells us without trial and error, which chords can be formed from the notes in our chosen key.
We can also apply theory to better evoke the desired emotional response to our composition.  Through theory, we understand that minor keys seem to evoke a more melancholy or sad feeling whereas major keys evoke a happier feeling.
If our goal is to compose a piece of music that will involve multiple instruments played by different musicians, then sticking with tried and trusted theory, will make it easier for the other musicians to either learn their parts, or instinctively follow the pattern because it fits within the framework of music theory, which is in reality, merely a descriptor of why a musician would naturally gravitate towards a certain note or chord or rhythm.
Allowing theory to provide the framework that defines certain parameters of the composition will help insure that the musicians who must perform their part of the composition will not get off track by following their natural instincts. It also gives you a degree of certainty that it will sound "right" and be satisfying to the listener.
In summary, if we wish to assert that music theory IS supposed to inform composition, it does so by defining the key, the tempo, the rhythm, the notes available, the chords available, and other parameters that will best convey the intended feeling or emotion to the listener in a pleasing manner - while being easily interpreted and performed by the musicians or instruments that the composer wishes to use to recreate the musical composition.
Answer: You need to know theory because:

Music composition is a craft. You may very well do something intuitively, but that doesn't change the fact that you need to learn the craft. More often people have an intuition for melody and harmony but they rarely have intuition for form, and form essentially is composition. Without form your music is at best sound design and at worst a blob of incoherent sounds. Learning theory can make your music more coherent and listenable. It might not, but it can.
Music theory gives you awareness of what you are doing, so that you don't naively think that you've just done something no one else has done before.

Being unaware of the rules doesn't automatically give you an advantage, knowing theory doesn't either. What gives you an advantage is hard work and some talent.
Answer:
How is theory supposed to inform composition?

Completely.

On the other hand, there are untutored musicians who know nothing
  about theory, and who in some sense are more "free to break the
  rules", being unaware of what the rules are.

I contend the fact that good musicians break the rules. If you break the rules for the mere sake of breaking them, it will definitely not lead to good music. Even impressionists who broke a whole lot of conventions did not do it for the mere sake of doing it, but had definite stylistic ideas they wanted to follow.
There may be musicians who have no training in theory, but still apply the things theory teaches to their music (even if they are unaware of doing so). James Hetfield, for instance, if he would ever feel the need to do theory, would instantly know the proper use of rhythm in melodies. He is a great rhythm player and uses the principles of good rhythm in his music regardless of whether his education is formal or not.
Even if you do think of impressionists and how they made their music, there was not a great room for this type of music to evolve and grow. That was the great deficiency of the genre; it lacked the manner in which other musical eras / genres evolved, and this had a great deal to do with the way in which it discarded long held conventions.
Comment: Can you elaborate on "completely"?  Below you gave examples of people who weren't trained in theory but were using it anyway.  This wouldn't be theory informing composition, it would be theory fit to a composition after the fact.   For people who do know theory, exactly how do they use it to inform their composition?   I'll accept "completely" as an answer, but it needs elaboration.
Answer: I am going to say  some heretic thoughts and think that have the right to do that as I already have  presented working radical new music system which is quite works from the very beginning and needn't contemporary music theory.
(
http://home.arcor.de/yuri.vilenkin/new-music-atoms.html
http://www.youngcomposers.com/forum/t33636/the-new-structure-of-muscal-note/
http://forum.emusictheory.com/read.php?5,16533
).
Of course it doesn't mean that possible alternatives make unimportant the knowledge of established music theory  as it is necessary  for   learning and understanding of already created music practice.
Nevertheless it is worthwhile to limit oneself to several most important authoritative works as, for example, not ago anew disclosed "Guide to the practical harmony" of P.Tchaikovsky, who isn't occupied with inventions of vague notions as "tonality" and doubtful speculations.
Particularly he wrote:
" It is important that by thoroughgoing  explanations of rudiments we should dispel at the start the superstitious awe that prevails regarding  so-called 'Theory' or 'Thorough Bass'."
Namely so called " theory".
The great deficiency of  established music theory is that it presents itself  as bearer of eternal truths. In reality the its most important part the harmony theory is about  chords and progressions, which appeared by spreading of   key instruments and may become unnecessary by further technical and scientific progress.
Now computer technology and results about of human music perceptions obtained by physiology and psychology permit to build music system which is directly oriented  on human sensations of scientifically verified music components (concerned to harmony), that is; of melody, dissonances, fundamental frequency, smoothness.
Answer: Everyone has is own music theory, often one for each music style, and music theory can sometimes be thought as a generative language.
Ideally, the music theory should predict what can come next after, for example, a given succession of chords : letting you choose among the 10 possibilities permitted by the music theory, instead of  searching for the next chord among an infinity of possibilities.
There is something magic about music, particularly the melodies. But that magic part of music (that is related to imagination, the concept of beauty, human capability to dream..) represents only 40% of the whole, the rest being algorithmic. That algorithmic part, related to grammatical rules, is exactly what music theory is about.
In my opinion, missing one of these two parts of music : magic + algorithmic
will make you incapable of composing music efficiently.
Comment: Bach, Mozart, Beethoven, Chopin, they all have an obvious algorithmic component in there music. And today, electronic music probably represents the best example of music with a huge algorithmic part.
Answer: Music theory can be helpful in composition but should not be thought of as a set of ironclad rules that must be adhered to.  There are so many facets to the evolution of music theory it would be difficult to draw a straight line from beginning to end, and I see many great answers here.  But I do feel compelled to add few thought to the discussion.

What you are referring to as "music theory" is most likely Western music theory and for that reason the discussion should end right here.  Other ethnic styles of music would fail to fit into the paradigm of "music theory" and never follow these so called rules.  Does that mean that it isn't music?  Does that mean that Asian musical traditions like Indian Raga are somehow "wrong" since they likely violate these rules?  To draw such a conclusion would be, in a word, racist (or in PC speak ethnocentric).  Rather than wondering how Indian music could be forced into the music theory paradigm or how music theory could describe Raga, one could ask if there is a version of the "rules", a theory, that supports the common practices of Raga.  In other words are there multiple music theories.

The "rules" of music in any culture are not like the laws of physic.  You cannot ever violate the law of gravity no matter how hard you try.  You can capitalize on the law of Burnoili to create lift in the atmosphere but that is not the same thing as breaking a law.  There is no consequence, like injury or death, when one violates a rule set in the arts (though it may lead to the death of one's career, popularity, or threats of violence, etc.  Consider the case the composition 4:33 by John Cage).  Artists use well established physical laws to assist in creating things, in bringing ideas to life.  A painter would spend years studying shading, color, geometric perspective, but when it comes to creating a piece of art none of the rules governing these must be followed.  In a similar vein the laws of acoustics and wave interference do somewhat govern how musical sound is created and perceived but that doesn't mean one must always use them in a predetermined fashion to write music.

In stark contrast to point 1 it turns out that for well over 100 years physics has been somewhat helpful in understanding what has evolved as Western Music Theory.  The physicist Herman Helmholtz was interested in such issues as consonance and dissonance, the inner workings of harmony, intonation and temperament at least in the Western musical tradition.  It does turn out that some of what is judged as "good" in the world of music seems to have a foundation in physical law.  I won't go into details of this research in my answer but recommend reading through "On the Sensation of Tone by Helmholtz" (if you are mathematically inclined) or "Physic and the Sound of Music" by Rigden (which is a common for teaching musical acoustic to non-science majors.  I've taught from this text and several universities and colleges).  In short the notes in the major scale in Just tuning can be seen to come from natural harmonics of vibrating system used to make instruments, interference patterns and beating can be used to explain consonance and dissonance, and by extension harmony.  It would seem inevitable that some humans would gravitate to these principles since our ear naturally creates aural harmonics from the same sequence and the brain is programmed to identify this sequence and I don't think that would have occurred in just the last few hundred year.  Despite these comments it is still a choice to follow what our culture has converged on as a best practice.

Related to my last point in item 3.  The Western tradition, like any other, has evolved over thousands of years.  What we now consider "correct" in music theory (and this is a mistake to use theory in this manner) might not have been "correct" a thousand years ago.  Our tastes have evolved and changed over time.  Interval choices that were popular in ancient music might not even appear as an option in modern theory.  What theory is today is really a description of best practices for composing music that will appeal to the masses, the largest section of listeners.  It is no coincidence that people on average agree with what specific combinations of tones are pleasant, or chord movement that "feels" definitive versus suspended.  However it is not clear if Helmholtz's explanation closes the lid on this by saying that physics mandates that V7-->I has more sense of closure than say IV-->I, or vi-->iii.  The fact that so many people agree on this may likely be cultural brainwashing that occurs in childhood.  But then again, why would we choose these patterns over other to wash our brains with?  This is a chicken and egg scenario in my opinion.

When it comes to untrained musicians somehow naturally getting it right this is no surprise.  It is not fair to say that untrained musicians have no background in music.  The very act of trying to play your favorite songs (or even having a favorite song) means you are already brainwashed.  You learn by example and if a majority of examples have common themes you will pick up on them even if you don't have a text book knowledge of what a cadence is or the significance of I-->IV-->V, etc.  I am not suggesting that the common themes in Western music must be the way they are, they could have evolved differently, but the fact that there is some sort of common denominator running through music is easy enough to pick up on.
Answer: A few days ago I read a detailed Analysis of the music theory "tricks" used by the swedish Progmetalband Opeth. It was - to the untrained hobby musician like myself - a very complex analysis, and, knowing that the composer of the songs (the singer) has no formal knowledge of music theory, I wanted to say: hey people, do you really think, he sat down and thought "ok lets play a diminished minor triad here (if that makes sense :-) and then shock the audience with an unexpected extended fifth and a mixolydian change over a major 7 chord"…of course Akerfeld does not compose this way, I assume he more or less "noodles" around on the guitar and tries to find cool riffs, no matter what that riff may be in theory. Of course his music can be theoretically analysed after the so to say ecclectic composing process, but I am very sure that many successful players like Akerfeld would have no clue (or even care about) what the music they compose can be described from a theoretical point of view. Knowing the alphabet or even the grammatical structure of a language does not make it easier to write a touching poem. Or, every child can speak perfectly understandable in their mother tongue without beeing able to explicitly name the grammatical rules behind it. If knowing the music theory would be sufficient to compose interesting music, would not everyone who attended git or berklee automatically have to be able to do just that and get famous?
Answer: Theory informs the craft of composition. Limitations in the development of craft can restrict the musician's expressive potential within the art of composition.
Composition as Craft:
virtuosity developed via music theory as generalizations, descriptive rules and patterns of style, technique, and method; developing understanding and excellence in the practice (i.e. the practice of music, law, medicine).
Composition as Art:
a practice/process existing beyond theory, measurement and rules: imagination, intuition, creativity, exploration, curiosity, aesthetics; awareness of meaning
Expressive potential in the art of composition and performance is limited by:

Expertise in craft: how, what;

technique, theory, practical experience historical awareness of styles, methods, techniques/technology, analysis, imitation, execution, proficiency, virtuosity, technique development, intellectual development; didactic and experiential learning; development of expressive means (toolkit).

Artistic development: why;

life experience, emotional, perceptual and aesthetic awareness, intuition, imagination, insight, curiosity, innovation; a search for meaning and aesthetic expression beyond current limits.

Intrinsic/Extrinsic factors:
talent, intelligence, creativity, motivation, persistence, opportunity, support, etc.

AI (artificial intelligence) can generate music compositions reliant on rule-based styles, techniques and theoretical methods of composition (i.e. aleatoric, stochastic, algorithmic, serialisms, fugues). Increasingly, the rule bound aspects of the craft of composition (styles, forms, techniques, etc.) are being replicated and simulated by technology.
https://ailabs.tw/human-interaction/ai-music-composition/
In a sense, AI technology demonstrates the generative possibilities of composition as craft only. That is, based on theoretical models. And this illuminates to a further degree many of the differences existing between the craft and art of music composition.
Answer: Do you not know the taste of chicken if you can't create a word for it, or a theory about why it tastes the way it does?
The formal study of music is an analysis of tendencies in common usage, and why some patterns create tension and drive towards certain psychological responses and expectations, while others do not. The effective patterns were discovered gradually, through trial and error. Composers built upon what had come before finding new ways to spice the more fundamental structural blocks of a piece of music. The theory came after the fact.
However, those tendencies are also learned and ingrained into the ear and memory through exposure to and engagement in music. If you know music from 1500 onwards in Europe, you can hear the progressions and the changes over time. You don't need to know the name of it to use it, providing you can create the sound, both on an instrument and then using some notation that others can readily understand.
Hence, there is a logic in learning enough to communicate ideas. But auditory experience and instrumental practice will trump anything learned in a book when it comes to practical application.
Also knowing the music that has come before will prevent you from committing the hubris of thinking you've just invented something that has been used a million times already. In fact, there is nothing in tonal music that hasn't been done. And then know that is so much the case that it was at the beginning of the 20th century that composers had to escape tonality and all traditional forms of structure and rhythm in order to advance anything new. Anything you hear in a song that you like, owes more to the execution and performance than any underlying originality in the music itself. New sounds and technology has opened up some additional variety, but it's really more cultural expression that drives originality, not the music. Even atonal music and modal blends have been exhausted leaving very little to contribute for the modern composer beyond repackaging. Anything new is just staging, or taking advantage of youth and ignorance.

Use of Music Theory in Composition


How to add CSS to menu_callback page?

Question: I have implemented hook_menu in my module and created a page. Now how to add CSS to this page? I have the below code inside my page_callback function, but still the css is not applied.
$css = "table,tr,th,td {padding: 10 !important; }";
drupal_add_css($css, 'inline');

Any help is appreciated.
Answer: Unless you've hacked D6, 'inline' only works with drupal_add_js(), not drupal_add_css().  So, to do what you want, you need to put that line of css in a file and include that file instead.

How to add CSS to menu_callback page?


How to prove $n^6$ is big-O but not big-Omega of the function $(1.001)^n$

Question: I know that, $n^c \in \mathcal{O}(2^n)$ for any constant $c$.
However, I don't know how to prove, or whether it is correct that, $n^c \in \mathcal{O}(1.001)^n$ for any constant $c$. Does anyone has an idea?
What I have tried so far:
By definition, $n^6 \in \mathcal{O}(1.001)^n \iff n^6 \leq c \cdot 1.001^n$ for $n \geq n_0$, where $n_0$ is a non-negative integer and $c$ is a positive integer.
How do I go from here?
Comment: Try taking logarithms.
Comment: Don't worry about the base of the logarithm. It only matters up to a constant. Then consider properties of logarithms
Comment: Is it that $\log_{1.001}n^6 \in \mathcal{O}(n)$?
Comment: Ah, it goes nearly flat as $n$ goes to infinity. Is that what you are referring to?
Answer: The proofs for $n^c \in \mathcal O(2^n)$ and $n^c \in \mathcal O((1.001)^n)$ are basically the same. You can prove:
Proposition. For arbitrary constants $c > 0$ and $r > 1$, we have $n^c \in \mathcal O(r^n)$.
Proof.
First, note that
$$\begin{align*}
n^c \le Cr^n
&\iff \log n^c \le \log Cr^n\\
&\iff c\log n - n\log r \le \log C.
\end{align*}$$
Thus it suffices to prove that a function
$$ f(x) = c\log x - x\log r \quad (x > 0)$$
is bounded from above. As
$$f'(x) = \frac{c}{x} - \log r \begin{cases}
> 0 \quad \left(x < \tfrac{c}{\log r}\right)\\
= 0 \quad \left(x = \tfrac{c}{\log r}\right)\\
< 0 \quad \left(x > \tfrac{c}{\log r}\right),
\end{cases}$$
the function $f$ has a maximum $f\left(\tfrac{c}{\log r}\right) = c\log \tfrac{c}{\log r} - c = \log \left(\tfrac{c}{e\log r}\right)^c$.
Hence we get $n^c \le \left(\tfrac{c}{e\log r}\right)^cr^n$ for $n \ge 1$; in particular, $n^c \in \mathcal O(r^n)$.
Answer: For any positive $n$:
\begin{align*}
1.001^n&=e^{n \ln 1.001}\\
&=\sum_{k=0}^\infty \frac{(n\ln 1.001)^k}{k!}\\
&>\frac{(n \ln 1.001)^7}{7!}&\text{(because all the terms in the sum are positive)}\\
&=\frac{(\ln 1.001)^7}{7!}n^7 \, .
\end{align*}


Angular resolve user on startup

Question: Hoping this is an easy one!
I want to make sure the user accessing the application is resolved before showing any screens or calling any subsequent services.
I can resolve the user through making a HTTP REST call using a token that will already be present on the first request.
This user is then passed into subsequent rest calls e.g. a REST service to "get my work".
I know I could use a resolve function on my routing but for this to work I'd have to add it into every single routing since I can't always guarantee users will come in via the front door.
I tried putting it into a main controller that spans the whole application but the problem here is that the routing resolve is called first which needs the user to do it's REST calls.
Any ideas?
Regards,
Kevin.
Answer: I've had a similair problem before and I was lucky enough to come across this example project.
We've got 2 projects

One has a home brewed auth mechanism consisting of an external app, server-side credential checking, then being redirected to the internal app.
and another (very prototype-ish) using the example project's concepts... so far I've been preferring this approach.

In project A we basically do something to this extent.

Write a userToken inside the cookie, if the cookie exists (& is valid) on return... job done.
If not, Please log in so we can create the cookie.

But my suggested route is to follow Project B:

You'll basically need an interim app/state where you can do your
initial check, if your user isnt entering via the normal login routes.

I've shamelesly stolen this graph below from the awesome mrgamer's angular-login example project.
His project can be found at here.

angular.module('angular-login.pages', ['angular-login.grandfather'])
.config(function ($stateProvider) {
  $stateProvider
    .state('app.admin', {
      url: '/admin',
      templateUrl: 'pages/admin.tpl.html',
      accessLevel: accessLevels.admin
    })
    .state('app.user', {
      url: '/user',
      templateUrl: 'pages/user.tpl.html',
      accessLevel: accessLevels.user
    });
});

The documentation is quite verbose and should explain some of the intricacies of the whole approach
OR
And I'm not as familiar with this approach (as I haven't tried it in a fully fledged app). You could perform a check on the $routeChangeStart
angular.module('angular-client-side-auth', ['ngCookies'])
.run(['$rootScope', '$location', 'Auth', function ($rootScope, $location, Auth) {

    $rootScope.$on("$routeChangeStart", function (event, next, current) {
        if (!Auth.authorize(next.access)) {
            if(Auth.isLoggedIn()) $location.path('/');
            else                  $location.path('/login');
        }
    });

}]);

Source from here
Comment: Thanks for the docs. So If I understand correctly, basically have a parent abstract route that resolves the user? All other routes then extend this?

Angular resolve user on startup


In general, how should we find the pmf given only the moment generating function without comparing its form to that of famous pmf?

Question: Background
It is known that moment generating function generates moments, but does it hold information about the probability of the random variable being realised at a particular value?
Example
Focusing on only discrete random variable,
we have
$$M_Y(t) = \frac{2^t+e^{3t}+4k}{3}$$ for $t \in \mathbb{R}$ and $k$ is a constant.
Question
For the moment generating function in the example, how is it possible we know $\text{Pr}(Y=1)$ without comparing to the known form of some famous probability mass function?
Answer: Note that with a discrete distribution the contribution of an atom of probability at some particular $x$-value $x_0$ has a characteristic effect on the mgf.
For example, the probability $p_0$ at $X=0$ will have a term in the mgf of $p_0$.
A probability of $p_1$ at $X=1$ will have a term in the mgf of $p_1e^t$.
A probability of $p_2$ at $X=2$ will have a term in the mgf of $p_2e^{2t}$.
A probabiity of $p_i$ at $X=x_i$ will have a term in the mgf of $p_ie^{x_it}$.
This all follows directly from the definition of the mgf.
The overall mgf will be a sum of such terms.
Consequently, if you see in the mgf a sum of terms of the form $ae^{bt}$ that means that you have probability $a$ at $X=b$. If you can, simply convert all the terms to be in this form.
Once you have it in the form of a sum of terms like that, you can just write down the probability at any specific value.
Answer: As you suggest in your question, the moment generating function holds information on the moments of a distribution. Except for notable examples (e.g. Bernoulli random variable) where the first moment also coincides with the probability of success of the trial, to the best of my knowledge don't hold any direct information on the probability mass.
What you are probably interested in is the probability generating function of a distribution. This on the other hand contains information on the probability mass associated to each value of the random variable's spectrum.
For a discrete non-negative random variable $X$ with $x \in \mathbb{N}$ and probability mass function $p$, then the probability generating function of $X$ is defined as
$$G_X(z) = E(z^X) = \sum_{x=0}^\infty p(x)z^x$$
The logic of it is very similar to that of a moment generating function: a clothesline where instead of hanging moments we hang probabilities of points on the spectrum. Taking the appropriate derivative and evaluating the function at 0 we obtain
$$P(X=k) = \frac{d^{(k)}}{dt^k}\frac{G_X(0)}{k!}$$
---Edit---
I'm sorry, I did not read the question thoroughly enough the first time, I'll clarify better off now.
One way you could go by doing this is using the connection between the mgf and the pgf of a discrete random variable. Using your definition of moment generating function and my definition of probability generating function, we can say that
$$M_Y(t) = E(e^{tY}) = G_Y(e^t)$$
and so a way to obtain probabilities directly from the moment generating function could be the following
$$\frac{1}{k!}\frac{d^{(k)}}{dt^k}M_Y(log(t)) \quad \text{evaluated at} \quad t=0$$
In your example, we would have
$$M_Y(log(t)) = \frac{2^{log(t)} + e^{3log(t) + 4k}}{3}$$
If you wanted to find $P(X=1)$, you would take the first derivative and let $t=0$.
Comment: Thank you for your answer. Suppose Y in my example is a discrete random variable that admits values other than positive integers, then is it possible to know Pr(Y=1) without considering probability generating function?
Comment: I have added some information. This still only works for a non-negative discrete random variable. If you want to expand the support, then one possible way to go would be to you a Fourier inversion, but it's slippery terrain
Comment: Thank you. But my prof says this is actually solvable without regards to pgf, I am now thinking about if the moment generating function corresponds to any common probability distribution, but I can't find one, do you have any idea?
Comment: Sorry for the mistake I made in the answer (I read it as $e^t$ instead of $2^t$), which creates problems because of and indeterminate form when evaluating the first derivative at $t=0$. The formula however should hold, and you might be able to get out of it by using l'Hopital's rule if the conditions hold.

With regards to your mgf, it does not remind me of any that I know. I would not know how to go by solving this problems without resorting to pgfs!
Answer: First, for a mgf $\DeclareMathOperator{\E}{\mathbb{E}} M_Y(t)=\E e^ {tY}$ we have that $M_Y(0)=1$. Using that you can find $4k=1$. Using as in the other answer the corresponding probability generating function (assuming that the given function is really the mgf of some random variable with support on the nonnegative integers), we could find the point probabilities by a series expansion. I did so in maple, but that gives a series with many negative coefficients, indicating that the assumption about the support is incorrect.  An example where this approach works.
So we should stay with the mgf.
If the mgf exists, in the sense that it exist for all arguments in some open interval containing zero, then it uniquely characterizes distributions, so that if two random variables have the same mgf (existing in above sense), then they have the same distribution. So, in principle $\mathrm{Pr}(Y=1)$ can be determined. But in practice that can be difficult. First, if $Y$ is continuous, then $\mathrm{Pr}(Y=1) =0$. But I do not know if/how we can determine from the mgf alone if the distribution is continuous ... In most practical (even theoretical) problems, apart from your quiz-type problem, we know beforehand at least the support of the random variable. Without that knowledge even numerical methods will have problems ...
Answer: Firstly, it is useful to note that the requirement that $M_Y(0) = 1$ means that we must have $k = \tfrac{1}{4}$.  Hence, this constant is fixed, and we can write the characteristic function of $Y$ as:
$$\varphi_Y(t) = \frac{1 + e^{(\ln 2) i t} + e^{3 i t}}{3} = \frac{e^{0 i t} + e^{(\ln 2) i t} + e^{3 i t}}{3}.$$
We can obtain the probability mass function for $Y$ by appropriate inversion of the characteristic function.  As a preliminary matter we note that:
$$\frac{1}{2T} \int \limits_{-T}^{+T} e^{i k t} dt = \text{sinc} (kT) \quad \quad \quad \quad \lim_{T \rightarrow \infty} \frac{1}{2T} \int \limits_{-T}^{+T} e^{i k t} dt = \mathbb{I}(k=0).$$
Hence, using a well-known Fourier inversion formula we obtain:
$$\begin{equation} \begin{aligned}
p_Y(y)
&= \lim_{T \rightarrow \infty} \frac{1}{2T} \int \limits_{-T}^{+T} e^{-ity} \varphi_Y(t) dt \\[6pt]
&= \lim_{T \rightarrow \infty} \frac{1}{2T} \int \limits_{-T}^{+T} \frac{e^{-iyt} + e^{(\ln 2 - y) i t} + e^{(3-y) i t}}{3}  dt \\[6pt]
&= \frac{\mathbb{I}(y = 0)+ \mathbb{I}(y = \ln 2) + \mathbb{I}(y = 3)}{3}. \\[6pt]
\end{aligned} \end{equation}$$
Hence, we see that $Y$ is uniformly distributed over the three points $Y=0,\ln 2, 3$.  (In fact, as Glen_b points out in his answer, with a bit of familiarity with Fourier transformation, this form can easily be seen from the original characteristic function, without having to do the maths.)