Getting the right balance of frequencies in mix

Question: I generally use Voxengo span vst to check if my frequency balance is right.
I would take a professionally produced song with a similar set of instruments that my song uses (or genre) and compare the frequencies through the voxengo span vst. To bring them closer I would use eq on my finally bounced mix, i.e. bounced after master buss fx things are done, like the EQ, Analoguer, widener, compressor, expander, limiter etc (this is not my exact fx-chain, however). Even though the frequency graphs are very close, the qualities of the sounds are way different. I do not understand how I am generating the mud in the low-mid frequencies though I try to get my kicks and basses separated and low-cut other things. And my highs do not sound high enough even when the frequencies above 5k-8k is boosted.
What is that I am doing wrong?
A thought, is my monitoring headphone (AKG K44) someway responsible?
Comment: This is very difficult to answer without an actual audible example. There are plenty of reasons why a mix may sound muddy; they mostly have nothing to do with master EQing, hence the equal-looking spectrums are pretty meaningless.
Comment: "*Analoguer, widener, compressor, expander, limiter etc*" Less is more, my friend. This is a pretty cluttered effects chain for the master bus. Also, you should use the worlds greatest tool for checking frequency balance: ears. You should have gotten two of them for free when you were born. You may have to train them up and sharpen them a bit, but they will always outperform any metering plugin or device ever made.
Answer: Matthew has provided a great answer. I want to expand a bit and look at different aspects of your question to help with some misconceptions that might be causing trouble.

I would take a professionally produced song with a similar set of instruments that my song uses (or genre) and compare the frequencies through the voxengo span vst... ...Even though the frequency graphs are very close, the qualities of the sounds are way different.

While it makes some sense to try this analytical approach to improving your mixes, it's just not going to work at all. First, the instrumentation is such a tiny piece of how a mix sounds that from a mix perspective, there's no reason to expect there to be any useful similarities between the material you are working on and the material you are comparing it two.
Second, no spectrum analyzer in the world has even one one-hundredth the resolution, detail, and analysis capabilities of even an untrained human ear. Basically, a spectrum analyzer is almost useless for making a mix sound right. That's why professional engineers spend tens of thousands of dollars on speakers and not much at all on spectrum analyzers. The only really effective analysis tools are on the sides of your head. The best thing is, they are free.

I would use eq on my finally bounced mix

This is good. EQ is one of the most important tools at all parts of the music production process, especially mastering. Only learning to EQ effectively will do more to improve your mixes than any other single thing you could learn.

bounced after master buss fx things are done, like the EQ, Analoguer, widener, compressor, expander, limiter etc

This is not so good. The analoguer, widener, and expander are almost certainly going to make your mixes sound worse and not better. Especially if you are mixing music. Most of these tools are meant to solve problems, but in solving those problems they create other problems. Usually the trade-off is worth it since the original problem is usually bad enough that the new problem is acceptable in exchange. It's highly unlikely that your mixes have the problems that are solved by "analoguers", wideners, and expanders, and if your mixes do have those problems, you need to fix them in another way (before they get to the mix buss). If your problem is mud, then cut these three out of your signal chain and never use them again.
Compressors and limiters are useful tools, but keep in mind that along with EQ, all of these tools do create problems when you use them. That means you want to use them as little as possible. If your mix doesn't sound full and clear when you throw the faders up with no plug-ins at all, then your problem is your recording process. If it does, then you're just looking for that extra 5% - 10% of improvement that you can get from careful and experienced use of EQ and compression (and reverb and delay). And everything you do to get that extra 5% - 10%, can take away from that initial fullness and clearness, so you have to be very gentle and back off if it doesn't actually sound better overall.
Compressors are the second most important tool in the engineer's toolbox (after EQ). Compression and EQ often require years of practice before an engineer knows how to use them effectively. That practice is going to involve EQing and compressing things gently and listening to the change in the sound. Only by listening critically can you develop your ears and create better sounding mixes. If you're looking at things while you're mixing, you're only distracting your brain from the important work it needs to do.

I do not understand how I am generating the mud in the low-mid frequencies though I try to get my kicks and basses separated and low-cut other things. And my highs do not sound high enough even when the frequencies above 5k-8k is boosted.

This probably won't make you feel any better, but everyone deals with exactly these kinds of problems when recording, mixing, and mastering. At each part of the production process, it's not too hard to take away something that's there and sounds bad, but it's usually much harder to add something that's good that's not there.
If clear highs are not coming out of the guitar amps and off the cymbals and drums, well you're not going to pick them up with a mic. If they are in the room but the mic is set up wrong, you won't get them recorded. If you get them recorded but you end up cutting them or compressing them out in the mix (yes, compressors mess with your highs and lows, that's part of the trade-off), then they won't be there any more when you want them at mastering. And if they aren't there when you're mastering, you pretty much can't add them back. Mastering cannot add very much at all. It can enhance what is already there and it can take away. Take away too much, and you can ruin things, so mastering is a very fine art that can be extremely challenging.
It's better to focus on making sure the instruments sound bright and not muddy in the room, then make sure you're capturing that sound in the recording. Then enhance and don't take away from that sound when mixing, and then when you get to mastering it will be pretty much good already.
In terms of cutting mud, if you can't go back to recording, you can do a little to cut the mud (since it's cutting, not adding). First, once again, you have to use your ears to tell you when you've cut enough but not too much. No plug-in has a "mud light" that lights up when there's mud and then turns off when the mud is gone, but your ears hear it right away and they will know when you've taken it out.
Mud usually somewhere between 150 and 300 Hz. It can be as high as 400 Hz or so but usually you want to start right smack dab at 250 Hz and try cutting that gently.
Here's the trick, though. You can cut all the 250 Hz right out of the mix and you definitely won't have any mud. The problem is you might not have any warmth or thump either. So you have to start cutting and listen for the change, and then slowly cut more and more until the mud is gone, and then listen and see if you still have thump and warmth. If you've still got them, then you're done and you got rid of the mud. If they are gone or not pleasing you any more, well ideally you'd go back to recording and mixing and see if you can get rid of mud as early as possible. Otherwise you have to spend a long time playing around with frequencies and different amounts of cuts to see if you can find a balance between mud, thump, and warmth.
Now you're thinking "Hey why can't I just boost the thump and warmth while I cut the mud?" If it's not already clear by now, trying to boost thump and warmth will pretty much end up boosting the mud back in again, and cutting and boosting the same thing just makes a huge mess. When mastering, it's much more common to cut than it is to boost.
Pro mastering engineers make most of their adjustments at a level of only +/- .5 dB, sometimes going as high as +/- 1.5 dB. From the standpoint of a mix engineer, those are almost inaudible changes, but in the master, it's a lot more sensitive. If you have to cut 3 dB or 6 dB to get rid of the mud, that probably means your mix is bad.

What is that I am doing wrong?

"Fix" as much as possible when recording, then try to do as little damage in the mix as possible, and your mastering will get a lot easier.
Use your ears and brain to analyze music, don't use your eyes.
Use hardly any plugins. Make the sounds sound good right away, and then don't mess up the goodness coming right from the instruments. A little bit of EQ here and there, a bit of compression on the bass and vocals, and some reverb to spice things up. Get really good at just those three effects and you'll stop wanting any other plugins (ok maybe delay). Your favorite mixes probably have none of the crazy plugins that plug-in makers put in their "mastering suites". Some of those people are just trying to get your money. Others are trying to give you a lot of good tools just in case you need them, expecting that you'll hardly ever use half of it, which is why they threw it in with the EQ and compression anyway - because they'd never sell it on its own.
Expect to spend years practicing and mixing and hating your mixes before you start to sound good. Pro engineers have decades of experience. The guy who mastered Taylor Swift's 1989 had already been mastering for ten years when Taylor Swift was born in 1989. They're not pros because someone gave them really awesome tools, they were given awesome tools because they are pros. They are pros because they have tons of experience and training from other pros.

Response to comment:

However, is an AKG K44 something I should let my ears trust?

No.
Unfortunately, you can't trust any pair of speakers or headphones. Not 100%. Every system has problems, and even if you magically had perfect speakers (BTW, speakers are generally better than headphones for monitoring for many reasons), your room would cause problems with the sound coming out of the speakers and so you will always be hearing something that is a little off.
So what do you do about that? Well once again it takes practice and experience to learn how your monitors are lying to you. Once you understand the limitations of your monitors, then you can compensate. The way you learn is by listening very carefully to your monitors and then compare them with all kinds of other speakers.
For example, I once had a set of monitors where I would mix the snare to a certain level, and then when I listened to my mixes in my car, on headphones, on my regular stereo, etc., the snare always seemed way too loud. So basically my monitors were lacking in an important snare frequency. So I had to make the snare sound "too quiet" on my monitors so it would sound right everywhere else.
Finding "good" monitors is not as important as learning how your monitors actually sound compared to where you want your mixes to be. Again, this takes a lot of time and practice. The more you read, research, and especially practice, the better your mixes will get.
Comment: I was looking for a detailed thing like this which would take out the points off my question and advise accordingly. However, is an AKG K44 something I should let my ears trust? The confusion is due to the fact that every pair of headphones/speaker system here is advertised as the _The #1 Studio Monitor_ and the ones I see in production videos on YouTube costs 1.5x to even 2x the actual price. Thanks!
Answer: equal looking frequency spectrum's do not mean that the sound will be perceived similarly. Dynamics, instrument separation, clashing tonal centers, there are a myriad of things responsible for how a mix is perceived that don't get translated to a frequency analyzer. (i use the same plugin too).
instead, use your ears to check if the mix is sounding the way you want, compare with some solid references on multiple systems(speakers, headphones, car), and make sure to monitor the condition of your ears. fatigued ears won't be accurate at all. keep doing this and your perception of frequencies, balance and presence will get tighter and tighter. the plugin is nothing more than a tool for checking and confirming what you're hearing.
i can only help so much without an audio example, but in short: don't let the plugin try to replace what your ears should be doing.
(if your only mixing on headphones you NEED some sort of open air speakers to reference on)
Comment: I wish I could upvote this 5 times because the asker needs to see how important this is.
Comment: I totally agree, as well with the other comments above, specially the "less is more" part. I would add that many times the problem with a mix starts with... the actual mix part, i.e. relative volume level of tracks. People tend to dedicate  too much time to EQuing, compression, etc. and not nearly enough time fine tuning the volume levels. Of course as has been said, we can't know if that's the case without hearing the track.
Answer: Try to be a composer before being a mixer.  A good composer doesn't write close-position chords in the low range of the piano - because they sound muddy.  He doesn't have several instruments, particularly ones in the same frequency range, playing similar but not identical things - because it sounds messy.  He LEAVES ROOM so that what he wants to be heard, is.
Above all, he rarely has any instrument constantly repeating the same pattern (yes, I know, Ravel's 'Bolero').
If you've constructed or recorded a song that needs "remedial mixing", see what you can do about making the instruments "listen to" each other rather than constantly competing.  Where could an instrument play less (or not play at all)?  Then you can leave your guitar SOUNDING like a guitar, your bass like a bass, rather than carving their sounds up with EQ.
Comment: Thank you so much for the suggestion. This used to cause some great problems in my mix until only two months back when I learnt that what creates wonder in solo may actually ruin the entire thing in a mix. It gets more difficult when working with VST instruments since the manufacturers of the cheap/free VSTi's usually  do very bad in recording/sampling the sounds from the real instruments, especially the acoustic ones like piano, guitar, and the expensive ones are way expensive!


How to move a field to a different region using Omega sub-theme / D7?

Question: I used to be pretty good at theming Drupal sites, but I haven't done it much since D7. I added a custom field to my Basic content type and I want to put it in a Sidebar if it exists. What's the best way to accomplish that?
Answer: Thank you IRC! At least two modules will help with this (quotes included are from their project pages):

CCK Blocks:

Since version 6.x-1.1 , the module does not hide the field in the node's content area anymore. You can do that for yourself in the display settings for your content type.
CCK blocks will define a display mode named "CCK Blocks", which you can use to configure the display of fields when they are appearing as blocks.
This allows you show the field both in the node's content area and in the CCK block, with different display settings.

Display Suite:

... allows you to take full control over how your content is displayed using a drag and drop interface. Arrange your nodes, views, comments, user data etc. the way you want without having to work your way through dozens of template files. A predefined list of layouts (D7 only) is available for even more drag and drop fun!
By defining custom view modes (build modes in D6), you can define how one piece of content should be displayed in different places such as teaser lists, search results, the full node, views etc.


Large performance variance when using back-propagation in neural networks for feature extraction

Question: I'm using a multi-layered neural network for feature extraction (similar to deep belief network).
I test the performance of my model with cross-validation.
When I'm using back-propagation to train my network, I get a very large variance in the performance.
Seems like it is really crucial which samples (and maybe in what order?) are used for back-propagation.
Is it this a known issue with NN?
I tried using methods from here (I have unequal classes) which helped performance but not the variance.
UPDATE: I'm using 256 features and I have about 2000 training samples. I'm training my network with layer-wise pretraining and then back-propagation. I'm using weight decay (around 0.02) and a learning rate of about 0.01 .
Thanks.
Comment: What is large performance variation? 1%? 10%? 25%? Over how many datapoints?
Comment: How large are your training and test sets? Can you give us more detail on how you trained the network (for example, on which hyperparameters you used)?
Answer: Yes, it is well-known that there are many local minimums. How you initialize the network and how you order the data affect the performance, which means there is a large random component.
Even with one hidden layer, the number of local minimums may be exponential in the number of hidden nodes. This is actually easy to see. Suppose you are approximating a function of one variable which is constant outside two small patches. A neuron which is unsaturated in both patches isn't doing much. So, neurons will tend to saturate in one patch or the other, and it is hard for a neuron to switch where it is unsaturated without going through a stage where it contributes nothing. Therefore you get a local minimum for most of the $2^n$ assignments of neurons to patches.
See Erhan et al, "Why Does Unsupervised Pre-training Help Deep Learning?" section 6.3 "Visualization of Model Trajectories During Learning." Although the graph shows that the local minimums found by random initialization differ greatly from the local minimims found by pre-training, it also shows that there isn't a convergence in parameter space of the models with pre-training (or without). Figure 2 shows there is a wide dispersion of error rates even within a training method.
Comment: I don't understand your concrete example of hidden producing hidden minima. Can you elaborate or point me to a more detailed explanation?
Comment: Additionally, it is generally believed that the more hidden neurons you have, the easier it is to escape local minima. That is because the probability of a subset of hidden neurons being near a better minima will increase with the number of units and tend to dominate during training.
Comment: Not hidden minimums, local minimums. I don't know if the example is in the literature. This is different from Auer et al "Exponentially many local minima for single neurons," which talks about exponentially many minimums in the dimension of the inputs.


C++. Weighted std::shuffle

Question: Is there a way to do nice and elegant weighted shuffling using standard library?
There is std::discrete_distribution.
What I want is something like this:
std::vector<T> data { N elements };
std::vector<int> weights { N weights };
std::shuffle(std::begin(data), std::end(data), something based on discrete distribution);

Comment: Could you please elaborate (maybe with an example) on what do you mean by "weighted shuffling"?
Comment: @Bob__ I would venture something like this: http://nicky.vanforeest.com/probability/weightedRandomShuffling/weighted.html
Comment: @SeverinPappadeux Ah. So something like this: https://wandbox.org/permlink/SuTYLHHG8brNNieq
Comment: @Bob__ Yep, looks good... You ought to post it as an answer
Answer: If OP intent is to shuffle a list r of items

such that, given a list of weights w, the element a[i] with weight w[i] should be the first element of the random shuffle r with probability w[i]/sum(w).

As stated in the page linked by Severin Pappadeux:

Weighted random shuffling is the same as weighted random sampling from a list a without replacement. That is, choose with probability w[i]/sum(w) element a[i] from a. Store this element in a list r. Then, remove element a[i] from a and w[i] from w, and select a new element of the modified list a, and so on until a is empty.

I'am not aware of such an algorithm in the Standard Library, but a simple implementation could be:
#include <random>
#include <algorithm>
#include <iterator>

template <class D, class W, class URBG>
void weighted_shuffle
    ( D first, D last
    , W first_weight, W last_weight
    , URBG&& g )
{
    while (first != last and first_weight != last_weight)
    {
        std::discrete_distribution dd(first_weight, last_weight);
        auto i = dd(g);
        if ( i )
        {
            std::iter_swap(first, std::next(first, i));
            std::iter_swap(first_weight, std::next(first_weight, i));
        }
        ++first;
        ++first_weight;
    }
}

Live example HERE.
Comment: @SolomonUcko Well, [yes](http://quick-bench.com/9A3LIIROzxSbRPdMXuUQPjJq1I8), it could be or [not](http://quick-bench.com/na2bMzmzW83v-HKIu4uJNzu44lc). When I wrote this, I was thinking about containers where `std::next(first, i)` would be O(n) (note that `std::shuffle` requires random iterators), so that it could have made sense to optimize that corner case. Of course in those cases it would be better to copy the data into a vector and transform that instead. In general, I agree, it's a *premature* optimization and I'll probably end up removing it.
Comment: nice. but why the `if ( i )`?
Comment: @JHBonarius well, premature optimization, I think. It's just to save the unnecessary *cost* of swapping and advancing the iterators. The random part should be the more time consuming, anyways.
Comment: ah, I get it now. It prevents swapping an element with itself.
Comment: I needed to do this: std::discrete_distribution dd(first_weight, last_weight)
Comment: @supo Yes, that kind of type deduction is a C++17 feature. If you can only target C++11, you can do something like this: https://wandbox.org/permlink/Bf3MIVP1avVIYjAG
Comment: @Bob__ Frankly, the branching could even be slower than the occasional extra swap.
Comment: I suspect this answer runs in time O(n^2) because the discrete_distribution constructor is O(n).
Answer: Check out Weighted Random Sampling (2005; Efraimidis, Spirakis).  If you create a list of values -pow(rand(0,1), weights[i]) and sort this, you will get what you want.
Equivalently (and slightly faster), this list can be created using an exponential distribution.
std::vector<size_t> weighted_shuffle(std::vector<double> const &weights, std::mt19937 &rng)
{
    //auto uniform_dist = std::uniform_real_distribution<double>();
    auto exp_dist = std::exponential_distribution<double>();

    std::vector<std::pair<double, size_t>> index_pairs;
    index_pairs.reserve(weights.size());
    for (size_t i=0; i<weights.size(); ++i) {
        double const p = weights[i];
        // from Efraimidis, Spirakis
        //index_pairs.emplace_back(-std::pow(uniform_dist(rng), 1.0/p), i);
        // equivalent and a bit faster
        //index_pairs.emplace_back(-std::log(uniform_dist(rng))/p, i);
        // equivalent and fastest
        index_pairs.emplace_back(exp_dist(rng)/p, i);
    }
    std::sort(index_pairs.begin(), index_pairs.end());

    std::vector<size_t> indices;
    indices.reserve(weights.size());
    for (auto const &[w, i] : index_pairs)
        indices.emplace_back(i);
    return indices;
}

C++. Weighted std::shuffle


Pass A Generic Codable Type as Parameter to a Method for Saving to Realm

Question: I am trying to create a generic method for decoding some JSON data. I need to cast the JSON data into Objects for later saving in Realm.
For example: Getting the makes, models, colors, and body types of vehicles.
In each of my JSON calls to the results are formatted exactly the same (See my structs at the end of the question). For brevity, I am only showing you Makes and Models, but Colors and Body Types are exactly the same, just with the name changes.
I currently have four methods that I call where Makes.self is replaced with one of the other structs.
if let results = try? JSONDecoder().decode(Makes.self, from: jsonData)) {
        DispatchQueue.main.async {
        //save data to realm
        self?.save(objects: results.data )
    }
}

Once I get my JSON Data, I would like to send my data to a generic method for processing.
So I could call something like :
process(jsonData, modelType: Makes.self)
process(jsonData, modelType: Models.self)
process(jsonData, modelType: Colors.self)
process(jsonData, modelType: Bodies.self)

I have tried variations on generic types but I can't seem to get it right.
func process<T:Codable>(_ jsonData: Data, modelType: T.Type = T.self) {

        if let results = try? JSONDecoder().decode(modelType.self, from: jsonData) {
            DispatchQueue.main.async {
                //save data to realm
                self?.save(objects:results.data)
            }
        }
}

How can I pass a Decodable Protocol type as a generic?
MAKES
import RealmSwift

struct Makes: Codable {
    let result: String
    let data: [Make]

    enum CodingKeys: String, CodingKey {
        case result = "Result"
        case data = "Data"
    }
}

class Make: Object, Codable {
    @objc dynamic var key: String
    @objc dynamic var value: String
    @objc dynamic var shortCode: String
    @objc dynamic var active: Bool

    enum CodingKeys: String, CodingKey {
        case key = "Key"
        case value = "Value"
        case shortCode = "ShortCode"
        case active = "Active"
    }
}

MODELS
import RealmSwift

struct Makes: Codable {
    let result: String
    let data: [Make]

    enum CodingKeys: String, CodingKey {
        case result = "Result"
        case data = "Data"
    }
}

class Make: Object, Codable {
    @objc dynamic var key: String
    @objc dynamic var value: String
    @objc dynamic var shortCode: String
    @objc dynamic var active: Bool

    enum CodingKeys: String, CodingKey {
        case key = "Key"
        case value = "Value"
        case shortCode = "ShortCode"
        case active = "Active"
    }
}

Answer: Why would you expect any Codable type to have a data property? results.data cannot work... You need to make T a subclass of Object to be able to save it to Realm and also Decodable to be able to pass it to the decode method.
func process<T:Object>(_ jsonData: Data, modelType: T.Type) where T:Decodable {
    if let results = try? JSONDecoder().decode(modelType.self, from: jsonData) {
        DispatchQueue.main.async {
            //save data to realm
            self?.save(objects:results)
        }
    }
}

Comment: `results.data` is the property that contains the object I want to save once it has been decoded.  In your example, the generic parameter of `Decodable` can not be used in a function signature. Among two other errors with the `modelType.self`
Comment: @user-44651 check my updated answer, it compiles fine now. As I've already said, `Codable` doesn't contain a `data` property, so you cannot use that. You need to pass the actual type that you want to decode into the function. If all of your encoded `Object` subclasses are part of a common root object in the JSON, make that root object generic too.


Sending an email to about 10K users (NOT SPAM!)

Question: After an update to my website I need to send a mail to all my users (about 10K).
I got the data email,user,new_pass in a plain CSV file.
Do you know any good service that can import the mail template and user data and send the mails?
Thanks
Comment: When sending 10.000 emails, there's a risk that your ISP will block your account during or after sending those messages! So, call your ISP to notify them that you're going to send a large amount of emails to subscribed members! Some ISPs already block users s soon as when only 50 emails are sent out within a short timespan!
Comment: see also http://serverfault.com/questions/68357/whats-the-best-way-to-send-bulk-email
Comment: What website does this belong to? I am inclined to believe it should be on SF, but I am not too sure
Answer: If you have a website that has that many users, I guess you have full control over a server.
I highly recommend you install PHPlist. It is overkill on small sites, but for a site with as many users as yours, it has many nice features such as auto pruning of dead addresses (and on a 10k list, you need it!).
Full features
Answer: Preventing your server from being listed on one of the many spam blacklists (you can check if you are already listed here) and managing/configuring the underlying mail server (postfix etc) is a considerable amount of hassle. If you are considering sending more than one mail to your subscribers, I would recommend outsourcing this to a 3rd party such as mailchimp (pay as you go pricing would be preferable). There is also a free version for up to 500 subscribers.
If you simply require a single mail shot, then make sure:

Your server has MX and reverse DNS records
You have SPF DNS records (many servers reject
mail without a valid SPF, GMail for
example)
Your mailserver's HELO
response matches your hostname
Your mailserver is not an open relay
Answer: I second the PHPList recommendation.
It allows you to send mails in batches and to throttle the send process so that you do not exceed your IPS's hourly limit.
It is a little bit of work to set up and configure.
I do think that ConstantContact, MailChimp etc charge exorbitant fees for their services, and they get away with it because of the barriers that a normal guy sending out emails faces. For larger numbers of subscribers, this quickly turns into real money.
If this really is a one-time deal, you probably don't want to set up PHPList. It took me a few days and several test mailings to get it working. In this case, I recommend http://www.easycontact.com/packages.html (have not actually used them) because their pricing is on a per-campaign basis as opposed to a subscriber-basis.
Answer: We use PHPlist and it can be a bit of work to get going. Not even so much for the technical details of installing PHPlist and your rDNS settings, DKIM, SPF, etc., but getting your ip whitelisted, working with the different webmail providers to pass your e-mail on. I think it comes down to how valuable your time is. It took me about a day to get the software technically running and another week or part time work to get the majority of the e-mail providers accepting our e-mail.
If you have the time to invest to get PHPlist running, it's worth it, but if not, I'll put in another plug for ConstantContact or iContact.  I've not used either, but a few friends I know do, rather than administer it yourself.
Answer: PHPList will work but if you don't want to use existing infrastructure, which I'd recommend to keep any possibilities of being flagged as a spam server, you can use a commercial mailing service such as mailjet.com
I personally try to separate mass mailing from my production infrastructure.


Extremely weird IE7/8 border/opacity compatibility issue

Question: The weird problem is borders disappearing when Opacity is applied in IE/8/9, but NOT in 7!
I've basically got a menu with tabs on top of the screen.
I.e:

  button 1...<*/td>
  button 2....<*/td>
  .
  .
  .

column 1

column 2

column 3

column 1

column 2

column 3

column 1

column 2

column 3

And this is the beautiful result when background-color is applied on IE8:
Comment: I eventually had to resort to moving the background color from the td to a div within the td(the div had to be slightly larger than the td to make it appear seamless) , while keeping the opacity and border on the td and having background:none on the td;
Comment: @Metatron: interesting new IE8 hack. I'm gonna try your solution and let you know. Thanks for sharing this idea.


Laravel nova keeps throwing exception Route [nova.login] not defined

Question: I've already posted this to https://github.com/laravel/nova-issues sadly hadn't got any love from there, so I'd like to know if anyone experienced this issue and how they resolved it.

Laravel Version: 5.7.27
Nova Version: 1.2
PHP Version: 7.2.12
Operating System and Version: MacOS 10.13.6
Browser type and version: Chrome (Latest) FireFox (Latest)

Description:
Whenever I access my nova route in /admin <-- (this is where my nova resides) I get this exception thrown from/vendor/laravel/framework/src/Illuminate/Routing/UrlGenerator.php line 389, throw new InvalidArgumentException("Route [{$name}] not defined."), my nova was installled correctly and currently I don't have any other existing app routes this is a fresh install of laravel and fresh install of nova.
It was working fine until I introduced the custom path.
Steps To Reproduce:

Change the 'path' => '/admin'
Run php artisan config:clear or php artisan config:cache
Comment: The title of your question mentions "nova.login", but the body of your question says "{$name}".  Is the error you're seeing mentioning nova.login?
Answer: Check your NovaServiceProvider.php and make sure it has withAuthenticationRoutes() in the routes() function like this:
protected function routes()
{
    Nova::routes()
            ->withAuthenticationRoutes()
            ->withPasswordResetRoutes()
            ->register();
}


Operations on Binomial coefficients

Question: If $t_0, t_1, t_2, t_3,....., t_n$ are terms in the expansion of $(x+a)^n$ then prove that
$(t_0 - t_2 + t_4 -.....)^2 + (t_1 - t_3 + t_5 - .....)^2 = (x^2 + a^2)^n$
I have tried several ways to solve question including using expansion of conjugate ie $(x-a)^n$ and then trying addition annd subtraction of the series but i always reach a dead end. Plz suggest me an algebraic method to solve this question.....thanks in advance!!!
Note- t0 indicates term no.
Answer: HINT
Think about $(x+ia)^n$ where $i$ is the complex number, $i^2=-1$
Answer: Hint. Let $i$ be the imaginary unit then the power $i^k$, for $k \geq 0$ is equal to
$$1,i,-1,-i,1,i,-1,-i,1,i,-1,-i,\dots$$
Hence
$$(x+ia)^n=(t_0 - t_2 + t_4 -\dots)+i(t_1 - t_3 + t_5 -\dots)$$
where $i$ is the imaginary unit.
Comment: Oh...thanks a lot...i got the missing link!!

Operations on Binomial coefficients


Is it ok to change between keyboard style and SATB style harmony notation?

Question: I began a harmony exercise in keyboard style but now my chords are opening up and I am finding it very hard to remain in keyboard style whilst still maintaining the smoothest voice leading. There seems to be a trade off required somewhere. If I remain in keyboard style my voices might need to leap more between certain chord changes. Is it a common problem in keyboard style in the sense that it may be necessary to leap more than in the SATB voicings?
Another way to ask the same question: In keyboard style is it normal to use more leaps or should the same smoothness of voice leading be achievable as in regular SATB style?
Please see an example. My voice leading from the I6 chord to the vii6 chord could be much smoother if I could keep opening up the voicing. But if I want to keep the keyboard style shapes in the right hand I would have to leap up from tenor A to D in the next chord. Is that ok?
Answer: Switching between the two doesn't usually happen, but there are a few caveats that may help the situation:

In many cases, keyboard style is chorale style, just that the tenor is now an octave higher and thus in the alto voice. This isn't always the case, but it shows how similar the two different "styles" actually are.
In other instances, the tenor is high enough that, although the excerpt may be written in chorale style (with the tenor in the bass clef, stems up), it's effectively keyboard style. Keep in mind that the tenor is comfortable a bit above middle C; many students push the tenor too low, afraid to occasionally use ledger lines for the tenor.
Lastly, although we still want smooth voice leading in keyboard style, sometimes voice overlap is unavoidable. So if one of your problems in keyboard style is voice overlap, I would say you should feel comfortable allowing it; especially if the soprano is more melodically oriented and with a few expressive leaps, voice overlap is all but impossible to completely eliminate.
Comment: Dekka, in keyboard style arent the bass tones played by the left hand only? I thought this was the way of it.... also it is supoosed that the upper 3 notes stay in one octave so can be played by one right hand.
Comment: Thank you. Would you say that bigger leaps are inevitable when using keyboard style? For example, leaps of a 4th in the inner voices.
Comment: I added an example. Look at the voice leading from I6 to vii°6. In SATB I could lower that A to G# but now it seems my only option is for the tenor to leap up to D.
Comment: @armani Yes, bigger leaps are often a part of keyboard style. In your example, your tenor could leap up to D, but I would argue it could even leap up to the F# above it!
Comment: @armani - If keyboard style means keeping the whole piece playable by a pianist, then why can't you drop the tenor from A to G# and assign the G# to the left hand?
Answer: You can write what you want.   But surely 'keyboard style' should be playable on a keyboard, SATB should be singable by those four voice types?
Of course, even if you're writing for a piano sound, there's now also 'sequencer style' where there's no requirement for consistency in voicing or playability by two hands on a keyboard.   And that's fine.   Although it might not be appropriate in a harmony exercise!


How to get rid of scroll bars/arrows in Wordpress, when using font style called 'Pre'

Question: When on Wordpress I use font Pre, instead of seamlessly showing up formatted as Fixed space font, which I was going for, I get

fixed space font
inside rectangular space area, colored in gray color to accentuate itself
it has horizontal and vertical scroll bars on right and bottom, with arrows.

Those arrows look ugly and distract from the overall placement.  moreover, there is nothing to scroll, so the arrows and scroll bars are meaningless.
Question:
How can I get rid of those scroll bars and arrows, while keeping fixed font styling?  I have WordPress 4.1 with default theme, Twenty Fifteen.
More on "Pre":
For clarity, I do not mean HTML's
 tag.  I mean the WP's Font Style called  Pre.  Upon examination, that font does insert HTML tags
 around the "Pre"-styled text block, but I am guessing it is the CSS styling or possibly the WP's Theme that causes those arrows and scroll bars to show up.
Comment: Do you mean the  tag?
Comment: No.  In WP Admin's "Edit Post" section, there is a "ribbon" with text formatting tools.  There is one that says "Paragraph" and allows you to change the level of text heading from `Heading 1` to `Heading 6`.  It also has an option called `Pre`.  I assumed it does fixed space font, which it does, but using it yields the above problem, when viewing the post in "user mode".
Comment: Heading 1 is just human for `` tag, the same way Pre is just human for `` - see here: https://developer.mozilla.org/en-US/docs/Web/HTML/Element/pre - It may not be what you're thinking it is. Aside that, just inspect element and play with the css. That's how you adjust it if you really want to, but I would say just use anything that's not pre since it is likely styled that way for a reason
Comment: that inserts a  tag I would guess. Click the `Text(HTML)`  in the top right of the text editor to see if there are `` tags.
Comment: Yes, that text gets surrounded by simple `` tags.
Also, the parent container uses a class called `entry-content`.  Looking at CSS I do not see anything that will cause those scroll bars, but I am guessing this is Theme-dependent.
Answer: By the sound of it you need to use the CSS overflow property. You would add this to your theme's style.css file.
pre {
  overflow: auto;
}

Note: If that doesn't work let me know and adjust it accordingly based on the article below.
See: http://www.w3schools.com/cssref/pr_pos_overflow.asp


Wallpaper not scaling correctly when placing it as activity backgroung

Question: I have a custom .png image set as my Android device's wallpaper.
As I understand it, wallpaper size should be 960x800 pixels but the Android device will only present the middle part of the image and the extra right and left parts are for when you scroll right and left on the screen. So I've taken a small image that I want it to be in the center of the screen (350x350) and filled the rest of the image with a black surrounding.
My problem is: I have an activity in my application that needs its background to be similar to the wallpaper (to imitate a blank activity with just a TextView presented on it).
I'm using this code to do so:
<code>private WallpaperManager wallpaperManager;
private Drawable wallpaperDrawable;
private RelativeLayout rtemp;

rtemp = (RelativeLayout)findViewById(R.id.temp_layout);
wallpaperManager = WallpaperManager.getInstance(this);
wallpaperDrawable = wallpaperManager.getDrawable();
rtemp.setBackground(wallpaperDrawable);
</code>
But the screen appears to have the wallpaper as a whole and not just the middle part anymore (it basically shrink down the image) and it is not consistent with the regular wallpaper anymore.
Are there any suggestions on how to solve it? Is there a way to avoid image shrinking on the activity or is there a way to make the image not spread as the wallpaper screen?
Thanx a lot!
Answer: Better use FrameLayout which contains both your RelativeLayout over an ImageView. Imageview gives you the options to scale your image & some furthermore customization.
Comment: But wouldn't it still scale down the wallpaper image to fit to the screen? while the actual wallpaper is much wider...
Comment: Its not, if you are using it with the correct scaletype & you can customize the imageview without being worried about your app's layout.

See this
http://developer.android.com/reference/android/widget/ImageView.ScaleType.html
Comment: I am not asking any clarification from anyone. I am just posting the answer which I think can resolve his problem.


shape and rate of the square of a variable having a gamma distribution

Question: from this answer (Expectation of a squared Gamma) I would like to know the shape and rate parameters of a squared gamma. I struggle a bit here.
<code>Gamma(shape, rate)^2 -> Gamma(?, ?)
</code>
Thanks.
Comment: How do you know that the square of a Gamma even has a shape and rate parameter analogous to those for the Gamma.
Comment: Your title and your body seem to ask different things. The title asks about a variable whose square is gamma while the body seems to ask about a variable which is the square of a gamma (which are different things). Both seem to rely on the mistaken idea that the result will itself be gamma. It is not so. Please clarify what you are asking.
Answer: It seems that by squared gamma, you mean:
If $X \sim \Gamma(\alpha, \lambda)$, then $X^2 \sim \Gamma(\mathrm{?}, \mathrm{?})$.
If this were the case, then unfortunately, $X^2$ does not follow a Gamma distribution.
To see this, assume $X \sim \Gamma(\alpha, \lambda)$, let us write $Y = X^2$. Then clearly, both $X$ and $Y$ have $\mathbb{R}^+$ as their supports. Now, by transformation of random variable, we may find the p.d.f. of $Y$.
For $y>0$, we have:
$$
\begin{align}
f_Y(y) &= \frac{\mathrm{d}}{\mathrm{d}y} \mathrm{Pr}(Y\le y) \\\\
&= \frac{\mathrm{d}}{\mathrm{d}y}\mathrm{Pr}(X\le \sqrt{y}) \\\\
&= \frac{\mathrm{d}\sqrt{y}}{\mathrm{d}y}\frac{\mathrm{d}}{\mathrm{d}\sqrt{y}}\mathrm{Pr}(X\le \sqrt{y}) \\\\
&= \frac{1}{2\sqrt{y}}f_X(\sqrt{y}) \\\\
&=\frac{1}{2\sqrt{y}}\frac{\lambda^\alpha}{\Gamma{(\alpha)}}(\sqrt{y})^{\alpha - 1}\mathrm{e}^{-\lambda\sqrt{y}} \\\\
&= \frac{\lambda^\alpha}{2\Gamma{(\alpha)}}(\sqrt{y})^{\alpha - 2}\mathrm{e}^{-\lambda\sqrt{y}} \\\\
\end{align}
$$
and $f_Y(y) = 0$ otherwise.
From the form of the p.d.f., we may note that $Y$ does not follow a Gamma distribution, at least not a "usual" one. Nevertheless, for $y>0$, we may write:
$$
\begin{align}
f_Y(y)
&= \frac{\lambda^\alpha}{2\Gamma{(\alpha)}}(\sqrt{y})^{\alpha - 2}\mathrm{e}^{-\lambda\sqrt{y}} \\\\
&= \frac{(\lambda^2)^{\frac{\alpha}{2}}}{2\Gamma{(\alpha)}}(y)^{\frac{\alpha}{2} - 1}\mathrm{e}^{-(\lambda^2 y)^{\frac{1}{2}}} \\\\
\end{align}
$$
Then it can be viewed as a Generalized Gamma Distribution with parameters $p=\frac{1}{2}$, $d=\frac{\alpha}{2}$ and $a=\lambda^{-2}$. Noted other parametrizations are also possible.


Trying to create sorting code with 3 trackbar values using the if command in c#

Question: I have to create a windows form with(c#),

3 trackbars
1 button
1 label

Using the if and else if commands.
My problem is,
I cant get the end result to show up in label1.
I did manage to display them in labels2-4. But this is not the way to go for this assignment.
here's the code.
    {
    public Form1()
    {
        InitializeComponent();
        trackBar1.Maximum = 10;
        trackBar1.Minimum = 0;
        trackBar2.Maximum = 10;
        trackBar2.Minimum = 0;
        trackBar3.Maximum = 10;
        trackBar3.Minimum = 0;
    }

    private void button1_Click(object sender, EventArgs e)
    {
        int a;
        int b;
        int c;

        a = Convert.ToInt32 (trackBar1.Value);
        b = Convert.ToInt32 (trackBar2.Value);
        c = Convert.ToInt32 (trackBar3.Value);

        int d;
        int E;
        int f;

        if ((a < b) && (a < c)&& (b> c))
        {
            label2.Text = Convert.ToString(d = a);
            label3.Text = Convert.ToString(E = c);
            label4.Text = Convert.ToString(f = b);
            label1.Text =Convert.ToString (string d,e,f);
        }
        if ((a < b) && (a < c) && (b < c))
        {
            label2.Text = Convert.ToString(d = a);
            label3.Text = Convert.ToString(E = b);
            label4.Text = Convert.ToString(f = c);
        }
        else if ((a > c) && (a > b) && (b > c))
        {
            label2.Text = Convert.ToString(d = c);
            label3.Text = Convert.ToString(E = b);
            label4.Text = Convert.ToString(f = a);
        }
        else if ((a < c) && (a > b) && (b > c))
        {
            label2.Text = Convert.ToString(d = c);
            label3.Text = Convert.ToString(E = a);
            label4.Text = Convert.ToString(f = b);
        }
        else if ((b < a) && (b < c) && (c > a))
        {
            label2.Text = Convert.ToString(d = b);
            label3.Text = Convert.ToString(E = a);
            label4.Text = Convert.ToString(f = c);
        }
        else if ((b < a) && (b < c) && (c < a))
        {
            label2.Text = Convert.ToString(d = b);
            label3.Text = Convert.ToString(E = c);
            label4.Text = Convert.ToString(f = a);
        }
    }

I need label1.Text to be the result of labels 2-4, I tried this label1.Text= Convert.ToString(d = b + E = c + f = a) and I tried replacing the + with , but that wont work either. I think I have to use a string format but I wouldn't know how and if its needed.
Answer: Is this what you want to do?  I would put this below your if statements so it's called under every condition.
label1.Text = (int.Parse(label2.Text) + int.Parse(label4.Text)).ToString();

Comment: almost, I have to remove the other labels. Cant just make em invisible. But thanks, I was looking or methods to get that all in ma label 1. totally forgot about ToString.
Answer: I think you want the contents of the labels label2, label3, label4 together to be shown in label1? Put after your ifs the line
label1.Text = d.ToString() + " " + E.ToString() + " " + f.ToString();

Comment: Long live the king, this was exactly what I was looking for. Totally forgot about ToString.
Answer: When concatenating string it is better to use string.Format
In your case it will be
label1.Text = string.Format("{0} {1} {2}", d,E,f);


Lie algebra of groups' element centralizer

Question:
Let $G$ be a Lie group. Let $Z_G(g)$ be a centralizer of $g \in G$. Prove that $Z_G(g)$ is an closed Lie subgroup of $G$ and prove that Lie algebra of $Z_G(g)$ is $\mathfrak  z = \{x \in \mathfrak g \mid \operatorname{Ad}_g(x) = x\}$.

The first part is easy since we can show that $Z_G(g)$ is a stabilizer of $g$ of action of $G$ on itself by conjugations ($h \mapsto hgh^1$).
The second part is trickier. Let $x \in \mathfrak g$ be such that $\operatorname{Ad}_g (x) = x$. If $\phi : G \rightarrow G$ ($h \mapsto ghg^-1$), then we can use functoriality of exponential map
$\require{AMScd}$
$$\begin{CD}
\mathfrak g @>\operatorname{Ad}_g>> \mathfrak g \\
@V\operatorname{exp}VV @VV\operatorname{exp}V \\
G @>>\phi> G
\end{CD}$$
to deduce that $\operatorname{exp}(x) \in Z_G(g)$. But how can I see that $\mathfrak z$ is exactly fixed points of $\operatorname{Ad}_g$?
Answer: Suppose that $x\in \mathfrak{z}$ for every real $t$, $g\exp(tx)g^{-1} = \exp(tx)$. This implies that $\left.\frac{d}{dt}\right|_{t=0} g\exp(tx)g^{-1} = \left.\frac{d}{dt}\right|_{t=0}\exp(tx)$. This is equivalent to saying that $\operatorname{Ad}_g(x) = x$.


App disappears when I deploy onto CloudBees with IntelliJ

Question: I am on the free tier of CloudBees.  I want to deploy a simple Clojure web app.
First, I create the app in CloudBees' app manager.  Once I do this, everything looks fine in the server logs.  I see the default application come up, and I can browse to it.
Then I try to deploy my own code from IntelliJ.  When I do, IntelliJ makes the connection to CloudBees successfully, and sits around for about 5--10 seconds.  Then it says that a server-side error occurred, and I should check server logs.
When I go to check the logs, I find that the app is no more.  It's as if IntelliJ deleted it.  I am able to re-create it with the same name.  I've tried this several times, with the same result.
How can I get more visibility into what's going on?
Answer: You would have to look into the IntelliJ logs for the cloudbees plugin (I am not sure who provides that plugin) - to see how it is deleting it.
Deleting on cloudbees is an explicit action - so it must be doing something very strange. I would suggest using the CloudBees CLI to deploy the app (is it a war app?)


$m\mid rq,sq\Rightarrow m\mid \gcd(r,s)q\,$ and its view via additive order

Question: Let $m,q,r,s$ be integers.
Suppose GCD($r$,$s$) = 1.
Suppose $m|qr$ and $m|qs$.
Show that $m$ divides $q$.
This was a result that was assumed in class. I couldn't see the reasoning behind it though.. please provide some guidance/hints.

What I've tried so far:
I note that since $(r,s)=1$, then either $m$ does not divide $r$, or $m$ does not divide $s$.
I suppose that $m$ does not divide $r$.
Then I note that $m|qr$ but m does not divide $r$.
I try to come up with a contradiction by assuming that $m$ does not divide $q$, but since $m$ isn't prime, this doesn't get me far.
Am I going down the wrong path? Is there something I'm failing to consider?
Comment: It is not just that $m$ does not divide $r$. It is that GCD $(m,r)=1$. This is a strictly stronger statement.
Comment: why is GCD(m,r)=1?
Couldn't I have m=6, s = 20, r = 21?
Comment: You're right. I was not thinking properly. *facepalm*.
Answer: Hint $\ $ By basic gcd laws $\rm\ m\:|\:qr,qs\:\Rightarrow\:m\:|\:(qr,qs)\, =\, q(r,s)\, =\, q\:$ by $\rm\:(r,s) = 1.\ \ $ QED
Or, instead of gcd laws one may use the Bezout identity: $\rm\:jr + ks = 1\:$ for some $\rm\:j,k\in\Bbb Z,\:$ hence
$$\rm\ m\:|\:qr,qs\:\Rightarrow\:m\:|\:j(qr)\!+\!k(qs) = q(jr\!+\!ks) = q\ \ \ {\bf QED}$$
Note how the proof by gcd laws eliminates the variables $\rm\,j,k,\:$ which only serve to obfuscate.
Remark $ $ It can also be interpreted in terms of orders of elements. Namely, the hypothesis viewed modularly says $\rm\! \bmod m\!:\ r\cdot q\equiv 0\equiv s\cdot q,\:$ which implies that the additive order of $\rm\:q\:$ divides the coprime integers $\rm\:r,s\:$ so it must be $1,\,$ i.e. $\rm\:1\cdot q\equiv 0,\:$ i.e. $\rm\:m\:|\:q.\:$ This viewpoint is discussed further in some of my posts on order ideals.
Comment: Thanks!

I also liked the remark about additive orders.
Answer: You need to consider each prime dividing $m$.  It can't divide both $r$ and $s$, so its highest power in $m$ must divide $q$.
Comment: Got it! thanks that was very helpful.
Oh, wait. nope, seems I made a mistake. I'll keep trying to look at what you've said and see if I get somewhere.


Is 31,250 kHz enough sampling rate for guitar effect

Question: I have guitar effect that has quite small sampling rate(31.250kHz) with oversampling and I wonder whether it is enough to convert signal from other effects, especially distortion, or it is designed only for raw guitar signal.
Comment: Do you hear a difference when putting other effects in front of this particular pedal? If not, I would not worry about it.
Comment: @topomorto  It seems like bad form to roll back an edit by the OP!  Just because the title doesn't mention the sample rate doesn't mean that that is not the most relevant part of the (edited) question.
Comment: What type of effect (delay, reverb, distortion...) is the pedal itself?
Comment: It is multi effect unit. I can hear difference but sound is improved in bypass mode
Comment: I've rolled back your edit as it completely changed the question you originally asked (which was in itself a good question). Feel free to ask another question, even if it seems to be about a similar topic.
Comment: @Dave I agree it doesn't seem good to roll back an edit by the OP, but I felt the edited question was very different - my answer to it would have been, at any rate (pun not intended!). teodozjan, apologies if I did the wrong thing - feel free to revert back and I'll delete my answer.
Comment: If you hear a difference, consider the possibility that it is actually the quality of the dsp that is lacking, and not the low-ish sample rate.
Comment: @topomorto I did some research and I will aks new question
Answer: All other things being equal, higher sampling rates are generally seen as better as they allow higher frequencies to be reconstructed when the signal is converted back to analogue.
Simplistically speaking, the highest frequency that can be reconstructed is half the sampling rate. This is why 44.1 KHz is a frequently-used sampling rate - it allows frequencies up to around 20 KHz - commonly thought of as the limit of human hearing - to be reconstructed, with a bit of room to spare (which may be needed for the anti-aliasing filter).
This is fine (in theory) if all you are going to do is listen to the signal. However, let's imagine that we are going to do further processing - for example, pitch shift the output down. You might want frequency information beyond 20KHz (and therefore a sample rate beyond 44.1 KHz) to allow those ultrasonic frequencies to be audible when they are shifted down.
So, even 44.1Khz can't always be said to be 'good enough' if you are going to do further processing. 31.25 KHz, then, is 'even worse'... but it's not that much worse. You're only losing about 5 semitones right at the top of the human hearing range.
Also, remember that fidelity probably isn't the aim of the game here - guitar signals are often band limited at the top to prevent them sounding unduly harsh. The very slight roll off at the top might even be a good thing.
For most applications, I wouldn't worry too much about it. If it's a good effect otherwise, there's no reason to think this technical limitation is a musical limitation.
Comment: For further reading, check out "Nyquist-Shannon Sampling Theorem." This is also why people always say "300ppi for printing images/photos": it is twice the 150 line screens which are the high-end of commercial printing halftone screens.
Comment: If you want to DSP it is good to do oversampling. My box does 64/128 oversampling so should be fine for processing
Comment: People often forget that the Nyquist sampling limit is only one parameter that affects the final quality.  The sample depth (e.g. 4-bit vs 32-bit resolution) is equally important, and the sample integration period as well.  You can sample at, say 40 kHz by integrating for 25 ms or by integrating for 5 ms and ignoring the other 20 ms - worth of signal inside the sampling window.   These choices will affect the sound quality and the effective bandwidth of the recording.
Answer: If it sounds good, it is good.
If the effect is well made, there will be analog filters prior to the input A/D converters. These analog filters will suppress frequencies everything above about 15.5kHz (1/2 the sampling rate) before the signal gets digitized.  This will have the effect of cutting off the highs in the processed signal, but shouldn't be a problem (if the pedal is well designed). Technically (i.e. if you ran it through a spectrum analyzer), the processed signal will be less bright, perhaps even noticeably so to your ears.  You might not even notice this if it is a reverb or delay or similar that mixes an unprocessed version of the signal (I'm assuming that the unprocessed path doesn't go through the filters) with the processed (and thus high-cut) signal.
If this is a modulation effect that is attempting to "sound analog" the lower sample rate is (probably) OK -- analog delays tend to roll off the highs anyway, so you might not need as much bandwidth to reproduce the sound.
Comment: And of course if you want it to sound best, get those $20,000 Monster cables :-)
Answer: Digitech used to make entry level multi effects with that sample rate.  44.1 kHz is preferable but 31.250kHz does the job.


How do you derive the secant method formula from the equation below?

Question: The Secant Method forumula is;
$$ x_{i+1}=x_i - \frac{f(x_i)(x_i-x_{i-1})}{f(x_i)-f(x_{i-1})}.$$
Derive the formula from the equation below;
$$\frac{f(x_i)}{f(x_{i-1})}=\frac{x_i-x_{i+1}}{x_{i-1}-x_{i+1}}.$$
Comment: What have you tried? Basically all you have to do is manipulate the equation so as to get it into the form you need. Start by getting the fraction alone on one side.
Comment: Once you have solved for $x_{i+1}$, it may be useful to bring the right-hand side of the **first** equation in the OP to a common denominator, observe the cancellation of the $x_if(x_i)$ terms, and conclude the equality.
Comment: @rogerl I've multiplied the top of the L.F.S by the bottom of the R.H.S and equaled it to the top of the R.H.S multiplied by the bottom of the L.H.S but i do not know where to go from there. Could you start me off in the right direction please?
Answer: $$ x_{i+1}=x_i - \frac{f(x_i)(x_i-x_{i-1})}{f(x_i)-f(x_{i-1})} \\ \overset{(1)}\iff \frac{f(x_i)(x_i-x_{i-1})}{f(x_i)-f(x_{i-1})}=x_i -x_{i+1} \\ \overset{(2)}\iff  f(x_i)(x_i-x_{i-1})=(x_i -x_{i+1})(f(x_i)-f(x_{i-1})) = (x_i -x_{i+1})f(x_i)- (x_i -x_{i+1})f(x_{i-1}) \\
\overset{(3)}\iff f(x_i)(x_{i+1}-x_{i-1})=f(x_i)(x_i-x_{i-1}-x_i+x_{i+1})=-(x_i -x_{i+1})f(x_{i-1}) \\
\overset{(4)}\iff \frac{f(x_i)}{f(x_{i-1})}=\frac{x_{i}-x_{i+1}}{x_{i-1}-x_{i+1}}
$$
(1) subtract $x_i$ on both sides
(2) multiply both sides by $(f(x_i)-f(x_{i-1}))$
(3) subtract $f(x_i)(x_i-x_{i+1})$ on both sides
(4) divide both sides by $-(x_{i+1}-x_{i-1})f(x_{i-1})$, note that if $(x_{i+1}-x_{i-1}) = 0$ or $f(x_{i-1})=0$ then the original problem makes no sense so we may suppose that they are different from $0$.


Mysql insert only if conditions are met

Question: Ok what I want to do is this.
I only want to insert if the amount I am inserting, plus the sum of the column is not over my value eg 112. I am only summing one invoice amount which is where the sales invoice id comes in. So I am going to add an amount of £20.
So I basically need a query which says
Insert Amount if Amount+"Sum of column" is smaller than or equal to the total quantity.
So here is my table layout
sipID|SalesInvoice_id|Date|Amount
1|116|07/11/2017|2|
2|115|07/11/2017|88|
3|116|07/11/2017|22|
7|115|07/11/2017|22|

So I thought an INSERT SELECT might work so I started getting the SELECT query to work first, and here is my working select query
SELECT SUM(`Amount`) FROM `salesinvoice_payments`
GROUP BY `SalesInvoice_id` HAVING SUM(`Amount`)+20 <= 112 AND `SalesInvoice_id`=115

Basically at the moment I am hard coding the amount I wish to add which is 20.
So what this select statement is doing. It will only get a value if the SUM(Amount)+20 is smaller or equal to 112 which is my total.
This works nicely.
So back to my original question. I want to insert only if the condition is true.
I can't seem to get the right format for this to work eg
INSERT INTO `salesinvoice_payments` (`Amount`)VALUES (20)
SELECT SUM(`Amount`) FROM `salesinvoice_payments`
GROUP BY `SalesInvoice_id` HAVING SUM(`Amount`)+20 <= 100 AND `SalesInvoice_id`=115

Comment: `INSERT INTO ... SELECT` is without the `VALUES` statement.  https://dev.mysql.com/doc/refman/5.7/en/insert-select.html
Comment: Yes but the select is being used like a where clause. I want to insert the value 20 if the condition is met. I am not sure how to lay it out, but I have put what I have worked out so far. I know the query I have put is wrong, but I don't know how to put it right.
Comment: i've posted a answer what should work.
Answer: INSERT INTO ... SELECT is without the VALUES statement.
Query
INSERT INTO `salesinvoice_payments` (`Amount`)
SELECT 20 FROM `salesinvoice_payments`
GROUP BY `SalesInvoice_id` HAVING SUM(`Amount`) + 20 <= 100 AND `SalesInvoice_id`= 115

Comment: I didn't think of putting the value in the select statement. Thanks. I was so close as well.

Mysql insert only if conditions are met


Can't figure out why this is not allowed

Question: Hope you can help understand this, it seemed so natural to do this :
    public interface IJob
    {
        bool started { get; set; }
    }

    public interface IJobManager
    {
        void StartJob(IJob job);
    }

    public class SomeJob : IJob
    {
        public bool started { get; set; }
        public void OnlySomeJobDoesThis();
    }

    public class SomeJobManager : IJobManager
    {
        public void startJob(SomeJob job) { } // --> Error'SomeJobManager' does not implement interface member 'IJobManager.StartJob(IJob)'
    }

But it won't compile, as you can see. I can't imagine why, .. as long as SomeJob implements the IJob interface
the compiler should not really have to care ?
Comment: C# is case sensitive. `startJob` is not the same as `StartJob`. If you really need it to be named lowercased, implement the interface explicitly.
Comment: So if I cast `SomeJobManager` to `IJobManager` and pass in my `SomeOtherJob : IJob` to `startJob`, what happens?
Comment: Aside: Naming conventions help avoid casing problems, and help train the eye to spot issues. Here's a great summary of C# naming conventions and recommendations: http://10rem.net/articles/net-naming-conventions-and-programming-standards---best-practices
Answer: Two issues.
First, C# is case sensitive. You define the method as StartJob (capital S), but implement startJob (lowercase s).
Second, your method takes in SomeJob which implements IJob. But your interface says the method should be able to take in an IJob. That is, any class which implements the interface, which isn't limited to just SomeJob.
Answer: Imagine if you've got another class that implements IJob :
public class FooJob : IJob
{
  // Whatever...
}

And you create an instance of your SomeJobManager like this:
IJobManager manager = new SomeJobManager();

Now, when you call StartJob like this:
manager.StartJob(new FooJob());

What would you expect to happen? Your SomeJobManager expects a SomeJob instance, but the interface says that if must be an IJob.
If your code was allowed you'd have broken the contract that the interface promises, which is that StartJob can be called with anything that is an IJob. You've said in your implementation that it has to be at least a SomeJob, which isn't the same.
Answer: Your interface is saying "any class that implements me must implement a StartJob method that can take any class that implements IJob."
Your implementation is saying "My StartJob method only works with a SomeJob, I don't know how to handle other implementations of IJob."
Your implementation is more restrictive than the interface, and therefore the compiler doesn't acknowledge that your implementation has fulfilled the interface requirements.
Answer: You are passing a concrete implementation of IJob to the method but it wants an instance of IJob.
Just do:
 public class SomeJobManager : IJobManager
{
    public void StartJob(IJob job) { }
}

Then just pass in SomeJob when you call StartJob:
//Something like this...
var myJob = new SomeJob();
manager.StartJob(myJob);


Which library should I use to connect to a socket.io 1.0 server in Objective-C?

Question: We just updated our servers to socket.io 1.0, but it breaks backward compatibility with older client libraries. Previously, I used https://github.com/lukabernardi/AZSocketIO but it does not support socket.io 1.0, so I need to switch to something else.
The official client is Swift only, but adding Swift would make my app way bigger and the blog post is not too enticing ("It can be used with Objective-C projects, but will require some extra work")
I took a look at this: https://github.com/MegaBits/SIOSocket but it uses a WebView as the implementation, which I tend to find ... awkward.
Is there any better solution out there that I did not find?
Answer: Take a look at the square socket client:
https://github.com/square/SocketRocket
I have used it and found it very easy to get up and running.


Difference in files laravel install local & on server

Question: When I install laravel on the server via the command:
cd httpdocs/ && /opt/plesk/php/7.1/bin/php /usr/lib64/plesk-9.0/composer.phar create-project laravel/laravel --prefer-dist

I am missing files and folders in the laravel directory, which I would have when I install laravel local on my laptop with the command:
composer create-project laravel/laravel --prefer-dist

The commands are the same, but why am I missing files on the server? Example of a missing file: /app/Http/routes.php and missing folder: /app/events/
In both situations laravel works and shows the default laravel page when I visit the url.
Hope to get a clear answer, I couldn't find it on google or here on stackoverflow.
Comment: routes.php was removed in Laravel 5.4 I believe.  Everything is in a routes directory now.   What version is installed on both?  Check your composer.json file.
Comment: You are right, the versions differ.
How come it installs another version on local then on server? Used the same commands?
Answer: Just tested this.  When using composer create-project, it looks like it will use the maximum version it can while satisfying project requirements.
Therefore, if you're installing using PHP 7.1, it will be able to install the latest, Laravel 5.6.  However, if you're running create-project using PHP 5.6, it will only attempt to install Laravel 5.4 since Laravel 5.5 requires PHP 7.0 and 5.6 requires 7.1.
This leads me to believe you don't have a recent version of PHP set up on your local system.


Merging PDF files with Python3

Question: I am writing a small script that needs to merge many one-page pdf files. I want the script to run with Python3 and to have as few dependencies as possible.
For the PDF merging part, I tried using PyPdf. However, the Python 3 support seems to be buggy; It can't handle inkscape generated PDF files (which I need). I have the current git version of PyPdf installed, and the following test script doesn't work:
import PyPDF2

output_pdf = PyPDF2.PdfFileWriter()

with open("testI.pdf", "rb") as input:
    input_pdf = PyPDF2.PdfFileReader(input)
    output_pdf.addPage(input_pdf.getPage(0))

with open("test.pdf", "wb") as output:
    output_pdf.write(output)

It throws the following stack trace:
Traceback (most recent call last):
  File "test.py", line 7, in <module>
    output.addPage(input.getPage(0))
  File "/usr/lib/python3.3/site-packages/pyPdf/pdf.py", line 420, in getPage
    self._flatten()
  File "/usr/lib/python3.3/site-packages/pyPdf/pdf.py", line 574, in _flatten
    self._flatten(page.getObject(), inherit)
  File "/usr/lib/python3.3/site-packages/pyPdf/generic.py", line 165, in getObject
    return self.pdf.getObject(self).getObject()
  File "/usr/lib/python3.3/site-packages/pyPdf/pdf.py", line 616, in getObject
    retval = readObject(self.stream, self)
  File "/usr/lib/python3.3/site-packages/pyPdf/generic.py", line 66, in readObject
    return DictionaryObject.readFromStream(stream, pdf)
  File "/usr/lib/python3.3/site-packages/pyPdf/generic.py", line 526, in readFromStream
    value = readObject(stream, pdf)
  File "/usr/lib/python3.3/site-packages/pyPdf/generic.py", line 57, in readObject
    return ArrayObject.readFromStream(stream, pdf)
  File "/usr/lib/python3.3/site-packages/pyPdf/generic.py", line 152, in readFromStream
    obj = readObject(stream, pdf)
  File "/usr/lib/python3.3/site-packages/pyPdf/generic.py", line 86, in readObject
    return NumberObject.readFromStream(stream)
  File "/usr/lib/python3.3/site-packages/pyPdf/generic.py", line 231, in readFromStream
    return FloatObject(name.decode("ascii"))
  File "/usr/lib/python3.3/site-packages/pyPdf/generic.py", line 207, in __new__
    return decimal.Decimal.__new__(cls, str(value), context)
TypeError: optional argument must be a context

The same script, however, works flawlessly with Python 2.7.
What am I doing wrong here? Is it a bug in the library? Can I work around it without touching the PyPDF library?
Answer: So I found the answer. The decimal.Decimal module in Python3.3 shows some weird behaviour. This is the corresponding StackOverflow question: Instantiate Decimal class I added some workaround to the PyPDF2 library and submitted a pull request.
Comment: This is the commit that fixes the error: [click](https://github.com/cedeon/PyPDF2/commit/c1fd166d8f9c65b40bcdc85ee5be22ca471b90bf) So just copy the green line and add it to the proper place in your file system. (Probably `/usr/lib/python2.7/site-packages/PyPDF2/generic.py:213`
Comment: Did it go through yet? I am suffering from the same problem.
Comment: I am sorry, I hit the wrong link. This is the correct (but still pending, god knows why) pull request to fix the bug: [click](https://github.com/knowah/PyPDF2/pull/4). It's [this](https://github.com/cedeon/PyPDF2) repo.
Comment: Btw, since I have PyPDF2 installed, is there a way to just copy and paste some files?
Comment: Thank you so much! Even though I couldn't get the general thing to work for merging, I wrote a function that avoids the "PdfMerger".
Answer: Just to make sure you are aware of already existing tools that do exactly this:

PDFtk
PDFjam (my favourite, requires LaTeX though)
Directly with GhostScript:
gs -dBATCH -dNOPAUSE -q -sDEVICE=pdfwrite -sOutputFile=finished.pdf file1.pdf file2.pdf
Comment: hi, thank you. But I find that PyPDF is a nice library and would like to use it. But thank you for the suggestions.
Comment: Just wanted to make sure you're not re-inventing the wheel when you don't actually mean to ;-)

Merging PDF files with Python3


Determining the unique(?) set of euler angles that produce a set of 3 left hand orthonormal vectors in $R^3$.

Question: Given three vectors representing an x direction, y direction, and z direction, is there a way to uniquely determine 3 angular rotations around each of the x,y,z axes. I have no experience with differential geometry. I'm just trying to convert a "frame" I have of an object in 3-dimensional space to a set of rotations I can use to rotate a 3D model into it's proper orientation. It's for making a thing walk on the surface of a sphere and this is the only thing I have left to do. Otherwise, I'd be left with a very bizarre looking thing (it would appear to roll on the surface of the sphere).
Once again, reiterating:

is there any way to take 3 vectors and determine rotations that produce them assuming we know which axis each one began as pointing in. Assume they are in regular cartesian coordinates (where x points out, y points right, and z points up).
Comment: It seems really restrictive to only be allowed to perform rotations around axes though. If you could apply arbitrary linear transformations (via matrices) to coordinate vectors, then to move the coordinate frame $\langle e_1,e_2,e_3\rangle$ to any new frame $\langle v_1,v_2,v_3\rangle$, you would just let $R$ be the matrix whose three columns are $v_1,v_2,v_3$. Is this not something you can do?
Comment: @TheGreatDuck Why not use [quaternions](https://en.wikipedia.org/wiki/Quaternions_and_spatial_rotation) to rotate it, instead?  Then you avoid possible Gimbal lock.
Comment: To send the frame $\langle v_1,v_2,v_3\rangle$ to the coordinate frame $\langle e_1,e_2,e_3\rangle$ using only coordinate axis rotations, it might be easier to use three rotations around only *two* coordinate axes. First, apply a rotation $R_1$ around the $x$-axis to get $v_1$ into the $xz$-plane, then apply a rotation $R_2$ around the $y$-axis to get $R_1v_1$ to $e_1$, then apply a rotation $R_3$ around the $x$-axis again to get $R_2R_1v_2$ to $e_2$ and $R_2R_1v_3$ to $e_3$. Will have to consider the case when $v_1$ is on the $x$-axis separately.
Comment: Then there's no time like the present to [learn](http://mathinfo.univ-reims.fr/IMG/pdf/Rotating_Objects_Using_Quaternions.pdf). ;-)
Comment: @TheGreatDuck If you have to use Euler angles then oh well.  I don't actually know much about Euler angles as I always use something that is [essentially equivalent to quaternions](http://www.geometricalgebra.net/quaternions.html).  Good luck.
Comment: Rotation is usually done BY multiplying "real-numbers" with quaternions...
Answer: There is no unique way. Say you have a model plane, pointing in the $x$ direction, $y$ direction is horizontal, perpendicular to $x$, and $z$ is vertical. Now you want to flip the plane upside down, pointing forward. That means $x'=x$, $y'=-y$, and $z'=-z$. I can get to this state in at least two different way. The most obvious one is a rotation around $x$ axis by 180$^\circ$. I can also rotate 180$^\circ$ around $y$ axis (plane is upside down, but pointing backwards in the $-x$ direction), and then rotate 180$^\circ$ around the $z$ axis.
In computer graphics programs what people are usually doing is deciding a simple rotation (usually the least amount of rotation) and decompose the path into equally spaced rotation angles, to make the motion seem smooth.
Comment: It looks like someone was unhappy about my answer, without saying why. @TheGreatDuck A way to get the rotation matrix is to write the new coordinate system $x',y',z'$ in terms of $xyz$ and assume that there is a matrix transformation between the two. Say the rotation matrix is R. Then $x'=R (1,0,0)$, $y'=R(0,1,0)$ and same for $z'$. We can write the three $x,y,z$ vectors as the identity matrix, so R is just the matrix made out of $x'y'z'$ vectors. Once you have R, you can use https://en.wikipedia.org/wiki/Rotation_matrix#Conversion_from_and_to_axis-angle
Comment: Even if I ignore the title, from your question "is there a way to ***uniquely*** determine 3 angular rotations around each of the x,y,z axes." I assumed that the uniqueness is important. If not, don't put it in the question


Is the machine learning community abusing "true distribution"?

Question: In articles such as "Research #1: Generative Models" one reads once more statements such as

These images are examples of what our visual world looks like and we refer to these as "samples from the true data distribution"

the images meant are the ImageNet dataset.
We also read statements such as

Mathematically, we think about a dataset of examples $x_1,\dots,x_n$ as samples from a true data distribution $p(x)$. In the example image below, the blue region shows the part of the image space that, with a high probability (over some threshold) contains real images, and black dots indicate our data points (each is one image in our dataset).

and

Our goal then is to find parameters $\theta$ that produce a distribution that closely matches the true data distribution (for example, by having a small KL divergence loss).

Whenever I read such language:

I wonder if statements such as the first one are not exaggerations in the sense that there is a huge number of 'real' images that could be in the dataset but are not in it. Or in other words that the ImageNet dataset is not representative of 'real image' even though it obviously samples it.
Being a real image does not seem to be a probabilistic matter to me. An image either came from the real world or did not. It does not matter that mechanical turk is used to make people guess if the machine generated images look real like in the article. This does not justify the 'probabilistic' interpretation of what the machine learning algorithm is doing. In other words, don't statements such as with a high probability (over some threshold) actually point to abuse or sweeping under the rug?
I wonder if statements such as the last one are not stretching it. We do not know the 'true data distribution', we only know a small number of samples of it. Using samples to measure loss is just a (huge) assumption about the relation of the samples to the distribution. That relation is swept under the rug.
I wonder if it is not possible to interpret what the machine learning algorithm does that does not rely on such terminology? Per example simply talking about compression? And that the generalisation produced is merely an assumption on the continuity between the samples (regularity)?

I know my questions are vague, but I would like to know if other people also have such thoughts, if they are well founded, if they are treated explicitly in some book or paper that I can't seem to find.
Comment: I am not sure what you are asking, but let me comment on #1. It is not important that the samples represent our world or not. What's important is the process that generated those images. We are in general taking pictures of things that are relevant to people. There is a huge part of electromagnetic spectrum that we cannot even see. As long as that process is stable (changing very slowly over time), meaning that we continue taking pictures of similar things, the probability distribution is also stable. Here the distribution is a conditional distribution (conditioned on our taste).
Comment: I am a statistician and I don't want to get into the issues of machine learning vocabulary.  I think there is of course an overlap with probability and statistics but it is developing into a separate discipline. I think however that this is a thoughtful question that the OP raises.  Just a short while ago today I was looking at a question in statistics where the argument was about "true models" and the mathematical properties  that we attribute to assumptions placed on models for which formal results such as consistency and unbiasedness etc can be made from these idealizations.
Comment: I know my questions are vague, so thanks for the comment. I think that the imagenet pictures are much more conditioned than to our taste. They seem to be conditioned to things like 'one main object per picture', 'portrait style' per example, and given that, I am not sure what 'true' here means. Is it then not the 'true distribution of pictures taken such that one mainly has a main object per picture taken in portrait style'? You see how that not being mentioned can be confusing to the novice reader ....
Comment: Another point I made is that I don't see the probabilistic component and it seems to be forced. An image is either yes taken or not taken from the real world, there is no probability around that and no thresholds. Do you have a comment on that?
Comment: the 'type' being what? 'real' and 'unreal' ?
Comment: However this can conflict with common english terms we use to express practical aspects of data analysis. It is easy to get confused about this and is not a issue in machine learning alone.
Answer:

I wonder if statements such as the first one are not exaggerations in the sense that there is a huge number of 'real' images that could
  be in the dataset but are not in it. Or in other words that the
  ImageNet dataset is not representative of 'real image' even though it
  obviously samples it.

And this is exactly what your quotes say, that those are samples from the distribution.

Being a real image does not seem to be a probabilistic matter to me. An image either came from the real world or did not. It does not
  matter that mechanical turk is used to make people guess if the
  machine generated images look real like in the article. This does not
  justify the 'probabilistic' interpretation of what the machine
  learning algorithm is doing. In other words, don't statements such as
  with a high probability (over some threshold) actually point to abuse or sweeping under the rug?

This depends on your definition of probability. It seems that in such cases as described above they implicitly adopt Bayesian understanding of probability, i.e. probability is a measure of how much believable something is. In such case you can talk about probabilities of non-repeatable events, for example what is the probability that the sun will rise tomorrow?. It will, or it will not, we have no data about such events happening in the past, so under a classical definition of probability this would not be a probabilistic problem, but it can be seen as probabilistic problem under Bayesian understanding of probability.

I wonder if statements such as the last one are not stretching it. We do not know the 'true data distribution', we only know a small
  number of samples of it. Using samples to measure loss is just a
  (huge) assumption about the relation of the samples to the
  distribution. That relation is swept under the rug.

And this is basically what statistics is about: we infer about properties of the population given only the limited sample from it, that we have. We learn about properties of the true distribution given only the empirical distribution obtained from our sample.

I wonder if it is not possible to interpret what the machine learning algorithm does that does not rely on such terminology? Per
  example simply talking about compression? And that the generalization
  produced is merely an assumption on the continuity between the samples
  (regularity)?

Yes, other models are possible, but it seems that the quotes you provided refer to probabilistic models. Again, statistics are grounded on probabilistic reasoning about data. Without probability it becomes much more problematic to quantify the uncertainty about the true distribution that rises from the fact that we are dealing with limited and imperfect data to infer about it.
Answer: This paragraph from a blog post seems to answer the question:

The key relationship between images and statistics is that we can interpret images as samples from a high-dimensional probability distribution. The probability distribution goes over the pixels of images. Imagine you're taking a picture with your camera. This picture will have some finite number of pixels. When you take an image with your camera, you are sampling from this complex probability distribution. This distribution is what we'll use to define what makes an image normal or not. With images, unlike with the normal distributions, we don't know the true probability distribution and we can only collect samples.

Upon more thinking, what cements the idea for me is that one can in fact make any wanted pattern be a 'real picture', by drawing that pattern and with proper conditions, taking a picture of it. Hence, all combinations of pixels are 'real'. With this said, it is obvious that the probabilistic component is a necessity for a 'fake'/'real' classification.

Is the machine learning community abusing “true distribution"?


Question about Projection operators

Question: Let $P\in L(X)$ be a projection operator, where $X$ is a complex non-trivial banach space, that is $P^2=P$ and $Q\in L(X)$ such that $Q^2=0$, then in my Functional analysis exam it was asked to see that we will have  $(P+Q)^2=P+Q$, however I cannot seem to prove this , we wil have that $(P+Q)(P+Q)=P^2+PQ+QP+Q^2=P+PQ+QP$ but how can I relate $PQ+QP$ with $Q$?
I also tried coming up with a counterexample if we consider $X=l^2(\mathbb{N})$ and the operator $P(x)=\langle x,e_1\rangle e_1$ and the operator $Q(x)=Q((x_1,x_2,x_3,...)=(0,x_1,0,x_3,0,x_5,...)$ isn't this going to be a counterexample? Because we will have that $(P+Q)(x)=(x_1,x_1,0,x_3,0,...)$ and that $(P+Q)^2(x)=(x_1,x_1,0,0,...)$.
Thanks in advance.
Answer: Your counterexample works !
My idea:
For $P=I$ we do not have $(P+Q)^2=P+Q$ for each $Q$ with $Q^2=0:$
$(I+Q)^2=I+2Q$, thus
$$(I+Q)^2=I+Q \iff I+2Q=I+Q \iff Q=0.$$
Someone told you nonsense !

Question about Projection operators


What is this cross staff tied/slurred note supposed to be?

Question: So I am learning Messiaen's Transports de Joie from L'Ascension suite. Things are fine until there is an ambiguous note on the top of page 16 (we are in F♯ Major and both hands are in the treble clef):

(Please excuse the heavily marked score.) I have marked with pencil a sharp sign next to the E, but I am really not sure how this should be played. Previously, as in the first and second beat in this measure, there is a melody line in the left hand that is frequently tied to the bottom note of a chord in the right hand. However, since we are in F♯ Major, I do not know what the bottom not of the chord indicated should be. According to the key signature, it should be an E♯, but according to the fact that it's tied, it should be an E♮.
Has anyone performed this piece before or knows enough about music typography to answer this for sure?
Comment: That's another thing: The bottom note of the LH 4th chord is an E♯, according to the key signature... how strange.
Comment: I have played this piece, and the chord must definitely be e-a-c sharp-d sharp. So the fact that there isn't a natural accidental in front of the e is simply an editor's error.
Comment: Also, wonder why there are # put before notes that are sharp due to the key sig. as in D# 1st chord, R.H. The E on 4th chord L.H. should also be a #. As the 'melody' is copied an octave higher in the R.H., E natural seems correct. Maybe it's a typo.
Answer: I have a couple suggestions and an answer:
Suggestion:
1.) I would check at least one other version / edition of the score to make sure it is properly notated.  If it's different, you have your answer.
2.) Messiaen used / created modes of limited transposition so if you want to get really nerdy you can either read an analysis or do an analysis yourself to see whether or not the pitch is supported in the given mode.  Though the key signature might say you're in F# major, with Messiaen you are most likely using some sort of pitch collection (note all of the accidentals!)
Answer:
With respect to notation, accidentals only apply to the octave in which they are written.  So if it says E# in the top voice but is not marked similarly at the bottom of the chord, it is E natural. Both / all octaves must be notated with an accidental if an accidental is desired.  The same is obviously true between hands on the piano as well.
In the LH, the E nat. moves down to D#, exploiting a half-step relationship that seems to be evident in Messiaen's fauxbourdon-like texture here. On the chord in question, the E# now serves as a leading tone resolving to F# in following chord, which as you state in your question is the tonic (or local tonic at least.)
Lastly, I just want to point out that although it wasn't stated, we are speaking about the above excerpt as if both hands are in treble clef.
Comment: It seems like Alphonse Leduc Cie. is the only manufacturer of the score. Looking at the series of chords, it seems that we are entirely in Mode 2 *except for that one note,* if we follow the time signature. So I am inclined to think it is a typo and that E♮ is correct, because E♯ is not in that transposition of Mode 2. And besides, that is the only instance where it would have been a cross-staff slur rather than a tie. So that's my verdict. Thank you for recommending I analyse the piece. Learning the scales used makes the piece itself less of a nightmare to play.
Comment: The slur could indicate that the chromatic movement is melodically important, too. Ie. you're supposed to hear the E♮ -> E♯ movement and notice how the chords support it. $.02
Comment: Yes, also definitely possible.  It is hard to say exactly without having done an analysis of the piece and without comparing different editions or looking at the original manuscript.
Comment: You're welcome - as I'm sure you know, analysis is great for performers because everything is so much clearer and effective!


Simulating the TAB keydown: focusing next element as determined by `tabIndex`

Question: I have two input elements, the first is focused, and I want to focus the second by simulating the TAB keypress/keydown event. (Note: I don't want to use .next() or such.)
This is my code, inspired from this question:
$('input').first().focus();

var e = $.Event('keydown');

e.which = 9; // TAB
$(':focus').trigger(e);

Please see http://jsfiddle.net/3PcPH/
The code doesn't work. What is wrong?
Comment: @mu is too short: Yes, exactly! I've been searching *so* long for this. Please help.
Comment: Do you actually have `tabindex` attributes on all your form elements?
Comment: No. This seems to me like a really trivial thing to do. And yet...
Answer: There is no simple programmatic way to do this using Javascript... so here's a brute force way.
According to W3:

Elements that may receive focus should be navigated by user agents
  according to the following rules:

Those elements that support the tabindex attribute and assign a
  positive value to it are navigated first. Navigation proceeds from the
  element with the lowest tabindex value to the element with the highest
  value. Values need not be sequential nor must they begin with any
  particular value. Elements that have identical tabindex values should
  be navigated in the order they appear in the character stream.
Those
  elements that do not support the tabindex attribute or support it and
  assign it a value of "0" are navigated next. These elements are
  navigated in the order they appear in the character stream.
Elements
  that are disabled do not participate in the tabbing order.

I accomplished this by storing the order of elements in the form that have tabIndex > 0 in their tabIndex order and then concatenating the rest of the elements in the order they appear within the document.  The following code simulates a tab keypress when focused on a form input and the letter 'z' is pressed (but you can change this to whatever condition you require):
$(':input').keypress(function(e){

    // if 'z' pressed
    if (e.which == 122) {

        // if we haven't stored the tabbing order
        if (!this.form.tabOrder) {

            var els = this.form.elements,
                ti = [],
                rest = [];

            // store all focusable form elements with tabIndex > 0
            for (var i = 0, il = els.length; i < il; i++) {
                if (els[i].tabIndex > 0 &&
                    !els[i].disabled &&
                    !els[i].hidden &&
                    !els[i].readOnly &&
                    els[i].type !== 'hidden') {
                    ti.push(els[i]);
                }
            }

            // sort them by tabIndex order
            ti.sort(function(a,b){ return a.tabIndex - b.tabIndex; });

            // store the rest of the elements in order
            for (i = 0, il = els.length; i < il; i++) {
                if (els[i].tabIndex == 0 &&
                    !els[i].disabled &&
                    !els[i].hidden &&
                    !els[i].readOnly &&
                    els[i].type !== 'hidden') {
                    rest.push(els[i]);
                }
            }

            // store the full tabbing order
            this.form.tabOrder = ti.concat(rest);
        }

        // find the next element in the tabbing order and focus it
        // if the last element of the form then blur
        // (this can be changed to focus the next <form> if any)
        for (var j = 0, jl = this.form.tabOrder.length; j < jl; j++) {
            if (this === this.form.tabOrder[j]) {
                if (j+1 < jl) {
                    $(this.form.tabOrder[j+1]).focus();
                } else {
                    $(this).blur();
                }
            }
        }

    }

});

See demo
Comment: jQuery UI has a [`:tabbable`](http://api.jqueryui.com/tabbable-selector/) and [`:focusable`](http://api.jqueryui.com/focusable-selector/) pseudo-selectors. In case you want to pull something like this in as a library. Should only need jquery-ui.core.js
Comment: Thanks for this! I've noticed two discrepancies on Chrome. 1) Using `z` will change the content of the `THIRD` focusable element to `z`. 2) When no element is focused, `TAB` will focus `FIRST` whereas `z` does nothing.
Comment: @Randomblue 1) Pressing 'z' was just an example trigger, I assumed this would be handled programmatically somehow.  If needed you can add a `e.preventDefault()`. 2) You can change this by adding the trigger to `$('document')` as well, but from your requirements it sounded like you only wanted this functionality on form inputs.
Comment: @Randomblue If you add `return false;` to the last part of the keypress function, it will not enter 'z' into the next textbox as returning false stops the browser from doing anything with the keypress that you first did (But only return false on your captured event otherwise all inputs will be captured)
Comment: heads up... `event.which` is now deprecated and should be replaced by `event.key` to check for `Tab`. Read about it on [Mozilla developer pages](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent)
Answer: The default tabbing behavior is to just go to the next (in source order) form element so you could just iterate through all the elements you care about, find the one that has focus, and move the focus to the next one. We have the :input selector for finding the form elements so something like this:
var $all = $('form :input');
var focused = $(':focus')[0];
for(var i = 0; i < $all.length - 1; ++i) {
    if($all[i] != focused)
        continue;
    $all[i + 1].focus();
    break;
}
// Must have been focused on the last one or none of them.
if(i == $all.length - 1)
    $all[0].focus();

Demo: http://jsfiddle.net/ambiguous/Avugy/1/
Or you could set tabindex attributes and increment them with wrap-around:
var next_idx = parseInt($(':focus').attr('tabindex'), 10) + 1;
var $next_input = $('form [tabindex=' + next_idx + ']');
if($next_input.length)
    $next_input.focus();
else
    $('form [tabindex]:first').focus();

Demo: http://jsfiddle.net/ambiguous/k9VpV/
Dealing with gaps in the tabindex attribute values is left as an exercise.
Comment: Thanks, but I don't like your approaches. Concerning the first, searching through all the elements I care about is *very expensive* (I have many) and is not dynamic (doesn't take into account the new ones I add). Also, I don't know *a priori* what the elements I'm interested in will be. Your second approach has the disadvantages of the first, and needs all the elements to have a different tabindex...
Answer: $('input').first().focus();

var e = $.Event('keydown');

e.which = 9; // TAB
$(':focus').bind('keydown',function(e){
    if(e.which == 9){
        //this.value="tab";
        $('input:eq(1)').focus();
    }
   e.preventDefault();
});

you need to bind 'keydown' event to  and custom your event function.
Comment: Thanks. However this end result is not what I want! What is the code I should use so that the next element as determined by `tabindex` will be focused?
Comment: This simply focuses to the second input element. That's *not* as prescribed by `tabIndex`!
Comment: It's not the answer to the actual question, but the google bring me here for my answer, so +1
Answer: Try this sample out http://jsfiddle.net/mporras/3jXQQ/18/embedded/result/
Answer: Here is a solution using jquery to simulate the TAB functionallity with the Enter key:
https://jsfiddle.net/tuho879j/
$('input').keypress(function(event){
  if(event.which == '13')   //ENTER
  {
    var tabIndex = $(this).attr('tabIndex');

    var all_inputs = $(this).closest('table').find('input:visible');
    var inputs = all_inputs.filter(function() {
      return $(this).attr("tabIndex") > tabIndex;
    })

    if(inputs.length != 0)
    {
        inputs = $(inputs).sort(function(a,b){
          return $(a).attr('tabIndex')-$(b).attr('tabIndex');
        });
    }
    else
    {
        inputs = $(all_inputs).sort(function(a,b){
          return $(a).attr('tabIndex')-$(b).attr('tabIndex');
        });
    }

    var elem = inputs.eq( inputs.index(this)+ 1 );
    if(elem.length == 0)
        elem = inputs.eq(0);

    elem.focus();
    event.preventDefault();
  }
});