How is $r$ used in vector equation for plane?

Question: How is $r$ used in vector equation for plane?
Since the equation is:
$$r \cdot n = a \cdot n$$
And the $r$ is a variable that remains in the final equation. But what is it used for?
Comment: Do you know what $a,n,$ and $r$ stand for ?
Comment: @YvesDaoust $a$ is the position vector of the known point $P_0$. $n$ is the given normal vector to the plane. $r$ is the position vector of some unknown point $P$. So $r$ is a parameter that defines any point on the plane? So it's the variable that we're solving for?
Comment: Yep, that's it. The equation specifies all possible values for $r$ (as there is a single equation, there is a double infinity of choices).
Answer: Lets rename $a$ to $r_0$, just to use the same letters as most literature, and also the linked pictures.
If you write your equation like $$(r-r_0)\cdot n=0$$ the equation is much more intuitive.
That equation is the so called normal form of a plane. All vectors $r$ that fulfill that equation define your plane.
Here is a picture that illustrates everything that follows. Look at it wihle reading through the rest of this answer.
(Source)
The vector defined by $(r-r_0)$  is the vector "from $r_0$ to $r$", as you can see in the picture. In the picture the vector $r$ is on the plane, so the red vector "lies exactly in the plane".
If the vector $r$ would be located below or above the plane, the red vector $(r-r_0)$ would "point out of the plane".
That property can be translated to "the red vector $(r-r_0)$ should be orthogonal to $n$".
And that is exactly what the scalar product $$(r-r_0)\cdot n\overset{!}{=} 0$$ does.
The reason is simple if we look at the (geometrical) definition
$$x\cdot y = |x||y|\cos(θ),$$
with $|x|$/$|y|$ being the length of vector $x$/$y$ and $θ$ being the angle between $x$ and $y$.
If these two vectors are orthogonal it is $θ=90°$, and $x\cdot y=0$. Otherwise the scalar product is not $0$.


Force C# to load an assembly that is referenced only in a cshtml file

Question: How to force C# run-time to load an assembly that is used only in a .cshtml file which is a Razor template?
I am using the JSON serialization functionality from Newtonsoft, the assembly is referenced by the project, but when the Razor engine compiles the template I get an error that the Newtonsoft namespace is not known. I also see that the dll is actually not loaded (I guess it makes sense since it is not referenced anywhere in the C# code). If I add a dummy line somewhere in my C# code that references any function from the assembly it is loaded and Razor is happy. Is there a way to specify that the assembly should be loaded even though it is not referenced? I really don't want to leave the dummy line in the code.
Comment: [How to add assembly in web.config file](http://stackoverflow.com/questions/9456207/how-to-add-assembly-in-web-config-file-of-mvc-4)
Answer: You are right, the compiler deletes the project reference during compilation/optimization, because it detects that it's not really being used by the code.
The official way to tell the runtime to load the assembly anyway by configuration, is to add a reference in your web.config file inside the <compilation> section
<compilation debug="true" targetFramework="4.0">
  <assemblies>
    <add assembly="Newtonsoft.Json" />
  </assemblies>
</compilation>

That being said, sometimes the web.config is not available, or I want to avoid  bloating it with more and more lines, so I personally prefer the hack of making a one line reference in the code: (yes, a dirty bad nasty & silly hack, but I can't find much harm being done).
class LoadNewtonSoftHack
{
    private void DoNothing()
    {
        var o = Newtonsoft.Json.Linq.JValue.Parse("{}");
    }
}

A third alternative would be to force the assembly load when the web app starts: (but ensure that your build copies the .dll in your bin\ folder).
Assembly assembly = Assembly.LoadFrom("Newtonsoft.Json.dll");

Comment: Since I didn't even have a `web.config` file I chose the third approach and it worked fine, thanks:)
Comment: @spender: comments fade away. It's not enough to link in comments. If it's relevant it should go into the answer.
Comment: The `web.config` method would be preferable IMO.
Comment: Unless precompilation of views is turned on, the views aren't compiled until run-time anyway. Using the web.config in the way described [here](http://stackoverflow.com/questions/9456207/how-to-add-assembly-in-web-config-file-of-mvc-4) is how you tell the run-time compilation to reference assemblies.
Comment: Your points are valid @spender, but I think this is a situation where more than one solution is applicable. I insist you add a new answer to this question.
Comment: I completely agree, but simply repeating the info that is in the other question/answer mostly leaves me wanting to press the dupe button ([which would be very final because of my gold badge](http://meta.stackexchange.com/a/231212/133351)). I think linking to this info in the comments is good enough... there's a reference to it in the comments to both the question and your answer.
Comment: To be fair, the answer would be a duplicate, but the question is not. I just added a 3rd option explaining how to add it into the web.config.
Comment: I started a conversation on meta about this. http://meta.stackoverflow.com/questions/333983/regurgitating-answers-for-subtly-different-questions


What exactly does computed properties in vuejs?

Question: There are couple of questions related computed properties like the following

"vuejs form computed property"
"Computed properties in VueJs"
"computed property in VueJS"
"Use computed property in data in Vuejs"

They are asking about specific error or logic. There are lot of websites that are explaining about vuejs related concepts. I read about computed properties on vuejs official website. When we do complex calculations or want to avoid to write more logic in our html template then we use computed properties.
But could not get any solid understanding about computed properties, when it calls, how it calls, what exactly do?
Answer: TL;DR: Computed properties are getters/setters in Vue.

When defined in the shorthand form, they are getters:
computed: {
  someComputed() {
    return `${this.foo} ${this.bar}`;
  }
}

is equivalent with
computed: {
  someComputed: {
    get: function() {
      return `${this.foo} ${this.bar}`;
    }
  }
}

which can also have a setter:
computed: {
  someComputed: {
    get: function() {
      return `${this.foo} ${this.bar}`;
    }
    set: function(fooBar) {
      const fooBarArr = fooBar.split(' ');
      this.foo = fooBarArr[0];
      this.bar = fooBarArr[1];
    }
  }
}

In short, Vue computed properties allow you to bind an instance property to

a getter: function run when you look up that property; usage:

this.someComputed // returns the computed current value, running the getter.

a setter: function run when you attempt to assign that property; usage:

this.someComputed = value; // sets the computed current value, running the setter.

Read more on getters and setters in Javascript.
And here's the documentation on Vue computed properties.
Answer: You can use computed properties when for example you have some logic what will blow up your template.
The idea is, that normally you want to keep all javascript logic in the javascript side of your vue component, and only access final data in your data (if possible)
For that you can use computed props, which normally are doing simple things like:
  computed: {
    // a computed getter
    reversedMessage: function () {
      // `this` points to the vm instance
      return this.message.split('').reverse().join('')
    }
  }

Or an another good example if you have some currency and you want to format it with thousand separator and euro ign at the end.
Then you can access your computed prop in the template like you access a normal prop, you dont have to call it as a function.
like so:

{{reversedMesage}}

Every time, when any variable what is used in your conputed prop is changing, vue vill take care of it and will re-calculate your computed property again.
Lets say you have the following:
  computed: {
    prettyAmount: function () {
      return this.amount + ' ' + this.currency.toUpperCase()
    }
  }

{{prettyAmount}}

Whenever currency or amount changes, the output of prettyAmount will be changed as well.


Is there an easy way (hopefully with ES6+) to apply mutations to array values base on config objects?

Question: I am attempting to write a function that allows me to configure array values. I would like to create config objects, like so:
var words = [
    'spacejump',
    'apples',
    'graphics',
    'javascript',
    'peaches'
];

var configs = [{
    upper_case:'first',
    length:[6,8]
},{
    upper_case:'last',
    length:[7,9],
    strip:'vowels'
},{
    length:10,
    strip:'consonants'
}]

and then apply those configurations to another array of strings (words in this case) and output the results, like so:
[
    [
        "Apples",
        "Graphics",
        "Peaches"
    ],
    [
        "spcjmP",
        "grphcS",
        "pchS"
    ],
    [
        "aai"
    ]
]

I am struggling to get started as I am trying to filter the results but into new individual arrays.
function configurate(config) {
    for (var filter in config) {
        switch (filter) {
            case upper_case:
            //capitalize either first or last letter
            case length:
            //include words with said length
            case strip:
            //strip vowels or consonants
        }
    }
}

function applyConfig(array, configs) {
    //forEach() word in array apply config
    //this is where I am confused a bit,
    //
    //
}

This is what I have so far, I left out too much implementation because I am worried that I am not doing this efficiently.
Comment: Use `map`, not `forEach`. Your `configurate` function seems fine given your custom configuration format
Comment: Can you elaborate more on that example array you provided? What does each sub-array mean? How did `Apples` become `spcjmP`? And why does the last array contain only one item?
Comment: My apologies! I shall edit! To clarify, the array could be any list of words. The only configurations at this point are to choose length, first/last letter capitalized and striping vowels or consonants.
Comment: I would say get it working first, then worry about efficiency.
Comment: True, I will begin to implement it with map now and see how that goes. Much appreciated everyone.
Comment: @Bergi could you possibly elaborate. I am curious as this aspect was scrutinized when I showed someone who does hiring at a successful startup (I was curious). I figured forEach was good for just manipulating the data. Thanks!
Comment: @penntreetz, map is faster and guarantees immutability. Also lets you do method chaining which looks a lot cleaner imo. With forEach you have to handle this yourself if it is the wanted behaviour.
Answer: You can use lambda functions to create the config operations and include these in your config objects.
Now you can loop over the configs array and for each word that matches the length requirement of the config, apply all functions to it.
Here is an example implementation. Could probably be done better in many ways, but I think it does what you want.

var words = [
    'spacejump',
    'apples',
    'graphics',
    'javascript',
    'peaches'
];

const config_functions = {
  upper_case: {
    first: s => s[0].toUpperCase() + s.slice(1),
    last: s => s.slice(0, s.length - 1) + s[s.length - 1].toUpperCase()
  },
  strip: {
    vowels: s => s.replace(/[aeiou]/ig,''),
    consonants: s => s.replace(/[bcdfghjklmnpqrstvxz]/ig,'')
  },
  range: (s, ...range) => range[1] ? (s.length >= range[0] && s.length <= range[1]) : s.length >= range[0]
};

var configs = [{
    modifiers: [
      config_functions.upper_case.first
    ],
    length: s => config_functions.range(s,6,8)
},{
    modifiers: [
      config_functions.upper_case.last,
      config_functions.strip.vowels
    ],
    length: s => config_functions.range(s,7,9)
},{
    modifiers: [
      config_functions.strip.consonants
    ],
    length: s => config_functions.range(s,10)
}];

let res = configs.map(config => words
                      .filter(word => config.length(word))
                      .map(word => config.modifiers.reduce((acc, func) => acc = func(acc), word)));

console.log(res);


Trying to sort tsv files by one column using powershell

Question: I have several .tsv files that I need to merge and then sort by only one column. Unfortunately that column is presented in digits (no decimals), but different length.
I used the following script:
$a=get-content -path\*filename*.tsv -encoding ASCII
$a|sort-object [int]column1|select-object -first ($a.count - $fileCount)|out-file -filepath -encoding ASCII

Unfortunately the outfile still not sorted. Any suggestion?
P.S  Actually it is sorted inside of individual files, but since several files were merged in variable $a, the total output is not sorted.
Answer: Ah, probably better to import them using import-csv. Try this:
gci *filename*.tsv|foreach{$a+=import-csv $_.fullname -delimiter "`t"}

Now you have an array that you can sort by whatever field you want, and can use:
$a|convertto-csv -Delimiter "`t" -NoTypeInformation|select -Skip 1|Out-File  output.tsv

Edited to remove header output.
Comment: the only thing is that each entry in array will have the column headers, and I need to remove all of them in the output file. And would not the existence of a header restart the sort for each file, I only need the final output file to be sorted. And once again the column itself could have different length :8-9-10
Comment: Did you try my code? Is there a problem with it that you are seeing? Column length should not matter, if they are truly tab separated values it will find the values correctly. Assuming all files have the same column headers it will build one large array, and you can output that to a single file with one header line.
Comment: I did not try it yet, but I will. Just want to understand, the output.tsv file will have sorted file with one header? Need to get rid of that header also
Comment: Answer updated, it will no longer output a header line, so you just get the data. Do the files you are reading from have header lines? If not this will not work, as the Import-CSV won't work right as it is written right now.
Comment: Tried to run in it in steps. gci command produced the following error:
Comment: sorry, no errors, but could not update my comment, the code runs forever for only handful of files, but in real life it is going to be maybe a hundred. It hosed my machine, takes about 7 gb of RAM, and what used to run couple of minutes, taking forever. Is it possible to tweak for performance?
Comment: Plus the file size is 5 times larger that it used to be. And I would love to keep the file in tsv format, not csv with every field wrapped in double quotes. But must admit it is sorted properly
Comment: The variable '$a' cannot be retrieved because it has not been set. that is the error, and interesting I had this error when I was trying to post it, then it ran, now it came back
Answer: `Not tested.
$filename = 'c:\somedir\somefilename.tsv'
$ht=@{}
filter Get-Record { if ($ht[$_] -ne $HeaderLine) {$ht[$_]} }
$HeaderLine = $null
$counter = 0

get-content -path\*filename*.tsv -encoding ASCII |
 foreach {
           if (-not $HeaderLine)
             { $HeaderLine = $_ }

            $counter++

            $ht["$($_.split("`t")[1])$counter"] = $_

         }

$HeaderLine | set-content $filename  #header
$ht.keys | Sort | Get-Record | add-content $filename

It should sort on whatever column you use from the $_.split("t")` array,
Comment: Should not $HeaderLine be defined earlier? Getting the error The variable '$HeaderLine' cannot be retrieved because it has not been set.
Comment: $HeaderLine should get set by the first line of the first file read.
Comment: Unfortunately it is failing with the error I described. When I physically defined the header by listing all the columns, it worked, but I should not have tondo that. And the biggest issue, it is very slow. Took 35 min to process less than 10 files. They are quite large. Any suggestions to improve the performance or should I move to vb.net?
Comment: It sounds like you have strict mode set.  I added a line to define $HeaderLine before it's used in the IF test.  As far as speeding it up, I'd need to know more about the data.  Is the field you're sorting on going to be unique for each record? If not, will there by relatively many or few records with the same value?
Comment: Yes I did have the strict mode set. Seems like it is working with this minor tweak. The sort field should be unique, at least to the best of my knowledge. And the number of files close to 100 with probably 150000 records per each file. Number of columns is quite substantial, over 60. And I assume I could add out-file -filepath $filename -encoding ASCII command after ($ht.keys | sort) -notmatch $HeaderLine | Get-Record ?
Comment: Just a little explanation, if it is possible. Do I need to add anything into sort command ( split array column expression) or it should be specified in ht.keys command? I am sorry , it is just absolutely new to me.
Comment: You don't have to add anything.  What it's doing is creating a hash table that uses the field you want to sort on as the key, and the entire line as the value. Once you have that you just sort the keys, and then spit out the hash table values in that order.
Comment: Just noticed and fixed a bug in that script. It won't exclude multiple headers as originally posted.
Comment: So, if you I need for example column 7 as the sort key, the hash table should have [6], correct?
Comment: Yes. You're basically splitting the line on the tabs, and choosing one of the split elements to be the hash table key.  Then you sort the keys. It isn't being converted to csv, and the output will be the original input line, so the output will still be tsv format.
Comment: Ran very fast, but created only one output record, and expected a lot - lot more. Had the input of 10 files with lots of records in each of them
Comment: The only change I made was added the real path to the output and input file. Now, what I did not do is specify the real column number I need to sort by, and since the first occurrence is the same , it produced only one file. makes sense to me.
Comment: I think it is working now as I expected. The only thing I do not need the header on the final result file. Can I just use the select-object cmdlet and skip 1, or it is possible to do with one of the commands already in the script? I did a quick get-help and did not find anything
Comment: The header is being added to the final result by the next to last line in that script. If you remove that, you won't get a header in the final result.
Comment: Removed it, works really fast. I did a quick count and found that I am missing couple of records from the total. You once asked if there is a possibility of duplication. Let's say, if there are. Could it be possible to included them in the final output? Trying to figure out what could cause the issue with loosing records.
Comment: Duplicate keys would account for missing records.  You'll either need to make the hash table values collections or arrays (which is going to slow it down), or find a way to make the keys unique.  I added a counter, and appended the value of that to the field value being used for the keys.  Hopefully that will eliminate the duplicate records without slowing it down too much.
Comment: mjolinor, was too fast to proclaim the total success, I am definitely loosing 1 record from each file, and when displaying the counter it is giving me one more that actual records written. It does one extra read I guess. Bur more worrisome is to loose one record from each file.
Comment: It's supposed to lose one record from each file - the header.
Comment: what I meant that it is loosing one more besides the header. let's say I had 10 files with 14001 in it (one for the header). then output expected to be 140000 (losing one for the header from each file). the actual result on the output file is 139990. It is easier to explain with real numbers
Comment: You're the only one with the data files, so you're the only one that can say which records are missing.  I'm not going to try and debug that blind.
Comment: mjolinor, I must say you were right. The last file was smaller, nothing was lost. I have made some changes to have the counter to show my real output numbers. And that was it. Thanks again for your help.


How can I play a guitar-based song on piano?

Question: The song in the picture as an example, it's a guitar-based song, I tried to play these chords on piano and sing but couldn't feel like it is the same song (Even after I did the transposing) , how can I turn it to a piano version (a new arrangement like many players do on Youtube).
https://qph.ec.quoracdn.net/main-qimg-3442feaf90bcb9509065deb29a0ce451?convert_to_webp=true
Comment: I'm voting to close this question because the link is dead, and there's not enough information to know what song is being discussed.
Answer: That one is actually very straightforward to arrange for piano, as you have so many ways to play each chord, just choose ones that sound good to you.
It doesn't need anything clever - you may just be using an inversion which doesn't match the chord used in the guitar version.
Answer: You won't make it sound much like the original, which was most likely written on guitar. Reason being, the strum that the rhythm guitar is using is difficult to emulate on piano.Of course, you can play the melody, bass and lead bits, but you'll never make the piano sound like the guitar strummed here. You may approximate it, with arpeggiated chords, but that's about all.You could play a different version, which is what others may do, and, yes, it changes the feel, even though it would stay in 6/8 and in D. You also would, as Dr. Mayhem suggests, have fun with different chord voicings.


FindsBy from SeleniumExtras can't find IWebElement

Question: I've updated packages from my project on Mac and find out that PageObjects has been moved to SeleniumExtras. I struggle to use it but the error "System.NullReferenceException : Object reference not set to an instance of an object." is shown.
Nevertheless, the same element can be found through FindElement. Currently, I run out of ideas and would appreciate the help.
Thanks!
<code>using Microsoft.VisualStudio.TestTools.UnitTesting;
using NUnit.Framework;
using NUnit.Compatibility;
using OpenQA.Selenium;
using OpenQA.Selenium.Chrome;
using SeleniumExtras.PageObjects;

namespace SomeTest
{
    [TestFixture]
    public class UnitTest1
    {
        [FindsBy(How = How.XPath, Using = "//*[@id='lst-ib']")]
        public IWebElement _searchField;

        public IWebDriver chrome;

        [SetUp]
        public void TestMethod1()
        {
            chrome = new ChromeDriver(@"/Volumes/Macintosh HD/QA/SomeTest/SomeTest/bin/Debug/netcoreapp2.1");
        }
        [Test]
        public void SomeTest()
        {
            chrome.Navigate().GoToUrl("https://www.google.com/");
            _searchField.SendKeys("Some Text");
        }
        [TearDown]
        public void CloseBrowser()
        {
            chrome.Close();
        }
    }
}
</code>
Answer: Got solution:

Add all DotNetSeleniumExtras through NuGet Packages: PageObjects and PageObjects.Core;
Add namespaces:
using FindsByAttribute = SeleniumExtras.PageObjects.FindsByAttribute;
using How = SeleniumExtras.PageObjects.How;


How to disable the "clear log messages" functionality for administrators?

Question: For a production site, for auditing purposes, I would like to disable the "clear log messages" functionality for all administrators. This function is shown within admin/reports/dblog (within the "Recent log messages" report).
How to do this?
Answer: You would have to use hook_form_alter, and either remove that form or put access control on it. This needs to happen in a custom module.
Answer: A quick css display:none on the form will do it, assuming you trust your administrators enough to not go into "inspect element" and turn it back on again.


Why does FIFA have so much authority over the entire sport of football?

Question: With respect to all of the recent headlines regarding FIFA, Sepp Blatter, and corruption, there are several aspects that don't make sense to me.  For instance:

Why does FIFA have the power to conduct trials, issue fines and bans, and otherwise exercise powers that are generally reserved for the judiciary branch of a sovereign government, and from whence does this power over private individuals derive?
How can FIFA ban someone from an entire sport? What does being banned from an entire sport even mean?
If there's such corruption in FIFA, why do football teams allow FIFA to have so much influence over their sport in the first place instead of just looking elsewhere and/or doing their own thing?
Who gave FIFA control of all of football in the first place?
Why is nobody proposing a world where people continue playing football, without FIFA?  That seems like such an obvious solution to the corruption issue to me, but I'm guessing in actual fact it's not?

Can someone shed some light upon what's going on, and especially upon the background details about how/why FIFA wields so much influence over an entire sport (and continues to do so, despite such obvious corruption)?
Comment: 3: Teams/Club leaders might  be corrupt too unfortunately ;)
Answer: FIFA has complete control over all footballing activities in the world since it is the recognized regulatory body for the sport of football. Every sport has its own international regulatory body. For example: International Tennis Federation (ITF) for tennis, International Association of Athletics Federations (IAAF) for athletics, etc. These regulatory(or governing) federations become official only after receiving recognition as the official governing bodies for the sport by the International Olympic Council (IOC).
As the official governing body for football, FIFA has the following roles and responsibilities:

FIFA has the duty to maintain top notch standards in soccer.
It is tasked with administering the world soccer associations.
It is in charge of organizing and promoting the tournaments.
It is in charge of governing field matters relating to soccer.
The body is responsible for constant development of soccer.
It relies on the statutes to govern the system.
It is also in charge of the Laws of the Game which are maintained by International Football Association Board (IFAB).

In answer to your questions:

FIFA has no powers like any judiciary body of a sovereign nation. FIFA can only govern in matters relating to the sport of football. Hence any trials, fines and bans will be in direct relation to the sport of football or footballing activities. FIFA's 'power' over private individuals extends only to their participation in footballing activities, including but not restricted to, playing the game or managing a team in any competitive game and taking part in any form of governance of football related activities.
Being banned from football means the person is not allowed to take part in any activities pertaining to football, i.e., they cannot hold any positions in football governing bodies, and they cannot be part of a team(player or manager) in any competitive match. They can be allowed to watch football games, if they purchase the tickets privately. Some people might not be allowed to even do that, which means they have been given a 'stadium ban'.
As to the corruption, well nobody can do anything about it, except the Ethics Committee in FIFA or the Court for Arbitration in Sport(CAS). Expecting the clubs to do something about FIFA's corruption is like expecting a player to show a red card to a referee in a football match. There is no chance of that scenario occurring whatsoever (even if it does happen, it will only result in the player getting into a lot of trouble). The maximum clubs can do is file a case against FIFA with CAS, although I don't see that happening, since none of the clubs have been directly affected by the corruption that has currently put FIFA in the limelight.
FIFA was recognized as the world governing body for football by the first few nations to play the sport in the early 1900's. FIFA's position became official upon recognition by the IOC as the the governing body for football in the world.
Asking football to continue without FIFA is like asking for a match to be played without a referee. Apart from the fact that FIFA governs football all over the world, FIFA also organizes tournaments like the World Cup, Youth World Cup, etc and has other roles and responsibilities as described above. A solution to what you are asking would be to disband FIFA and create another regulatory body for football. But the problem here is not FIFA, but the people running FIFA. Hence, even disbanding FIFA would make no sense if the same people are running the new governing body. The real solution is to get rid of the corrupt people, and ensure FIFA is being run in a clean and transparent way. Hence, FIFA President Sepp Blatter and FIFA Vice-President Michel Platini have been given 8 year bans upon being found guilty of corruption by the FIFA Ethics Committee.
Comment: @aroth. Many (or most?) local teams will be part of the governing pyramid that has FIFA at the top. Usually as a player you will only interact with your club and a local governing body, but they will subscribe directly (or indirectly via a national football association) to FIFA. But if you want to step outside the FIFA pyramid, nobody can stop you. And Sepp Blatter could still play football with some friends in the park despite a FIFA ban. Your private football team could play other private teams whenever they want.
Comment: To address your point about "purchasing a world-class team", FIFA can't control everything that you can do with that team and, I believe, you could choose not to interact with them. But then you likely would not be able to compete in whatever league the team is a part of (since the league likely recognizes FIFA) and likely would not be able to partake in things like the Champions' League or other International Competitions (which are also governed, ultimately, by FIFA).
Comment: Thanks for the detailed answer.  With respect to #1, do you mean that if I were to play a game of football on a local team and do something both disgraceful and football-related then FIFA would have power to intervene even if I've never entered into any agreement to abide by FIFA's terms?  And the same if I were to scrape up enough money to purchase a world-class team; FIFA could dictate what I can do with that team even if I don't enter into any direct agreement with them?  I'm still somewhat confused about how they can preside over _everything_ football-related.
Answer: FIFA has the power to do so because the various nations, and by proxy the various players, agree to give it that power.  It is very similar to the NCAA in the US; it has no "legal" authority, and at any point any of its members could simply walk away.  That's not a theoretical point; speculation has been going for years that the European and South American nations might pull out of FIFA in order to form a new body that is more in their favor (as opposed to in the favor of smaller nations, as FIFA was set up to be).
In any event, the various nations and leagues agree to give it this power because it serves a useful purpose to them: it is a "neutral" body that can serve to act as judge and jury in disputes between nations, and set ground rules that all can follow.  If FIFA didn't exist, some other body would, and would serve largely the same purposes.  Whether they would have the same issues is an interesting question in and of itself.


Why do these matrices within Pascal's triangle all have determinant $1$?

Question: In Pascal's triangle left-justified, take any square matrix that shares a border with the left edge of the triangle. An example is shown in red below.

It seems that the determinant of such a matrix is always $1$.

Is there an intuitive explanation why the determinant of such a matrix is always $1$?

(Here is an example of an intuitive explanation: a scalar triple product is $0$ if the vectors are dependent, because the scalar triple product is the volume of the parallelipiped formed by the vectors.)
I know that the determinant of a matrix is the volume of the region that results from applying the matrix to the unit cube. So if the determinant is $1$, the volume is unchanged. But I don't see why a matrix in Pascal's triangle (as described above) preserves volume.
I found some articles about Pascal's triangle and determinants, but the matrices there were different from mine; they were symmetric or lower/upper triangular, so it's obvious that their determinants equal $0$.
Context: Recently I've been wondering a lot about Pascal's triangle, for example, does it contain three consecutive integers? Can it be split?
Comment: Not an intuitive explanation, but if you take successive differences of the rows, you end up with a upper triangle matrix with 1's on the diagonal.
Comment: Other special partitions of the Pascal triangle [here](https://www.sciencedirect.com/science/article/pii/S2468227621002362)
Comment: In the terminology of [Ira Gessel, Gérard Viennot, *Binomial Determinants, Paths, and Hook Length Formulae*, Adv. in Math. **58** (1985)](https://sites.math.washington.edu/~billey/classes/561.fall.2021/past.articles/Gessel.Viennot.1985.pdf), your red determinant is $\dbinom{i, i+1, \ldots, i+k-1}{0, 1, \ldots, k-1}$. The claim that this determinant is $1$ follows easily by induction from Lemma 9 in that paper, and is probably a particular case of something explicitly stated there, although I don't know the paper well enough to tell what.
Answer: By definition on the lattice $\mathbb Z_+^2$, any entry $a_{ik}=a_{i-1,k} +a_{i-1,k+1}$ with all $a_{ik}=0,k>i$,  $a_{1,1}=1$.
It follows, that by subtraction of rows, without change of the determinant, you may transform your square matrix  into an upper tridiagonal matrix with all 1 on the diagonal.
Answer: Here is another point of view that I will express through 2 examples :
Case $3 \times 3$
$$\left(\begin{array}{rrr}1&7&21\\1&8&28\\1&9&36\end{array}\right)=
\left(\begin{array}{rrr}0&1&0\\0&0&1\\1&-3&3\end{array}\right)
\left(\begin{array}{rrr}1&6&15\\1&7&21\\1&8&28\end{array}\right)$$
More generally, denoting by $R_k$ the $3$ first entries of the $k$th row of Pascal's triangle that we are concerned with, we have :
$$\underbrace{\left(\begin{array}{r}R_{k+1}\\R_{k+2}\\R_{k+3}\end{array}\right)}_{M_{k+1}}=
\underbrace{\left(\begin{array}{rrr}0&1&0\\0&0&1\\1&-3&3\end{array}\right)}_{L_3}
\underbrace{\left(\begin{array}{rrr}R_{k}\\R_{k+1}\\R_{k+2}\end{array}\right)}_{M_{k}}$$
which is valid for any $k>1$ with the same matrix $L_3$ where you have may have recognized the coefficients of the $3$rd row of Pascal's triangle (minus the first one) : $1,3,3,1$ with alternated signs.
Taking the determinant on both sides, as the determinant of $L_3$ is $1$, we get :
$$\det(M_{k+1})=\det(M_{k})$$
therefore the result is proven by an immediate recurrence reasoning, knowing that the initial determinant is :
$$\det M_2 = \det \pmatrix{1&2&1\\1&3&3\\1&4&6} = 1$$
Case $4 \times 4$
$$\left(\begin{array}{rrrr}1&6&15&20\\1&7&21&35\\1&8&28&56\\1&9&36&84\end{array}\right)=
\left(\begin{array}{rrrr}0&1&0&0\\0&0&1&0\\0&0&0&1\\-1&4&-6&4\end{array}\right)
\left(\begin{array}{rrrr}1&5&10&10\\1&6&15&20\\1&7&21&35\\1&8&28&56\end{array}\right)$$
which can be generalized in the same way as in the first case ; for any $k>2$ :
$$\underbrace{\left(\begin{array}{r}R_{k+1}\\R_{k+2}\\R_{k+3}\\R_{k+4}\end{array}\right)}_{M_{k+1}}=
\underbrace{\left(\begin{array}{rrr}0&1&0&0\\0&0&1&0\\0&0&0&1\\-1&4&-6&4\end{array}\right)}_{L_4}
\underbrace{\left(\begin{array}{rrr}R_{k}\\R_{k+1}\\R_{k+2}\\R_{k+3}\end{array}\right)}_{M_{k}}$$
Here, coefficients $1,4,6,4,(1)$ with an alternated signs are the elements of the $4$th row of Pascal's triangle.
Etc.
Of course, a rigorous treatment is possible if needed, but I think I have conveyed the main ideas by presenting these 2 examples.
Remarks :

The underlying reason for the alternate sign binomial coefficients is that the inverse of any Pascal matrix such as :

$$P_4=\pmatrix{ 1 &0 &0 &0 & 0\\
  1&1& 0& 0 & 0\\
   1 &2 & 1& 0 & 0\\
  1 & 3 &3 & 1&  0\\
   1 &4 & 6 &4 & 1} \ \text{is} $$ $$P_4^{-1}=\left(\begin{array}{rrrrr}1 &0 &0 &0 & 0\\
  -1&1& 0& 0 & 0\\
   1 &-2 & 1& 0 & 0\\
  -1 & 3 &-3 & 1&  0\\
   1 &-4 & 6 &-4 & 1\end{array}\right)$$

Matrices similar to matrices $L_k$ are often met in linear algebra in particular as companion matrices of more generally as "Leslie matrices".
Comment: I have improved my answer (see in particular Remark 1 at the bottom)
Answer: This is NOT an intuitive explanation, but it comes from the relations between binomial coefficients.
You can do it by induction. The case of matrices of size $2$ is obvious. If your matrix $M$ has size $k$, and let $L_1,\ldots,L_k$ be the rows of your matrix, do successively the row operations $L_k\leftarrow L_k-L_{k-1}, L_{k-1}\leftarrow L_{k-1}-L_{k-2},\ldots,L_2\leftarrow L_2-L_1$.
Now expand your determinant with respect  to the first column. The usual relations between binomial coefficients shows that you get the determinant of the submatrix of $M$ obtained by deleting the last row and last column. Now apply your induction hypothesis.
For example, if you take your matrix in red, performing the row operations above yields the matrix $\begin{pmatrix}1 & 6 & 15& 20 \cr 0 &1 & 6 & 15 \cr 0 & 1 & 7 & 21 \cr 0 & 1 & 8 & 28 \end{pmatrix}$.
So we you expand the determinant, you get the determinant of $\begin{pmatrix}1 & 6 & 15\cr 1 & 7 & 21\cr 1 & 8 & 28\end{pmatrix}$


Show a term description when the search filter in a view is that term?

Question: I have a content type that has several vocabularies. Nodes can have 0, 1, 2 or all 3 terms selected.
Ive added a field to the terms so they all have a description as well as their name.
Color (vocabulary)
-Red (term)
  --This has red items (term description)
-Blue (term)
  --This has blue items (term description)
-Green (term)
  --This has green items (term description)
Pattern (vocabulary)
-Stripy (term)
--This has stripy items (term description)
-Spotted (term)
--This has spotty items (term description)
-Pinstripe (term)
--This has pinstriped items (term description)
I have a View of nodes of the content type. I'm using Better Exposed Filters so you can filter by the different terms. I need it so when you have selected a single term its description is shown at the top of the view.
So if you checked 'Red' and 'Stripy', or 'Blue' 'Spotted' and 'Pinstripe', then no description would be shown. But if you just checked 'Blue' then 'This has blue items' would be printed at the top of the view before the nodes tagged with 'Blue' were listed.
Comment: This sounds like a job for contextual filters and views attachments.
Comment: I cant attach this view to a term page (which is what I think your suggesting) as there are filters based on many different taxonomy vocabularies.
Comment: What is preventing it?
Comment: It doenst solve my problem. My view is a single page, its not attached to term pages. Also you can filter with many different vocabularies for a single search.
Comment: Can you edit your question to describe how filtering with many vocabularies is seat up?
Comment: Nodes have multiple vocabularies assigned to them, and the view can filter these terms. Sorry but whats not clear?
Comment: Can you describe how these filters are set up as part of your question?
Comment: Ive updated my question.
Comment: What url paths are you using, are you updating the path when you change the filters?
Comment: I havnt changed the paths, they are the default ones created by the view. Its a string like mysite.com/myviewname/?tid%5B%5D=22&tid%5B%5D=23&tid%5B%5D=24&tid%5B%5D=25&tid_1%5B%5D=26&keys=
Answer: Create a template for the view.
Edit the view. Under "Advanced" find "Theme: Information". Click on it to find the names of the templates that are applied in your theme. I think "Display output" is what you want to use. It will show you the contents of the template.
In your custom theme, create a template with the same name as the template you copied. Paste in the contents of the template you copied.
Now you can use PHP to get the information you want (available variables are listed in the comments of the templates), manipulate it as needed, and add it to the <code>$header</code> or wherever you want it, without any PHP in the database.
Answer: I really don't know if this is the best way to solve this but what I would do in that case is:

Add two fields to the view, one for each term description
Hide them (exclude from display)
Create a new custom field below them (so you could use the fields from (1) as "Replacement Patterns")
Re-write the result of the custom field using PHP (Views PHP) checking whether both descriptions are empty or not, to decide when to show or not.

Hope it helps!
Comment: I guess the solution would be *without* Views PhP, for security reasons...?
Comment: The Views PHP exists for a reason. I guess you could even call a function there instead, passing the values to sanitise and validate them before doing anything?
Answer: You might be looking for this:
https://drupal.org/project/taxonomy_tooltip
Using you get description of vocabulary and term description on hovering wherever they appear in content.It automatically add CSS and some effects to term or vocabulary name and shows description of it on hover.
There are lot other options also available you might be interested in. related to tooltip like :
tooltip,
field tooltip,
views tooltip.


I want to identify duplicates and keep the most recent one and delete the other in Google Sheets

Question: I want duplicates in my data identified. Once I have this data I want to sort the duplicates by date and keep the most recent one.
I cannot not provide a copy of my sheet because of the sensitive information inside.
Comment: Welcome. The question is too broad as it doesn't include enough details. Regarding your sheet, create a demo sheet with fictitious data and also add a brief description of your search/research efforts as is suggested on [ask].
Answer: do it like this:
<code>=ARRAYFORMULA(IFERROR(VLOOKUP(UNIQUE(B:B),
 QUERY({A:B}, "select Col2,Col1
               order by toDate(Col1) desc
               format Col1 'dd/mm/yyyy' ", 0), {2, 1}, 0)))
</code>

<code>=ARRAYFORMULA(QUERY(IFERROR(VLOOKUP(UNIQUE(QUERY({Data!A:H},
 "select Col3
  where toDate(Col5) >= date '"&TEXT(A1, "yyyy-mm-dd")&"'
    and toDate(Col5) <= date '"&TEXT(B1, "yyyy-mm-dd")&"'
  order by toDate(Col1) desc ", 0)),
 QUERY({Data!A:H},
 "select Col3,Col1,Col2,Col4,Col5,Col6,Col7
  where toDate(Col5) >= date '"&TEXT(A1, "yyyy-mm-dd")&"'
    and toDate(Col5) <= date '"&TEXT(B1, "yyyy-mm-dd")&"'
  order by toDate(Col1) desc
  format Col5 'mm/dd/yyyy' ", 0), {2,3,1,4,5,6,7}, 0)),
 "format Col1 'yyyy-nn-dd hh:mm:ss', Col5 'mm/dd/yyyy'"))
</code>

<code>=ARRAYFORMULA(QUERY(IFERROR(VLOOKUP(UNIQUE(QUERY({Data!A:H},
 "select Col2
  where toDate(Col5) >= date '"&TEXT(A1, "yyyy-mm-dd")&"'
    and toDate(Col5) <= date '"&TEXT(B1, "yyyy-mm-dd")&"'
  order by toDate(Col1) desc ", 0)),
 QUERY({Data!A:H},
 "select Col2,Col1,Col3,Col4,Col5,Col6,Col7
  where toDate(Col5) >= date '"&TEXT(A1, "yyyy-mm-dd")&"'
    and toDate(Col5) <= date '"&TEXT(B1, "yyyy-mm-dd")&"'
  order by toDate(Col1) desc
  format Col5 'mm/dd/yyyy' ", 0), {2,1,3,4,5,6,7}, 0)),
 "format Col1 'yyyy-mm-dd hh:mm:ss', Col5 'mm/dd/yyyy'"))
</code>
Comment: The data is being pulled from the Data Sheet and being imported to Sheet2 and filtered out by the dates listed in row 1. The data that is being imported, I the duplicates removed but keeping the latest date. See the spreadsheet: https://docs.google.com/spreadsheets/d/1X_NBWq1m9iBxvYXhy2wcttHanvPFPlAOJWgbbKbJimQ/edit?usp=sharing
Comment: QUERY(All!A:Z, "select A, B, C, D, E, F, G, H
                 where toDate(E) >= date '"&TEXT(A1, "yyyy-mm-dd")&"'
                   and toDate(E) <= date '"&TEXT(B1, "yyyy-mm-dd")&"'
                 order by (I) desc", (FILTER(A:Z,TRUE)
                  ))
Comment: what is the purpose of "(FILTER(A:Z,TRUE) " ?
Comment: The purpose of filter was to only show items that were not duplicates. This formula is only showing items that are duplicates.
Comment: @retter did you try the 2nd formula from the answer? if this still not what you seek, go to your sheet you shared and make manually an example of your expected outcome
Comment: The first formula returns no data. The 2nd formula only returns 7 results. It should return more. The only results that should not show up are the duplicated results. Everything that is not duplicated should be returned.
Comment: which column should be unique and with no duplicates? column with names Mike, Julie, etc. ??
Comment: Column B. The projects
Comment: Its showing more results but not all over them. Results should only be removed if there are duplicates. With duplicates the most recent date is kept. I added in green of what the results should be on the sheet.
Comment: it does exactly that but you probably forgot that you also filter by date range (A1, B1)  that's why you getting fewer results than you expect.
Comment: I see. So how do I make it return the results I want? Thanks for all of your help
Comment: widen the range... let A1 be 1/1/2000 and B1 be 1/1/2020 (for example)


Showing the expected value of $S_t^n$ where $S_t=S_0e^{(r-\frac{\sigma^2}{2})t+\sigma W_t}$

Question: The answer is $\mathbb{E}[S_t^n]=S_0^ne^{nrt+\frac{n(n-1)}{2}\sigma^2t}$. But I can't obtain this result.
First off, while this might be slightly disconnected to the question, "what is the distribution of $S_t$?" I heard it's log-normal.
But in a nutshell, what exactly is it's probability density function? I can't find a clear answer anywhere; I was told it has mean $\mu = \text{ln}S_0+(r-\frac{\sigma^2}{2})T$ and variance $\sigma^2T$ but am I to substitute these straight into the density function of a normal distribution, $f(x)=\frac{1}{\sigma \sqrt{2 \pi}}e^{-\frac{(x-\mu)^2}{2\sigma^2}}$?
Now to the question itself, my attempt,

$S_0^n\mathbb{E}[e^{n(r-\frac{\sigma^2}{2})t+n\sigma x}]=S_0^n \frac{1}{ \sqrt{2 \pi}t} \int_{-\infty}^{\infty} e^{n(r-\frac{\sigma^2}{2})t+n\sigma x-\frac{x^2}{2t}}dx$ taking $f(x)$ as the normal density I stated above. Proceeding with the in the usual way, I end up with $S_0^ne^{nrt}$ simply the nasty looking terms of $n$ that I should get disappearing by cancellation.
Specifically, I get $\frac{n \sigma^2t-n \sigma^2t}{2} = 0$

Either that 1. I made an error in my integration process 2. I used the wrong $f(x)$(density function) for integration.
Can someone please point out what I should be doing? Thank you so much
Answer: First pull constant factors out of the expectation:
$$
S_0^n\mathbb{E}[e^{n(r-\frac{\sigma^2}{2})t+n\sigma W_t}]=S_0^ne^{n(r-\frac{\sigma^2}2)t}\mathbb E e^{n\sigma W_t}
$$
You're now left with $\mathbb E e^{n\sigma W_t}$. Rather than carry around all those parameters, you can make your life easier by writing $n\sigma W_t = aZ$ where $Z$ has standard normal distribution and $a=n\sigma\sqrt t$. Now calculate:
$$
\mathbb E e^{aZ} = \int e^{az}\frac1{\sqrt{2\pi}}e^{-z^2/2}\,dz
= \int \frac1{\sqrt{2\pi}}e^{-[z^2-2az]/2}\,dz
= \int \frac1{\sqrt{2\pi}}e^{-[(z-a)^2-a^2]/2}\,dz=e^{a^2/2}.
$$
Apply this with $a=n\sigma\sqrt t$ to obtain
$$
\mathbb Ee^{n\sigma W_t}=e^{(n\sigma\sqrt t)^2/2} = e^{n^2\sigma^2t/2}.
$$
Combining this with the factors pulled out earlier, the exponent will be
$$
n\left(r-\frac{\sigma^2}2\right)t+n^2\sigma^2t/2=nrt+\frac{\sigma^2t}2(n^2-n),
$$
as desired.
Comment: Hello, thanks for answering; one question for your answer. Isn't the expected value $\mathbb{E}$ we need is with respect to $t$? Is it with respect to $W_t$? I ask this as in the very first line, you took out the term with exponents $n(r-\frac{\sigma^2}{2})t$ Is our random variable $W_t$ and not $t$?
Comment: @JohnTrail My understanding is that $t$ is a constant. If $t$ were a RV, the expectation you're trying to calculate would have to end up being free of $t$. The only random component seems to be $W_t$.
Comment: I see, I'll have that in mind when solving similar problems in future, thank you!!


Substituting multiple occurrences of a character inside a grep match

Question: I am trying to use TextWrangler to take a bunch of text files, match everything within some angle-bracket tags (so far so good), and for every match, substitute all occurrences of a specific character with another.
For instance, I'd like to take something like
xx+xx <f>bar+bar+fo+bar+fe</f> yy+y <f>fee+bar</f> zz

match everything within <f> and </f> and then substitute all +'s with, say, *'s (but ONLY inside the "f" tag).
xx+xx <f>bar*bar*fo*bar*fe</f> yy+y <f>fee*bar</f> zz

I think I can easily match "f" tags containing +'s with an expression like
<f>[^<]*\+[^<]*</f>

but I have no idea on how to substitute only a subclass of character for each match. I don't know a priori how many +'s there are in each tag.
I think I should run a regular expression for all matches of the first regular expression, but I am not really sure how to do that.
(In other words, I would like to match all +'s but only inside specific angle-bracket tags).
Does anyone have a hint?
Thanks a lot,
Daniele
Comment: Is this question **really** about the UNIX tool `grep` as tagged or is it about some function of the same name within some tool named `TextWrangler` which hasn't been tagged?
Comment: Hi, honestly that can be both. If I can do it in TextWrangler (which I forgot to tag - I'll fix straight away, sorry), via its grep function, that would be perfect. If there's another way with command line "grep" (I'm on OSX) that might also work...
Comment: UNIX grep isn't for doing substitutions it's for doing `g/re/p` (there is a clue in it's name :-) ), i.e. it's to Globally find a RegExp and Print the matching string. It'd be trivial with awk if you're open to that.
Answer: In case you're OK with an awk solution:
$ awk '{
    while ( match($0,/<f>[^<]*\+[^<]*<\/f>/) ) {
        tgt = substr($0,RSTART,RLENGTH)
        gsub(/\+/,"*",tgt)
        $0 = substr($0,1,RSTART-1) tgt substr($0,RSTART+RLENGTH)
    }
    print
}' file
xx+xx <f>bar*bar*fo*bar*fe</f> yy+y <f>fee*bar</f> zz

The above will work using any awk in any shell on any UNIX box. It relies on there being no < within each <f>...</f> as indicated by your sample code. If there can be then include that in your example and we can tweak the script to handle it:
$ awk '{
    gsub("</f>",RS)
    while ( match($0,/<f>[^\n]*\+[^\n]*\n/) ) {
        tgt = substr($0,RSTART,RLENGTH)
        gsub(/\+/,"*",tgt)
        $0 = substr($0,1,RSTART-1) tgt substr($0,RSTART+RLENGTH)
    }
    gsub(RS,"</f>")
    print
}' file
xx+xx <f>bar*bar*fo*bar*fe</f> yy+y <f>fee*bar</f> zz

Comment: Thanks, this is perfect. Is there a way to tweak it should I need to substitute TWO characters? E.g. + with * and, say - with _. (I need to look much more into it before being able to understand what it does...)
Comment: And yes – now that you mention it, I could indeed have other tags within the  tag, say xx+yy+zz+ww. I guess your second example should solve the issue (it is unclear to me what the RS does exactly: is it equivalent to \n?). Thanks so much again.
Comment: for your first question - sure, it's only software and so anything is possible. Just add a line that says `gsub(/-/,"_",tgt)` under the existing gsub() line. For your second - awk reads records that are separated by whatever value `RS` contains. It's almost always `\n` but sometimes `\r\n` and sometimes other things. In your case I'm assuming that RS is `\n`. So I'm replacing `` with a char that cannot currently appear in  the record (since records are **separated** by RS) so I can then negate that char in the regexp `[^\n]*`. That will work whether `RS` is `\n` alone or `\r\n`.
Comment: Thank you, everything is much clearer now. Just one last question: what if between my tags I also allowed having new lines \n? Could I set RS differently to avoid confusion?
Comment: You can hack it by throwing in control-chars and hope they don't show up in your data but it's not that easy to handle that robustly for **any** input since then you'd need to figure out what string DOES separate your records, and depending on  your awk version you may or may not be able to use a multi-char string for RS, and there are various possible solutions. It's not a huge deal but we'd just have to see what your data really looks like.


Divisor sum property of Euler phi function with Mobius inversion

Question: I have the following formula of the Mobius inversion:
$$g(n) = \sum_{d|n}f(d) \iff f(n) = \sum_{d|n}g(\frac{n}{d})\mu(d)$$
The euler phi function has a divisor sum property: $\sum_{d|n}\phi(\frac{n}{d}) = \sum_{d|n}\phi(d)$
As I understand it:
In this case $f = g = \phi$ and $\mu(d) = 1 \,\text{for }\forall d$.
Are my assumptions correct(is the above understanding of the connection of Euler phi and Mobius correct)?
Why is $\mu(d) = 1$ if my assumptions are correct.
Answer: In the property for Euler's totient function we just use that the divisors $d$ are in bijection with the codivisors $n/d$, so that
$$\sum_{d|n}\phi\left(\frac{n}{d}\right) = \sum_{d|n}\phi(d)=n$$
This is also called Sum Over Divisors Equals Sum Over Quotients.
However, the Moebius inversion formula, for $f(n)=\phi(n)$ gives  $g(n)=\sum_{d\mid n}f(d)=n$, and not $g(n)=\phi(n)$. So this is impossible.
Comment: Moebius version formula is a different topic. This is like you would ask to show that $2$ divides $6$ by using the functional equation for $\zeta(s)$.
Comment: So basically I don't even have to know the Mobius function to prove this.
Comment: Yes, you can prove it just by "sum over divisors equals sum over quotients" for the divisor sums.
Comment: Do you maybe know how to prove it with Mobius function ?


Numerical methods for solving nonlinear ordinary differential equation

Question: I have been reading the Strogatz book on Nonlinear Ordinary Differential equations and I understand the graphical/qualitative method to solving these types of equations. However, Strogatz did not seem to address the role of numerical methods in solving nonlinear ODEs or systems of ODEs. I also looked at the book by Jordan and Smith on nonlinear ODEs, but they don't have a chapter on numerical methods for ODEs either.
So I was just trying to understand what is the role of numerical methods in looking at nonlinear odes? The basic approach of the qualitative methods seems to be curve sketching, so in a sense we are already using a numerical method--but we are drawing the nonlinear ODE itself instead of its integral curves right. But how does this approach relate to using numerical methods for linear ODEs like Euler, or Runge-Kutta, or Tsit?
UPDATE:
Tsit stands for Tsitouras-5 ODE solver.
Answer: Basically you use numerical methods when you want (a good approximation of) an actual value $y(x)$.  The qualitative methods might give you a very rough ballpark estimate, but numerical methods will give you the actual numbers.
I'm a bit confused by your writing "numerical methods for linear ODE's".  Numerical methods such as Euler and Rung-Kutta work just as well for nonlinear ODE's as for linear ones.  And what is "Tsit"?
Comment: thanks for the input. Sorry, by Tsit I meant the Tsitouras-5 ode solver, which I think is an adaptation of RK-4. Okay, so Euler and RK work fine for both linear and nonlinear ODEs then, so that clarifies that point of confusion. So if I need an exact solution I can use one of those methods. By "ballpark" do you mean that the qualitative methods let me sketch the direction field but don't give me an exact solution.


Append Isolated Points to Compact $T_2$-Space

Question: My question concernes a construction in  this article [PDF] at page 185:
Let $X$ be a compact $T_2$-space and $Y$ (resp. $Z$) results of adding one (resp two) isolated point(s) to $X$, then $X \cong Z \not \cong Y$.
Futhermore there is said that $X \oplus X \cong X \oplus Z \cong Y \oplus Y$ holds.
My questions:

Why $X \cong Z$ ?
" $ X \oplus Z \cong Y \oplus Y$ ?

Here the concerning excerpt:
Answer: Your statement of the result, beginning "Let $X$ be a compact $T_2$-space ..." would normally be understood as a statement about all compact $T_2$-spaces. The actual result that Scott quotes from Sundaresan is about one very particular $T_2$-space.  The reason $X\cong Z$ is that Sundaresan worked hard to get this property; it's far from automatic. On the other hand, $X\oplus Z\cong Y\oplus Y$ because both of these spaces are just $X\oplus X$ plus two isolated points.
Comment: If you read a little further in Scott's paper, you'll find that the proof that $X\cong Z$ is actually pretty easy, once you've got Sundaresan's space. Scott gives that proof as a parenthetical comment near the top of the second page.  The hard work is proving $X\not\cong Y$, which is what most of Scott's $2$-page paper is about.


What are the bounds for this median?

Question: Ok, I can't figure out how to exactly calculate the median.  I have a pdf for a continuous random variable f(x) = x/2, for 0 < x < 2, and 0 otherwise.  I THINK the median is found using something like $$1/2 = \int_0^m x/2 \,dx$$, but I don't know what the lower bound is supposed to be in this context.
Comment: Never mind, I figured it out.  I had it right.  According to a website
Let X be a continuous random variable. The median of X is the number M such that
P(X ≤ M) = 1/2.
Comment: @johny The median is not the mean.
Answer: An answer just for completeness:
In general for a continuous random variable the median is the value $n$ which satisfies $$ \int_{-\infty}^m f(x) \,dx = \frac12$$ which, with the particular density you mention corresponding to a triangular distribution with parameters $a=0, b=2, c=2$, indeed gives the expression in your question, leading you to solve $\frac{m^2}{4}=\frac12$, i.e. $m= \sqrt{2}$, slightly more than the mean of $\frac43$ and rather less than the mode of $2$.

What are the bounds for this median?


How do we call when one model is trained by another?

Question: Suppose I have one model (say, for image classification) as black box. I don't posess it and don't know it's parameters. Suppose it is web API.
Then I take bunch of images, classify them by this model and pass them as training set to my own model.
So, the knowledge of first model is transmitted to second one.
What is the term for this?
Transfer learning looks is something different.
Answer: I don't think there is any term for this other than trying to create artificial training dataset. Just a warning though, if you use another models output (instead of true label) you are likely to amplify the error from previous model, no matter how good your model is. (feeding picture of a dog when it's actually a cat).
Transfer learning is actually quite different. In transfer learning, part of the pre-trained model (e.g., VGG_19) is retained/frozen and custom layers are added to fit specific objective.
The retained layers basically are tuned to detect different data structures on a larger/diverse data while the specific neural network layers are to create final layer of abstraction for the specific task.
More technical and intuitive article - https://blog.slavv.com/a-gentle-intro-to-transfer-learning-2c0b674375a0


cards created dynamically are arranged vertically it should be horizontal

Question: I am trying to create a card dynamically but when I create the cards they  are vertically arranged. I need them to be arranged horizontally.
function _getall() {
  $.ajax({
    url: 'http://localhost:8888/books1/getall',
    type: 'GET',
    dataType:'json',
    success: function(data) {
      var templateString = '';
      $.each(data, function(i, item) {
       templateString = '

'+item.name+'

'+item.description+'

'
         + item.author+'

' + item.price+'

'
         + item.release_date+'
<button class="button"
           onclick="_deleteBook('+item.id+')">Delete</button>'
         + '<button
         class="button" onclick="_update('+item.id+')">Update</button>

';
         $('#test').append(templateString);
       })
     },
     error: function(request, error) {
       alert("Request: " + JSON.stringify(request));
     }
   });

Comment: Does that code even work at all? It seems like you have several syntax issues.
Comment: If you want `div` elements to appear side by side, use `display: inline-block`
Comment: If you are using bootstrap, you can check their documentation about cards (what they show as example is creating a grid), otherwise as @RoryMcCrossan mentioned you just need to style them appropriately to what you want.
Comment: Let's hope you want the `templateString` to be display in full page, then use ``
Answer: You should be able to create a simple css class for your cards. Here is an example of how I'm assuming your templateString will be rendered in the browser. You can see how your cards now stack horizontally.
.card {
  border: 1px solid #000;
  display: inline-block;
  padding: 20px;
  margin: 5px;
}

Taking this a step further, I would consider using a Bootstrap grid if you want a responsive layout.


How to know if some data already exists on a device disk?

Question: The simple way to check if disk include  filesystem is to do:
mount /grid/sdb /mnt

and if sdb or other /dev/sdx have file-system then mount will be succeeded, if not. Probably file system exists!
But this is an ugly way to check that.
What the other elegant alternative to check file-system on disk?
My target is to check if file-system already configured on disk's as /dev/sdb - /dev/sdx.
Answer: Your best shot to check filesystem on disks is the lsblk --output NAME,FSTYPE,LABEL,UUID,MODE
It is a list block devices command which will output all your block, hard devices on your machine. With theese option you will get something you want to achieve:
$ sudo lsblk --output NAME,FSTYPE,LABEL,UUID,MODE
NAME        FSTYPE LABEL     UUID                                 MODE
sda                                                               brw-rw----
├─sda1      ntfs   WinHyperX 2D6BFC4E0CDCFAD8                     brw-rw----
├─sda2      ext4   HyperX    ef761208-bab3-4a26-87d2-ed21a7f5a1bb brw-rw----
└─sda3      swap             74259007-a80b-4866-b059-0bdbe6331040 brw-rw----
sdb                                                               brw-rw----
└─sdb1      ext4   4TB       91e32977-0656-45b8-bcf5-14acce39d9c2 brw-rw----
sr0                                                               brw-rw----
mmcblk0                                                           brw-rw----
└─mmcblk0p1 exfat            9C33-6BBC                            brw-rw----

Just to add, if you just simply want to see if there is or not a filesystem on a disk and you dont want to know which or what is it you could also use this command file -s /dev/sda1 or even list fdisk -l which I think shows all disks and returns error when disk has no filesystem on it.


Bring code from view into a popup in Rails

Question: I want to bring this code from my view html into a popup when a link is clicked
Is that possible in Ruby on Rails? I already have the pop up working but I'm wondering about the code to show just the comments:

<% if post.comments.exists? %>
  <% post.comments.each do |comment| %>
  <%= image_tag("http://www.gravatar.com/someavatarlink %)
    <%= link_to comment.user.name, comment.user %>
            <%= time_ago_in_words(comment.created_at) %> ago
    <%= comment.comment_content %>
    <% end %>
<% end %>

Added Ajax call to _comment_form.html.erb
 <%= link_to "Link", comment, :remote => true %>
      Comments
    <% end %>

<% if post.comments.exists? %>
      <% post.comments.each do |comment| %>
      <%= link_to comment.user.name, comment.user %>
                <%= time_ago_in_words(comment.created_at) %> ago
        <%= comment.comment_content %>
        <% end %>
    <% end %>

Added def show into comments controller
class CommentsController < ApplicationController
     def new
    @post = post.new(params[:post])
    end

def show
  @comment = Comment.find(params[:id])
  respond_to do |format|
    format.js
  end

   def create
    @post = post.find(params[:micropost_id])
    @comment = Comment.new(params[:comment])
    @comment.post = @post
    @comment.user = current_user
    if @comment.save
       redirect_to(:back)
    else
      render 'shared/_comment_form'
    end
  end
end

Created show.erb.js and put it into 'comments' and 'shared' folders
$("#popup").html('<%= escape_javascript(render "comments") %>');

Then finally wrote my partial which is in comments/_comment.html.erb
<% if post.comments.exists? %>
  <% post.comments.each do |comment| %>

    <%= link_to comment.user.name, comment.user %>
            <%= time_ago_in_words(comment.created_at) %> ago
    <%= comment.comment_content %>
    <% end %>
<% end %>

Answer: 1. Ajax call
To retrieve the data you use an Ajax call.
<%= link_to "Link", comment, :remote => true %>

Rails will evaluate these requests and will look for a .js view first (it will use .html if it does not exist).
Make also sure that the controller accepts requests to .js like
def show
  @comment = Comment.find(params[:id])
  respond_to do |format|
    format.js
  end
end

2. write js view
Add a show.erb.js view to your Comments . This is a JavaScript file with ERB evaluation.
In this template use your js popup code and tell it to fill a div with your html code like so:
$("#popup").html('<%= escape_javascript(render @comment) %>');

This will render the comment. The only thing we need then is a partial to render the html of the comment.
3. write partial for html
Write a partial for the view part you want to have in the popup. This can then be used in a normal html view or the js view. To make it work with the code above call it _comment.html.erb
To know more about partials you can check the guides here:
http://guides.rubyonrails.org/layouts_and_rendering.html#using-partials
Comment: I'm looking over your answer, but have a quick question. I have put the above code in my original post into 'shared/comment' and the file name is _comment.html.erb.  Can I use the <%= link_to %> here to render the view in the popup?
Comment: FYI - making the popup is something I already have working (I'm using facebox). My issue is trying to figure out what the link_to code should be given the above code in my original post
Comment: The link needs to be a "remote" link. I updated the answer. I am just a bit confused what you would like to show. Is it 'user' or 'comment'?    Guess you will figure out how to modify the code.
Comment: ok, updated based on your input. let me know if it solves your problem
Comment: I went step by step but I'm getting this error in views/shared/_comment_form.html.erb:26: syntax error, unexpected keyword_ensure, expecting $end. I posted up all of the steps that I took in the updated post. Could you take a look?
Comment: The error is probably just the result of you leaving off an "end"  in your code.


Use Stokes' theorem to show that the line integral has the value given.

Question: Problem 9 from Apostol's Calculus 2 book, page 443:

Use Stokes' theorem to show that the line integral has the value given:
$$\int_C (y^2 + z^2)\,dx + (x^2 + z^2)\,dy + (x^2 + y^2)\,dz = 2\pi ab^2$$
Where $C$ is the intersection of the hemisphere $x^2+y^2+z^2 = 2ax$, $z>0$, and the cylinder $x^2 + y^2 = 2bx $, where $0<b<a$. Traverse $C$ in the correct orientation to arrive at the given answer.

Attempt
As suggested by Ted Shifrin, I used the portion of the cylinder between the $xy$-plane and the intersection with the sphere.
In the intersection, we have:
$$x^2+y^2 = 2bx$$
$$x^2 + y^2 + z^2 = 2ax $$
Thus,
$$z^2 = 2(a-b)x$$
Since the curve of intersection is on the cylinder, I used the following parametrization:
$$x = b + b\cos\theta$$
$$y= b\sin\theta $$
$$z=z$$
With $0 < z < \sqrt{2(a-b)b(1+\cos\theta)}$, because the surface is between the $xy$-plane and the intersection of the cylinder with the sphere. Thus,
$$\vec r(\theta, z) = (b+b\sin\theta, b\cos\theta, z)  $$
Using the Stokes theorem, we have:
$$\int_C (y^2 + z^2)\,dx + (x^2 + z^2)\,dy + (x^2 + y^2)\,dz = \iint_S 2(y-z,z-x,x-y) \cdot \frac{\partial\vec r}{\partial \theta} \times \frac{\partial\vec r}{\partial z} \,dz \,d\theta$$
Where $S$ is the portion of the cylinder between the $xy$-plane and the intersection with the sphere. Besides,
$$\frac{\partial\vec r}{\partial \theta} \times \frac{\partial\vec r}{\partial z} = b(\cos\theta, \sin\theta,0) $$
Therefore, using the parametrization, we have:
$$2b\iint_S (b\sin\theta - z, z - b - b\cos\theta, b + b\cos\theta - b\sin\theta)\cdot (\cos\theta, \sin\theta,0)\,dz \,d\theta = $$
$$2b\int_0^{2\pi}\int_0^{\sqrt{2(a-b)b(1+\cos\theta)}} [z(\sin\theta - \cos\theta) - b\sin\theta ]\,dz\,d\theta = -2\pi b^2(a-b)$$
Whose module is different from $2\pi ab^2$. What's wrong?
Comment: It should be the part of the sphere that is inside the cylinder. That surface is bounded since the sphere is bounded.
Comment: The cylinder works fine. As I said, you cut it off at the $xy$-plane and correct by the line integral over $C'$. In my haste, I erroneously said that integral was $0$. One must also pay attention to orientations!
Answer: HINT: (slightly edited) You might try that portion of the cylinder lying between the $xy$-plane and the sphere, oriented correctly. The curve $C$ and the curve $C' = \{x^2+y^2=2bx, z=0\}$ (each properly oriented) will form the boundary of this surface, and so, keeping track of orientations, one will need to adjust by the line integral over $C'$. (Did Apostol specify the orientation of $C$? I bet yes.)
Comment: Watch out for orientations and adjust by the line integral over $C'$, which is not $0$. Except for sign, what you've done so far is correct.
Comment: Could you check my attempt? I found the value $2\pi b^2(a-b)$, which is different from $2\pi ab^2$.
Comment: Actually, Apostol said to traverse $C$  to arrive at the given answer.


Redirect after login through different login form

Question: I try redirect user to specific tab on user profile page. I found couple solution how I can do that but it doesn't work if I use login form modules like Super Login, Bootstrap login form, fancy login, etc. When I try redirect user via trigger It give me AJAX error.
Then I try use Rules module and it doesn't redirect after login at all. All of it works fine if I login through standard login form.
I spent 2 days for this issue and can't find any solution. Please give me right way how to do that.
I use Bootstrap login module
link to my tab: user/[account:uid]/mytab
This is my rule:
<code>    { "rules_red" : {
"LABEL" : "redirect",
"PLUGIN" : "reaction rule",
"OWNER" : "rules",
"REQUIRES" : [ "rules" ],
"ON" : { "user_login" : [] },
"DO" : [ { "redirect" : { "url" : "user\/[account:uid]\/mytab" } } ]
 }
}
</code>
Comment: Please spend 2 more minutes on your question here to include an export of your rule which doesn't perform the redirect as you'd want (and also include the **path** (s) that you're using for those special tabs on the profile page.
Comment: Many modules that do a redirect after login use drupal_goto() to redirect after login. However, if logging in through Ajax, this call to drupal_goto() breaks the ajax response, which is why you see the ajax error. For the Fancy login module (which I'm the developer of), if you want to have a redirect after login, you need to create a custom submit handler, and set the redirect on $form_state. The module will respect that and redirect when submission is complete. The module is not compatible with Rules and Login Toboggan.
Comment: Jaypan, unfortunately my knowlage in this case very simple and I can't dfo that =( maybe anyone know another way?
Answer: I found out how to solve this issue. I install popup module and activate popup block submodule. then go to block  and set "User login" block in "Navigation" region (I use bootstrap theme), after that open configuration of "User login" module and do it popup. I hope it  will usefull for anybody.
Answer: You can alter the form in custom module and alter its submit hook , so after submission it will redirect to your desired destination
Comment: unfortunately, I don't have appropriate skill for use hook yet.


Faz diferença usar LONGTEXT ao invés de VARCHAR(255)

Question: Eu gostaria de saber se eu usar LONGTEXT ao invés de VARCHAR(255) causaria mais "lag", qual teria uma vantagem maior ??
Answer: Sim, faz diferença.
Esses dois tipos de dados são armazenados de formas diferente no banco de dados e tem funcionamentos diferentes. Por exemplo, você consegue indexar uma coluna do tipo VARCHAR, mas não pode indexar uma coluna do tipo TEXT ou LONGTEXT
Só use LONGTEXT se for para armazenar uma granda quantidade de texto nessa coluna (ela pode armazenar até 4GB). Do contrário, para informações textuais mais simples, prefira VARCHAR.
Comment: Vamos dizer que eu vá guardar o nome de arquivos, sendo que eu não saiba o tamanho desse nome, me recomenda usar qual ??
Comment: @LucasCarezia `VARCHAR(255)` é suficiente nesse caso.


How should IPv6 hosts register their name in DNS without using Active Directory?

Question: I have about 25 devices on a complex network that is now IPv6 enabled. Since, in IPv6-land, we use names and not really long IP addresses, how are my boxes supposed to register their dns names locally? With Active Directory and Windows domain clients, the clients register their IPs automatically, both v4 and v6, so that makes sense to me, but in a Linux/OSX-based environment I don't see that happening. Is there a simple client to powerdns or bind that each host can use to authenticate and update their internal/IPv6 IP?
Am I going about this the wrong way? If this isn't it, then how would you ever find some IoT device, like a Raspberry Pi, once you throw it on your IPv6 network (other than by using ndp or another protocol)? Just use static IPs for all non-Windows devices that you might want back into later?
Comment: You probably need to configure your DHCP server to handle DNS registration when it hands out an IP address. Also I'm pretty sure all DNS servers have an option to accept DNS record updates from unauthenticated clients (which is likely not a security issue on a home network).
Comment: [configuring isc-dhcpd for ddns, wiki.debian.org](https://wiki.debian.org/DDNS). powerdns and bind9 both support this update mechanism.
Answer: As some have already noted (if only in comments), if you hand out addresses via DHCP you can set things up to permit dynamic DNS updates just as you would for ipv4.
The cheap-and-cheerful alternative, which works for me on tightly-controlled (eg, home) networks, is that because all my clients are getting their v6 addresses via stateless address autoconfiguration, each client will always construct for itself the same address, and I know in advance what that'll be as it's a simple munging of the MAC address.  So I preenter those all in my static DNS zone files, and occasional devices - which I won't need to treat as proper network members - just don't get A and PTR records.
As a best-practice reminder, now I have routed v6 to the house I'm constantly surprised how many modern devices are v6-capable, and automatically acquire addresses, and use them - don't forget to make sure that your v6 firewall is up-to-snuff, as all these client devices are now fully functional, globally-accessible endpoints.
Comment: ...And when your sixxs or HE tunnel drops, a surprising number of important users notice, though you didn't expect them to be using ip6.
Comment: @AndrewDomaszek agreed!  Alhough I was specifically referring to *natively-routed* v6 to the house, it's nice to know that people are trying hard to climb onboard the train despite the stubborn refusal of most big ISPs to acknowledge the large metal object next to their horse-and-cart.


How can I know if there are innodb tables in a mysql server?

Question: I have a mysql server and I want to disable innodb support for it.
It's said that I can cut-off my memory usage up to 100MB.
I'm pretty sure but not 100% sure, that there is no innodb tables in the server.
Is there a easy way to be 100% sure that there is no innodb tables in the server so I can disable innodb support safely
Answer: In the information_schema database:
SELECT * FROM `TABLES` WHERE `ENGINE` LIKE 'InnoDB'

That'll tell you which database and tables.
Answer: select table_schema, table_name from
information_schema.tables where engine='innodb';


Loopback with meteor

Question: we have a database connected to meteor and loopback services each one edits in the same collection in database.
I found that meteor have to create the model in a way and this link in loopback https://loopback.io/doc/en/lb2/MongoDB-connector.html
 includes only connecting to database and create model not to connect already with a collection in database so anyone have an idea how to design and connect the two services with same collection to edit ? or they detect automatically the collections once I connect the datasource?
Answer: Yes, this should already work. Meteor uses OPLog tailing to detect changes to the database and it doesn't have any opinion on how the documents in the collection should look like. It will create _ids that are strings rather than ObjectIds, but it can work with either. So as long as the other services doesn't mind the string _ids you should be fine.

Loopback with meteor


SQL top 3 most recent records by group

Question: I have a table with a date column and a string column. I'm trying to filter the string column to the most recent 3 records.
+----------+--------------+
|   date   |    string    |
+----------+--------------+
|2000-11-14|           AAA|
|2009-11-07|           AAA|
|2020-11-20|           AAA|
|2019-11-07|           AAA|
|2018-11-07|           AAA|
|2020-11-22|           BBB|
|2019-11-20|           BBB|
|2018-11-20|           BBB|
|2014-11-21|           BBB|
|2016-11-22|           CCC|
|2017-11-08|           CCC|
|2018-11-07|           CCC|
|2019-11-22|           CCC|
|2020-11-09|           CCC|
|2020-11-11|           DDD|
+----------+--------------+

The final table would look like this:
+----------+--------------+
|   date   |    string    |
+----------+--------------+
|2020-11-20|           AAA|
|2019-11-07|           AAA|
|2018-11-07|           AAA|
|2020-11-22|           BBB|
|2019-11-20|           BBB|
|2018-11-20|           BBB|
|2020-11-09|           CCC|
|2019-11-22|           CCC|
|2018-11-07|           CCC|
|2020-11-11|           DDD|
+----------+--------------+

I don't think I can use MAX(date) by group here, since I'm trying to get the top 3 most recent records (not top 1).
Comment: Are you using MySQL or Spark?  They're not the same thing.
Comment: Sorry, I'm using Spark
Answer: The ROW_NUMBER analytic function is particularly well suited to this type of problem:
WITH cte AS (
    SELECT *, ROW_NUMBER() OVER (PARTITION BY string ORDER BY date DESC) rn
    FROM yourTable
)

SELECT date, string
FROM cte
WHERE rn <= 3;

SQL top 3 most recent records by group


Show that the distribution defined by $f_n(x)=\sin(nx)$ converges to $T_0$

Question: Let $n>0$ and define the function $(f_n)$ as $f_n(x)=\sin(nx)$.
Show that $T_{f_n} \underset{\mathcal{D'}}{\rightarrow} T_0$.
As a hint, I was told to use the fact that for distributions one can interchange differentiation and limit.
What I did:
The idea is that if I calculate the primitive $(F_n)$ of $(f_n)$ and show that $(F_n)$ converges uniformly on any compact set to $0$, then I could somehow use differentiation and interchange it with the limit.
$\displaystyle \int \sin(nx)dx=-\frac{\cos(nx)}{n}$
$\displaystyle \sup_{x \in [-\pi,\pi] }|-\frac{\cos(nx)}{n}| \leq \frac{1}{n} \leq \epsilon$
if $\epsilon
\geq \frac{1}{n}$
This means $T_{F_n} \underset{\mathcal{D'}}{\rightarrow} T_0$
If $L=\frac{d}{dx}$ , then $L^*=\frac{d}{dx}$
$$\lim_{n \rightarrow \infty} \langle T_{f_n},\phi \rangle=\lim_{n \rightarrow \infty} \langle \frac{d}{dx}T_{F_n},\phi \rangle \underset{(1)}{=} \frac{d}{dx}\langle \lim_{n \rightarrow \infty}T_{F_n},\phi \rangle$$
I am a little bit confused on how to write that down. I don't even know how $\frac{d}{dx} \langle T,\phi \rangle$ is defined in case of Distributions.
I only know that if $L: \mathcal{D}(\Omega_1) \rightarrow \mathcal{D}(\Omega_2)$ is a linear and sequentially continuous function and further if $L^*$ exists and is also sequentially continuous with $\langle L(\phi),\psi=\langle \phi, L^* \psi \rangle$ for all $\phi \in \mathcal{D'}(\Omega_1), \psi \in \mathcal{D'}(\Omega_2) $
Then the operator $L$ is defined as
$\langle L(T),\psi \rangle:=\langle T,  L^* (\psi)\rangle$
Hope someone could show me how to write it down correctly (and if my approach is correct).
Comment: $\int \phi (x)f_n(x)dx \to 0$ as $n \to \infty$ for every test function  $\phi$ by Riemann Lebesgue Lemma.
Comment: Your Q could benefit from some added punctuation to your train of reasoning (comma, period, implication arrow as intended), and TeX placement of a backslash [ \ ] before common proper non-variable names (operators, bounds, etc.; e.g. $\sin$, $\sup$) to make them appear more properly (i.e., not italicized like something generic). For the particular case of derivative "d" one way to format it is via \mathrm{d} (which can be quick-sourced by right-clicking the LaTeX portion of the title of [this top Q](https://math.stackexchange.com/questions/21199/is-frac-textrmdy-textrmdx-not-a-ratio)).
Comment: How about evaluating against a given test function, then integrating by parts before letting $n\rightarrow +\infty$?
Comment: @StefanLafon Do you mean like this $lim_{n \rightarrow \infty} \int_{\Omega} f_n(x) \phi(x)dx=lim_{n \rightarrow \infty} \int_{\Omega} \frac{d}{dx} F_n(x) \phi(x)dx= \frac{d}{dx} \int_{\Omega} lim_{n \rightarrow \infty} F_n(x) \phi(x)dx$. Is there some way to write this down with the Distribution Notation?
Comment: @KaviRamaMurthy But why? As mentioned in the question, I should use the fact that I can change limit and derivative.
Answer: By definition, if $\varphi$ is a test function,
$$\langle T_{f_n}, \varphi\rangle = \int_{\mathbb R} f_n(x)\varphi(x)dx=\int_{\mathbb R} \sin(nx)\varphi(x)dx$$
If you integrate by parts, noting that the test function evaluated at $\pm \infty$ is $0$:
$$\langle T_{f_n}, \varphi\rangle = \int_{\mathbb R} \frac{\cos(nx)}n\varphi^\prime(x)dx = \frac 1 n\int_I \cos(nx)\varphi^\prime(x)dx$$
where $I$ is the support of $\varphi$.
Finally, you can conclude by noticing that $$\left|\langle T_{f_n}, \varphi\rangle  \right|\leq \frac{\|\varphi^\prime\|_\infty |I|}{n}\xrightarrow[n\rightarrow+\infty]{}0$$
As noted in the comments, this is known as the Riemann-Lebesgue lemma.


Why play a B chord on piano with this fingering?

Question: I am taking piano lessons, and my teacher has taught me the scales and chords/arpeggios for the keys of C, G, D, A, and E.  So far, the fingerings for the chords of each key have been the same- fingers 1, 3, and 5 on each hand. For example, for a C chord:
Left hand:     Right hand:
5 on C         1 on C
3 on E         3 on E
1 on G         5 on G

This seems natural to me, especially since I can play the 4-note or the 2-note of chords without adjusting where my hands are. However, the fingering for B was taught differently. For a B chord, I'm taught:
Left hand:     Right hand:
5 on B         1 on B
3 on D#        2 on D#
2 on F#        3 on F#

As you can see, neither hand is 1-3-5 fingers, and the hands are different from each other. I would have thought that with 5-3-2 on the left hand, then the right hand would perhaps be 1-3-4.
My teacher is university-trained and has been playing/teaching her whole life, but she did not have a ready answer when I asked why the fingering for B was different that way, especially the right hand. She might come back with an answer during a later lesson (which is fine- I'm doing as taught even if I don't fully understand), but I was wondering:
Does anyone know why the fingering for B would be done this way?
Is there some advantage which I don't yet realize, some common note progressions that this facilitates, or some easier way to change to other common chords?
Edit: For example, I am thinking that the right hand 1-2-3 positioning would make some song melodies more difficult to play in the key of B (e.g., the "Ode to Joy"), and quite a few songs that I am familiar with use the notes 1 through 5 heavily in their melodies. If playing these in the key of B, maybe for these I would use a different positioning, but does the 1-2-3 positioning offer any benefits that I might not be seeing?
(Note: I realize that there are probably other ways that B is taught. I'm not trying to find a better or different way with this question. I am only trying to find out the reasoning for this particular fingering.)
Comment: Funny that even she doesn't even know why she's teaching you that fingering. While I often play the highest note of a chord with the fourth finger of my right hand because it's much stronger than my fifth finger, the only reason why I would use my third finger is if I need my fourth and fifth fingers to play some higher notes right before or after the chord.
Comment: When I teach, I ask myself all of these question because I don't just repeat what I've been told. IMHO that's not teaching. If I don't know why I'm teaching something I either find out or don't teach it that way.
Comment: I can - sort of - see the case for the left hand.  You are avoiding putting your thumb on the black key (f#) which twists the hand out of position slightly.  The right hand I can't understand but, oddly, it is how I always do it.  Don't know why - probably how I was taught.
Comment: @ToddWilcox I agree, but I'm giving her the benefit of the doubt since she's my teacher. Also, I think most of her students are younger kids so she probably hasn't had to answer many questions like this :P
Answer: The reason why you are not using 1-3-5 in either hand for a B chord is that your first and fifth fingers are shortest, and the black keys are furthest away. Using 5-3-2 and 1-2-3 simply avoids having 1s or 5s on black keys. These fingerings make intuitive sense to me (also university-trained), but I can imagine that 1-2-3 is uncomfortable for beginning piano players, since you need to stretch your hand a bit.
I would see no problems with other fingerings like 1-2-4 (RH) or 5-4-2 (LH). You mention 1-3-4, which is fine, but I would argue that it is less comfortable than 1-2-4 since this way you don't have to span a third with 3-4. Again, that is perfectly possible, but given the choice I would prefer 1-2-4.
Comment: @BraddSzonye Thank you for your edit! Somehow I assumed it was about b minor. In the case of a D# 1-3-4 makes more sense, too. I might still be somewhat concerned about playing the D# too loudly, but it indeed also depends on hand shape.
Comment: @elmer007 I was exclusively referring to a situation where the triad is notated as a chord or arpeggiation. Then I would play it with these fingers. In the case of a melody in B (that is to say, if there are other notes present), it depends heavily on the shape, range, speed and countless other characteristics of the specific melody. It is impossible to say anything about the fingering of a piece of music without seeing the specific piece, let alone solely based on the key of the piece.
Comment: Depends on the shape and length of your fingers. 1-3-4 works best for me for the right hand, then 1-2-4. But a lot would also depend on dynamic context too, and I might favor 1-2-3 if I had a melody or a seventh to play with my 4 or 5.
Comment: @11684 Thanks for this answer. When you say that the fingerings make intuitive sense, do you mean that this is how you play B? If so, do any disadvantages become apparent when you think of playing it some other way? For example, with RH 1-2-3, I imagine that some common note patterns in melodies (e.g., *Ode to Joy*, if played in the key of B) would be rather difficult. A number of songs that I am familiar with use the notes 1 through 5 heavily in their melodies, and I am thinking that they would be difficult to play in B like this.
Answer: All I can think of is that l.h. B sort of reflects the scale fingering, in that index goes on D#, then on F#. Now, you can't play both with the same finger, so middle takes over D#. But that's weird.
Both hands for the B chord leave it easy to put the octave, 7th or 6th on top with thumb (l.h.) and pinky (r.h.).
However, if that's teacher's thinking, and it's good, why hasn't the same idea been followed with C. It's entirely possible to play C, l.h.5,3,2 and r.h.1,2,3, again leaving an extra digit to play an octave root, 6th, 7th, on top, without any changes.
As Todd says, and I entirely agree, I must have good reason for anything 'being that way'. Just because I say so isn't enough. And certainly not just because one of my teachers said so, years ago! However - I, as often as possible, give options, because I do it one way doesn't necessarily mean a student will find that the best.
Your best option is to experiment a little, as there are often two, or three different fingerings for the same thing. And show teacher that they work just as well! I chuckle when scales have to be played with only this fingering. Chances are in a piece in that key, playing a run - usually less than an octave - a different fingering works better than the 'scale' one.
Answer: I suppose that is partly because, aside from other reasons proposed by others, in classical/conventional usage, if one wishes to play a B major arpeggio across multiple octaves they would use the fingering as what is given by your teacher. So it would be not only plausible but also convenient to use the same fingerings to play the chord.
Answer: I would add that it is easier to continue from the B chord to the E(-minor) chord if your B chord fingering is 532 instead of 531. It is faster to just alternate between the 2 and 1 fingers instead of moving the 1 finger from one piano key to another.


Ensembling Logistic Regressions Fit on Different Datasets

Question: I would like to predict a binary response variable $Y_i$ using sets of predictors $\textbf{X}_{1i}, \textbf{X}_{2i}, \textbf{X}_{3i}$ for $i=1,\dots,n$. Each $\textbf{X}$ contains a few dozen predictors.  For a large enough $n$, I could simply fit a standard logistic regression. However in my setting, $n$ is relatively small compared to dim($\textbf{X}$), so that it's difficult to fit such a model.
Alternatively, I have available separate datasets with $Y$ and each $\textbf{X}$ (with much larger $n$). Since I don't have a good way to combine these datasets into one large dataset, I'd like to fit three individual models and then ensemble them in some way based on my "wide but short" dataset.
Now I've got a set of 3 probabilities $p_1, p_2, p_3$ which I'd like to combine into some overall probability $p$. I've considering combining them on the following scales

Probability
Odds
Log-odds

The log-odds approach seems initially appealing since it will have predictors that live on the real line (seems reasonable that it could be close to linearly related with the logit of the response $Y$, but I'm not entirely sure.
I've found this paper, which seems related, but a slightly different setting, since I don't have "many forecasters".
Is there some theoretical justification for choosing one of these (or something completely different) to ensemble my three models?
Comment: What makes it difficult to combine the datasets?  What is the exact number of candidate predictors and the counts of $Y=0$ and $Y=1$?
Answer: Recommendation one: Cross validation to compare competing options
Try all three methods and use cross validation to see which one performs best given your error metric.
Recommendation two: Wide dataset with regularization
Instead of making three datasets and combining the results later, just make one really wide one and use l1 or l2 regularization to "solve" the dimensionality problem. Use cross validation to find your tuning parameters.
Recommendation three: Layered ensembling
You should not ensemble in-sample predictions and cross validate different ways of combining them. Instead, you should try to ensemble your cross validated predictions. This means that you do the exact same thing as in recommendation one, except instead of combining the in-sample predictions, you create cross validated predictions to ensemble.
Comment: Agree with recommendation 2 - Regularization techniques should be explored, especially LASSO which works "well" when number of predictors is large relative to number of observations. Besides if you have so many predictors, it is likely that some of them are not so important, and then LASSO could help you identify these less important variables.
Comment: "Well" is questionable.  The probability that _lasso_ finds the "right" predictors is very, very low.  Separate feature selection from prediction.  For optimizing predictions, ridge logistic regression (or better: Bayesian models with shrinkage priors) are recommended.


well known sieve?

Question: Incidentally I've shown the following fact.
Cancelling from the natural numbers $1$, the even integers, the integers of the form $n^2+2nk$, with $n>1$ odd and $k$ nonnegative, we obtain all (and only) the prime numbers.
Is it well known?
Comment: If you let $k$ vary in the inner loop, and $n$ in the outer, you have the classical Sieve of Eratosthenes, with a few easy (common) optimisations.
Answer: Yes; your result is that every odd composite integer $N$ can be written in the form $N=n(n+2k)$ for some odd $n$ and $k \geq 0$. This follows immediately by considering the smallest divisor $n>1$ of $N$ and noting that $N/n$ is odd and not smaller than $n$. Of course, primes cannot be written in this form.

well known sieve?


How can I conduct a non-parametric version of MANCOVA?

Question: Is it possible to transform my variables to their ranks and apply MANCOVA to the transformed data, just like how it is done in rank ANCOVA?
Comment: (Example adapted from "The Analysis of Covariance and Alternatives") Suppose we have two dependent variables in an achievement study - scores on an achievement test of mathematics and scores measuring interest in mathematics. The independent variable is the type of training that the subjects underwent (3 in this case) and the covariate is a measure of aptitude. Our goal is to test whether the three adjusted population centroids are equal. It seems that MANCOVA can be used in this example. However, I am wondering what we can do if our data violate the normality assumptions of MANCOVA.
Answer: In this case Peter O'Brien's method of turning the problem around makes sense.  Use a polytomous logistic regression model to estimate the joint relationship between the two dependent variables and the probability of being assigned to each of the three training methods.  This makes no distributional assumptions. You can relax assumptions that are akin to the equal covariance matrix assumption by including nonlinear terms on the right hand side of the model.  See https://www.jstor.org/stable/2288918


Jarque-Bera test for Normality

Question: Which test should I consider if by JB-test result I have heteroscedasticity and by the result of two others no.
$JB
JB-Test (multivariate)

data:  Residuals of VAR object var.2c
Chi-squared = 10.051, df = 4, p-value = 0.03958
$Skewness
Skewness only (multivariate)

data:  Residuals of VAR object var.2c
Chi-squared = 5.8453, df = 2, p-value = 0.05379
$Kurtosis
Kurtosis only (multivariate)

data:  Residuals of VAR object var.2c
Chi-squared = 4.2056, df = 2, p-value = 0.1221
Answer: The JB-test (Jarque-Bera test) is a test of normality, not of heteroskedasticity. The JB-test tests whether your sample of data has the same skewness and kurtosis as the normal distribution. You'll recall that the normal distribution has skewness = 0 and kurtosis = 3 (or excess kurtosis = 0). In the first test, you tested for both simultaneously, whereas in the second and third tests you tested for these separately. However, all three tests are test of normality, not heteroskedasticity. See the Breusch-Pagan test for a test of heteroskedasticity.
Comment: Plot the data to get a better idea of what is going on. You should be able to confirm the above findings visually.
Comment: You are right....sorry.What about normality in the first test?By a p-value<0.05 I should conclude that the residuals don't have normal distribution?@ColorStatics
Comment: Your null hypothesis is that the data is normally distributed. The result of the first JB test, which uses both skewness and kurtosis, indicates that assuming that the null hypothesis is true (i.e. data is normally distributed), there is a less than 5% chance that you'll observe a sample as extreme (with regards to skewness and kurtosis) as the one you have. Therefore, you reject the null and conclude that the data is not normally distributed. The second and third tests give you the additional insights that the departure from normality is bigger in terms of skewness than in terms of kurtosis.
Comment: Thank you very much.What should I do for having normal distribution?I mean , in this case the estimation of the model is not ok?
Comment: You're welcome. It is difficult to say without knowing more details about your model. I suggest you edit the posting by adding some details about what you are trying to do and what sort of data you are working with.
Comment: I have estimated a VAR model with two time series: the public debt and the economic growth and than I have run the diagnostic tests.
Comment: I am not an expert on VAR, so others may guide you better. I'll note that your inquiry should now be directed to the asymptotic properties of your estimator. Having consulted Hamilton (1994), I note here the author's claim that the ML will give consistent estimates of population parameters and variance even if the true innovations are non-Gaussian. I believe this gives you license to interpret the estimated parameters, standard errors, and t-statistics as you normally would under the assumption of normality. However, lacking a deeper understanding of the topic, I am not certain.

Jarque-Bera test for Normality