What is the highest probability

Question: At a faculty the probability of seeing a person greater than 190cm is 12%. From a class of $24$ people, is it more reliable to meet $2$ people above $190cm$ or $4$ people above $190cm$?
I dont undersand. Consider that the solution may be related to any distribution (Binomial or Poisson). Help me please to solve. Thanky very much for my hard?
Answer: Here is a binomial distribution for $p=0,12$ and $n=24$:
Comment: $\frac{n!}{k!(n-k)!}p^k(1-p)^{n-k}$, what is k=? please
Comment: $k$ is a number of sucsseses. It runs from 0 to 24. You are interested what is happening if $k=2$ and $k=4$.
Comment: Case 1 :$\frac{24!}{2!(22)!}0.12^2(0.88)^{22}$;                                                     Case 2 :$\frac{24!}{4!(20)!}0.12^4(0.88)^{20}$;
Comment: Yes, and a "graph" of this function is drawn in the answer.
Comment: can you give me any other explanation about the picture that is unclear, you were very clear about the example
Comment: can i ask you for another example, or will i have to post it, you made the example very clear, you are extraordinary
Comment: It is a graph of function $f(k) = {24\choose k}0,12^k\cdot 0,88^{24-k}$ where $k$ runs from $0$ to $24$.
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/106121/discussion-between-madrit-zhaku-and-aqua).

What is the highest probability


Context free grammar for $L$

Question: Find context free grammar for
$$ \left\{  w \in \left\{a,b \right\}^* \mid |w|_a = 2k  \text{ and } |w|_b = 2l+1, l \in \mathbb{N_{0}}\right\} $$
Any hint helps!
Comment: Why do you want a context-free grammar for a regular language? What did you try?
Comment: In this case, the title of your question is misleading: it is a question on regular languages. I am pretty sure it was already asked on this site.
Comment: I want to find the regular expression for the language, which seems hard to do from scratch. I drew the DFA for the language and tried to get the regular expression from there, but it seemed too hard. So I wanted to try to get the regular expression from the grammar.
Comment: You cannot in general convert a context-free grammar to a regular expression.
Comment: A [similar question](https://math.stackexchange.com/questions/1665392/regular-expression-for-strings-with-even-number-of-1s-and-number-of-0s-divisib).
Answer: Here is one way to construct a regular expression for the language of all words with an even number of $a$'s and $b$'s (using similar ideas, you can solve your problem). Let us first consider all words without any $aa$ or $bb$. In this case, the regular expression is simply
$$
(abab)^* + (baba)^*.
$$
Now we want to allow $aa$, i.e., to undo the mapping $aa \to \epsilon$. We simply need to convert any "empty space" to $(aa)^*$, obtaining the regular expression
$$
(aa)^*((aa)^*a(aa)^*b(aa)^*a(aa)^*b(aa)^*)^*(aa)^* + (aa)^*((aa)^*b(aa)^*a(aa)^*b(aa)^*a(aa)^*)^*(aa)^*.
$$
(This is certainly not the most economical way...) Undoing the mapping $bb \to \epsilon$ by converting any "empty space" to $(bb)^*$, we obtain the desired regular expression, which is however too verbose to write.
Comment: Your expression does not seem to match the word $bb$.
Comment: @J.-E.Pin What expression? I haven't actually written it down. You have to insert $(bb)^*$ before and after each symbol.
Comment: Ok, I missed that.

Context free grammar for $L$


What is the inverse of $\tanh$?

Question: How to find out the value of $Z$?
$A = \tanh(Z)$
Here I know $A$.
How to find the value of $Z$?
Comment: Does this help? https://math.stackexchange.com/questions/2922852/prove-formula-operatornamearctanh-x-frac12-ln-left-frac1x1-x-rig no quadratics.
Comment: Many software engineers are not super familiar with the math concepts or have forgotten some concepts, and now we see machine learning everywhere! I would like moderators not to just downvoting questions like this. Genuinely many software developers don't have a background in machine learning math and applying ML as a tool. So would appreciate a bit helpful approach!
Answer: HINT: If $\tanh(z)=a$, then
$$\frac{e^z -e^{-z}}{e^z + e^{-z}} =a$$
If we substitute $y=e^z$, then this equation becomes
$$\frac{y-\frac{1}{y}}{y+\frac{1}{y}}=a$$
Can you solve this equation for $y$? (Spoiler alert: it can be simplified to a quadratic.)

What is the inverse of $\tanh$?


Computing $P(X+Y \geq3)$

Question: Suppose X and Y have joint probability function
$\displaystyle f(x,y)={\left(\frac{1}{2}\right)}^{x+y} \quad{}\text{ for }\,x=1,2,3\dots,\quad{}y=1,2,3\dots$
$\text{Compute }\,P(X+Y\geq 3)\text{.}$
I tried to do $P(Y\geq 3-X)=1-P(Y\leq 3-X)$
But then it is
$$1-\int_1^{\infty}\int_1^{3-x}({1\over2})^{x+y}dydx$$ which does not converge unless I did it wrong.
Comment: Aren't $x,y$ discrete? So the integral should be a sum. And it'll be almost trivial because it'll have only a few terms since $x,y$ are at least 1.
Comment: So I could do $1-P(X+Y<3)$? where this is just $1-P(X=1,Y=1)$?
Comment: Maybe a transformation of variables could help.
Answer: The integral does not converge because $x,y$ follow a discrete distribution, not a continuous one as Alex R. said.
The probability you want is:
$P(X+Y\geq 3)=P(Y\geq3-X)=1-P(Y < 3-X)=1-P((X,Y)=(1,1))=\frac{3}{4}$
You could also do the following:
$P(X+Y\geq 3)= \sum\limits_{x\geq2}\sum\limits_{y\geq1}$
$(\frac{1}{2})^{x+y}+\sum\limits_{x=1 ,y\geq2}(\frac{1}{2})^{x+y}$
$=\frac{1}{2}+\frac{1}{4}=\frac{3}{4}$

Computing $P(X+Y \geq3)$


How do I create an instance of type array in 3rd party XML?

Question: I have written a simple C# Windows application to test a 3rd party web service.  Here are two of the fields from the generated Reference.cs
/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute(Order = 4)]
public PriceType Price
{
    get
    {
        return this.priceField;
    }
    set
    {
        this.priceField = value;
        this.RaisePropertyChanged("ExpectedPrice");
    }
}

/// <remarks/>
[System.Xml.Serialization.XmlElementAttribute("Contact", Order = 5)]
public ContactType[] Contact
{
    get
    {
        return this.contactField;
    }
    set
    {
        this.contactField = value;
        this.RaisePropertyChanged("Contact");
    }
}

I created the request object, and assigned a value to Price as follows:-
RequestServiceType myRequest = new RequestServiceType();

myRequest.Price = new Blah.PriceType();
myRequest.Price.GrossPrice = new Blah.AmountType();
myRequest.Price.GrossPrice.Value = 10M;

However
myRequest.Contact = new Blah.ContactType();

Errors with 'Cannot implicitly convert type 'RequestServiceType.ContactType' to 'RequestServiceType.ContactType[]'.

ContactType is an array in the Reference.cs (ContactType[]).  How do I create an instance of Contact in myRequest?
Comment: You cannot have an array of Attributes.  Change from : XmlElementAttribute to : XmlElement
Comment: Thank you.  The web services are provided by an external 3rd party, and Reference.cs is auto-generated.
Comment: If they are autogenerated this is done from a schema that may have errors.
Comment: Thank you jdweng.  This schema is used by a lot of organisations. It's my programming that has errors.  I really need to sit with a subject expert and go through the logic (or lack of it). Are there any Land Registry experts in the house?
Answer: You could try explicity casting?
myRequest.Contact = (Contact[])(new Blah.ContactType());
Comment: Thank you, but the IDE then shows 'cast is redundant'.  The potential fix is to remove the cast, which puts me back at square one.
Answer: Your syntax is what is the issue here.
the error message clearly explains that you are trying to assign an instance of the object to the property when the property expects an array of that object.
This will crate an array containing one instance
myRequest.Contact = new []{ new Blah.ContactType() };

which is just syntatic sugar for
var contact = new new Blah.ContactType();
var array = new Blah.ContactType[1];
array[0] = contact;
myRequest.Contact = array;

Comment: Hi Nkosi.  I managed to sort it last week, but your example is more elegant.  Thank you.


Vague convergence implies convergence of oscillations

Question: Let $G$ be a compact metrisable abelian group. For any real-values $f \in C_c(G)$ and any Borel probability measure $\mu$ on $G$, define the oscilation $\text{osc}_f(\mu)$ of $\mu$ with respect to $f$ to be the quantity $\text{osc}_f(\mu):= \sup_{y\in G} \int_G \tau_yfd\mu(x)-\inf_{y\in G} \int_G \tau_y fd\mu(x)$.
I want to show that is a sequence $\mu_n$ of Borel probability measures converges in the vague topology to a Borel probability measure $\mu$, then $\text{osc}_f(\mu_n) \to \text{osc}_f(\mu)$ for all $f \in C_c(G)$. \
I am actually not quite sure why this is true at all. For any $y \in G$, obviously $\int_G \tau_yfd\mu_n(x) \to \int_G \tau_yf\mu(x)$ but it seems like as the sequence goes along, the supremum may be different. Also, I tried working with corresponding linear functionals to see if there were any properties there that would help but it didn't seem like it.
EDIT: I sort of found something? Let $\mu * f: G \to \mathbb{R}$ be defined as $\mu *f(y) = \int_G \tau_yfd\mu$. Clearly $\mu *f$ is continuous and compactly supported so it reaches a minimum and maximum. Vague convergence implies  $\mu_n * f \to \mu * f$ pointwise so therefore they reach the same min and max. This last step is not correct.
EDIT2: Are the $\mu_n * f$ uniformly equicontinuous? cause then we have uniform convergence and my statement about the min and max will work.
EDIT3: Not quite sure about that uniformly equicontinuous claim. Seems more promising to figure out something to do with compactness.
Comment: One approach would be to consider Gamma- convergence. If you show that maximisers of the convolution converge to maximisers (no latex tonight, let me know if you want it in the AM) but also minimisers converge to minimisers, then I think your result would follow from local uniform convergence of measures in a Wasserstein metric.
Comment: Also +1 for username
Comment: tex would be chill
Comment: yo I still want an answer on this if it's alright, if not then whatever, it's chill.
Comment: Hi, not forgotten. Will try to reply tonight! Have you got access to Andrea Braides' Homogenisation of multiple integrals book?
Comment: found a pdf copy
Answer: In order to investigate whether the function $\text{osc}_f$ is sequentially continuous, for each $f \in C_c(G)$ fixed, which is the assertion (I think). I would consider $\Gamma$-convergence (Good intro is Chapter 7 of 'Homogenisation of Multiple Integrals' of the functionals $F_n : y \mapsto \int_G \tau_y f d \mu_n$. If you can show that $\sup_{y \in G} F_n \rightarrow \sup_{y \in G} F =:\sup_{y \in G} \int_G \tau_y f d \mu$ and $\inf_{y \in G} F_n \rightarrow \inf_{y \in G} F =: \inf_{y \in G}\int_G \tau_y f d \mu$ then you are done. This statement is equivalent to saying that $F_n \stackrel{\Gamma}{\rightarrow} F$ and $-F_n \stackrel{\Gamma}{\rightarrow} -F$ ($\Gamma$-convergence as described in the book ensures convergence of minimum values of $F_n$, you don't need to worry about the equi-coercivity conditions, considering $-F_n$ allows one to study the convergence of the maximum values too, you will need a topology on $G$ to ensure some convergence of points in $G$). Writing out the definitions of $F_n \stackrel{\Gamma}{\rightarrow} F$ and $-F_n \stackrel{\Gamma}{\rightarrow} -F$, you will see that this is identical to saying that $F_n(y_n) \rightarrow F(y)$ for all $y \in G$ and $y_n \rightarrow y$ (in some suitable second countable topology on $G$). I think once this step is made then the proof follows quite easily. Write the integral as $\int_G \tau_{y_n} f d \mu_n = \int_G (\tau_{y_n}-\tau_{y}) f d \mu_n + \int_G \tau_{y} f d \mu_n$. The second term would then converge to your answer, the first term would ideally vanish using the dominated convergence theorem or something similar - perhaps even another split. I hope there is enough detail here for you to move between the steps and that this answers your question.
As an interesting aside, the fact that you need to show that $F_n(y_n) \rightarrow F(y)$ for all $y \in G$ and $y_n \rightarrow y$ demonstrates that while pointwise convergence seems like a good candidate convergence, in fact you need what is almost like a 'sequential continuity along the sequence'.
Edit: I decided you didn't need the Wasserstein metric, because a topology on $G$ is more important. You can use the Wasserstein metric if you need to metrise the topology of vague convergence.


*nix OS that is easy to update to latest software

Question: I need to configure a server (*nix) that runs our (bespoke) CMS and Applications.
In the past I have defaulted to using Cent OS 5, but I find this outdated difficult to upgrade the software to the versions we require.
For example, we need PHP 5.3, but CentOS 5 has 5.2. Updating is fine but breaks something else (normally MySQL support in PHP).
Eventually it will get to a situation where I can't upgrade because of missing dependancies and incompatible versions.

Error: Missing Dependency: httpd = 2.2.3-43.el5.centos.3 is needed by package httpd-devel-2.2.3-43.el5.centos.3.i386 (updates)

Is there a better alternative OS for hassle free updates, I need:

Apache 2.2.17 (the development version for apxs)
MySQL 5.5.8
PHP 5.3.5
Comment: FYI, CentOS 5.6 release is imminent and should contain PHP 5.3 (RHEL 5.6 now ships with blessed PHP 5.3 packages). MySQL is still 5.0.77 and Apache is 2.2.3 (but that's just RH's crazy convention for the most part).
Comment: I mixed up the name, it's CentOS-Testing - http://wiki.centos.org/AdditionalResources/Repositories, after enabling this repository you should be able to install php 5.3
Comment: Note that it's now 3 weeks after Jason's comment, and the CentOS 5.6 release is still 'imminent'. This is not a complaint (We know they are working hard, and it's not an easy job), but just a reality check on the "CentOS 5.6 release real soon now" rumors which have been floating around for several months now.
Comment: You can enable CentOS experimental repository which has PHP 5.3
Comment: @VickVega care to elaborate?
Answer: All stable enterprise distros will suffer from this to some extent: in order to know that they're deploying a reliable combination of packages, vendors will avoid rolling out the latest and greatest until it's had a chance to be tested both by the vendor and the public.
Our solution to this has been to maintain our own private YUM repository of packages we compiled ourselves to meet our own requirements; this allows you to be reasonable about dependencies and still provides reasonable simplicity (no need to recompile every time) for new deployments of your standard packages.
I would caution against running a distro like Fedora for production: it is very clearly, in its own estimation, an option that sacrifices enterprise-class reliability for the latest-'n-greatest package set.
Hope these suggestions are helpful!
Comment: +1 If you need to stay on the bleeding edge for some packages building them yourself may be the only way to go.  Building packages usually isn't as difficult as it sounds since you can usually pull the source package(s) from the distribution development channel and backport pretty easily.
Answer: Personal I've been happy with FreeBSD. For some reason it's always made a little more sense to me than other *nix OS (It has great documentation). The ports system is great for applying updates, and I've had little problem with updates breaking things. Pkg_updating especially helps.
With any distro, if you're using packages that come with the os or even through 3rd party repo's, you're going to have to wait a least a little bit for them to build the latest version of the software you want, and sometimes that's a good thing because there may be stability or dependency issues you might not know about.
Of course, you can always build directly from source, then you never have to wait.
PS: Upgrading the base os is also quite easy and stable using freebsd-update even between major versions.
Answer: For severs I think debian is the best choice if you need a totally free solution.
Comment: I'm not sure how stating a preference for a particular distribution answers the question about package recency and interdependency.
Comment: For package interdependency Debian stable (plus the volatile repository) have low entropy and hence one does not bump into problems of missing packages. After all Debian stable is what it says, so there must be a very serious reason for a package version change. If one needs more recent / newer package versions Debian testing is OK. You get newer versions, and when interdependency problems arise they are promptly solved by the package maintainers. At least that is my experience for the last 6 years.
Comment: ...in much the same way as CentOS's stable repository provdes a low-entropy experience, and other third-party repos provide a more bleeding-edge package set. This is not a concept unique to Debian, or any actively maintained enterprise-class Linux distribution.
Comment: This does not answer the OP.
Answer: I'll put my vote for ArchLinux.  It's a rolling release setup, so no matter what you start with, you can always sync it to latest/greatest.  I don't know if I'd run any servers on it, that might be a bit too adventurous for my taste, but it makes a great workstation.
Comment: There's servers and then there's servers.  Are you running a hospital on it, or your own web/mail?  I have a file server on arch with 230+ days of uptime on a 7yr old computer, so it's obviously stable, as long as hardware underneath it is healthy.
Comment: +1 for Arch's actuality and its philosophy of simplicity / minimalism, which allows you to fine-tune most details of the system.
Comment: He specifically mentioned it was for a server. But ArchLinux is still awesome for a desktop :)
Comment: Arch is great if you have the discipline to test before upgrading. It is bleeding edge, however. IMHO it is one of the fastest all around best distros out there.
Answer: fedora will allow you to get the newest versions, with the downside that you may need to upgrade every 6 months, although that does not always mean a reinstall. If you have rpm's (or centos/redhat related scripts) or knowledge of these it may be an acceptable option.
Otherwise, a ubuntu LTS version will be better with a life span of 18 months, with the downside of needing to convert to debs / dpkg. This may or may not be an issue for you.
Alternatively, try a rolling release distro (such as arch linux), that way you avoid the upgrade issues, but i've no experience of using rolling release setups for servers... and it gives me the heebie-jeebies.
On the other hand, centos 6 should be out fairly soon, which may solve your initial problem.
Answer: I understand this is going to sound a  retro & counter-intuitive:
"Use the source,Luke"
I've run into exactly these problems with almost every distro family:
Rpm-Yum-Centos-FC, Deb-Apt-Get-Ubuntu,  Slack*, Bsd/& Gentoo. For me?
I created a source hierarchy and a few build scripts several years ago for our
needs and because of these we have 100% distro (& architecture) independence.
It takes < 3 hours to port (really just copy and make) our stuff onto
anybody's linux:RS Cloud, Slice, Ec2, generic dedicated hosts,etc.
Every few months I upgrade some part (php,httpd,mysql,etc)
For me the tradeoffs are well worth it.  I don't have to worry
about upstream folks keeping the right stuff on hand. My build script checks
to see whether we have make and gcc installed and adds those if not,etc.
I find out the versions and features we need and also have some QA tests
for a build,but once you get set up with your own source hierarchy, and
have automated building testing and installation, life is easier for me.
I created it to help w/ my then nightmarish upgrade from apache 1.3.x. php5.0.x
(cgi mode no less) &  mysql4 to apache 2.2.x,php5.2.5/mysql5.0 a few years
back. I think for going from php5.2.5 to php5.3.3 I had to only change a couple
of lines.
I'm rather annoyed at the crazy dependencies that exist in most
of the main line repositories. If I want to install ImageMagick from
a package manager, I end up with all this Xwindows cruft,that has
no value to us at all.
You could even ... put your build stuff in your fave SCM (svn,git,etc) and
just check out your stuff and go. Or drive it all with chef,puppet or even
(don't laugh) expect :-)
Lastly,I try to keep machines in a farm at the same distro,and architecture,
and then I can just copy our binaries around.
Answer: I'll echo @matthew's answer.
FreeBSD supports all of this in the main FreeBSD ports tree, right now. No need to add 3rd Party repositories, no funny hacks needed, and all of this is availalbe using the regular FreeBSD utilities.
Here are the versions in the FreeBSD ports tree, with links:

Apache 2.2.17 (the development version for apxs)
MySQL 5.5.8 - FreeBSD provides a newer version, mysql-server-5.5.9
PHP 5.3.5

FreeBSD is a little different then OS's based on Linux. There is a small learning curve to get started. Some of this is appreciated (Ports always live under /usr/local , it's easy to control services using /etc/rc.conf). But don't be intimidated-- if you know Unix, you can learn FreeBSD.
Comment: +1, Three best parts of FreeBSD: 1. Cleanliness 2. [Ports](http://www.freebsd.org/ports/) system 3. [Tha Handbook](http://www.freebsd.org/doc/handbook/) - Note Googling "Handbook" the 3rd result is this link. There is a learning curve, and plenty of experts around this site.
Answer: You can setup your CentOS system to use 3rd party repo like atomic rocket turtle that offers more up to date software you need and dependences.  If you want to switch distro you can look at Ubuntu (not-LTS) as those deb repos are pretty new.
Answer: Have you considered Scientific Linux (www.scientificlinux.org)?
Like CentOS, Scientific Linux is a Redhat derivative only it is put together by Fermilab, CERN, et. al.
They have their 6.0 version out (based on Redhat 6) and it comes with:

php-5.3.2-6.el6
mysql-5.1.47-4.el6
httpd-2.2.15-5.sl6

Another option, if you're not in a time crunch, is to wait for CentOS 6-- I have no idea how close they are to releasing tho.
Edit: Looks like the versions are still a little shy of what you're asking for...


How do I set which libstdc++.so to be linked with libarrow.so?

Question: I built libarrow.so and pyarrow from source using gcc7.2 on Redhat 7.4.
Still, I am stuck with the following error, which seems to be caused by using different version of gcc (4.8.5 vs. 7.2.0).
<code>[u0017649@sys-97675 ~]$ python
Python 3.7.1 (default, Dec 14 2018, 19:46:41)
[GCC 7.3.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import pyarrow
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/u0017649/anaconda3/lib/python3.7/site-packages/pyarrow/__init__.py", line 47, in <module>
    from pyarrow.lib import cpu_count, set_cpu_count
ImportError: /usr/local/lib64/libarrow.so.13: undefined symbol: _ZN5boost6system16generic_categoryEv
</code>
I checked with ldconfig, and it clearly shows that libarrow.so is linked with libstdc++.so from Redhat OS (built with gcc4.8.5), not with one from my own build with gcc7.2.0.
<code>[u0017649@sys-97675 ~]$ sudo ldd /usr/local/lib64/libarrow.so.13
/usr/local/lib64/libarrow.so.13: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.20' not found (required by /usr/local/lib64/libarrow.so.13)
/usr/local/lib64/libarrow.so.13: /lib64/libstdc++.so.6: version `CXXABI_1.3.9' not found (required by /usr/local/lib64/libarrow.so.13)
/usr/local/lib64/libarrow.so.13: /lib64/libstdc++.so.6: version `CXXABI_1.3.11' not found (required by /usr/local/lib64/libarrow.so.13)
/usr/local/lib64/libarrow.so.13: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.22' not found (required by /usr/local/lib64/libarrow.so.13)
/usr/local/lib64/libarrow.so.13: /lib64/libstdc++.so.6: version `GLIBCXX_3.4.21' not found (required by /usr/local/lib64/libarrow.so.13)
    linux-vdso64.so.1 =>  (0x00003fff92a70000)
    libbrotlienc.so.1 => not found
    libbrotlidec.so.1 => not found
    libbrotlicommon.so.1 => not found
    libdl.so.2 => /lib64/libdl.so.2 (0x00003fff924a0000)
    librt.so.1 => /lib64/librt.so.1 (0x00003fff92470000)
    liblz4.so.1 => /lib64/liblz4.so.1 (0x00003fff92430000)
    libsnappy.so.1 => /lib64/libsnappy.so.1 (0x00003fff92400000)
    libz.so.1 => /lib64/libz.so.1 (0x00003fff923c0000)
    libzstd.so.1.3.7 => not found
    libboost_system.so.1.68.0 => not found
    libboost_filesystem.so.1.68.0 => not found
    libboost_regex.so.1.68.0 => not found
    libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00003fff92230000)
</code>
I re-checked my LD_LIBRARY_PATH, but it looks OK.
<code>[u0017649@sys-97675 ~]$ env | grep LD_
LD_LIBRARY_PATH=/usr/local/cuda/lib64:/usr/local/lib64:/usr/local/lib:/usr/lib64:/usr/lib:/lib64:/lib:
</code>
What did I do wrong ?  How do I fix this situation ?  Pls help.
Comment: Can you provide more insight (executed commands and their output) on how you have built this?
Answer: Never mind.  I was stupid enough to use 'sudo' in front of ldd for nothing, which changed the environment variable of LD_LIBRARY_PATH.  Without sudo, the proper LD_LIBRARY_PATH set, I could see everything was fine.


Can the product of a positive definite and a symmetric matrix by skew-symmetric?

Question: I am interested in properties of the matrix product $AB$ where the matrix $A\in\mathbb{R}^{n\times n}$ is positive definite (i.e., $(Av,v)>0$ for all non-zero vectors $v\in\mathbb{R}^n$) and where matrix $B\in\mathbb{R}^{n\times n}$ is symmetric (i.e., $(Bu,v)=(Bv,u)$ for all $u,v\in\mathbb{R}^n$).
I know that we can not expect positiveness or symmetry without additional assumptions but are we at least able to exlude skew-symmetry of the product (except for the trivial case $B=0$ of course)? I have tried to investigate this and expect it to be the case but I wasn't able to show it (or to find a counter-example).
Hence my question:
Is it possible for the product $AB$ of a positive definite matrix $A$ and a symmetric matrix $B\neq0$ to be skew-symmetric?
Note: I am specifically thinking about $n=3$ but have formulated the question for general dimension $n\in\mathbb{N}$.
Answer: When $B\ne0$, no, because $AB$ is similar to the real symmetric matrix $A^{1/2}BA^{1/2}$.
Comment: You mean $B$ instead of $B^{1/2}$ I think.
Comment: @OmranKouba Yes, of course. Thanks for the catch.


WebAPI project doesn't seem to post transformed web.config to bin folder?

Question: I've bene doing well with .NET config transforms. I have them in place now on a class library for data usage and a WPF app.
However, when I attempt to set them up with an ASP.NET WebAPI project, something strange seems to happen.
The config file never shows up in my bin directory, and so the web.config always shows as the pre-formed config file.
If I run MSbuild with parameters of "/t:TransformWebConfig /pConfiguration=Test" on the csproj, I see the following:

CollectWebConfigsToTransform:   Found The following for Config
  tranformation:   Areas\HelpPage\Views\Web.config, Web.config,
  Views\Web.config, bin\Web.config PreTransformWebConfig:   Skip copying
  Web.config to obj\Test\TransformWebConfig\original\Web.config, File
  obj\Test\TransformWebConfig\original\Web.config is up to date   Skip
  copying C:\Users\killesj1\Repositories\MRP Trunk\Macro
  Projects\VEUploader\src\app\VEUploader.WebAPI\Web.config to
  obj\Test\TransformWebConfig\original\bin\Web.config, File
  obj\Test\TransformWebConfig\original\bin\Web.   config is up to date
  TransformWebConfigCore: Skipping target "TransformWebConfigCore"
  because all output files are up-to-date with respect to the input
  files. TransformWebConfigCore: Skipping target
  "TransformWebConfigCore" because all output files are up-to-date with
  respect to the input files. PostTransformWebConfig:   Transformed
  Web.config using Web.Test.config into
  obj\Test\TransformWebConfig\transformed\Web.config.   Transformed
  C:\Users\killesj1\Repositories\MRP Trunk\Macro
  Projects\VEUploader\src\app\VEUploader.WebAPI\Web.config using
  C:\Users\killesj1\Repositories\MRP Trunk\Macro
  Projects\VEUploader\src\app\VEUploader.WebAPI\Web.Test   .config into
  obj\Test\TransformWebConfig\transformed\bin\Web.config.

It appears that the transformation is tranforming the file, but somehow it's not making its way back into the bin directory, where the old Web.config remains.
Is this normal? How might I get this to behave similarly to other web transforms?
Comment: I guess a better way to phrase this is "is there a problem with this not being outputted to the bin directory?" When I do a "preview transform" in Visual Studio, it appears to show up perfectly. While I'm waiting on the expertise here I'll write a quick method to see if it's referring to the new values.
Comment: OK, so I tried a quick method that just returns a config setting, and it looks like it's still using the untransformed web.config. Not sure why everything would work except for the final copy to the original file?
Answer: I had a similar problem, deploying Test projects on Appveyor that weren't being transformed, and followed the advice in the link below and now everything works nicely. I had all my projects set up to do xxx.config transforms in the [Target Name="AfterBuild"] and it worked perfectly on my local dev machine, but on pushing the code to Appveyor, the tests would fail because of untransformed files etc. Basically, move everything to the [Target Name="BeforeBuild"] and see if that helps.
MSBuild - how to force "AfterBuild" target when I do deployment?
Answer: web.config normally located in the root and is not copied to bin subfolder. To apply transforms you need to have some template web.config and transform it to root web.config.
E.g. see https://stackoverflow.com/a/16239488/52277 and Use Visual Studio web.config transform for debugging


Wordpress(wpdb class) and mysql stored procedures

Question: $query = "CALL ..........";
$result = $wpdb->get_results($query);
print_r($results);

Is returning an empty array, how do you run stored procedures from the $wpdb class?
Answer: I'm not 100% sure since I've not worked with stored procs in MySQL yet (although I have coded many a stored-proc for MS-SQL in the 90's), but try:
global $wpdb;
$wpdb->query('CALL ...');
print_r($wpdb->last_result);

Whatever you pass to $wpdb->query() gets passed to the PHP mysql_query() function so whatever works there will work with WordPress' $wpdb->query(). I do know this works:
global $wpdb;
$wpdb->query('SELECT * FROM wp_posts LIMIT 10');
print_r($wpdb->last_result);

If you want to read the source code for $wpdb->query() to further understand what is happening you can find it in /wp-includes/wp-db.php at lines 1057-1153 in v3.01.
Hope this helps.
-Mike
P.S. You might want to check out StackOverflow's sister site WordPress Answers next time you need help with WordPress. Lots of WordPress enthusiasts are on hand over there to answer your WordPress questions.
Comment: Small update: `$wpdb->last_result` will be [deprecated in WP 3.1](http://wpdevel.wordpress.com/2010/11/12/if-you-were-using-wpdb-last_result-yo/), you should use `$wpdb->get_results()` to get the last result.
Comment: @Jan Fabry - Yeah I saw that after posting this answer. Unfortunately `$wpdb->get_results()` doesn't work with v3.0.


powershell: How to pass this string to an exe

Question: Powershell can't seem to parse this correctly:
mysql.exe '-uroot -p123 DB < c:\test\DB.sql'

I also tried this:
Start-Process mysql.exe -arg '-uroot -p123 DB < c:\test\DB.sql'

Edit: Well this works:
 cmd '/c mysql.exe -uroot -p123 DB < dump.sql'

This there a more elegant way to do this? Its always a pita to pass args to exe with powershell.
Comment: Does this thread work for you:
http://stackoverflow.com/questions/1673967/how-to-run-exe-in-powershell-with-parameters-with-spaces-and-quotes
Answer: Seems that Powershell does not support the < character.
A workaround that works for me is :
Get-Content dump.sql | ./mysql.exe -uroot -p123 DB

However, the CMD approach is not so bad.
Comment: I'll take it! I believe gc can also change the -Encoding before passing it through the pipeline which is convenient.
Comment: Right, you can change Encoding : `Get-Content dump.sql -Encoding Unicode | ...`


Prove $|\log(1-x)+x|\leqslant cx^2$

Question:
Problem: Prove $|\log(1-x)+x|\leqslant cx^2$(c is a constant)
  holds for $|x|<\frac{1}{2}$.

My proof:
$\log(x-1)=-x-O(x^2)$ then
$\log(x-1)+x=-x-O(x^2)+x\implies \log(x-1)+x=O(x^2)\implies|\log(x-1)+x|=O(x^2)\implies |\log(x-1)+x|\leqslant cx^2$
However the author points out that the latter identity only holds for $|x|⩽\frac{1}{2}$. This later point did not show in my derivation.
Question:
What am I doing wrong?
Thanks in advance!
Comment: As a continuous function, $f(x)=\frac{\log(1-x)+x}{x^2}$ for $|x|\leq 1/2$ has MAX and MIN value!
Comment: Perhaps it is a typo $|x|\leqslant1/2$.
Comment: @user108128 Yes it was indeed a typo. Thanks for pointing that out. I have already corrected it.
Comment: In your attempt you have written $\log (x-1)$. Is that a typo ? It's hard to critique a proof with typos in it.
Comment: @Riemann . Best one-liner I've seen this week.
Comment: It is obvious since $\log(1-x)$ is an analytic function in a neighbourhood ($|x|<1$) of the origin and the first term of the Maclaurin series of $\log(1-x)$ is $-x$.
Answer: For $|x|<1,$ $\ln (1-x) =-(x+x^2/2+x^3/3 + \cdots)$ Thus
$$\ln (1-x) + x = -(x^2/2+x^3/3 + \cdots)$$
This gives
$$|\ln (1-x) + x| \le |x^2/2+x^3/3 + \cdots)| \le x^2(1/2 + |x|/3 + |x|^2/4 +\cdots)$$ $$ \le x^2(1+|x|+|x|^2+ \cdots) = x^2/(1-|x|).$$
If we now use $|x|\le 1/2,$ we see the last expression is $\le x^2(1-1/2) = 2x^2.$ So we may take $c=2.$
Answer: $\log (1-x)$ is defined only for $x<1$.  As $x$ increases to $1$, $\log (1-x)+x \to =-\infty$ so the inequality cannot be true for $x$ near $1$. The question you have to think about is: what exactly is the meaning of $O(x^{2})$ here.
Answer: Rewrite your proof in this way:
$$\log(1-x)+x=-x+O(x^2)+x=O(x^2)$$
so there is a constant $c>0$ such that
$$|\log(1-x)+x|\leqslant cx^2$$
Comment: Thanks for your answer! I think I got to your later expression. What should I do then?
Comment: You've done. Good job.
Comment: Your inequality is right locally, but  Pedro Gomes wants to a global inequality on the closed interval $[-1/2,1/2]$ .
Comment: Of course. thanks
Answer: Kavi Rama Murthy has explained why the OP's work is invalid.  I am presenting an explicit way to extract such a constant $c$.
By Taylor's Theorem, we have $$\ln(1-x)=-x-\frac{1}{2}\,x^2-\frac{1}{3\,\big(1-\xi(x)\big)^3}\,x^3\text{ for all }x<1\,,$$
where $\xi(x)$ is a number between $0$ and $x$.
That is,
$$-\ln(1-x)-x\leq \frac{1}{2}\,x^2+\frac{1}{3\,\left(1-\frac{1}{2}\right)^3}\,\left(x^2\cdot\frac{1}{2}\right)=\frac{11}{6}\,x^2\text{ if }0\leq x<\frac{1}{2}$$
and
$$-\ln(1-x)-x\leq \frac{1}{2}x^2\text{ if }x<0\,.$$
That is,
$$\big|\ln(1-x)+x\big|\leq \frac{11}{6}\,x^2\text{ for all }x\in\left[-\frac12,+\frac12\right]\,.$$

In fact, let $f:\mathbb{R}_{<1}\to\mathbb{R}$ be the function defined by
$$f(x):=\left\{\begin{array}{ll}
\frac{-x-\ln(1-x)}{x^2}\,,&\text{if }x\in(-\infty,0)\cup(0,1)\,,\\
\frac{1}{2}\,,&\text{if }x=0\,.
\end{array}\right.$$  Then, $f$ is an increasing positive function.  Therefore, the best constant $c$ in this problem is $$f\left(\dfrac12\right)=4\,\ln(2)-2\approx 0.77259\,.$$
Comment: Thanks for you proof! I have been reading your proof but I have got some questions. First you explain correctly by the rest of the expansion that $x<1$ but on the following step you take on the interval $(0,1)$, $\xi(x)=\frac{1}{2}$. Why $\frac{1}{2}$? Was it random? Then you compute $c=\frac{11}{6}$, however I do not understand what follows next. Why $f(\frac{1}{2})=c$? What is this later part about? Thanks in advance!
Comment: I only dealt with the assumption that $|x|<\frac12$.  There is no such constant $c$ if you only assume $|x|<1$, as Kavi Rama Murphy said.
Comment: For $0\leq x<\frac12$, we have $0\leq \xi(x)\leq x$, so that $\xi(x)<\frac12$.  Thus, $$\frac{1}{\big(1-\xi(x)\big)^3}\leq \frac{1}{\left(1-\frac12\right)^3}\,.$$
Comment: For the last part, I noted (without proof, and will not be giving a proof) that the function $f$ is an increasing positive function.  Thus, we have $$\big|x+\ln(1-x)\big|=x^2\,f(x)\leq x^2\cdot f\left(\frac{1}{2}\right)$$ for all $|x|\leq \frac12$.  Since the equality holds for $x=\frac12$, $c:=f\left(\frac12\right)$ is the optimal (smallest) value of $c$.
Answer: Let $f(x)=\frac{\log(1-x)+x}{x^2},x\in[-1/2,0)\cup(0,1/2]$ and $f(0)=\lim_{x\to 0}\frac{\log(1-x)+x}{x^2}$.
So $f(x)$ is a continuous function defined on the compact set [-1/2,1/2].
Therefore, the function $f(x)$ has Maximum and minimum denoted by $M$ and $m$ respectively.
So $|f(x)|\leq C$, where $C=max\{|M|,|m|\}$ for $x\in[-1/2,1/2]$.
And then $$\left|\log(1-x)+x\right|\leq Cx^2.$$
Comment: Thanks for your answer! How do you define your first interval?
Comment: Define $f(x)=\frac{\log(1-x)+x}{x^2},x\in[-1/2,0)\cup(0,1/2]$.
Comment: I want to know why you defined the function that way. Could I have chosen any random interval?
Comment: Fist , your inequality is right when $x=0$, and in this case you can choose $c$ to be any positive number. And then you need prove you inequality is right on $[-1/2,0)\cup(0,1/2]$, and in this case, you can Divide $x^2$ in both side because in the case $x\neq 0$.

Prove $|\log(1-x)+x|\leqslant cx^2$


Printing dates between two other dates on PHP

Question: I'm trying to print dates between two other dates. Here is my code:
$begin = date("d/m/y");
$end = date("d/m/y", strtotime("+1 month"));

$i = 0;
while( strtotime($begin) <= strtotime($end) ){

    echo "$begin\n";

    $i++;
    $begin = date("d/m/y", strtotime("+$i day") );

}

You can execute the same code here:
http://sandbox.onlinephpfunctions.com/code/34c4b721553038f585806798121941bee0c66086
For some reason this code is printing just the dates between 25/01/2017 and 31/01/2017 instead of 25/01/2017 and 25/02/2017. I don't know what's wrong. Can someone help me?
Comment: Dont get me wrong, but why are you using `date()` here? It can be done only with `strtotime()`. And you will call less functions in the iteration.
Answer: strtotime() doesn't support dates in d/m/y format. It treats these dates as m/d/y.
To fix your code, use Y-m-d format in the first two lines.
On a sidenote, I'd recommend to use \DateTime classes to manipulate dates instead of strings and integers. Read more here: https://paulund.co.uk/datetime-php
Comment: So simple!! Thank you my friend. This helped a lot!
Comment: `doesn't support` is not right (`echo date('Y-m-d',strtotime('01/01/2017'));` works), it is buggy in a way. Test it on the sandbox link. If strtotime doesn't support d/m/y  why are the first dates correct printed. It becomes broken when it comes to month switch.
Comment: Yes, it also works for `strtotime('02/02/2017')`, `strtotime('03/03/2017')` and so on. I'll leave it for you to figure out why.
Comment: And `echo date('Y-m-d',strtotime('01/11/2017'));` `echo date('Y-m-d',strtotime('12/2/2017'));`,....
Comment: Ok, got it. http://php.net/manual/en/datetime.formats.date.php
Answer: <?php
error_reporting(-1);
ini_set('display_errors', true);

$begin = new DateTime();
$end = (new DateTime())->modify('+1 month');
$interval = DateInterval::createFromDateString('1 day');

$period = new DatePeriod($begin, $interval, $end);

foreach ($period as $date) {
    echo $date->format('d/m/y')."
";
}


Confused about a mathematical induction detail

Question: Suppose I wish to prove that $\forall n\in\mathbb{N}\ge 5,$ the statement $\mathscr{P}(n): n^2<2^n$ is true.
Proof:
Proceeding by induction on $n$, we note that $\mathscr{P}(5):(5)^2=25<2^5=32 \implies \mathscr{P}(5) $ holds. Now we induct on $n$ and assume the statement $\mathscr{P}(n)$ holds for some $n=k>5$, that is, we assume $\mathscr{P}(k): k^2<2^{k}$ holds for some $k\in\mathbb{N}>5$. We have: \begin{align}
        k^2<2^k\\\
        2k^2<2^{k+1}\\\
(k^2)+k^2<2^{k+1}\\\
(2k+1)+k^2<(k^2)+k^2<2^{k+1}\\\
\end{align}
The last inequality $2k^2>k^2+2k+1$ follows from the fact that $k^2-2k-1=(k-1)^2-2>0$ for $k>5>1\pm\sqrt{2}.$ Continuing, we have that: \begin{align}
k^2+2k+1<2k^2<2^{k+1}\\\
(k+1)^2<2k^2<2^{k+1}\\\
\implies (k+1)^2<2^{k+1}\space\text{as desired}\space
\end{align}
Hence we have shown that the truth of $\mathscr{P}(k) \implies\space\text{the truth of}\space\mathscr{P}(k+1)\space\text{for any}\space k\in\mathbb{N}>5$. We have shown by the Principle of Mathematical Induction that $n^2<2^n$ for all $n\ge5$. $\square$
My concern with my proof is using the auxiliary notion that $k^2>2k+1$ in the induction step. Is this proof valid? Thanks a lot in advance!
Comment: Having to use some "extra fact" to prove something is typical, even as an intermediate step in a larger proof. So yes this is fine. You could get away with being more terse: you want to get $(k+1)^2<2^{k+1}$ and $(k+1)^2=k^2+2k+1$ so it suffices to have $P(k)$ (assumed) and $2k+1<2^k$ (which you must show some other way).
Comment: Unless you are trying to avoid the use of some known or provable fact, just use it if you want..... BTW  a Q on this site asked to prove $(n^2+n)/2=\sum_{j=1}^nj$ for all $n\in \Bbb N, $  $without$ induction. Many answers, all rejected by the proposer for using induction (implicitly or explicitly).  The problem is that you cannot even define what $\exists n\,(x= \sum_{j=1}^n j) $ means, from the basic axioms of arithmetic, without induction.
Answer: This is perfectly valid, nowhere does it say that you need to use only the inductive hypothesis and nothing else. You even proved the 'auxiliary notion' to boot.


Update Sheets Rows with Formula

Question: I am currently trying to make a function that allows a sheet to add the same formula to each row in column B upon insertion of new rows, so that only blank values will yield formula insertion. I based this on the answer given by Oriol Castander. I got his answer to work for one of my formulas, but not the ones for col B:
My current code for col B is:
function updateformula(){

 var ss = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Active Student List")

  var values = ss.getRange("B2:B").getValues();

  for(var i = 0; i<values.length; i++){
        if (values[i] == ""){

          var rangeToModify = ss.getRange("B2:B");
          rangeToModify.setValue('=(IF(ISBLANK(A2)=TRUE," ", IF(ISNA(VLOOKUP(A2,'Student Matches'!D$2:D,1,FALSE)),"Yes","No")))');
        }
      }

Apps Script spits out error for the "rangetoModify" line with the code inside the .setValue(), likely because it looks like a mess. However, everything within the ' ' is the formula copied directly, which has worked in other codes and in Oriol Castander's solution. Any ideas how to make the last line work? It just seems to be a technical thing (not with Sheet).
Comment: The real problem is your space in the sheet name 'Student Matches'.  That is causing the leading single quote to terminate the substring.  Because of that space you need single quotes around the sheet name for the formula to recognize the sheet name.  But you also have double quotes within the formula.  My suggestion to you, because I haven't figured out how to escape the single quote, is to remove the space in the sheet name or change it to an underbar and then remove the single quotes around the name.
Comment: Thank you so much! It works, and we are very grateful! What a blessing for beginners like us :)
Answer: Description
The only way I was able to get your formula to work is to change the single quotes of the entire formula to double quotes.  Then every occurance of double quote within the formula has to be escaped as shown.  Then the single quotes on the sheet name will work. For ranges including sheet names with a space only single quotes will work in a formula.
Script
rangeToModify.setValue("=(IF(ISBLANK(A2)=TRUE,\" \", IF(ISNA(VLOOKUP(A2,'Student Matches'!D$2:D,1,FALSE)),\"Yes\",\"No\")))");

Update Sheets Rows with Formula


If $ \{ p_n \} $ is Cauchy, then it has a subsequence $ \{ p_{n_k}\} $ with $ \sum_{k=1}^\infty d(p_{n_k}, \, p_{n_{k+1}}) $ being convergent

Question: Show that if $ \{ p_n \} $ is a Cauchy sequence, then it has a subsequence $ \{ p_{n_k}\} $ such that the series $ \sum_{k=1}^\infty b_k $ converges, where $ b_k = d(p_{n_k}, \, p_{n_{k+1}}) $.
My approach
we know that if $p_n$ is cauchy sequence, it has some subsequence that converges. That means that the $d(p_{n_k}, \, p_{n_{k+1}})\to 0$ for big $k$.
Hence the sum of $b_k$ also converges. I think it is right but can someone put it in more formal complete steps? I think I am missing few steps and I am not sure how to write it more formally than this.
Comment: What space are we working with?
Comment: your approach is not fully correct. you need to assure the distances are small enough, say assure that $b_k \leq 2^{-k}$ or any other series that you know to be convergent
Comment: Its not enough for  $d(p_{n_k},p_{n_{k+1}})\to 0$. But you can make  $d(p_{n_k},p_{n_{k+1}})$ go to zero as fast as you want... fast enough to make the series converge.
Comment: This is very close to being true by definition.  Since the given sequence is Cauchy, you can choose distances between successive terms to be as small as you like.  So the statement is hardly saying anything more than "there exists a convergent infinite series of positive terms".  (OK I guess it requires the comparison test too.)
Comment: What are $p_n$? What is $d$?
Answer: Note that your assertion that $p_n$ has a convergent subsequence is only true if we're working in a complete metric space.
Since $p_n$ is Cauchy, that means that given $k \in \mathbb N,  \exists N_k$ such that $\forall n,m\ge N_k,$ $d(p_n, p_m) < \frac{1}{2^k}$
Now consider the subsequence $p_{N_k}$. Can we use this in any way?
Comment: One small nitpick : You need to ensure that $N_{k+1} \geq N_k$, which means you need to proceed by induction.
Answer: Just because $b_k = d(p_{n_k},p_{n_{k+1}}) \to 0$ does not mean that $\sum b_k$ converges.
But, we can use this to find a convergent subequence.
Answer: Chose $p_{n_k}$ inductively. Given $n_k$, let $N$ be such that if $n,m \geq N$ then
$|p_n-p_m|< \frac{1}{2^k}$.
Now chose $n_{k+1}=N$
This will insure that
$$b_{k+1}=d(p_{n_{k+1}},p_{n_{k+2}}) <\frac{1}{2^k}.$$
(regardless of how $n_{k+2}$ is chosen at the next step.)


The expected Ejabberd filter_packet function not being called

Question: The ejabberd module I'm using, mod_pottymouth is not filtering messages as expected.  After adding logging I see a generic handler method being called instead of the one that does the actual filtering. Problem is, I am not able to parse the ejabberd message to ensure the proper function is called. Can anyone help?
on_filter_packet({_From, _To, {xmlel, <<"message">>, _Attrs, Els} = _Packet} = _Msg) ->
  %This is what should be called to filter messages, but is never called
  FilteredEls = filterMessageBodyElements(Els, []),
  {_From, _To, {xmlel, <<"message">>, _Attrs, FilteredEls}};
on_filter_packet(Msg) ->
 % This is what actually gets called
 Msg.

This is using ejabberd 17.01
Comment: using ejabberd 17.01, and the latest mod_pottymouth from ejabberd-contrib
Answer: Starting from 16.12 ejabberd doesn't route xmlel elements. You should process new style records: message, presence or iq.
Please read https://docs.ejabberd.im/developer/guide/#ejabberd-router
and https://github.com/processone/xmpp/blob/master/README.md
So, basically, your code should look like this:
on_filter_packet(#message{body = Body} = Msg) ->
    NewBody = filterMessageBody(Body),
    Msg#message{body = NewBody};
on_filter_packet(Stanza) ->
    Stanza.

Answer: Have you tried using xmlel as record instead of tuple ?


Does the probability commute with limit?

Question: Does the probability commute with limit?
For example, is it true that for $(N_t)_t$ random variables which take values in the set of natural numbers,
$$ \mathbb{P}(\underset{t \rightarrow 0}{lim} \hspace{3pt} N_t = 0) = \underset{t \rightarrow 0}{lim} \hspace{3pt} \mathbb{P}(N_t = 0)? $$
Thank you!
Comment: Me? I didn't flag your previous comment. I didn't read your previous comment.
Comment: Hmm this might be a stupid question with an obvious answer but how are you defining the left hand side? I can see what the right side means since the $\mathbb{P}$ is always applied to a given random variable which has some specific probability distribution associated with it but I'm not exactly certain how you would unambiguously interpret the left side.
Comment: OP: Did you flag my previous comment? If so, kudos, you succesfully found a way to *avoid* thinking about the problem yourself.
Comment: because I wasn't here
Comment: OK, someone did, I presume, and a mod took a strange decision.
Comment: Assuming you are using the left hand side to refer to the probability of the limit of the distribution functions for the random variables to equal 0, then have you considered the situation where each $N_t$ is a discrete distribution which has $P(N_t=0)=1/2$ and $P(N_t=1/t)=1/2$?
Comment: In my problem $N_t$ are dicrete random variables. They take values in the set of natural numbers.
Comment: Well in that case look at the example I gave and replace $1/t$ with $\lfloor 1/t\rfloor$.
Comment: Yes. I understand that this is a wrong question. I want to close it :d thank you for explanation
Comment: @rodie: I am sorry to see that you consider your question to be wrong. Perhaps the introductory wording was strange but the question itself made me give an answer. Having accepted my answer, please, let me know if it helped you to get closer to the essence of the issue you raised.
Answer: The answer is NO in general. Here is an example supporting this negative answer.
Consider the interval $\Omega=[-1,+1)$ and its Borel subsets, and let the probability measure of a subinterval of  $\Omega$ be defined as the half of its length.
Then, let the random variables $N_t$, with the parameter $t\in (0,1)$ be defined as follows
$$N_t(\omega)=\begin{cases} 1 \text{ if } \omega \in \big[\sin(\frac{1}{t}),\sin(\frac{1}{t})+t \big)\text{ and if }\sin(\frac{1}{t})+t\le1\\
0\text{ otherwise.}\end{cases}$$
This function of $\omega$ equals $1$ over an up and down walking and, at the same time,  shrinking interval. So $$\lim_{t\rightarrow0}P(N_t=0)=1.$$
On the other hand there is no $\omega$ for which $$\lim_{t\rightarrow0}N_t(\omega)=0.$$That is$$P(\lim_{t\rightarrow0}N_t=0)=0.$$


How can I test Heteroskedasticity in GAM?

Question: I'm trying to test heteroskedasticity in different models namely in linear regreesion model, polynomial regression model, and generalized additive model. Using the ols_test_breusch_pagan function library(olsrr) I can test heteroskedasticity for linear and polynomial models but I couldn't figure out how to test heteroskedasticity in the generalized additive model (GAM). I followed the below process to test heteroskedasticity in the linear and polynomial models.
    ##################
    ###Linear Model###
    ##################
    >sm1 <- lm(adN ~ GC3 , data = train.data)
    >ols_test_breusch_pagan(sm1)
    ###########################################
     Breusch Pagan Test for Heteroskedasticity
     -----------------------------------------
     Ho: the variance is constant
     Ha: the variance is not constant

                 Data
     -------------------------------
     Response : adN
     Variables: fitted values of adN

            Test Summary
     -----------------------------
     DF            =    1
     Chi2          =    0.04513367
     Prob > Chi2   =    0.8317584

     ######################
     ###Polynomial Model###
     ######################
    >poly_degree(train.data$GC3, train.data$adN, type = "BIC")
    5
    >pm1 <- lm(adN ~ poly(GC3, 5, raw = TRUE), data = train.data)
    >ols_test_breusch_pagan(pm1)

     Breusch Pagan Test for Heteroskedasticity
     -----------------------------------------
     Ho: the variance is constant
     Ha: the variance is not constant

                 Data
     -------------------------------
     Response : adN
     Variables: fitted values of adN

            Test Summary
     -----------------------------
     DF            =    1
     Chi2          =    0.02017309
     Prob > Chi2   =    0.8870547

Therefore, It suggests that the polynomial model is better for addressing heteroskedasticity in the data.
Now I want to know how can I test heteroskedasticity in the generalized additive model (GAM).
I used library(mgcv) to fit GAM.
    ################################
    ###Generalized Additive Model###
    ################################
    gm1 <- gam(adN ~ s(GC3), data = train.data)

This is a humble request that it will be an immense help if someone kindly let me know the solution of the above issue.
Answer: The easiest way to assess the fit of your models (in my opinion) is to plot the residuals of your GAM against the independent variable and visually inspect the results for heteroskedasticity. If there is any heteroskedasticity, the residuals of the model should spread out in the form of a cone/fan (i.e. there will be more spread in the residuals as the independent variable increases). You can obtain the residuals for the GAM and the LM usings the command resid(your_model).


Inequality: norm of differential forms and mass of singular simplex

Question: Let M be a Riemannian manifold of dimension $n$ with a differentiable $p$-form $\omega\in \Omega^p(M)$. Let $\sigma\colon \Delta^p\to M$ be a differentiable singular $p$-simplex. We may assume that $\sigma$ is lipschitz if needed.
I'm interested in the following inequality from $[1]$:
$$|\omega(\sigma)| \leq \|\omega\|_\infty \cdot  \text{mass}(\sigma)$$
though I'm not 100% sure I know what all the ingredients in the inequality are, as my diffentialgeometryskills are not the best. (Also, there could be more assumptions missing, but I don't think so.)
So I tried to make sense of the objects appearing. First the LHS:
Having a $p$-form on $M$, I can pull that back by $\sigma$ to obtain a $p$-form on $\Delta^p$. Which I then may integrate. That would be
$$\omega (\sigma) = \int_{\Delta^p} \sigma^*(\omega)$$
The mass of a simplex is$^{[2]}$ the integral of the Jacobian over $\Delta^p$.
$$\text{mass}(\sigma) = \int_{\Delta^p} |(J\sigma)| \text{vol}_{\Delta^p}$$
Apparently, the Jacobian $J\sigma$ at $x$ is the (absolute value of? the) determinant of the transformation matrix of the map $T_x\sigma\colon T_x \Delta^p \to T_{\sigma(x)}M$, where I restrict the codomain to the image. I have to do this since the dimension won't match up.
Last but not least, the norm of $\omega$. With the Hodge-star-operator, we may turn $p$ into an $n-p$-form $\star \omega$. Wedging both, we obtain an $n$-form, which is a multiple of the volumeform on $M$. This multiple is the norm.
$$\|\omega\|^2 = \star(\omega \wedge \star \omega)~~~\text{ or }~~~ \omega\wedge \star \omega = \|\omega\|^2 \text{vol}_M$$
Now $\|\omega\| \colon M\to \mathbb R$, so we may take the supremum $\|\omega\|_\infty = |\|\omega\||_\infty$ over $M$.
In the explicit case, this is bounded by a constant.
So how do these things match up? How to get the above inequality (I guess it shouldn't be that hard, ass ECHLPT don't say anything about it).
[1] The inequality is from Epstein-Cannon-Holt-Levy-Paterson-Thurston's Word Processing in Groups, p.239.
[2]  according to Word Processing in Groups, p. 221
Edit (solution if $n=p$):
If $n=p$ holds, this is not hard. As $\omega$ is now a $n$-form, we can write $w=f \cdot \text{vol}_M$, where $f\colon M\to \mathbb R$. Even more, we have $\|\omega\|=f$.
$$\omega(\sigma) = \int_{\Delta^p} \sigma^*(f\cdot \text{vol}_M) = \int_{\Delta^p} \sigma^*(f) \cdot \sigma^*(\text{vol}_M) = \int_{\Delta^p} \underbrace{f\circ \sigma}_{\leq |f|_\infty} \cdot \sigma^*(\text{vol}_M) \leq |f|_\infty \int_{\Delta^p} \sigma^*(\text{vol}_M) = |f|_\infty \int_{\Delta^p} |J\sigma| \text{vol}_M = \|\omega\|_\infty \cdot \text{mass}(\sigma)$$
However, the transformation formula (first to second line) cannot be easily applied for $p\neq n$ and the characterization of $\omega$ as a multiple of the volume form won't work either.
Answer: I think i got it (with the help of a friends, thank btw).
Let $x\in \Delta^p$. We show that $\sigma^\ast(\omega)\leq \|\omega\|_\infty |J\sigma| \text{vol}_{\Delta^p}$.
Let's assume that $\sigma_\ast \colon T_x\Delta^p \to T_{\sigma(x)}M$ is injective, otherwise the Jacobian $|J\sigma|$ is zero, as well as $\sigma^\ast(\omega)$. Let $(c_1,\dots,c_p)$ be an orthonormal basis of $T_x \Delta^p$ and $(b_1,\dots,b_n)$ be an orthonormal basis of $T_{\sigma(x)}M$ such that $\langle \sigma_\ast(\{c_1,\dots,c_p\})\rangle = \langle b_1,\dots,b_p\rangle$. We can do this by applying Gram-Schmidt to the image of the first basis. In the following, I denote by $(b^1,\dots,b^n)$ and $(v^1,\dots,v^p)$ the dual basis.
Therefore, we can decompose the images of the $v_i$:
$$\sigma_\ast(v_i)=\sum_{j=1}^p a_{ij} b_j$$
In particular, $|J\sigma|=\det(a_{ij})_{ij}$.
Furthermore, we have
$$\sigma^\ast(b^j)(v_i) = b^j(\sigma_\ast(v_i))=\langle \sigma_\ast(v_i),b_j\rangle = \begin{cases}a_{ij}&\text{if } j\leq p\\0 &\text{if } j>p\end{cases}$$
Therefore, $\sigma^\ast(b^j)=\sum\limits_{i=1}^p a_{ij} v^i$ for $j\leq p$ and $=0$ else.
Now, $\sigma^* (b^1\wedge \dots \wedge b^p) = \sigma^*(b^1)\wedge\dots\wedge\sigma^\ast(b^p) = \bigwedge\limits_{i=1}^p \sum\limits_{j=1}^p a_{ij}v^i = |J\sigma| v^1\wedge\dots\wedge v^p = |J\sigma|\text{vol}_{\Delta^p}$.
Let $\omega=\sum\limits_{\substack{|I|=p\\I\subset\{1,\dots,n\}}}\omega_I \bigwedge\limits_{i\in I}b^i$. Then
$$\sigma^\ast(\omega) = \sum\limits_{\substack{|I|=p\\I\subset\{1,\dots,n\}}}\sigma^\ast(\omega_I) \bigwedge\limits_{i\in I}\sigma^\ast(b^i) = \sigma^\ast(\omega_{1,\dots,p})\sigma^\ast(b^1\wedge \dots \wedge b^p) \leq \|\omega\|_\infty |J\sigma| \text{vol}_{\Delta^p}$$
Integrating the inequality yields the result. I guess there are some absolute values missing at many points, but I don't really care.
What do you think? Is this the way to prove it? Probably there is a way to do it coordinate free.


Equivalent SIMD instruction for multiplying specific array elements

Question: I just understood how to get a dot-product of 2 arrays (as in the following code):
int A[8] = {1,2,3,4,5,1,2,3};
int B[8] = {2,3,4,5,6,2,3,4};

float result = 0;

for (int i = 0; i < 8; i ++) {
    result += A[i] * B[i];
}

is equivalent to (in SIMD):
int A[8] = {1,2,3,4,5,1,2,3};
int B[8] = {2,3,4,5,6,2,3,4};

float result = 0;

__m128 r1 = {0,0,0,0};
__m128 r2 = {0,0,0,0};
__m128 r3 = {0,0,0,0};

for (int i = 0; i < 8; i += 4) {
  float C[4] = {A[i], A[i+1], A[i+2], A[i+3]};
  float D[4] = {B[i], B[i+1], B[i+2], B[i+3]};
  __m128 a = _mm_loadu_ps(C);
  __m128 b = _mm_loadu_ps(D);

  r1 = _mm_mul_ps(a,b);
  r2 = _mm_hadd_ps(r1, r1);
  r3 = _mm_add_ss(_mm_hadd_ps(r2, r2), r3);
  _mm_store_ss(&result, r3);
}

I am curious now how to get the equivalent code in SIMD if I want to multiply elements that aren't consecutive in the array. For example, if I wanted to perform the following, what would be the equivalent in SIMD?
int A[8] = {1,2,3,4,5,1,2,3};
int B[8] = {2,3,4,5,6,2,3,4};

float result = 0;
for (int i = 0; i < 8; i++) {
    for (int j = 0; j < 8; j++) {
        result += A[foo(i)] * B[foo(j)]
    }
}

foo is just some function that returns an int as some function of the input argument.
Comment: Have you had a crack at it yourself? Trying and failing will teach you faster than being given the answer.
Comment: Also, while you are at it, try using OpenCL. On an Intel system, this lets you by-pass the need to compile the code for each processor - while getting the same speed as the intrinsic.
Comment: Is there a confusion in your data types between `int` and `float` and `__m128`?
Comment: You ought to focus on getting the first example right before moving on to anything more complex. There are several mistakes, and even when these are fixed the code is far from optimal. Since SIMD is all about getting close to maximum theoretical best case performance you really have to pay a lot more attention to detail and be prepared to keep iterating through the optimisation process until the code is nearly perfect.
Comment: Well that probably deserves to be a Stack Overflow question in its own right, but you should probably get rid of the int to float conversions, do everything in the integer domain, and move the horizontal operations outside the loop, just for starters. You need to tighten up the requirements too, e.g. how many elements max, what is the range of the input data, etc.
Comment: Search on the `[sse]` or `[simd]` tags here on StackOverflow - there are many good questions and answers which are worth studying.
Answer: If I had to do this task, I would do it as follows:
int A[8] = {1,2,3,4,5,1,2,3};
int B[8] = {2,3,4,5,6,2,3,4};

float PA[8], PB[8];
for (int i = 0; i < 8; i++)
{
    PA[i] = A[foo(i)];
    PB[i] = B[foo(i)];
}

__m128 sums = _mm_set1_ps(0);
for (int i = 0; i < 8; i++)
{
    __m128 a = _mm_set1_ps(PA[i]);
    for (int j = 0; j < 8; j += 4)
    {
        __m128 b = _mm_loadu_ps(PB + j);
        sums = _mm_add_ps(sums, _mm_mul_ps(a, b));
    }
}
float results[4];
_mm_storeu_ps(results, sums);
float result = results[0] + results[1] + results[2] + results[3];

Answer: Generally speaking, SIMD does not like such things as random access to individual elements. However, there are still several tricks that can be used.
If the indices provided foo are known at compile time, you can probably shuffle both vectors to align their elements properly. Just look at intrinsics in swizzle category in the Intrinsics Guide. Most certainly you'll need something like _mm_shuffle_ps and _mm_unpackXX_ps. Also various shift/align instructions may be useful.
With AVX2, you can try to use gather instructions. For float type in 32-bit mode you can
use _mm_i32gather_ps or _mm256_i32gather_ps intrinsics. However, @PaulR writes here that they are no faster than trivial scalar loads.
Another solution may be possible with _mm_shuffle_epi8 instrinsic from SSSE3. It is a great instruction that allows to perform in-register gather operation with granularity of individual bytes. However, creating the shuffle mask is not a simple task. This paper (read sections 3.1 and 4) shows how to extend this approach to input arrays larger than one XMM register, but it seems that for 64 and more elements it is no longer better than scalar code.


Python Regex MULTILINE option not working correctly?

Question: I'm writing a simple version updater in Python, and the regex engine is giving me mighty troubles.
In particular, ^ and $ aren't matching correctly even with re.MULTILINE option. The string matches without the ^ and $, but no joy otherwise.
I would appreciate your help if you can spot what I'm doing wrong.
Thanks
target.c
somethingsomethingsomething
    NOTICE_TYPE revision[] = "A_X1_01.20.00";
somethingsomethingsomething

versionUpdate.py
fileName = "target.c"
newVersion = "01.20.01"
find = '^(\s+NOTICE_TYPE revision\[\] = "A_X1_)\d\d+\.\d\d+\.\d\d+(";)$'
replace = "\\1" + newVersion + "\\2"

file = open(fileName, "r")
fileContent = file.read()
file.close()

find_regexp = re.compile(find, re.MULTILINE)
file = open(fileName, "w")
file.write( find_regexp.sub(replace, fileContent) )
file.close()

Update: Thank you John and Ethan for a valid point. However, the regexp still isn't matching if I keep $. It works again as soon as I remove $.
Comment: Two thoughts: 1) If you're matching a single line, why do you need `re.MULTILINE`? 2) Are there spaces after the `;`?
Answer: Change your replace to:
replace = r'\g<1>' + newVersion + r'\2'

The problem you're having is your version results in this:
replace = "\\101.20.01\\2"

which is confusing the sub call as there is no field 101.  From the documentation for the Python re module:

\g<number> uses the corresponding group number; \g<2> is therefore
  equivalent to \2, but isn't ambiguous in a replacement such as \g<2>0.
  \20 would be interpreted as a reference to group 20, not a reference
  to group 2 followed by the literal character '0'.
Answer: if you do a print replace you'll see the problem...
replace == '\\101.20.01\2'

and since you don't have a 101st match, the first portion of your line gets lost.  Try this instead:
newVersion = "_01.20.01"
find = r'^(\s+NOTICE_TYPE revision\[\] = "A_X1)_\d\d+\.\d\d+\.\d\d+(";)$'
replace = "\\1" + newVersion + "\\2"

(moves a portion of the match so there is no conflict)


Simple Number Theory question! What is the remainder when 4^999 is divided by 100?

Question: I know I'm supposed to use modular arithmetic, but I must be messing up my process somehow. Can someone explain how to do this?
$4^{999}$'s last two digits in other words (What is $4^{999}$'s remainder when divided by $100$)
Comment: One way is to work separately modulo $4$ (trivial) and modulo $25$.
Answer: Since $\phi(25)=20$, we have:
$$ 4^{999}\equiv 4^{-1}\equiv 19\pmod{25} $$
while obviously $4^{999}\equiv 0\pmod{4}$, hence by the Chinese theorem:
$$ 4^{999} \equiv 44\pmod{100}. $$
Comment: This helped too!
Answer: $$
4^6 = 4096 \equiv -4 \bmod 100
$$
so the cycle must repeat every $2(6-1) = 10$ powers of $4$.  Now,
$$
4^9 = 2^{18} = 262144
$$
so the last two digits are $44$.
Comment: Thank you! I'm just learning NT and am rubbish at mod, so this helped a lot. :)
Comment: The Chinese remainder theorem approach is more systematic; my solution here is much more *ad hoc* (but I knew someone would post the CRT solution).  Jack D'Aurizio's solution does not expand on the details of how to construct the solution; look here for a description of how to do so: https://en.wikipedia.org/wiki/Chinese_remainder_theorem
Comment: I preferred your solution because keep in mind my lack of mod experience, and this is a method I am more familiar with. Thanks for the link.


Determine the value of a

Question: Please,this is the last problem that i need to solve:
Can you help me?
Determine the value of a such that the vectors A = (a, 4), B = (2,5) are parallel.
Comment: How is this related to the software program Mathematica? Maybe you wanted to post on math.SE instead?
Comment: @anderstood may you give me a link to go there?
Comment: http://lmgtfy.com/?q=math.se
Comment: You want to solve $\frac{a}{2} = \frac{4}{5}$
Answer: Hint:
Equate the direction ratios
$$\frac{a}{2} = \frac{4}{5}$$

Determine the value of a


Multiple App Executed Bluemix

Question: Can I run multiple apps/processes in one Bluemix instance? Right now I run them on localhost with one on port 3000 and the other on 4000. The second app is in a subfolder of the parent app, but they do not share any dependencies. I can split them up, that's no problem, but I want to know how to get them to run at the same time when I push to Bluemix. Do I create a procfile with web: node app.js and then web: node enterprise/app.js on the next line?
Answer: You would have to run these apps as two different Bluemix applications. You can not customize the open ports on a Bluemix application, so your current setup would not be possible. If you want to deploy them in the same command, I would suggest setting up a deployment pipeline that takes each app from their respective place in the source code directory and deploys them to two separate endpoints.

Multiple App Executed Bluemix


Setar timeout para função específica

Question: Tenho um script com várias funções.
Gostaria de setar um timeout (tipo set_time_limit) específico para uma função, e se estourar o tempo, ele "desconsiderar" e continuar a execução do loop/script.
Exemplo:
function teste(){
    sleep(10);
}

foreach($array as $v) {
    echo $v;
    teste();
}

Considerando o exemplo, a função teste() irá executar por 10 segundos a cada loop.
Então quero setar um timeout de 3 segundos para a função, e caso "estourar" o tempo, ele descarta, e continua o loop.

Existe essa possibilidade?
Comment: A biblioteca ReactPHP provê formas de se implementar está funcionalidade. Com funções especifícas do PHP, acredito que você não conseguirá este comportamento. [ReactPHP](https://reactphp.org/)
Answer: A minha curiosidade me levou a esta resposta. Não sei se é a melhor solução, mas funciona. Para fazer o que você quer eu consegui usando execdo php para executar o arquivo que contém a função teste() em plano de fundo. Assim:
$array = [1,2,3,4,5,2,1];

foreach($array as $v) {
    $var = exec('C:\xampp\php\php.exe  '. __DIR__ .'\teste.php '.$v, $saida);
    echo $var;
}

Arquivo teste.php
error_reporting (0);
set_time_limit(3);
function teste($sec){
    sleep($sec);
    echo "executou > $sec - ";
}
$sec = $argv[1];
teste($sec);

A variável $v é lançada como um argumento para o script que é recuperado em $sec.
Resultado
executou > 1 -executou > 2 -executou > 3 -executou > 2 -executou > 1 -

Comment: Apesar de eu achar válida idéia (apesar de não responder diretamente à duvida da pergunta), o que você fez ai é trocar o crontab ou um agendador de tarefas por um PHP (não tou dizendo que isso é ruim, só acho interessante observar.). Se for bem implementada sua idéia, dá pra fazer um "crontab configurado pelo DB", por exemplo (até cheguei a sugerir isso numa resposta antiga minha).
Comment: É um serviço que a cada minuto pode executar uma tarefa, e você configura assim: https://pt.stackoverflow.com/questions/124518/70
Comment: Em cada linha você põe uma definição de tempo, um executável e seus argumentos. A cada minuto o crontab vai verificar a lista de horários e executar o que for apropriado praquele momento.
Comment: @Bacco verdade! Um crontab seria uma opção interessante.
Comment: Quis dizer o oposto, você aproveitar sua idéia e fazer um "crontab próprio" para usar com PHP (mas não pro caso da pergunta). Pq o crontab original você tem que mexer pelo shell, um PHP assim pode servir como agendador para um sistema em PHP configuravel por painel, pq sendo executado pelo shell ele pode ter loop infinito (desde que tenha um sleep pra liberar cpu pras outras coisas, claro).
Comment: @Bacco entendi. Eu nunca usei o cron, apenas ouvi falar. Me parece que ele não é dinâmico né? Você configura uma certa data e horário ele executa um script certo?
Comment: Por exemplo, a tarefa da linha um todo sábado, a cada meia hora. a da linha dois toda segunda, quarta e sexta às 12h e 19h30... A da linha 3, executa todo dia a cada 7 minutos, e assim vai.
Comment: @Bacco legal. É uma boa solução para executar scripts para atualização de banco backup...

Setar timeout para função específica


Erro para chamar Activity

Question: Estou com problema para chamar outra activity. Segue código da Activity:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_principal);
}

public void entrarOnClick(View v) {
    Intent intent = new Intent(this, Menu.class);
    startActivity(intent);
    }

}

e o androidmanifest
<activity
        android:name=".Principal"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name=".Menu"
        android:label="Menu" >
    </activity>

segue o logcat:
09-23 14:03:21.527: E/AndroidRuntime(2464): FATAL EXCEPTION: main
09-23 14:03:21.527: E/AndroidRuntime(2464): java.lang.IllegalStateException: Could not execute method of the activity
09-23 14:03:21.527: E/AndroidRuntime(2464):     at android.view.View$1.onClick(View.java:3599)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at android.view.View.performClick(View.java:4204)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at android.view.View$PerformClick.run(View.java:17355)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at android.os.Handler.handleCallback(Handler.java:725)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at android.os.Looper.loop(Looper.java:137)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at android.app.ActivityThread.main(ActivityThread.java:5041)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at java.lang.reflect.Method.invokeNative(Native Method)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at java.lang.reflect.Method.invoke(Method.java:511)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at dalvik.system.NativeStart.main(Native Method)
09-23 14:03:21.527: E/AndroidRuntime(2464): Caused by: java.lang.reflect.InvocationTargetException
09-23 14:03:21.527: E/AndroidRuntime(2464):     at java.lang.reflect.Method.invokeNative(Native Method)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at java.lang.reflect.Method.invoke(Method.java:511)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at android.view.View$1.onClick(View.java:3594)
09-23 14:03:21.527: E/AndroidRuntime(2464):     ... 11 more
09-23 14:03:21.527: E/AndroidRuntime(2464): Caused by: android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.radiosu/android.view.Menu}; have you declared this activity in your AndroidManifest.xml?
09-23 14:03:21.527: E/AndroidRuntime(2464):     at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1618)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at android.app.Activity.startActivityForResult(Activity.java:3370)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at android.app.Activity.startActivityForResult(Activity.java:3331)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at android.app.Activity.startActivity(Activity.java:3566)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at android.app.Activity.startActivity(Activity.java:3534)
09-23 14:03:21.527: E/AndroidRuntime(2464):     at com.example.radiosu.Principal.entrarOnClick(Principal.java:32)
09-23 14:03:21.527: E/AndroidRuntime(2464):     ... 14 more

Comment: Bem Vindo ao StackOverFlow em Português. Qual o erro que você está tendo?
Comment: Porque é que existe uma função dentro de uma função aí? entrarOnClick não deveria estar dentro do onCreate
Comment: Era uma pergunta. Faltou o ?. Esse problema já foi resolvido mais abaixo.
Comment: Está a tentar usar outra class Menu em vez da sua. Está a ver `Menu.class`? Está a apontar para android.view.Menu em vez da sua class Menu. Em vez de usar `Menu.class` experimente usar `com.seupackage.Menu.class`
Comment: deu certo agora, muito obrigado.
Answer: Está a tentar declarar uma função dentro de outra função.
Altere o seu código para este:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_principal);

}
public void entrarOnClick(View v) {
    Intent intent = new Intent(this, Menu.class);
    startActivity(intent);
    }

Alem disso está a tentar apontar para o Menu do android.view e não o seu. Use o caminho completo da sua classe em vez de Menu.class. Algo como com.example.radiosu.Menu.class provavelmente.
Comment: Então o melhor a fazer é atualizar a sua pergunta e colocar o stacktrace do Logcat para podermos saber o que se está a passar.
Comment: as {}. Quando diz que é iniciante em programação android não está a querer dizer iniciante em programação em geral certo?
Comment: detalhe tão sutil que passou batido. - vou remover o comentário acima e depois removo esse. Abraçs!
Comment: Lembre-se de marcar a resposta como correta se esta resolveu o seu problema e tenha um bom dia.
Comment: Não posso fazer isso.. pq não sou o criador do tópico.  :)
Comment: Foi um comentário para a comunidade em geral caso o criador se lembre de ler as respostas às suas perguntas :)
Comment: era um detalhe que eu não tinha visto, mas agora está aparecendo a mensagem de erro " unfortunately, app has stopped. Muito obrigado
Answer: Não seria porque você não clicaria em algo "vazio". Tente setar a imagem e ou botão pelo seu id, internamente ao onCreateView(), usando onClickListener() (desta forma é certeza que vai funcionar):
  findViewById(R.id.bt_menu).setOnClickListener(new View.OnClickListener()
    {
      public void onClick(View v)
      {
        Intent it = new Intent(this, Menu.class);
        startActivity(it);
      }
    });

Vendo seu AndroidManifest ele abre em Menu, não abria primeiramente na Activity Main  (a atividade principal, base para as demais)?

Erro para chamar Activity


How to recalculate a variable value every time it is used?

Question: I want a variable to be calculated each time it is used.  For example, var1 = var2 + var3 each time var1 is printed.  How can I create a "dynamic" variable like this?
var2 = 4
var3 = 2
print(var1)  # 6
var3 = 8
print(var1)  # 12

Comment: If you were in the context of an object, you'd be looking for [properties](https://docs.python.org/2/library/functions.html#property), outside of objects, I'm not so sure.
Comment: @AvinashRaj No, it would not. That would check what is stored in var1, and then print what was the value of var1, it would not make any calculations.
Comment: Can you update your question with examples?
Comment: @nu11p01n73R Whatever it would be necessary, for example, if I want var1 always be the sum of var2 and var3, every time I call var1, it would be necessary to sum var2 and var3 together and get a new value for var1
Answer: You'll need a property on a class instance. The property will execute some code each time it's accessed. For example, here's a property that increments its value each time it is accessed. Define dunder methods that access the property to automatically increment it when performing operations on the object. For example, define __str__ and print(var) will increment the value.
class MyVar(object):
    def __init__(self, initial=0):
        self._var1 = initial

    @property
    def var1(self):
        self._var1 += 1
        return self._var1

    def __str__(self):
        return str(self.var1)

var1 = MyVar()
print(var1)  # 1
print(var1)  # 2
print(var1.var1)  # 3

Calculate var1 = var2 + var3:
class MyVar(object):
    def __init__(self, var2, var3):
        self.var2 = var2
        self.var3 = var3

    @property
    def var1(self):
        return self.var2 + self.var3

var = MyVar(4, 2)
print(var.var1)  # 6
var.var3 = 8
print(var.var1)  # 12

Answer: You could also store the computation function in a variable and call it everytime you need the value:
>>> var1 = lambda: var2 + var3
>>> var2 = 4
>>> var3 = 2
>>> print(var1())
6
>>> var3 = 8
>>> print(var1())
12


How to add the "user role field" in View showing users

Question: I created a view showing users. Then I have a list of users. I need to add a field to show the user role. I clicked add field but I don't see this field. Do I need to add a relationship to have this field available?
Update: I have Aggregation enabled.
Comment: Roles dissapear cuz of aggreagation, if u read the description on views u will see `If enabled, some fields may become unavailable.`
Answer: So you need to add 2 field into your view User uid(exclude from display) and Custom text, next go to your template.php and do next
//implement hook_preprocess_views_view_fields
function YOURTHEME_preprocess_views_view_fields(&$vars) {
    $view = $vars['view'];
    $fields = $vars['fields'];

    if ($view->name == 'usr1') { // change on your view name
        $results = $view->result;
        $roles = array();
        foreach ($results as $row) {
            $user = user_load($row->uid);
            $roles = implode(', ',$user->roles ); //get all user roles
            //check if user name from field equal to current user in array
            if ($fields['name']->raw === $row->users_name) {
                $fields['nothing']->content = $roles;//put that roles to custom text field
            }
        }
    }
}

THIS CODE NEED IMPROVEMENTS, cuz it iteracts on every field of your view, so you can work on this :D.
Comment: thanks, but I don't get it. Do you mind to elaborate on this, please
Comment: ok wait a bit, gonna post example here
Comment: I can't get it working, no errors, just not working.
Comment: are you sure u use proper view name `if ($view->name == 'usr1') {` and use `dpm` for debug to see what is wrong, maybe some names may differ from mine,  like this -> `$fields['name']` or `$field['nothing']`
Answer: Try to disable Aggreegation, enable the Role field and then enable again the Aggreegation.
Notice that the Role field is a multi-value one (Roles is a list).
So if I understand well you should better use a module like https://www.drupal.org/project/views_aggregator.
Answer: There should be User:Roles available in field list.
Comment: I agree. But look at the capture I uploaded at the bottom of my question


Use a different confirmation url on completed webform submission in email confirmation link

Question: When a user submits a webform submission, they get redirected to a confirmation page, in my case its node/40. Now if they also have to click on an email confirmation link, it also sends them to the same confirmation url node/40.
How can you set a different confirmation url for the one in the email?
Comment: nevermind! i found it... there's another field for another url on that page. didn't see it.
Comment: @duckx If you found the answer, please write a brief answer so that it's clear your problem is solved.
Comment: How's the e-mail confirmation link being sent? custom module? or...
Comment: Its being sent via the webform **Confirmation request emails (always send)** page. This page: http://prntscr.com/gsyno2
Answer: There is actually a Set the redirect URL field in the "confirmation" email page setting which i totally missed. See below:


Persistent Internet Explorer mode under Edge without GPO

Question: we need to start an older java applet via Edge with IE Mode. The 30 (to 90) days solution works, but none of the official or inofficial solutions for a permanent solution.
The temporary solution:
Under edge://settings/defaultBrowser loading pages in the Internet Explorer Mode needs to be allowed. If the adress (http://localhost/startpage.html) is put there, it will open in IE Mode for 30 days (or up to 90). But we need to have it permanent since we can't manually add them there every 90 days for every customer.
This was tried so far:

Using the --ie-mode-test parameter by running edge with the following shortcut: "C:\Program Files (x86)\Microsoft\Edge\Application\msedge.exe" http://localhost/startpage.html --ie-mode-test

Doesn't work anymore, the parameter was officially discontinued. Source: https://gpsearch.azurewebsites.net/#15453

Using the Site List Manager via edge://compat/SiteListManager . Putting the site there manually didn't result in opening in IE Mode. This was it's content:

<site-list version="1">
  <site url="http://localhost/startpage.html">
    <compat-mode>Default</compat-mode>
    <open-in>IE11</open-in>
  </site>
</site-list>

Creating an XML file via Enterprise Mode Site List Manager and importing it in Edge. It was a little bit different than the XML created by Edge, but it didn't work either. This was it's content:

<site-list version="1">
  <created-by>
    <tool>EMIESiteListManager</tool>
    <version>184.108.40.206</version>
    <date-created>04/22/2022 10:31:03</date-created>
  </created-by>
  <site url="localhost/frischli/lager.html">
    <compat-mode>Default</compat-mode>
    <open-in>IE11</open-in>
  </site>
</site-list>

There is another small thing: On every Microsoft page, there is a reference to the GPOs of Edge being in the following path: Computer/User -> administrative templates -> Edge, but that doesn't exist for me. The Edge policies are under Computer/User -> administrative templates -> Microsoft Components -> Microsoft Edge.
Does anybody know how to get this running?
Answer: You could consider the CheerpJ Applet Runner extension, developed by Leaning Technologies.
Full disclosure, I am CTO of Leaning Technologies and lead dev of CheerpJ
Please note that the extension if free only for personal use, any commercial or business use requires a license. Please see here for more info.
Answer: Yes, you are right. The IE mode site list setting in the browser only keep 30-90 days, so if you need to make it work in IE mode for a long time, you need to configure it via group policy.

Creating an XML file via Enterprise Mode Site List Manager and importing it in Edge. It was a little bit different than the XML created by Edge, but it didn't work either.

The configuration file format generated by this tool is more in line with the specification. The reason why this configuration does not work is related to your second question. You can refer to this document to view the format requirements of this configuration file:Enterprise Mode schema v.2 guidance.

On every Microsoft page, there is a reference to the GPOs of Edge being in    the following path: Computer/User -> administrative templates -> Edge, but            that doesn't exist for me.

First you need to download and install the Edge policy template, please navigate to offical link and select your environment, and then download the policy template like this image. And then install it in your machine, finally configure Edge IE mode policy.
For the installation of Edge policy templates and the configuration of Edge IE mode, you can refer to these two documents:
Configure Microsoft Edge policy settings on Windows.
Configure IE mode policies.
Finally after your configuration is complete, you can navigate to edge://compat/enterprise in Edge and click the Force update button to see if it takes effect, by default, group policy will take a minute to work.


How do I elegantly rename Pandas value counts output?

Question: I want to call df['item'].value_counts() and, with minimal manipulation, end up with a dataframe with columns item and count.
I can do something like this:
df['item'].value_counts().reset_index().rename(columns={"item":"count", "index": "item"})

... which is fine but I'm like 95% sure there is a cleaner way to do this by passing a variable to reset_index or something similar
Answer: Let us try with groupby
df.groupby('item')['item'].count().reset_index(name='count')

Comment: Did not realize that `reset_index` had a `name` parameter!
Answer: Using set_axis is very slightly cleaner.
df['item'].value_counts().reset_index().set_axis(['item','count'], axis=1)

Answer: Using groupby, value_counts, and to_frame
import pandas as pd  # 1.5.1

df = pd.DataFrame({"item": list("aaabbbbbbccc")})

counts = df.groupby("item").value_counts().to_frame("count").reset_index()

print(counts)

  item  count
0    a      3
1    b      6
2    c      3

using value_counts and to_frame
counts = df["item"].value_counts().to_frame("count").reset_index(names="item")

print(counts)

  item  count
0    a      3
1    b      6
2    c      3

References
to_frame
df.reset_index calls for parameter names vs name in pd.Series.reset_index
Comment: index should be item :-)
Comment: Ah , happy coding ~


I have a moderate to high correlation and a p-value that is non-significant. Do I still reject the whole hypothesis?

Question: I have a correlation of 0.777 but only a p-value of 0.069 (not significant) on my Pearson's test. My sample size was of 54. Should my hypothesis still be rejected even if there is a correlation? Is the non-significant p-value due to sample size?
What can I say about the hypothesis in this case?
Comment: @broccolops in statistics, this is what we call a "game changer".
Comment: I think something's wrong with the p-value calculation.  For a sample size of 50 an *r* of 0.27 should be a *p*-value of about 0.05.
Comment: I apologise, I have made a mistake in my question. My sample size was of 6.
Comment: Then, yes, with a sample size of 6, I think you would need an *r* of, say, 0.82 to get a *p*-value less than 0.05.
Comment: It sounds like you might like to read the answers at https://stats.stackexchange.com/questions/31 concerning what p-values mean and how to interpret them.
Comment: See, [real-statistics.com/statistics-tables/pearsons-correlation-table/](https://real-statistics.com/statistics-tables/pearsons-correlation-table/). Just approximately, for df = 52, *r* = 0.77, I get *t* = 8.8, *p* = 8e-12.
Answer: I'm sure this question is covered elsewhere on this site.  But basically, for Pearson correlation, there is a relationship between sample size, the correlation coefficient, and the resultant p-value.
This relationship can be seen on tables like this one: real-statistics.com/statistics-tables/pearsons-correlation-table/, or can be found in many analysis of experiments textbooks.
For a given r value, the p-value becomes smaller as the sample size increases.  This is basically a feature of how we do hypothesis testing.
Practically speaking, getting a relatively large r value with a small sample size is suggestive.  Likely, there is a real correlation, but we have limited evidence against the possibility that this apparent correlation occurred simply by chance.  Likewise, a p-value less than 0.10 is suggestive, but certainly not dispositive.
Comment: +1. Worth considering is that, with such a lack of precision in the estimate, there is a real chance that the true correlation is *less than zero*, despite the empirical correlation of $0.777$.
Answer: When you do a significance test, you reject, or you fail to reject, the null hypothesis based on the p-value from the significance test.
Your p-value is not significant, therefore you fail to reject the null hypothesis. You have not found evidence that the null hypothesis is false.
You ask "Do I still reject the whole hypothesis?" No. You do not reject any hypotheses because of a non-significant test.


Proof that {$\frac{1}{b_n}$} is bounded and $\limsup\limits_{n\rightarrow\infty}$ $\frac{1}{b_n}$=$\frac{1}{\liminf\limits_{n\rightarrow\infty}b_n}$

Question: I need help/suggestions for improvements for a task, that I try to solve as a preparation for my exam.
Let {${b_n}$}$_{n\in\mathbb{N}}$ be a bounded sequence with $b_n \neq 0$ $\forall$ n $\in\mathbb{N}$ and ${\liminf\limits_{n\rightarrow\infty}b_n}$ >0. Show that the sequence {${\frac{1}{b_n}}$}$_{n\in\mathbb{N}}$ is bounded and $$\limsup\limits_{n\rightarrow\infty}\frac{1}{b_n}=\frac{1}{\liminf\limits_{n\rightarrow\infty}b_n}$$
a) Show that the sequence is $\frac{1}{b_n}$ is bounded: Well we know ${b_n}$ is bounded with L=${\liminf\limits_{n\rightarrow\infty}b_n}$ >0. So we have $$0<L<b_n<S={\limsup\limits_{n\rightarrow\infty}b_n}$$ Since $\frac{1}{b_n}\leq \frac{1}{L}$ and $\frac{1}{b_n}\geq \frac{1}{S}$. We get $$\frac{1}{S}\leq \frac{1}{b_n}\leq \frac{1}{L}$$ Thus {${\frac{1}{b_n}}$} is bounded.
Is this proof correct?
b)Let L= ${\liminf\limits_{n\rightarrow\infty}b_n}$ and M=$\limsup\limits_{n\rightarrow\infty}\frac{1}{b_n}$.
L= ${\liminf\limits_{n\rightarrow\infty}b_n}$ $\leftrightarrow$ $\forall \epsilon >0$ $\exists n\in \mathbb{N}$ with $b_n<L + \epsilon$ (dividing by L+$\epsilon$) $\rightarrow$ $\frac{1}{L+\epsilon}$<$\frac{1}{b_n}$. Since L + $\epsilon$ is fixed, we get$\frac{1}{L+\epsilon}$$\leq$M=$\limsup\limits_{n\rightarrow\infty}\frac{1}{b_n}$.
Doing exactly the same with M=$\limsup\limits_{n\rightarrow\infty}\frac{1}{b_n}$, we get L= ${\liminf\limits_{n\rightarrow\infty}b_n}$ $\leq$$\frac{1}{M-\epsilon}$.
We let $\epsilon \rightarrow$ 0 and get $M\geq \frac{1}{L}$ and $M\leq\frac{1}{L}$. Thus $$M=\limsup\limits_{n\rightarrow\infty}\frac{1}{b_n}= \frac{1}{L}= \frac{1}{{\liminf\limits_{n\rightarrow\infty}b_n}}$$
Is this proof correct? The problem with my approach. We know L=infX $\leftrightarrow$ $\forall \epsilon$>0 $\exists$ $x\in X$ with $x<L + \epsilon$. Are we allowed to replace infX with $\liminf\limits_{n\rightarrow\infty}$X ? Also, am I allowed to divide with $L + \epsilon$ ? L could be smaller than $\epsilon$. Maybe I should write straightaway, that we let $\epsilon \rightarrow 0$....
I am thankful for any advice.
Comment: Maybe stupid question, but isn't $b_n=1/n$ bounded and $\neq 0 \forall n\in\mathbb{N}$?
Comment: @Diger jep ${b_n}$ is bounded with b_n= \frac{1}{n}. However I don't believe that using this example as $b_n$ would be sufficient. But thats doesn't matter since I believe that a) is correct. I am really unsure with b though.
Answer: Just some minor points:
In a) you should write $\forall \epsilon>0,\epsilon<L$
$$0<\underbrace{\liminf_{n\rightarrow \infty}b_n}_{L>0}-\epsilon < b_n < \underbrace{\limsup\limits_{n\rightarrow\infty}b_n}_{S}+\epsilon$$
for almost all $n\in\mathbb{N}$, i.e. $\forall n\geq N$ for some $N\in\mathbb{N}$, because it could be possible that no $b_n$ satisfies $b_n \geq L$ or $b_n \leq S$ (see discussion below). Since $b_n>0$, it is clear that for the finitely many $b_n$ with $n<N$ you still have boundedness of $1/b_n$.
For b) I'm not quite sure what you do there. If you fix $n$ by saying $\exists n\in \mathbb{N}$, you can not take the limit (what limit for some fixed $n$?). I guess you need to work with subsequences here, i.e. there exists a subsequence $a_k\in\mathbb{N}$ s.t. $\forall k\in\mathbb{N}$ it follows $$b_{a_k} < L + \epsilon \\
\frac{1}{b_{a_k}} > \frac{1}{L+\epsilon} \,.$$
You will still find $b_n$ that violate this inequality, but these $b_n$ do not give any information about the $\limsup$ (since they are actually smaller) and so you can say $$\limsup_{n\rightarrow \infty} \frac{1}{b_{n}}=\limsup_{k\rightarrow \infty} \frac{1}{b_{a_k}}>\frac{1}{L+\epsilon} \,.$$
Similarly, we clearly know $b_n>L-\epsilon$ for all $n\geq N$ (this time) and so $$\frac{1}{b_n} < \frac{1}{L-\epsilon}\\
\limsup_{n\rightarrow \infty}\frac{1}{b_n} < \frac{1}{L-\epsilon}\,.$$ Since this is true $\forall \epsilon>0$, the result follows.
Comment: I just thought that if M= supX $\leftrightarrow$ $\forall \epsilon >0$ there exists a $x \in X$ with x>M-$\epsilon$ (the defintion of supremum) then we could do the same with M= lim sup X......

Also, are we allowed to divide with (L-$\epsilon$)? Could be 0 or smaller than 0...
Comment: $L>0$ maybe small, but we can always pick a smaller $\epsilon>0$ (that is what's relevant here). I'm still not sure I get what you are saying with this supX. If there is only 1 $x\in X$ for which $x>M-\epsilon$, then there is no point in taking the $\limsup$. You need infinitely many $x\in X$.
Comment: However, it is true that if $M=\sup X$, then there maybe only 1 $x\in X$ for which $x>M-\epsilon$. For $\limsup$ this is different, you need infinitely many. This is because if $\limsup$ exists, you must have a subsequence that converges to this $\limsup$. Recall the definition of $\limsup b_n$ as $\sup\{b_k | k\geq n\}$.
Comment: Yeah you are totally right. What I still don't understand is... why is $b_n \geq$ lim inf $b_n$ for some n.... I mean its the lowest limit of $b_n$, so it should be valid for all n?  I probably have a wrong image of the limes superior and the limes infimum...
Comment: $b_n \geq \liminf b_n$ for almost all $n$, not all. Think of the infimum of all $b_k$ for $k\geq n$ and then take the limit $n\rightarrow \infty$.
Comment: $\liminf -1/n$ is still $0$.
Comment: I am sorry but I don't understand what this task has to do with 1/n. There is no limes inferior for $b_n= \frac{1}{n}$. $\frac{1}{n}$ has an infimum.
Comment: Maybe this example is not good, but in any case $$\inf_{k\geq n} \frac{-1}{k} = -\frac{1}{n} \, , $$ then take the limit, which is $0$.
Comment: For this particular $b_n=\frac{-1}{n}$, you have that no $b_n$ satisfies $b_n \geq \liminf b_n$.
Comment: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/134406/discussion-between-analysis-mark-and-diger).


Area form of $M^2 \subseteq \Bbb R^4$: does $(-1)^{i+j-1}\det_{i'j'}(n,\nu) = dx^i \wedge dx^j$?

Question: This is a follow up question from this one. I'm asking separately since one way or another, that one is sort of answered. Now, we know that if $M^{n-1} \subseteq \Bbb R^n$, then the volume element $dM$ satisfies $$(-1)^{i-1}n_i\,dM = dx^1\wedge \cdots \wedge \widehat{dx^i}\wedge \cdots dx^n,$$where $(n_1,\cdots, n_n)$ is normal to $M$. For $M^2 \subseteq \Bbb R^4$ I got the expression $$dM = \sum_{1\leq i < j \leq 4} (-1)^{i+j-1}\begin{vmatrix} n_{i'} & n_{j'} \\ \nu_{i'} & \nu_{j'}\end{vmatrix}\,dx^i\wedge dx^j,$$where $i'<j'$ are the remaining indices (e.g., if $(i,j) = (1,2)$ then $(i',j') = (2,4)$, etc). I wanted a relation like the one I put above for hypersurfaces and I'm itching to say $$(-1)^{i+j-1}\begin{vmatrix} n_{i'} & n_{j'} \\ \nu_{i'} & \nu_{j'}\end{vmatrix}\,dM = dx^i\wedge dx^j, \quad \forall\,1\leq i < j \leq 4,$$where $n$ and $\nu$ are normal to $M$, following notation from my previous question. But I'm not sure that this is true, and I'm having trouble attacking this. I tried to mimic Spivak's proof of theorem $5.6$ in page $128$ of his Calculus on Manifolds, but I know it's hopeless to try and define a cross product for only two vectors in $\Bbb R^4$. Help?
Answer: HINT: Generalized Laplace expansion by cofactors. The way I like to think of it is this. Reduce to the case of an oriented orthonormal basis $v_1,\dots,v_n$ for $\Bbb R^n$ (in your case, some will be tangent to $M$ and the rest normal to $M$). Consider the Hodge star operator on both forms and multivectors. Then it boils down to
$$(dx^i\wedge dx^j)(v_1\wedge v_2) = \big({\star}(dx^i\wedge dx^j)\big)\big({\star}(v_1\wedge v_2)\big) = \big({\star}(dx^i\wedge dx^j)\big)\big(v_3\wedge\dots\wedge v_n\big).$$
Comment: That's why I switched to multivectors. It maps the basis normal $2$-multivector to the basis tangent $(n-2)$-multivector.
Comment: Hi Ted, thanks! I sort of showed that what I wanted was equivalent to $$\begin{vmatrix} n_i & n_j \\ \nu_i & \nu_j \end{vmatrix} \star(dM) = dx^i \wedge dx^j, $$ and I proved that above expression for **normal** vectors, while the expression in the body of the question was supposed to hold for **tangent** vectors. Is there a reason for that? I suspect that is related to your hint but I can't put my finger on it.
Comment: Yup, you just need to $\star$ everything :) It is (pretty much) what I said.
Comment: But why applying $\star$ changed tangent vectors to normal vectors?
Comment: Ah, that makes more sense. I'm not so used to thinking in multivectors, I guess. Thanks again!