How do I view the contents of a SELinux policy package

Question: As the title says, how do I view the contents of a SELinux policy package? The resulting files end with .pp. I'm running on centos 6, but I guess it's the same way on "all" distros.
For example
    cp /usr/share/selinux/targeted/cobbler.pp.bz2 ~
    bunzip2 cobbler.pp.bz2
    MAGIC_SELINUX_CMD cobbler.pp

Answer: A SELinux policy module is built by following steps:

generate a set of policy rules: audit2allow
compile: checkmodule
build: semodule_package

http://wiki.centos.org/HowTos/SELinux
Assuming that I have a postgreylocal.te file with belows content:
module postgreylocal 1.0;
require {
        type postfix_smtpd_t;
        type postfix_spool_t;
        type initrc_t;
        class sock_file write;
        class unix_stream_socket connectto;
}
#============= postfix_smtpd_t ==============
allow postfix_smtpd_t initrc_t:unix_stream_socket connectto;
allow postfix_smtpd_t postfix_spool_t:sock_file write;

postgreylocal.pp policy module will be created with:
# checkmodule -M -m -o postgreylocal.mod postgreylocal.te
# semodule_package -m postgreylocal.mod -o postgreylocal.pp

To unpack this policy module, you need a tool which is called semodule_unpackage to extract the .mod file and then use dismod to disassemble the binary module to textual representation.
On my Gentoo, the following packages need to be installed:
[I] sys-apps/policycoreutils
     Available versions:  [M]2.0.82 [M](~)2.0.82-r1 [M](~)2.0.85 [M](~)2.1.0 {M}(~)2.1.0-r1
     Installed versions:  2.1.0-r1(05:12:27 PM 10/14/2011)
     Homepage:            http://userspace.selinuxproject.org
     Description:         SELinux core utilities

[I] sys-apps/checkpolicy
     Available versions:  [M]2.0.21 [M](~)2.0.23 {M}(~)2.1.0 {debug}
     Installed versions:  2.1.0(01:27:53 PM 10/14/2011)(-debug)
     Homepage:            http://userspace.selinuxproject.org
     Description:         SELinux policy compiler

[I] sys-libs/libsepol
     Available versions:  [M]2.0.41!t [M](~)2.0.42!t {M}(~)2.1.0!t
     Installed versions:  2.1.0!t(01:25:43 PM 10/14/2011)
     Homepage:            http://userspace.selinuxproject.org
     Description:         SELinux binary policy representation library

Firstly, extract the module from .pp file:
# semodule_unpackage postgreylocal.pp postgreylocal.mod

and secondly, disassemble with dismod:
# cd checkpolicy-2.1.0/test/
# ls
dismod.c  dispol.c  Makefile
# make
cc -g -Wall -O2 -pipe -I/usr/include   -c -o dispol.o dispol.c
dispol.c: In function 'main':
dispol.c:438:8: warning: ignoring return value of 'fgets', declared with attribute warn_unused_result
dispol.c:465:9: warning: ignoring return value of 'fgets', declared with attribute warn_unused_result
dispol.c:476:9: warning: ignoring return value of 'fgets', declared with attribute warn_unused_result
dispol.c:500:9: warning: ignoring return value of 'fgets', declared with attribute warn_unused_result
cc   dispol.o  -lfl -lsepol -lselinux /usr/lib/libsepol.a -L/usr/lib -o dispol
cc -g -Wall -O2 -pipe -I/usr/include   -c -o dismod.o dismod.c
dismod.c: In function 'main':
dismod.c:913:8: warning: ignoring return value of 'fgets', declared with attribute warn_unused_result
dismod.c:982:9: warning: ignoring return value of 'fgets', declared with attribute warn_unused_result
dismod.c: In function 'link_module':
dismod.c:787:7: warning: ignoring return value of 'fgets', declared with attribute warn_unused_result
cc   dismod.o  -lfl -lsepol -lselinux /usr/lib/libsepol.a -L/usr/lib -o dismod
# ls
dismod  dismod.c  dismod.o  dispol  dispol.c  dispol.o  Makefile

./dismod postgreylocal.pp
Reading policy...
libsepol.policydb_index_others: security:  0 users, 1 roles, 3 types, 0 bools
libsepol.policydb_index_others: security: 0 sens, 0 cats
libsepol.policydb_index_others: security:  2 classes, 0 rules, 0 cond rules
libsepol.policydb_index_others: security:  0 users, 1 roles, 3 types, 0 bools
libsepol.policydb_index_others: security: 0 sens, 0 cats
libsepol.policydb_index_others: security:  2 classes, 0 rules, 0 cond rules
Binary policy module file loaded.
Module name: postgreylocal
Module version: 1.0

Select a command:
1)  display unconditional AVTAB
2)  display conditional AVTAB
3)  display users
4)  display bools
5)  display roles
6)  display types, attributes, and aliases
7)  display role transitions
8)  display role allows
9)  Display policycon
0)  Display initial SIDs

a)  Display avrule requirements
b)  Display avrule declarations
c)  Display policy capabilities
l)  Link in a module
u)  Display the unknown handling setting
F)  Display filename_trans rules

f)  set output file
m)  display menu
q)  quit

Command ('m' for menu):  1
unconditional avtab:
--- begin avrule block ---
decl 1:
  allow [postfix_smtpd_t] [initrc_t] : [unix_stream_socket] { connectto };
  allow [postfix_smtpd_t] [postfix_spool_t] : [sock_file] { write };

Command ('m' for menu):  a
avrule block requirements:
--- begin avrule block ---
decl 1:
commons: <empty>
classes: sock_file{  write } unix_stream_socket{  connectto }
roles  : <empty>
types  : postfix_smtpd_t postfix_spool_t initrc_t
users  : <empty>
bools  : <empty>
levels : <empty>
cats   : <empty>

Command ('m' for menu):

Comment: fyi, on Fedora (17) it is `sedismod`. It is already available along with `checkpolicy` and `semodule_unpack` with the default installation. Btw, via `semodule_unpackage foo.pp foo.mod foo.fc` you can also extract the filecontexts file.
Comment: The links in this post are 404.  Could you update them?  I need to install *semodule_unpackage* and *dismod* for my box. Thanks!
Comment: `dismod` can be found in the SELinux source code
Answer: Are you getting a problem like wrong magic number for module package:  expected 0xf97cff8f, got 0x39685a42?
.pp files are stored internally in bzip2 format, so you'll need to do bzip2 -cdk policyfile.pp > policyfile.pp.out
BEFORE
semodule_unpackage policyfile.pp.out policyfile.mod.
Comment: Compiled policy files are not compressed with BZip2 : `bzip2: policy.30 is not a bzip2 file.`
Comment: Installed policy files are compressed as bzip2, as `file` will attest. Even though the suffix is not changed ...


Joining to Test Domain

Question: I keep getting this error when trying to join a test workstation to a test domain. Any idea what this means? Google hasn't been very forthcoming.

The following error occurred attempting to join the domain "test.companyname.com"
Name Translation: Unable to resolve completely, only the domain was found
Answer: This looks like a DNS issue in resolving the actual domain controller. Is the DNS role installed on the test Active Directory Domain Controller(s) in your test environment? Are both the test workstation and the ADDC/DNS server using that ADDC/DNS server as its DNS server (itself, in the case of the ADDC)?
If you're actually using "test.companyname.com" as the domain, and you have not done the above, then you're going to get yourself into a ton of DNS delegation problems. It's probably trying to find the ADDC in companyname.com and only finding that the record exists, but that there's no AD there. This is why you don't use top-level domains in Active Directory. Here are Microsoft's best practices concerning naming domains.
Comment: Correct. I have the workstation pointing to the IP of the test DC/Exchange box server (which is a VM running Windows server 2008 R2 x64). The workstation is a laptop running XP pro. I have the dc pointing to itself for DNS.
Comment: Not sure if this makes a difference, but I renamed the domain name from "test.companyname.com" to "test.companyname"
Answer: Sounds like it has something to do with DNS (sorry if that is extremely obvious!)
Is DNS running and properly configured on the test domain?
What is the client OS and domain functionality level?
Are these running in a virtual environment or are they two physical machines?
I guess in summation, a lot more info about what you have tried and what your environment would be helpful.
Comment: Test domain controller/exchange 2007 box is a VM running Server 2008 R2 x64 Enterprise. Workstation is a laptop running Windows XP Pro. DNS is running, though I didn't make any special config changes beyond the defualt settings. Domain functionality is 2008 R2.
Comment: The domain is test.companyname, DC name is gnu.test.companyname.com
Comment: On the laptop, I've changed the DNS setting in the IP properties to the IP of the test DC.
Comment: domain name used to be called test.companyname.com but I changed it to test.companyname... not my idea ;o)

Joining to Test Domain


Why here template Vector3 cannot convert to Vector3?

Question: It seems quite weird. Here you can see the error message is that a convert happens between one type and it fails. If I remove the explicit modifier from Vector3's copy constructor it is fine, no error. Could someone explain why? I'm confused.
template<typename T>
class Vector3 {
public:
    explicit Vector3(const Vector3& v) :x(v.x), y(v.y), z(v.z) {}
    Vector3() :x(0), y(0), z(0) {}
    T x, y, z;
};
template<typename T>
Vector3<T> getVec3() {
    return Vector3<T>(); //c2440 "return":cannot convert Vector3<int> to Vector3<int>
}
int main()
{
    getVec3<int>();
}

Comment: Copy constructor should not be declared `explicit`.
Comment: It compiles using `/std:c++17` or later, fails with `/std:c++14`. https://godbolt.org/z/MPh9e6vz4
Comment: `getVec3` is performing [RVO](https://en.cppreference.com/w/cpp/language/copy_elision), where move ctor is *meant to be* called implicitly. But when you define a copy ctor yet lack a move ctor, you are suppressing the implicitly defined default move ctor. In your case, you should define neither, as your class does not hold any ownership. See [the rule of zero](https://en.cppreference.com/w/cpp/language/rule_of_three).
Answer: return Vector3<T>(); performs copy initialization, which won't consider explicit constructors: including the copy constructor. That's why you should mark the copy constructor non-explicit.

Copy-initialization is less permissive than direct-initialization: explicit constructors are not converting constructors and are not considered for copy-initialization.

BTW: Since C++17 your code would work fine because of mandatory copy elision, the copy (and move construction) will be omitted completely.
Comment: Thank you! It is clear to me now.


Access to XMLHttpRequest has been blocked by CORS policy - 401 (Unauthorized)

Question: I'm using ShipStation API to create order, but getting error Access to XMLHttpRequest has blocked,
The code provided below is generated on https://www.shipstation.com/developer-api/#/reference/orders/createupdate-order/create/update-order?console=1
so I'm using it on https://tampermonkey.net/ extension, the funcion is called on button click error screenshot

<code> (function () {
    'use strict';
    const $ = window.jQuery;
    $(document).ready(function () {

        const AUTHKEY = '112233'
        $("#send").on("click", sendRequest)

        const sendRequest = () => {
            var request = new XMLHttpRequest();

            request.open('POST', 'https://ssapi.shipstation.com/orders/createorder');

            request.setRequestHeader('Content-Type', 'application/json');
            request.setRequestHeader('Authorization', AUTHKEY);

            request.onreadystatechange = function () {
                if (this.readyState === 4) {
                    console.log('Status:', this.status);
                    console.log('Headers:', this.getAllResponseHeaders());
                    console.log('Body:', this.responseText);
                }
            };
            var body = { 'data is correct just deleted for now': '' };
            request.send(JSON.stringify(body));
        }
    });
})();
</code>
Comment: Is that endpoint meant to be consumed client side(ie through browser js) or server side? Some apis endpoints arent meant for client side as certain details need to be sent with the request like secret api keys which would be easily visible when used client side. If it is meant for client side check you are using the correct cors mode in the request per the error message
Comment: Hi, yes I'm providing API Key and Secret key in 'Authorization' and that's what I want to know how to provide correct cors mode in the request
Comment: You dont do that client side if you are needing to use a secret key. It means that you are meant to use that api on the server through whatever language you are using like curl with php
Answer: The API is not made for use in Clientside.
make a callto your own backend and send it from there.
Its very dangerous to publish your APIKEY


Show that $e^{-x}/(1-x) \leq e^{x^2}$ for some interval around $0$

Question: Show that  $e^{-x}/(1-x) \leq e^{x^2}$ for some interval around $0$.
What I've tried
My first attempt was to expand the LHS by applying a taylor expansion to both terms and then trying to bound the terms to get rid of one of the summations. I think this might work, but I am missing a trick on how to proceed.
My other thought is to choose two points on either side of $0$ such that the difference of the LHS and RHS is nonpositive at these points (by trial and error). Then I can show that if the difference is ever positive, then there must be some maximum in the interval. Taking the derivative to find all critical points in this interval and showing that they lead to a nonpositive result shows the claim. Unfortunately, the equation I get by setting the derivative to 0 involves some terms I do not know how to handle without the Lambert function.
I am looking for hints on how to proceed.
Comment: You need a parenthesis pair. Unclear whether $e^{-x}$ is part of the denominator or numerator on left.
Comment: @coffeemath it's supposed to be in the numerator, but I agree that the expression should be rewritten.
Comment: @AlannRosas How do you know it's part of the numerator?
Comment: @coffeemath used Desmos.
Comment: It's also kinda silly to put a term with a negative in the exponent in the denominator, but I agree that it's ambiguous.
Comment: Thanks everyone, I rewrote it. Turns out not everyone follows PEMDAS like they taught me in grade 3 :D
Answer: This rearranges to
$$\frac1{1-x}\leq e^{x+x^2}.$$
The right side is, using Taylor series,
$$1+(x+x^2)+\frac{(x+x^2)^2}2+O(x^3)=1+x+\frac32x^2+O(x^3),$$
while the left side is $1+x+x^2+O(x^3)$. Subtracting, the inequality becomes $\frac12x^2\geq O(x^3)$, which holds for small enough $x$.
Answer: Consider the function
$$f(x)=\frac{e^{x^2}}{\frac{e^{-x}}{1-x}}=e^{x^2+x}(1-x)$$
We can compute $f'(x)=e^{x^2+x}(x-2x^2)$ and $f''(x)=e^{x^2+x}(-4x^3-x+1)$ to see that $f'(0)=0$ and $f''(0)=1>0$. Thus, $f$ has a local minimum at $0$, so for some open interval $I$ containing $0$,
$$f(x)\geq f(0)=e^{0^2+0}(1-0)=1\text{ for all }x\in I$$
It follows that $\frac{e^{x^2}}{\frac{e^{-x}}{1-x}}\geq 1$ on $I$, that is,
$e^{x^2}\geq\frac{e^{-x}}{1-x}$.
Answer: Consider two cases based on the sign of $x$:
Suppose $x$ is positive:
The power series expansion of $e^x$ is $\sum_{i=0}^\infty \frac{x^i}{i!}$.  Therefore, the power series expansion of $e^{x^2}$ is $\sum_{i=0}^\infty\frac{x^{2i}}{i!}$.  Note that for any $n$,
$$
\sum_{i=0}^n \frac{x^{2i}}{i!}\leq e^{x^2}.
$$
The power series for $e^{-x}$ is $\sum_{i=0}^\infty \frac{(-x)^i}{i!}$, and it is alternating (for $x$ sufficiently close to $0$).  Therefore, whenever $m$ is even,
$$
\sum_{i=0}^{m}\frac{(-x)^i}{i!}\geq e^{-x}.
$$
Therefore, it is enough to find an $n$ and even $m$ so that
$$
\sum_{i=0}^{m}\frac{(-x)^i}{i!}\leq (1-x)\sum_{i=0}^n \frac{x^{2i}}{i!}.
$$
When $n=1$ and $m=2$, we have the inequality
$$
1-x+x^2/2\leq(1-x)(1+x^2)=1-x+x^2-x^3,
$$
which is equivalent to
$$
x^3\leq x^2/2,
$$
which is true when $0<x\leq 1/2$.
Suppose $x$ is negative:
The power series expansion for $\frac{1}{1-x}$ is $\sum_{i=0}^\infty x^i$ is alternating for $-1>x>0$.  Therefore, for any even $m$,
$$
\sum_{i=0}^m x^i\geq\frac{1}{1-x}.
$$
On the other hand, when $-1<x<0$, $x^2+x<0$, so the power series expansion for $e^{x^2+x}$ is $\sum_{i=0}^{\infty}\frac{(x^2+x)^i}{i!}$ is alternating.  Therefore, for any odd $n$,
$$
\sum_{i=0}^{\infty}\frac{(x^2+x)^i}{i!}\leq e^{x^2+x}.
$$
When $m=2$ and $n=1$, we have the inequality
$$
1+x+x^2\leq 1+x+x^2,
$$
which is true for all $x$.
Comment: I don't follow your argument that because all the powers are even the sum is positive; you've already said $x$ is positive so the sum is always positive isn't it?
Comment: Thanks, that comment was extraneous.  I had organized the answer differently before and needed that comment.
Answer: Hint :
As $f(x)=e^{x^2}$ is convex we have the inequality for $x\in(0,\varepsilon)$ with $\varepsilon>0$ sufficiently small
$$f'\left(0\right)x+f\left(0\right)+\frac{f''\left(0\right)}{2}x^2\leq f(x)$$
Where we have used strong convexity .
Now we have to show $x\in(0,\varepsilon)$ with $\varepsilon>0$ sufficiently small :
$$e^{-x}\leq \left(1-x\right)\left(f'\left(0\right)\left(x\right)+f\left(0\right)+\frac{f''\left(0\right)}{2}\left(x^{2}\right)\right)$$
Or :
$$e^{-x}\le (1-x)(1+x^2)$$
You can differentiate third times and come back to the inequality .
Ps: It's not particulary elegant but it works .
Edit : We don't need strong convexty we can use directly :
$$(1+x^2)\leq e^{x^2}$$
For $x>0$
Answer: Yet another approach:  Let
$$f(x) = \frac{e^{-x}}{1-x}\,;\qquad g(x)=e^{x^2}$$
then with a bit of computation, get the first and second derivatives as:
$$
f'(x) = \frac{x}{(1-x)^2} e^{-x}\,;\qquad
g'(x) = 2xe^{x^2}
$$
$$
f''(x) = \frac{1+x^2}{(1-x)^3}e^{-x} \,;\qquad
g''(x) = (4x^2+2)e^{x^2}
$$
Now observe that $f(0) = g(0)$ and $f'(0)=g'(0)$ and $f''(0) < g''(0)$ witch implies that $f(x) \leqslant g(x)$ for all $x$ in some neighborhood of 0.  So in the remainder let's show that theorem.  It's pretty intuitive, but I don't know if it has an estabished name.  Apply the theorem to the difference $h=g-f$.

Theorem: Let $h$ be a function in $C^2(\Bbb R)$ such that $h(0) = 0$, $h'(0) = 0$ and $h''(0) > 0$.  Then there is a neighborhood $U$ of 0 such that $h(x)\geqslant 0$ for all $x\in U$.$\def\e{\varepsilon}$

To show this, there is some neighborhood $U$ of 0 and $\e>0$ such that $h''(x) \geqslant \e$ for all $x\in U$.  This is because $h''$ is continuous and $h''(0)> 0$. Integrating from 0 to $x\in U$ yields:
$$\e x = \int_0^x \!\!\e\,dt \leqslant \int_0^x h''(t)\, dt \stackrel{(1)}= h'(x) \tag3$$
for all $x\in U$, where equality $(1)$ holds because $h'(0)=0$. Integrating from $0$ to $x\in U$ again:
$$0\leqslant \frac12 \e x^2 = \int_0^x \!\!\e t\,dt \stackrel{(3)}\leqslant \int_0^x h'(t)\, dt \stackrel{(2)}= h(x)\tag 4$$
for all $x\in U$, where equality $(2)$ holds because $h(0)=0$. This concludes the proof.  It allows for a result that's a bit stronger, namely that $h(x) > 0$ for all $x$ in a punctured neighborhood of 0.


Registering remote procedures with autobahn java

Question: The standard way of registering procedures in autobahn-java is:
CompletableFuture<Registration> order_to_produce = session.register(prefix + "order_to_produce", this::order_to_produce);
order_to_produce.thenAccept(registration -> LOGGER.info("Registered procedure: " + registration.procedure));

Since we have a lot of functions to register I was thinking to put registration names and functions to a HashMap but I am unable to reference any function with method reference.
I would like to make something like this:
    Map<String, Runnable> functions = new HashMap<>();
    functions.put("order_to_produce", this::order_to_produce);

    for (Map.Entry<String, Runnable> function : functions.entrySet())
    {
        CompletableFuture<Registration> registerProcedure = session.register(prefix + function.getKey(), function.getValue());
        registerProcedure.thenAccept(registration -> LOGGER.info("Registered procedure: " + registration.procedure));

        // or using reflection ?
        //
        CompletableFuture<Registration> registerProcedure = session.register(prefix + function.getKey(), obj.getClass().getMethod(function.getKey()));
        registerProcedure.thenAccept(registration -> LOGGER.info("Registered procedure: " + registration.procedure));
    }

Is there a way to do this ?
In python I could do that with ease on backend component.
functions = {'backend.add_service': self.add_service,
             'backend.online_services': self.services_online}

for functionToRegister in functions.keys():
    yield self.register(functions[functionToRegister], functionToRegister, options=self.REGISTER_OPTIONS)

Regards, Marko.
Answer: I'm still interested in original question but for now I made it so:
LinkedList<CompletableFuture<Registration>> functions = new LinkedList<>();
functions.add(session.register(prefix + "order_to_produce", this::order_to_produce));

for (CompletableFuture<Registration> function : functions) {
    function.thenAccept(registration -> LOGGER.info("Registered procedure: " + registration.procedure));
}


f from sorgenfrey line to R which is continuous

Question: Suppose $f:X \mapsto \mathbb{R}$, such that  $f(x)= \cases{ \frac{1}{x} & , x $\neq$ 0 \\
                       0 & , x=0 }$
where $X$ is the topological subspace $[0,1]$ of the Sorgenfrey line.
Show that $f$ is continuous.
I have to show that $f$ inverses intervals of the form $(a,b)$ which are basic open sets, to open sets in the Sorgenfrey line.
So I take cases $0<a<b$ and $f^{-1}((a,b))= (\frac{1}{b}, \frac{1}{a})=\cup_{n=1}^\infty (\frac{1}{b},\frac{1}{a}-\frac{1}{n}]$ which belongs to Sorgenfrey topology $a<b<0$ which gives the empty set and $a<0<b$  and $f^{-1}((a,b))=(\frac{1}{b},1] \cup \{0\}=(\frac{1}{b},1] \cup (\cup_{n=1}^{\infty} (-\frac{1}{n}, \frac{1}{n}])$ which also belongs to Sorgenfrey topology.
Is this approach correct?
Answer: If you look at it locally: $f$ is continuous at $x=0$ because $\{0\} =[0,1]\cap (-1,0]$ is an open set in $[0,1]$ and so in the local continuity definition or continuity at $x=p$:

For all open neighbourhoods $O$ of $f(p)$ there exists some neighbourhood $U$ of $p$ such that $f[U] \subseteq O$.

applied to $p=0$ we can just take $U = \{0\}$ for any $O$.
Then for $p>0$ we have that $f$ is already continuous as a map from standard reals to standard reals, and we can use that:
Suppose $O$ is an open neighbourhood of $f(p)$, then by standard continuity there is some relativised open interval $U=(p-\delta, p+\delta) \cap [0,1]$ such that $f[U] \subseteq O$ and this is already a valid neighbourhood for $p$ in $X$ as well. ($f$ is already continuous at $p$ in a smaller/coarser topology on the domain, or use $(p-\delta,p] \cap [0,1]$ if you want to use the basic open sets directly). So $f$ is continuous at all points (only $0$ is a special case) and so $f$ is continuous.
Answer: It is almost correct. The only problem is that the last equality is false. But$$\left(\frac1b,1\right]\cup\{0\}=\left(\left(\frac1b,1\right]\cup(-1,0]\right)\cap[0,1],$$which is an open set.
Comment: Did you notice that $X$ is the topological subspace $[0,1]$ of the Sorgenfrey line?
Comment: @dr_kelly I have edited my answer. Thank you.
Comment: Thanks for your help. However there is an extra question:
the sequence $x_n=\frac{1}{n} \in X$ converges to $0 \in X$ ?
Comment: @dr_kelly No, since $\{0\}$ is a neighborhood of $0$ (in $[0,1]$) which contains no term of the sequence.
Comment: Sorry, I do not completely understand this. Why $\{0\}$ is a neighborhood of $0$ (I understand that $0 \in \{0\}$)?
Comment: @dr_kelly Because $\{0\}=(-1,0]\cap[0,1]$ and therefore $\{0\}$ is an open subset of $[0,1]$.


Problema para gerar números inteiros no gráfico Chartist.JS

Question: Estou usando um plugin chamado chartist.js ele funciona bem o problema está sendo  os números laterais eu estou colocando de 1 a 5 o ideal seria ficar assim 1 2 3 4 5 porem ele está gerando assim 1, 1.5, 2, 2.5, 3, 3.5 e assim por diante eu não consigo deixar os números inteiros e fora que o gráfico fica gigante de atura segue meu código e uma screenchot de como deveria ficar e de como está ficando
HTML:

Informações gerais da O.S

                        build

7.516
Ordem de serviços abertas

Cerca de 7.250 clientes estão satisfeitos com os serviços prestados

CSS:
.ct-series-a .ct-line {
                stroke: $gray-medium;
                stroke-width: 4px;
              }

              .ct-series-b .ct-line {
                stroke: $blue-1;
                stroke-width: 4px;
              }

              .ct-series-b .ct-bar, .ct-series-b .ct-line, .ct-series-b .ct-point, .ct-series-b .ct-slice-donut{
                stroke: $blue-1;
              }

              .ct-series-b .ct-area, .ct-series-b .ct-slice-donut-solid, .ct-series-b .ct-slice-pie{
                fill: $blue-1;
              }

              .ct-label{
                fill: $gray-light;
                color: $gray-light;
              }

              .ct-grid {
                stroke: $gray-light;
                stroke-width: 1px;
                stroke-dasharray: 2px;
            }

JS:
 var chart = new Chartist.Line('.ct-chart-os', {
  labels: ['Seg', 'Ter', 'Qua', 'Qui', 'Sex', 'Sab', 'Dom'],
  series: [{
    name: 'series-1',
    data: [1, 3, 2, 4, 2, 5, 2]
  }, {
    name: 'series-2',
    data: [1, 2, 4, 3, 2, 4, 1]
  }]
}, {
  fullWidth: true,
  high: 5,
  onlyInteger: true,
  chartPadding: 30,
  low: 0,

  axisX: {
    showGrid: true,
    showLabel: true,
  },

  axisY: {
    showGrid: true,
    showLabel: true,
    offset: 0,
    onlyInteger: true,
    labelInterpolationFnc: function(value) {
      return (value / 1) + 'k';
    }
  },

  series: {
    'series-1': {
      lineSmooth: Chartist.Interpolation.simple(),
      showPoint: false,
      showArea: false
    },
    'series-2': {
      lineSmooth: Chartist.Interpolation.simple(),
      showPoint: true,
      showArea: false

    }
  },
  height: '300px'
}, [
]);

Está ficando assim apos inserir altura fixa:

e é assim que tem que ficar:

console
Answer: Cara segundo a documentação para controlar se é inteiro o não deveria usar o onlyInteger https://gionkunz.github.io/chartist-js/api-documentation.html
// Can be set to true or false. If set to true, the scale will be generated with whole numbers only.
onlyInteger: true,

Só que vc tem que usar no eixo que vc escolher X ou Y, e o mesmo vale para a linha se vc quer remover no X ou Y, no seu caso ficaria assim
  axisX: {
    showGrid: false //remove linhas do grid no eixo X
  },
  axisY: {
    onlyInteger: true //seta só números inteiros no Y
  }

O height vc pode controlar até pelo CSS usando por exemplo .ct-chart { height: 300px; } ou como fiz abaixo, dentro dos options

Segue o exemplo da imagem acima

new Chartist.Line('.ct-chart', {
  labels: [1, 2, 3, 4, 5, 6, 7, 8],
  series: [
    [1, 2, 3, 1, 5, 0, 1, 8],
  ]
}, {
  high: 8,
  low: 0,
  showArea: false,
  showLine: true,
  showPoint: false,
  onlyInteger: false,
  fullWidth: true,
  axisX: {
    showGrid: false
  },
  axisY: {
    onlyInteger: true,
  },
width: '300px', //largura se quiser...
  height: '200px' //altura se quiser
});

<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/chartist/0.11.3/chartist.min.css">

Comment: @FelipeHenrique reveja o código, execute novamente, acabei de editar o script, falando como controla o height. São as duas últimas propriedades alo, deixei o comment do lado. Acredito que vc não vai precisar mais desse offset...
Comment: @FelipeHenrique conferiu pelo DevTools se o gráfico ficou com 300px mesmo? Acho que o seu problema pode ser nesse lado http://prntscr.com/p4fh6m e não no lado do gráfico...
Comment: maravilha agora sabe porque o grafico fica gigante desse jeito da imagem ? se eu colocar um offset que e uma propriedade do proprio plugin resolve isso porem fica uma espaço vazio como se tivesse uma div vazia com tamanho fixo entende ?
Comment: @hugocls então eu editei a pergunta para você ver como ficou o resultado funcionou mas fica um espaço vazio  eu alterei o script e coloquei na pergunta para você ver como está ficando tem um print
Comment: @hudocls então isso é apenas um card eu fiz uma alteração no código para vc ver o html eu tbm coloquei um print do console mostrando que o grafico tem 300px mesmo
Comment: @FelipeHenrique só com o print não consigo te ajudar, coloca um height fixo no card-body  pra ver se ajuda. Tipo coloca height 320 no card


Why is implication $A\Rightarrow B$ defined as $(\neg A) \lor B$?

Question: I don't get the idea behind it. There are some things in the truth table which disturbs me. As if $A$ is false, the $A\Rightarrow B$ is always true. I read that implication was the negation of ($A \land (\neg B) $). Thus indicating that if $A$ is true and $B$ false, then the implication is false and that is all we care about, the other cases are just a consequence of the definition. Is this right?
Comment: Yes, the negation of (a ^ not b) is not a  or b. For the implication to hold, either a is false (and not a true) or a is true, requiring b to be true.
Comment: Think about it this way. When is $A\to B$ false? To put it in natural language and exemplifying, when will I have lied if I say that "If it rains, then I take an umbrella"? Do you really want to say that I lied when it doesn't rain?
Comment: see also the questions and answers linked here https://math.stackexchange.com/questions/3082747/doubt-on-implication-of-logical-reasoning
Answer: It is a matter of convenience. The idea is that $a\Rightarrow b$ is false  only when $a$ is true and $b$ is false. A false premise corresponds (in terms of sets) to the empty set. It is convenient to consider the empty set as a subset of any set, and it is convenient to identify properties (like $a$) with the subset of elements having the property. For example, it is true that "if $T$ is a right equilateral triangle, then $T$ is red" just because there is no triangle satisfying your hypothesis.
You could define the implication otherwise, but then this correspondence is lost and many simple propositions would have exceptions, etc.
Answer: The teach us think "if conditions hold" then "Are these statements true" but I find it better and more into intuitive to think if these statements are true, what is possible.
If $A \implies B$ what is possible?
Is $A$ possible? yes but only if $B$ is; If $A$ then $B$.
Is $A$ being false possible? Sure, $A\implies B$ doesn't say anything about what happens if $A$ is false.
Is $B$ possible?  Sure, if $A$ then $B$ must be true. And if not $A$ then anything is possible.
Is $B$ false possible? Well, not if $A$ is true it's not but if $A$ is false that's just fine.
What about $A$ and $B$ etc.  Well, $A$ and $B$ and $A$ and not $B$ and not $A$ and not $B$ are all possible but only $A$ and not $B$ are impossible.  That can't ever happen (if we accept $A \implies B$) so one way or another we are either going to not have $A$ or we will have $B$.
Now do the same for $\lnot A \lor B$.  You get the same results.  That two statements can only be true under the same conditions.


Drupal on custom page?

Question: I created a .php page outside of Drupal. On that page I want to check if a user is logged into my Drupal site.
Is that possible?
Comment: This is really an unsupported way of Drupal.
Answer: If the PHP file is in the same directory where cron.php, and index.php files from Drupal installation are, then you can use the following code.
/**
 * Root directory of Drupal installation.
 */
define('DRUPAL_ROOT', getcwd());
include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

if (user_is_logged_in()) {
  //...
}

If the PHP file is in another directory, then you should use the following code.
/**
 * Root directory of Drupal installation.
 */
define('DRUPAL_ROOT', 'the directory containing the includes directory from Drupal');
include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

if (user_is_logged_in()) {
  //...
}

Answer: Then you need to include these lines at top of your file
define('DRUPAL_ROOT', getcwd());

include_once DRUPAL_ROOT . '/includes/bootstrap.inc';
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);

Then use the following code to check if the user is logged in or not,
global $user;
if ($user->uid) {
// User is logged in
}

For anonymous user uid will be 0.

Drupal on custom page?


If $X$ is one of several variables that sum to $Y$, is the $R^2$ between $X$ and $Y$ a useful value?

Question: One assumption for regression analysis is that $X$ and $Y$ are not intertwined. However when I think about it It seems to me that it makes sense.
Here is an example. If we have a test with 3 sections (A B and C). The overall test score is equal to the sum of individual scores for the 3 sections. Now it makes sense to say that $X$ can be score in section A and $Y$ the overall test score. Then the linear regression can answer this question: what is the variability in overall test score that is attributable to section A? Here, several scenarios are possible:

Section A is the hardest of the 3 sections and students always score lowest on it. In such a case, intuitively $R^2$ would be low. Because most of the overall test score would be determined by B and C.
Section A was very easy for students. In this case also the correlation would not be high. Because students always score 100% of this section and therefore this section tells us nothing about the overall test score.
Section A has intermmediate difficulty. In this case the correlation would be stronger (but this also depends on the other scores (B and C).

Another example is this: we analyze the total content of a trace element in urine. And we analyze independently the individual species (chemical forms) of that trace element in urine. There can be many chemical forms. And if our analyses are correct, the sum of chemical forms should give us the same as the total content of an element (analyzed by a different technique). However, it makes sense to ask whether one chemical form is correlated with the total element content in urine, as this total content is an indicator of the total intake from food of that element. Then, if we say that $X$ is the total element in urine and $Y$ is chemical form A in urine then by studying the correlation we can explore whether this chemical form is the major one that contributes to the overall variablity or not.
it seems to me that it makes sense sometimes even when $X$ and $Y$ are not independent and that this can in some cases help answer scientific questions.
Would you think $R^2$ can be useful or meaningful in the examples above ? If we consider the test score example above, I would already say there would be about 33% contribution of each section had the difficulty been exactly the same for the students. But in practice this is not necessarily true. So I was thinking maybe using regression analysis can help us know the true variability attributed to each section of an exam. So it seems to me that $R^2$ would be meaningful even though we already know the null hypothesis is not true.
Are there alternative modified regression methods to account for such situations and provide us with meaningful parameters?
Comment: I don't agree with this statement: "1- section A is the hardest of the 3 sections and students always score lowest on it. In such a case, intuitively R squared would be low."  If section A is the hardest then there will be more inconsistencies of answers leading to increased variability as a result, R-squared, which measures the proportion of variability explained by section A would be larger.
Comment: Thanks for your comment. My thinking was that section A is hard to the extent that all students are scoring very low (and close to zero on a 0-100 scale) on this section. Then variability in the score of this section does not contribute significantly to the overall test score (for example it doesnt matter if it is 15 or 20 or 10%). The overall test score (and its variability) will be determined by the other more variable test scores that play the bigger part of the overall score.
Comment: Why are you expecting $Y$ and $X$ to be independent in a regression analysis? One is the mean value of the other (at least if we omit other predictors). Also, I don't understand your first sentence, what assumption is that? A regression should involve some kind of intertwining.
Answer: You might want to consider an approach outside of the traditional regression approach. This is comparable to the types of problems that psychometrics is designed to resolve (well, actually your first example is precisely that, since it is a test).
In Classical Test Theory, one of the most common metrics is the item-total score correlation, which is essentially the correlation between the item score and the total score. It tells you the item's discrimination - it's ability to discriminate between high and low scoring respondents. This is comparable to explaining the variance, like what you are asking about above with $R^2$. There are two ways to calculate this score, either by using the total test score including the item of interest, or excluding it. When you have a lot of items, these two methods are almost the same, but when you have few items, then they can make a big difference.
Another approach from Item Response Theory (IRT) is to estimate, either via a 2-parameter item response model or via a confirmatory factor analysis (which statistically are the same, but interpretation-wise are different). A 2-parameter model includes a parameter for the item difficulty (the relative difficulty of the item) and one for item discrimination, which is interpreted very similar to the item-total score correlation. High discrimination=the item differentiates between high and low scorers well. If you use confirmatory factor analysis (CFA), you have item loadings, which are essentially your discrimination parameters. They tell you how much of the total score is driven by a particular item.
Using IRT or CFA assumes you have a latent score, not an observed score, that you are trying to estimate. In the examples you give above, you are concerned with an observed score, that isn't latent. So these models wouldn't be what you are after, since they are probabilistic and you kind of have a tautological relationship (your total is by definition made up of the parts, with no error). But I point them out as examples of ways statistics gets at similar answers.
Last thing I want to point out, and this is probably something others would argue with, but while an assumption is that regressors are independent, when we have a categorical variable, and we enter dummies into the model, those dummy variables are, by definition, correlated. So this would seemingly violate assumptions of independence and bring in multicollinearity. If you think of it this way, it would make sense to run your regression of say the elements in urine, and exclude one, the coefficients would be valid just as if it was a single categorical variable. In that sense, you are getting a comparable number to the item-total correlation from Classical Test Theory I pointed out above.
Answer: A quick mathematial way of looking at it is to expand out the formulas. Let $Z=X+Y+W$.
$$ R^2 =\left(\frac{Cov(X,Z)}{\sigma_X \sigma_Z}\right)^2 =\left(\frac{Var(X)+Cov(X,Y)+Cov(X,W)}{\sigma_X \sigma_Z}\right)^2 $$
So in a nutshell You're going to get the variance of $X$ plus its relationship with your other two variables, divided by a scaling factor. The scaling factor itself could be expanded, but the numerator is telling the story. In general, things that will affect that number are a) the relative scale of X compared to Y and W, b) the relative variance of X, c) X's "contribution" to the variance of Y and W.
As for whether that's useful or not, that kind of depends on what you're after. It's probably best to think of it as a "percentage of total  variation" or something like that, even though the same for Y and W may not all sum to 1 (or maybe it does...not sure).
Answer: If X is one of several variables that sum to define Y, then clearly the assumptions of linear regression are broken. The P values won't be useful. The slopes and their confidence intervals can't be interpreted in the usual way. But is $R^2$ still useful? I suppose it is as a descriptive statistics. If you have three $R^2$ values quantifying correlation between Y and each of its three components, I suppose you'd learn something interesting by seeing the relative values of $R^2$.
Comment: Thank you for your comment. That was exactly my feeling. That R2 values and a comparison between them might provide us with useful information.
Answer:
One assumption for regression analysis is that $X$ and $Y$ are not intertwined.

This is incorrect. One assumption for regression analysis is that the ERRORS are uncorrelated. See the wikipedia entry for the Gauss-Markov theorem.

If $X$ is one of several variables that sum to $Y$, is the $R^2$ between $X$ and $Y$ a useful value?

About the only use I can think of for the $R^2$ between $X$ and $Y$ is to show how much better your model performs when you include other predictors. There's other values that would be much informative. The values of the estimated coefficients and their standard errors in particular.


If Else in where clause

Question: Here is a snippet of what I have:
select something from myTable
where curentFlag = 'Y'
and
case when @Year2 is not NULL then
 AYEAR >= @Year AND AYEAR <= @Year2
else
 AYEAR= isnull(@Year ,AYEAR)
end
        ADATE = ISNULL(@Date, ADATE)

But this yields:

Incorrect syntax near '>'.
  Incorrect syntax near 'ADATE'.

The user should be able to search by a year (equals to) or a year range. So I'm either passing in just @YEAR or both @YEAR and @YEAR2. So let's say my data set:
DECLARE @y TABLE(AYEAR INT);
INSERT @y VALUES(2008),(2010),(2010);

Now I have these variables:
DECLARE @YEAR INT, @YEAR2 INT;

If I pass in @YEAR = 2008 I should get 1 result.
If I pass in @YEAR = 2010 I should get 2 results.
If I pass in @YEAR = 2008 and @YEAR2 = 2010 I should get all 3 results.
Comment: You need to post more of your code (the part before `WHERE`) so we can get some context. The syntax you posted is nowhere near correct, but it's difficult to tell you how to fix it without more info.
Comment: here is the [case on msdn](http://msdn.microsoft.com/en-us/library/ms181765.aspx).
Comment: Did you mean `@YEAR2=2010`? And what if `@YEAR` is null and so is `@YEAR2`? What if only `@YEAR2` has a value?
Comment: this wont' happen because of my .net checks on the form. it will either be only year, or both year and year2.
Answer: CASE is an expression that returns a single value. It cannot be used for control of flow logic.
If you are sure that @Year will always be populated and @Year2 will only sometimes be populated, than this much simpler logic should work:
WHERE CURRENTFLAG = 'Y'
AND AYEAR BETWEEN @Year AND COALESCE(@Year2, @Year)
AND ADATE = COALESCE(@Date, ADATE);

You can try it with a very simple example:
DECLARE @y TABLE(AYEAR INT);
INSERT @y VALUES(2008),(2010),(2010);

DECLARE @YEAR INT = 2008, @YEAR2 INT = 2010;
--DECLARE @YEAR INT = 2008, @YEAR2 INT = NULL;
--DECLARE @YEAR INT = 2010, @YEAR2 INT = NULL;

SELECT AYEAR FROM @y
  WHERE AYEAR BETWEEN @YEAR AND COALESCE(@YEAR2, @YEAR);

Comment: just tried it, does nto work, it gives me everything even if i only pass in Year and null for  Year2. i only want to display resutls for @year if that's the only one passed in, and a range if both are passed in.
Comment: @Tanya then please post some sample data and desired results so we don't have to guess what you're after based on incorrect syntax. Also, what if neither are passed in?
Comment: @Tanya uh, I took that from your question: `ADATE = ISNULL(@Date, ADATE)`
Answer:  where CURRENTFLAG = 'Y'
    case when @Year2 is not NULL then  --after THEN should be statement or BEGIN block not AND
 and AYEAR >= @Year AND AYEAR <= @Year2
    else
     AND  AYEAR= isnull(@Year ,AYEAR)   -- here also
    end
        and    ADATE = ISNULL(@Date, ADATE)

Comment: No, `CASE` is not a control of flow statement in T-SQL, it is an *expression*. THere is no `BEGIN` after `THEN`. You are thinking of `IF` or perhaps how `CASE` works in other languages like VBScript.

If Else in where clause


Como desativar Ctrl + V do contextmenu?

Question: No textbox não pode de jeito nenhum colar, o código a seguir funciona certo:
private void Textbox_PreviewExecuted(object sender, ExecutedRoutedEventArgs e)
{
    if (e.Command == ApplicationCommands.Paste)
    {
        e.Handled = true;
    }
}

O problema está mostrando no contextmenu ao clicar no mouse direito:

Como desativar Ctrl+V ?
Comment: @RovannLinhalis veja a minha resposta !
Comment: vê se ajuda: https://stackoverflow.com/q/9632/4713574
Answer: Código a seguir oculta "Ctrl+ V":
<TextBox>
    <TextBox.ContextMenu>
        <ContextMenu>
            <MenuItem Command="ApplicationCommands.Copy" />
            <MenuItem Command="ApplicationCommands.Cut" />
        </ContextMenu>
    </TextBox.ContextMenu>
</TextBox>

Resultado:

Outro código a seguir, desabilita "Ctrl+V":
<TextBox>
    <TextBox.ContextMenu>
        <ContextMenu>
            <MenuItem Command="ApplicationCommands.Copy" />
            <MenuItem Command="ApplicationCommands.Cut" />
            <MenuItem Command="ApplicationCommands.Paste" IsEnabled="False" />
        </ContextMenu>
    </TextBox.ContextMenu>
</TextBox>

Resultado:

Como desativar Ctrl + V do contextmenu?


What parts go under source code version control?

Question: I am wondering what the best practices are for putting Drupal code under version control. I'll be mostly using core and standard Drupal modules. I'll be developing a custom theme, and one or two custom modules.
As far as I see it, I have 3 options:

Put the entire Drupal folder under version control. Developers can directly check out the folder in the Apache htdocs folder and go from there.
Check in only my custom code (modules + themes). Developers checkout the code in the appropriate folders.
Set up something like Docker.
Comment: Docker has nothing to do with it. Some people even version their stack, some don't. Look at the Drupal Composer project or Acquia BLT for great examples of tight VCS.
Answer: There are different ways to approach this, depending on what you need. The easiest approach is the one you described in #1 (Put the entire Drupal folder under version control).
That allows you to easily checkout the full working copy of the codebase with just Git. The downside is that you are storing a lot of code in your Git repo which already exists in other Git repos (ie: Drupal core, contrib modules, etc).
With Drupal 8, the community is generally moving towards using Composer for managing dependencies and building the Drupal codebase. Then, you only need a composer.json file (which points to specific versions of Drupal core and contrib projects), and your custom code in the Git repository. More information: https://www.drupal.org/docs/develop/using-composer/using-composer-with-drupal
Another option is to create an installation profile, and use Drush Make. This method is deprecated in favor of Composer in Drupal 8, but still works nicely for Drupal 7 projects. This is better suited to common code/configuration that you might use to set up lots of similar sites, rather than one highly-customized and specific site.
Regarding Docker - that's sort of a separate decision. You'll still need to choose one of the above options, and then build the codebase accordingly inside the Docker container (or mount it in a volume).
Answer: You should build with Composer as it is the recommended approach. Even Drush recommends installing Drush via composer, on a per-project basis. drupal-composer is a good starter which pretty much sets up an ideal Drupal setup. Drupal and all your modules are defined as Composer dependencies.
What you check in depends more on your workflow than anything else.

If you deploy to services like Acquia, Pantheon, OpenShift or some other PaaS where your repo is your web root or has limited deploy scripting, then you have no choice but to check in everything. It's pretty straight-forward, but also the least flexible.
If you run a build server, then drupal-composer's default setup is ideal for this. You only check in your code (modules, themes, libs). On each commit, have the build server pull in dependencies, process code, package artifacts, and send them off.
This setup is great if your workflow involves one or more of the following:

You're doing CSS/JS pre-processing (i.e. SCSS, ES modules). You commit the manifest (i.e. package.json, bower.json) and the raw files and the server does the building for you.
You're dealing with custom environments (i.e. AWS) that need special deployment procedures.
Your environments are containers spawned from images from a registry (i.e. Docker Hub). Build server builds the images for you.

Docker has nothing to do with how you commit code. However...
If you're simply building themes/modules and your repo setup is like the project repos found in Drupal.org (where the module/theme is the only thing in the repo), you could use the official Drupal Docker image for development. Simply run a container, mount the project directory as a directory in modules/themes, enable the module/theme, and start writing code. No Drupal core code will exist on the host nor the repo, only your module/theme.


Analysis of the Benjamini-Hochberg adjusted p-values

Question: I have:
Condition #1 : 5 independent objects (1 object = a time series)
Condition #2 : 5 independent objects
My GOAL: test H0 that using condition #1 gives different results from using condition #2
I have a pairwise test statistics to test if one pair of objects are different. In total, I can calculate 5! pairwise comparisons => 120 p-values
Now I use Benjamini-Hochberg procedure to calculate adjusted p-values in R:
<code> p.adjust(pvalues, method="BH")
</code>
(I can use Benjamini and Yekutieli instead for dependence, but lets skip this for now)
As far as I understand, this gives me a set of q-values, that is

"the adjusted p-value of an individual hypothesis is the lowest level
  of FDR for which the hypothesis is first included in the set of
  rejected hypotheses." (Reiner et.al, Bioinformatics, 2003).

Now I have 120 adjusted p.values, and I reject the null for all cases when p < 0.05. This would control the false discovery rate at 5%.
Can I say that "condition #1 gives different results from using condition #2" if number of rejected nulls is more than 120*5% = 6? In other words, since I expect 5% of false positives, can I say that the results are significant if I see more than 5% positives?
Comment: Actually, not. It would be "approximately" true if you would use FWER methods such as Bonferroni correction (you can have more than 5 FP results with low p-values just by chance). Now you use FDR, and it controls proportion of false positives, so it is more difficult to say if your results are significant or not. For real significance estimation is always better to have some prior knowledge of expected effect size.
Answer: Firstly we are going to formalize the hypotheses that you are testing
$$H_0 = \{ \text{using condition #1 gives the same results as using condition #2} \}$$
versus
$$H_1 = \{ \text{using condition #1 gives different results than using condition #2} \}$$
(I corrected your $H_0$, I think you want to formulate it like this)
Then you can formulate your hypothesis in terms of smaller hypothesis
$$H_0 = \cap_{i,j \in \{1,2,3,4,5\}} \{ \text{time series $i$ from condition 1 and time series $j$}$$
$$\quad \quad \quad \quad \text{ from condition 2 are comparable}\}$$
Is that correct?
Further, in this formulation there are only 5*5=25 smaller hypotheses to test, not 120...
With respect to our question,I would say no because significance implies that you are controling the probability for an type 1 error. Instead you are controling the FDR which is another concept.


Show that all complex numbers $z \not= -1$ can be written as $z=\frac{1+it}{1-it}$

Question: Show that for all complex number $z \not= -1$, with $|z| = 1$, can be written as $z=\frac{1+it}{1-it}$, with $t \in \mathbb{R}$.
I think this structure seems to be a stereographic projection from the unit circle in the complex plane. This observation is clear when we regard this equation : $\frac{1+it}{1-it}= \frac{1-t ^2}{1+t^2} + i \frac{2t}{1+t^2}$.
Instead of this solution, could we use the fact that $\frac{1+i \tan \alpha}{1-i \tan \alpha} = (1-\tan \alpha) + i 2 \tan \alpha$ for $\alpha \in (\frac{-\pi}{2}, \frac{\pi}{2})$?
BTW, this website has the same initial problem, but not the same final question
Comment: This was asked at least 4 times here.
Answer: If $z = \frac{1+it}{1-it}$ then $z -itz = 1 +it$. Simplify to obtain $$t= \frac{z-1}{i+iz}.$$ Now I suggest to show that, if $|z|=1$ then $\frac{z-1}{i+iz}$ is real.
Comment: So I have to show that $t = \bar{t}$, except for the case $z=1$?
Comment: Yes ! (But that's also obviously true for $z=1$.)
Comment: I know, I mean $z=-1$, of course
Comment: Yep, your argumentation is good, thank you!
Answer: Taking a slightly different approach, since you're interested in an approach using $\tan$:
Division of complex numbers means, when regarding complex numbers as vectors, dividing lengths and subtracting angles: $\dfrac{r_0e^{\theta_0i}}{r_1e^{\theta_1i}} = \frac{r_0}{r_1}e^{(\theta_0-\theta_1)i}$.
You know that $|1+it|=|1-it|$, so $|\frac{1+it}{1-it}| = 1$ for all $t$.
You also know that any angle $\theta$ in the range $(-\frac{1}{2}\pi, \frac{1}{2}\pi)$ can be represented by $1+i\tan\theta$, with the negated angle $-\theta$ representable by $1+i\tan-\theta=1-i\tan\theta$. It should be easy to prove from this that $\frac{1+it}{1-it}$ can represent any angle in the range $(-\pi,\pi)$.
Combine these two and you have what you're after.
Answer: For all bijection $f$ of $\mathbb C$ you can do $$z=f(t)$$ In particular $f(t)=\frac{1+it}{1-it}$ is a bijection whose inverse is $f^{-1}(z)=\frac{-iz+i}{z+1}$ and it is not the only homography you can use to the same purpose, of course.


Has the hash password function changed in magento? If so, to what?

Question: I am using magento version 220.127.116.11.
For switching to magento purposes I need to create a login function for customers outside the magento framework.
I have looked up the method magento uses to hash and validate passwords, but the method doesn't seem to work anymore.
Below the code I use to validate a user login outside magento. This code is just to try proof of concept and is not being used in a live environment for obvious reasons :).
function checkPassword($entity,$passwordInput){
    $query = mysql_query("SELECT value FROM customer_entity_varchar WHERE entity_id = '$entity' AND attribute_id = '12' LIMIT 1");
    $fetch = mysql_fetch_object($query);
    $fetch_data = explode(':',$fetch->value);
    $hashed_password = $fetch_data['0'];
    $salt = $fetch_data['1'];

    $hashInput = md5($passwordInput . $salt);
    if($hashInput == $hashed_password){
        return 'Success';
    }
    else{
        return 'Failure';
    }
}

$entity is the entity_id passed after email validation,
$passwordInput is the password entered in the login form.
It returns Failure. Which I'm not surprised about because when I return $hashInput and compare it with $hashed_password it's not the same.
Has the way Magento hashes passwords been changed? Or is there a mistake in my code?
Comment: Have you solved that issue? If so, can you send solution?
Comment: Yes, it has been a while back but the above code does actually work (only for customers). I made a stupid mistake and wrong data was being posted ($passwordInput wasn't right) Therefore it obviously returned Failure. Don't use this code in live environment though.
Answer: If you check in \app\code\core\Mage\Customer\Model\Customer.php you can find something like this (near line 430) :
/**
 * Encrypt password
 *
 * @param   string $password
 * @return  string
 */
public function encryptPassword($password)
{
    return Mage::helper('core')->encrypt($password);
}

The helper('core') is \app\code\core\Mage\Core\Helper\Data.php
In \app\code\core\Mage\Core\Helper\Data.php, you find :
/**
 * Encrypt data using application key
 *
 * @param   string $data
 * @return  string
 */
public function encrypt($data)
{
    if (!Mage::isInstalled()) {
        return $data;
    }
    return $this->getEncryptor()->encrypt($data);
}

and getEncryptor() function is :
/**
 * @return Mage_Core_Model_Encryption
 */
public function getEncryptor()
{
    if ($this->_encryptor === null) {
        $encryptionModel = (string)Mage::getConfig()->getNode(self::XML_PATH_ENCRYPTION_MODEL);
        if ($encryptionModel) {
            $this->_encryptor = new $encryptionModel;
        } else {
            $this->_encryptor = Mage::getModel('core/encryption');
        }

        $this->_encryptor->setHelper($this);
    }
    return $this->_encryptor;
}

$this->_encryptor is in \app\code\core\Mage\Core\Model\Encryption.php and in this file you can find :
/**
 * Encrypt a string
 *
 * @param string $data
 * @return string
 */
public function encrypt($data)
{
    return base64_encode($this->_getCrypt()->encrypt((string)$data));
}

and
/**
 * Instantiate crypt model
 *
 * @param string $key
 * @return Varien_Crypt_Mcrypt
 */
protected function _getCrypt($key = null)
{
    if (!$this->_crypt) {
        if (null === $key) {
            $key = (string)Mage::getConfig()->getNode('global/crypt/key');
        }
        $this->_crypt = Varien_Crypt::factory()->init($key);
    }
    return $this->_crypt;
}

(string)Mage::getConfig()->getNode('global/crypt/key'); is in /app/etc/local.xml file.
Your variable $hashed_password pass by this last method.
Your variable $hashInput also pass there ?

So, you can change in your checkPassword() function :
$hashInput = md5($passwordInput . $salt);

to
$hashInput = encryptPassword($passwordInput);

Thereby, $hashInput and $hashed_password will follow the same way.
Comment: And if you try this : `$hashInput = md5($salt . $passwordInput);` // see:Mage_Core_Model_Encryption at line 74
Comment: Better late than never, thanks for your help. The end result was a stupid mistake on my side, wrong data was being posted and therefore it returned Failure. Thank you for giving me more insights on magento code though!
Comment: My function needs to operate outside the magento framework. So it needs to function without the use of any magento classes/functions.


Is it reasonable to ask SE for help walking through econ papers?

Question: I was going to ask "What are good general ways to ask for help understanding econ papers?" in main Econ SE but the editor suggested it was a subjective question likely to be closed, so I'll ask this in meta instead.
I'm a PhD student in another field with some basic micro understanding (I passed a grad-level micro course, at least, so I can do some of the math after it's explained to me) but in reading papers relevant to my research I often get lost in the math. The proverbial "second pair of eyes" would be helpful.
It's probably often just one sentence or one insight that's hanging me up, but I really need someone willing to read through the paper enough to understand the road block. I can even envision a repository of notes for major papers.
If SE isn't a good place to ask for this sort of help, are there other sources of help? I've even thought of hiring a tutor through my university's econ department.
Answer: I think it would be ok as long as the question is specific and is reasonably self-contained. Here is a question that I asked earlier that you might use as an example:
Derivation on p.99 of Salanie, The Economics of Taxation (2nd edition)
Answer: Walking through papers? No. Try chat for that. Chat is asynchronous, so if you want to post something there, don't wait for a bunch of people to arrive, just post it, and people will pick it up and reply as they see it.
As jmbejara says, the main site is for asking specific, self-contained answerable questions, for which a single answer of a 1-5 paragraphs could be definitively identified as the right answer.
Comment: I probably didn't make what I'm proposing clear enough, so I can't tell if your suggestion applies to what I'm proposing or to something else.

Suppose I'm interested in this paper:
Comment: Well, the specific paper doesn't matter. But suppose there's one point in the model I don't understand. So I'm not looking for hand-holding throughout the entire paper, but rather for help getting myself unstuck on one point. I believe one answer could be definitively identified--after all, the author used that particular phrasing to mean something concrete, and the reviewers didn't complain about it, so in theory (if not always in practice!) it should have one meaning to trained economists.
Comment: Note also that if 50 people all asked about different parts of some famous paper, and each person tagged the question appropriately, we'd end up with a nice little reader's guide to that paper!


real multiply effect with svg?

Question: I was wondering if there was a way to apply a real multiply effect on a svg element ? I tried various solution found here but it seems like the multiply effect in svg is applyied on the object itself not on the elements behind like photoshop does. Is there a way to do it in svg or with any other method ?
Here is the code : http://jsfiddle.net/pool4/H7GLE/
<code>    <div id="bg">
    <svg id="logo" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 100 55.7" xml:space="preserve">
        <filter id="multiply">
            <feBlend mode="multiply"/>
        </filter>
        <g>...
    </svg>
    </div>

#logo:hover {
        filter:url(#multiply);
}
</code>
Comment: Could you clarify what you mean by "multiply"?
Comment: Nope. CSS can't handle that AFAIK. JS might be able to though...
Comment: @Paulie_D Sure, I mean getting the shade of the element and applying them to the elements behind. My example with multiply applied on the #logo http://imageshack.com/a/img691/4503/5cwm.jpg as you can see, you can see the wall relief through it since only the shade applied on the wall.
Comment: Google for feBlend tutorial and get this on the first page which shows you proper syntax: http://www.svgbasics.com/filters1.html
Comment: @Michael Mullany The problem is that this syntax assume that you want to mix 2 "images" not a svg vector and a image, Not even mentionning a background image... I had a look at that answer earlier as well but it didn't help as  doesn't seem to work inside a filter tag and that any "result" outside of the filter tag isn't read. i.e : http://jsfiddle.net/pool4/4QZ54/ http://jsfiddle.net/pool4/Lcux6/
Comment: For what it's worth, there is a part of the SVG spec that would [allow filters to grab the "background" behind the element being filtered](http://www.w3.org/TR/SVG11/filters.html#AccessingBackgroundImage), and use that as the second input image to the filter.  But none of the browsers even implement this for SVG content, let alone for SVG filters applied directly to HTML content.  As @ErikDahlstrom points out, Adobe has been pushing for blend modes in HTML, so that might happen sooner than background images in SVG filters.
Answer: It is not currently possible to multiply an SVG shape with a CSS-defined background (except for the very very new compositing and blending stuff which is only available behind a flag to the best of my knowledge.)
It is possible to get a multiply effect with SVG filters, but you have to follow SVG filter conventions as well as be aware of the subset of filter capabilities that are implemented in today's browsers. It can be challening to shoe-horn a properly sized filter effect into an existing SVG file that's combined with CSS because of unit system differences & quirks.
This is a version of your graphic done entirely within an SVG inline element that shows that it's possible to get a multiply effect but if it's all done within the SVG universe.
<code> <defs>
    <filter id="multiply">
       <feImage xlink:href="http://imageshack.com/a/img21/7676/y2hg.jpg" result="bg"/>
       <feBlend mode="multiply" in="SourceGraphic" in2="bg"/>
    </filter>
 </defs>
   <g filter="url(#multiply)"> etc.
</code>
FWIW: the interactions between CSS and SVG unit systems as well as filter units make this challenging to size correctly.
Comment: Fiddle link is broken
Answer: You will be able to do this with 'mix-blend-mode', when browsers implement the Compositing and Blending Level 1 specification.
<code>#logo:hover {
    mix-blend-mode: multiply;
}
</code>
See fiddle.
In Chrome Canary, enable the experimental web platform features flag (chrome://flags/#enable-experimental-web-platform-features), to see it working.
Comment: Very interesting, I hope it get released soon.$
Comment: as of june 2015 this is implemented in chrome, firefox, opera; partially in safari and not in IE. see http://caniuse.com/#search=mix-blend-mode
Answer: Ok so I found 2 different ways to do it thanks for Paulie_D.
1) Pixastic : http://www.pixastic.com/lib/
it's a javascript library allowing the use of blend mode. However it isn't compatible with IE however according to the doc IE has a way to it with some native filters.
2) In my case I just wanted to see the lines of my file, thus by using photoshop channels I made a alpha mosaic of the wall.
I dont really know which one is the more optimized option but I went for the second option as it made my background lighter due to the mosaic (arround 40kb vs 200kb before).
Thanks a lot to Paulie, I really do hope that in the future they'll implement a multiply effect in browsers.

real multiply effect with svg?


Is there a standard width for piano keys?

Question: Is there a standard width for piano keys?
If not, how much variation is there?
Do other keyboard instruments have significantly different widths of keys?
Comment: This really makes me curious, inspiring me to measure the width on my 1915 Steinway Model M vs. 2002 Yamaha S08 Synth with 88-note weighted-action... so +1 for the inspiration just got to remember to do this soon and get back to you.
Comment: Any variation of the width of similar piano keyboards is likely to be due to the space between the keys, than the size of the keys themselves, looking at catalogues for replacement piano parts, I haven't found any offering for sale keys of varying width.
Comment: @LeeKowalkowski, actually I'd suspect quite the opposite. To make keyboards playable, the spacing of the keys ought to be fixed, the width of key/space may vary within that.
Comment: There is significant variation in the distance between black keys among digital piano brands.
Comment: @Benjol think about how they're attached to the chassis, if you took all the keys off and replaced them with marginally thinner or thicker ones, you're affecting the spaces, not the width of the keyboard itself, so measuring the keyboard is not the way to determine the width of the keys, as such.
Answer: This question got me curious, so I started googling. Keyboard size is not officially standardized (there is no committee creating and enforcing standards), but in practice, there is very little variation.
Browsing through forum topics on www.pianoworld.com, people measured 88 key keyboards from anywhere between 48 inches to 48 1/2". Wikipedia (http://en.wikipedia.org/wiki/Musical_keyboard) describes the width of an octave on a modern keyboard as 164-165 mm, which leaves almost a centimeter variation in width over the entire keyboard.
There is also the option of buying a deliberately manufactured smaller keyboard, as described at http://www.smallpianokeyboards.org/keyboard-history.html. This would have a width as small as 141 mm for an octave, or over 2 cm smaller than a standard. I don't play piano, but as a small handed woman, that sounds pretty attractive.
Historically, from both the wikipedia and the smallpianokeyboards.org sites, older keyed instruments had octave widths as small as 125 mm, but not modern pianos.
For piano-like instruments, such as midi-controllers and cheap electronic keyboards, smaller keys are common when manufacturers have goals other than producing a standard piano.
Answer: While I see no reason to dispute the answers already presented I thought I would follow up with posting the measurements that I proposed in my comment under the question.
Measuring several keys near middle C with a calibrated digital caliper:
1915 Steinway Model M (New York) with original action:
22.1 to 22. 9 mm (slight variance), +/- fractions of 0.86 inches
2002 Yamaha Model S08 88-note weighted-action synthesizer:
22.8 mm or 0.89 inches
I suspect the variance of the width on the Steinway is due to the 1915 tooling vs. computer assisted manufacturing of the 2002 Yamaha.
To get a more authoritative answer I have contacted an authorized Steinway tech that tunes my Steinway and restores them as well (wish I could afford that) to review this. Pending his email answer, I will post an update later.
UPDATE June 30th, 2014:
It has come to my attention that the following answer would be more valuable to the community if I were to credit my source properly. I have been reluctant to reveal my source these past few days as I did not want him to be subjected to unnecessary distractions (spam) or harassment from adversarial points of view. As I stated clearly last week "protect my source."
I have been in contact and we have reviewed our options on this post.
So without any further chit chat, I would like to introduce to you, John Callahan of Callahan Piano in the San Francisco Bay Area, a Steinway restoration specialist.
http://www.callahanpiano.com/
Please be nice to him, he gets it right every day from tuning to restoration and beyond.
"You are correct, 100 year old piano keys will vary slightly in width. Some of that is the original tooling and cutting (piano keys are sliced like bread from one piece of material) and some of the variance can be from wear. The keys at the far ends of the keyboard will be a good bit wider on an older, heavily played instrument than the keys in the middle of the keyboard, where the most playing occurs."
"No standard width. You can measure many different pianos, and while they will all be within a fairly standard range, you will see differences. Same goes for the sharps.
This also holds true for many other piano dimensions. Keytop thickness, head length (distance from the player's end of the natural key to the cutout for the sharp), tail length, height of the keytop off the floor, height of the pedals off the floor, etc."
Comment: "The keys at the far ends of the keyboard will be a good bit wider on an older, heavily played instrument than the keys in the middle of the keyboard, where the most playing occurs." I think that is a (good) answer to the question you asked, but not what the OP wanted to know. The spacing **between** the keys is set by the construction of the key bed, which can't "wear" since it is one solid piece of material. The width of the keys themselves is not too important except for the visual appearance, so long as they are not so wide that they rub against each other when played.
Answer:
Do other keyboard instruments have significantly different widths of keys?

Organs seem to have the same key widths but I can't verify that. Accordions do vary - I can just reach a 10th on a piano but can easily get at least a 12th on an accordion.
Answer: 7/8" appears to be the industry standard, but there is a slight (2 or 3%) difference occasionally.Some keyboards I think are slightly smaller, but can't access mine for a while, so can't measure.I'm not talking mini-boards here,which are made either for kiddies or for studio pro. use.Got a Yamaha keyboard here with 7/8" keys. I think the main differences, which subtly affect things, are the length of keys and the amount that they get pressed down.That, and the different 'balance' feel, will make each piano different, but width-wise, not a lot.
Answer:
Do other keyboard instruments have significantly different widths of
  keys?

I can speak from experience that melodica keys are significantly narrower than piano keys. Where I cannot comfortably reach more than an octave on a piano, I think my range is more like a 10th on the melodica. It was surprisingly tricky to reprogram my fingers for the shorter scale.
I can only imagine that an accordion would have a similarly-shortened keyboard.
In addition, Karen mentioned smaller keys on some midi controllers. Here is an example of one such device, designed for portability.
Answer: My Evolution e-Keys mini USB piano keyboard has 17 mm wide naturals with 1 mm gaps between them so the center-to-center measurement is 18 mm, 5 mm less than what is normal on a piano. The distance from the front edge of the naturals to the accidentals are 30 mm while on a piano this is 50 mm and on organs often 46 mm.


Write a recursive function that copies some characters from start of each word in the parameter list to create a new string

Question: I want to write a function using recursion that copies the first character from the first word in the list, 2 characters from second word and so on.
Here is what I wrote:
def word(words_list, i):
    if len(words_list[i]) <= 1:
        return words_list[i]
    else:
        return words_list[i][0] + get_code(words_list[i][1:],i)
    i += 1

>>>print(word(["tigers", "zebras", "and", "lions"], 0))
tzeandlion # Expected
ti # received

How can I go about this? Any help pls?
Answer: With your setting, an option might be:
def word(words_list, i=0):
    if i >= len(words_list):
        return ''
    return words_list[i][:i+1] + word(words_list, i + 1)

print(word(["tigers", "zebras", "and", "lions"])) # tzeandlion

With a different parameterization:
def word(words_list, length=1):
    if not words_list:
        return ''
    return words_list[0][:length] + word(words_list[1:], length + 1)

If you were not required to use recursion, the following might be simpler and perhaps faster:
output = ''.join(word[:length] for length, word in enumerate(words_list, start=1))


Search API isn't returning results with words in the title

Question: I just installed search api and setup a server and index. Then I setup a Views page and exposed the search filter option. Searching all fields work, but for some reason its not searching the title. What could be the issue? I tried turning all fields off on the index and just left the title field option and its still not working.
Answer: I had to turn on the setting Search on parts of a word on the Server's page in order to get it to work. Now it searches titles. I'm not sure why it doesnt search titles with that unchecked.


HTTP basic authentication to API endpoint for PUT request

Question: I'm make a PUT request to a Drupal API end point created via a custom module and have enabled HTTP based authentication. When I call the api via rest client using Authorization header, the username and password prompts keeps coming again and again even though I supply a valid Drupal user. I see unauthorized user error as well using the advanced rest client on chrome. How do I solve it?
This is the code I am using.
function anonymize_user_services_resources() {
  return array(
    'update' => array(
      'update' => array(
        'help' => 'When user is deleted  users info should be anonymized',
        'callback' => 'anonymize_user_info',
       // 'access callback' => 'anonymize_callback',
        'access arguments' => array('update anonymize_user'),
        'access arguments append' => FALSE,
        'args' => array(
            array(
               'name' => 'id',
               'type' => 'int',
               'description' => 'The id of the user to update',
               'source' => array('path' => '0'),
               'optional' => FALSE,
            ),
          ),
        ),
      ),
    );

/**
* Implements hook_permission()
*/
function anonymize_user_permission() {
  return array(
    'update anonymize_user' => array(
      'title' => t('Update inactive user and anonymize'),
      'description' => t('Perform rest call to update and anonymize inactive user'),
    ),
  );
}

Comment: It would help if you could supply some relevant code. Did you enable basic_auth in your custom service? You can do so via REST UI module (https://www.drupal.org/project/restui).
Answer: The apache server needed to know the HTTP authorization header so the htaccess file had to be modified to accept the HTTP authorization header.
<IfModule mod_rewrite.c>
  RewriteEngine on

  SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1


Who was V. Viskovatov?

Question: I'd be interested to learn some biographical detail about Vasilii Viskovatov, whose name is associated with a method for converting (a ratio of) power series to a "corresponding" continued fraction, c.f. Handbook of Continued Fractions for Special Functions, p. 20 (Springer, 2008).
A few Internet hits (prominently Google books links, not wholly accessible) provide the following literature reference to his work, albeit with apparent mis-transliterated initial:
B. Viskovatov: 'De la méthode générale pour réduire toutes sortes des quantités en fractions continues', Memoires de L'Academie Impériale des Sciences de St. Petersburg, 1(1803-1806), pp. 226-247
[Trans.: 'A general method for reducing all types of quantities to continued fractions'.]

The algorithm itself can be described simply.  Given the ratio of two power series $p(z)/q(z)$ with $q(0) = 1$, remove as a constant term $b_0 = p(0)$, and after factoring out the leading term $z$ in the numerator, invert the remaining factor from $p(z) - p(0)q(z)$:
$$ \frac{p(z)}{q(z)} = b_0 + \frac{a_ 1 z \cdot r(z)}{q(z)} = b_0 + \frac{a_1 z}{q(z)/r(z)} $$
where for simplicity I've assumed a single power of $z$ in the numerator.  Continue to apply the process to $q(z)/r(z)$ and a corresponding-type continued fraction emerges.
Comment: Either that $\,1803-1806\;$ is a reference to the dates of the works, or else this guy was damn precocious...
Comment: There is an article about him in Russian Wikipedia. Here is an automatic English translation of the article: http://www.microsofttranslator.com/bv.aspx?from=ru&to=en&a=http://ru.wikipedia.org/wiki/%D0%92%D0%B8%D1%81%D0%BA%D0%BE%D0%B2%D0%B0%D1%82%D0%BE%D0%B2,_%D0%92%D0%B0%D1%81%D0%B8%D0%BB%D0%B8%D0%B9_%D0%98%D0%B2%D0%B0%D0%BD%D0%BE%D0%B2%D0%B8%D1%87
Comment: I'm sure you are right; edited for clarity (I'd transcribed one citation from Google books).
Comment: There's also a nice discussion of Viscovatov's algorithm in Lorentzen/Waadeland's *Continued Fractions with Applications* and Cuyt/Wuytack's *Nonlinear Methods in Numerical Analysis*. Is this related to your quest to determine a CF expansion of the polylogarithm?
Comment: @J.M.: Right, related. I'm pretty sure I remember seeing this fairly simple transformation in Khintchin's little book, years ago.  Seems like a guy who deserves an English Wikipedia article, so maybe I'll stub in a draft here as community wiki.  I'd noticed some "c" rather than "k" in transliterations of his last name.
Answer: It might be Vasilii Viskovatov:
http://encyclopedia2.thefreedictionary.com/Viskovatov,+Vasilii+Ivanovich
The time-frame and location is correct.
Don't forget that 'Vasilii' written in Cyrillic starts with a glyph that looks like a roman B:
Comment: Nice find!  This [note about his son](http://marksrussianmilitaryhistory.info/ViskovatovBio.html) is really starting to fill in the details.  I'd seen stuff about the son, whose [Russian military illustrations](http://www.christies.com/lotfinder/lot/viskovatov-aleksandr-vasilevich-and-4407930-details.aspx?intObjectID=4407930) have recently been ["rediscovered"](http://rafa-pardo-almudi.blogspot.com/2011/08/russian-discovery-viskovatov-pictures.html), but of course I did not know what relation they might be.
Comment: FWIW, I came across that by searching permutations of common trasliterations of Slavic names: Viskovatoff, Biskovatov, Wiskovatov, and the combinations therein.
Comment: I'm going to "correct" the initial in my Question's title, given your transliteration.
Answer: Putting together some of the findings and references as community wiki.
From Russian Wikipedia article (tweaked Google trans.):
Vasily Viskovatov (December 26 1779 ( 6 January 1780 ), St. Petersburg - 8(20) October 1812, St. Petersburg ) - Russian mathematician. Well-known expert in the field of mathematical analysis and the calculus of variations, one of the most active followers of Simon Guriev in the promotion of new and innovative research ideas.
Released from the Artillery and Engineers Royal Cadet Corps in 1796 as bayonet-cadet in the corps officers.
In 1803 declared a major mathematician, he was elected an academician of the St. Petersburg Imperial Academy of Sciences.
In 1810 - Professor of Pure and Applied Mathematics at the Institute of Railway Engineers 1.
First used the Russian term "derivative". 2

The Free Dictionary entry mostly duplicates the above but cites The Great Soviet Encyclopedia, 3rd Edition (1970-1979). © 2010 The Gale Group, Inc. All rights reserved, so I won't give a quote.  However it names a couple of the "major works" by Viskovatov, albeit in a transliterated form making automatic title translation fail.

From Mark Conrad's Russian Military History:
Major General Aleksandr Vasil'evich Viskovatov, Russian historian
This was V. Viskovatov's only son, "born in St. Petersburg on 22 April 1804."  I presume this is a Julian calendar date, as Russia/Soviet Union did not adopt the Gregorian calendar until 1918 (which is the reason for two sets of dates in the previous Wikipedia article).  It is mentioned that the family descended from a "branch of the Meshcherskii princes."
The son inherited his father's enthusiasm for mathematics, but sadly lost him at an early age (nine years old?).  The date of the father's death is given here as 1813, which differs from that shown in the Wikipedia article, a detail I'll attempt to clarify.

The development of mathematics in Russia in XVIII-XIX centuries
After graduating from military school, he was left there for the teaching of mathematics. At the age of twenty (1799) he was elected corresponding member, and in 1804 an associate of the Academy of Sciences. Later, he was promoted to the extra-ordinary academician. With the establishment of the Institute of Railway Engineerss, he was appointed professor in 1812 but died 34 years old. Viskovatov published several memoirs in the publications of the Academy, and a guide to elementary algebra. He has translated and published "Principles of Mechanics" by Bossu and published a new edition of the Euler's "Algebra". Despite his premature death, Viskovatov already had many disciples.
I.V. Ignatushina.
Formation of differential geometry as an academic subject in Russia in XVIII - the first half of the XIX century: disciples and followers of Leonhard Euler
V.I. Viskovatov, Guriev's student, taught mathematics and mechanics at the Artillery Cadet Corps, and then at the Institute of Railway Engineers and Mining Institute. In 1808 Viskovatov presented a work  "Summary of the famous Lagrange method to interpret the differential calculus and the application thereof to the geometry of curves" (1810). The second part of this work, entitled "On the application of differential calculus to the geometry of curves", is one of the first presentation of the issues of differential geometry of plane curves in Russian. It discusses the concept of a tangent to the curve, convexity,  curve inflection point, multiple points of cusps of the first and second kind, notions of evolute and involute of the curve and the concept of contiguous curves. He derived the equations of the tangent and normal line drawn at a given point of the curve, and the radius of curvature in the cases when the curve is set in a rectangular, oblique and polar coordinate systems.
Comment: @JeanMarie: It may have lost something in translation.  Google translate suggests "Institute of Communications".  This [JSTOR article](https://www.jstor.org/stable/41615445) says the St. Petersburg Institute of the Corps of Communications Engineers was established in November 1809.
Comment: "In 1810 - Professor of Pure and Applied Mathematics at the Institute of Railway Engineers" : In 1810 ??? There were no railways at that time !

Who was V. Viskovatov?


probability of failing

Question: The probability of a component to fail in each day is 0.0002
After 12.000 days of use the probability to not fail is more than the probability of failure.
Any hint on how to approach the question?
If the component has probability of failure of 0.0002 each day would it be the same after 12.000 days?
thanks
Answer: The probability to not fail during a specific hour is $1-0.0002=0.9998$. The probability of not having failed at all in $12000$ hours is thus $0.9998^{12000}=0.09...$ (assuming independence), while the probability of failing at least once during the same timeframe is $1$ minus that probability, which is much larger.
The claim as stated is therefore false under the assumption of statistical independence.
Comment: thanks, specifically we use the power because it implies that it did not fail before? (so the multiplication rule for AND)? right?
Comment: Whether or not it has failed before is irrelevant, as the probabilities for the individual hours are looked at separately (so the multiplication rule applies). Basically, you are computing the probability that for ALL hours, the "not" event has occurred.
Comment: thanks..saying that for ALL hours is the same as saying that it never happened, so AND... no? or I am just confusing myself maybe..
Comment: Yes, that's correct, we're ANDing the events together.

probability of failing


Lag selection for Augmented Dickey Fuller test

Question: Apologies in advance, I am a beginner so these questions might be quite simple.
I am testing log real exchange rates for unit root stationarity for EU15 countries. I was wondering what is the best way to select the optimal lag length if I have 100 observations.
I've got three questions:

I was using the AIC and SIC to determine which is the best fit, but at the same time I don't want to have too few lagged differences. Where do I find the balance? What's the best approach?
What do I do when AIC and BIC are negative? Choose the more negative one?
For Greece for example, I can see a decline i.e. a time trend, but when I add it, it turns out to be insignificant, what's that about?

Thank you in advance for any help!
Comment: AIC/SIC *are* there to make sure that you have a balance beteween too many and too few. There are many criteria around in active use, so it is kind of to be expected that there is not a single "best" one that is to be preferred all the time. Hence, we have to live with the fact that there may be disagreement among different lag-length selection criteria. And yes, always choose the smallest value, so -50 is better than -40.
Comment: I am no expert in exchange rate modelling but I would think twice before include a trend in the ADF test regression. If you had a model to explain why the trend was there, it could make sense to account for it; on the other hand, a "trend" in something as "random-walkish" as currency exchange rates may be just a coincidence (a random walk can have patterns that look somewhat like pieces of linear trends).
Answer: The first question has been discussed extensively in the literature. Some propose using the AIC or SIC criteria, others employ significance tests. To cite just a couple of references, Ng and Perron (1995) compared methods based on information criteria with sequential testing of additional lags. Ng and Perron (2001) propose a modified information criterion.
I agree with @ChristophHanck that there isn't a single strategy that will perform better than others in any possible situation. The residuals of the Dickey-Fuller regression should be inspected instead of trusting the choice of a given procedure. If serial correlation remains in the residuals, then one additional lag can be added until no structure is detected in the residuals.
Bootstrap is an interesting alternative because it can potentially deal with any kind of autocorrelation beyond those structures explored by simulations in the literature.

Note: P-values based on the original critical values may be a rough value. The distribution of the statistic has been tabulated for some fixed sample sizes and do not account for serial correlation. Cheung and Lai (1995) employed the method described in MacKinnon (1996) based on response surface regressions to obtain a procedure that gives the p-value of the ADF test for different sample sizes and lag order selection methods.

References

Cheung, Y. and Lai, K.S. (1995)
  Lag Order and Critical Values of the Augmented Dickey-Fuller Test.
  Journal of Business & Economic Statistics, Vol. 13, No. 3 (Jul., 1995), pp. 277-280. URL
MacKinnon, J.G. (1996)
  Numerical Distribution Functions for Unit Root and Cointegration Tests.
  Journal of Applied Econometrics, Vol. 11, No. 6 (Nov. - Dec., 1996), pp. 601-618. URL
Ng, S. and Perron, P. (1995)
  Unit Root Tests in ARMA Models with Data-Dependent Methods for the Selection of the Truncation Lag.
  Journal of the American Statistical Association, 90(429), 268-281.
  DOI
Ng, S. and Perron, P. (2001).
  Lag Length Selection and the Construction of Unit Root Tests with Good Size and Power.
  Econometrica, Volume 69, Issue 6, pp. 1519-1554.
  DOI
Comment: Thank you for your answer! I was just wondering: if I want to increase lag-length to eliminate autocorrelation, but the lags are completely insignificant, how do I find a balance?
Comment: If there is autocorrelation but the lags that you add turn out to be insignificant, it may be that the autocorrelation happens at higher orders. You could try removing the insignificant lags and checking whether higher order lags are significant.
Comment: How many times can I difference it before it becomes unreasonable?
Comment: There is no rule, it depends on the data. Overdifferencing induces negative correlation, see for example [this post](http://stats.stackexchange.com/questions/77593/). If consecutive negative autocorrelations show up in the partial autocorrelations, this may be a sign of overdifferencing.


Uniform continuity : stuck at an intermediate step

Question: $$f(x)= \frac{x}{1+x^2}, \, x \in \mathbb{R}$$
I have proved till the following step. I can't understand how do I proceed further. Please help $$f(x)\le|(x-y)||1-xy|$$
Comment: $| f(x) - f(y)| = |(x-y)(1-xy)/(1+x^2)(1+y^2)| \le | (x-y)(1- x^2)/(1+x^2)(1+x^2)| \le |x-y|$ ( $ x \le y$)
Answer: For all $x \in \mathbb{R},$ we have
$$f'(x) = \frac{1 - x^2}{(1+x^2)^2} $$
For $|x| \leqslant 1$ we have
$$|f'(x)| = \frac{1 - x^2}{(1+x^2)^2} \leqslant \frac{1}{(1+x^2)^2} \leqslant 1,$$
and for $|x| > 1$ we have $|f'(x)| \to 0$ as $x \to \pm \infty$ and local maxima at $x = \pm \sqrt{3}$ where $f'(\pm \sqrt{3}) = 1/8.$
Since the derivative is bounded, $f$ is uniformly continuous.
Alternatively, following your approach
$$\left|\frac{x}{1+x^2} -  \frac{y}{1+y^2}\right| = |x-y|\frac{|1  - xy|}{1 + x^2 + y^2 +x^2y^2} \leqslant |x-y|\frac{1  + |xy|}{1 + x^2 + y^2 +x^2y^2}. $$
I'll leave it to you to show that the RHS is bounded by $C |x - y|$ where $C$ is a constant.
Hint:
If $|xy| < 1$ then
$$\frac{1  + |xy|}{1 + x^2 + y^2 +x^2y^2} < \frac{2}{1 + x^2 + y^2 +x^2y^2}$$
If $|xy| > 1$ then
$$\frac{1  + |xy|}{1 + x^2 + y^2 +x^2y^2} < \frac{2|x||y|}{x^2 + y^2}$$
Comment: shouldnt it be like this???$$|f'(x)| = \frac{x^2 - 1}{(1+x^2)^2} \leqslant  \frac{x^2}{(x^2)^2} = \frac{1}{x^2} $$
Comment: You have an error in your post.  That should be $|f(x) - f(y)| \leqslant |x-y||1 - xy|$.  But you need to keep the denominator $1 + x^2 + y^2 + x^2y^2$ as I have done to make sure you can bound that.
Comment: I took $$x=3$$ in the $$|f'(x)| = \frac{x^2 - 1}{(1+x^2)^2} \leqslant  \frac{x^2}{(2x^2)^2} = \frac{1}{4x^2} \leqslant \frac{1}{4}.$$ it comes out as $$0.08\le.028$$
Comment: I appreciate your efforts :)
Comment: The upper bound $$|f'(x)|\leqslant\frac1{4x^2}$$ for $|x|>1$, is wrong.


How can I get a summary from a view into another view?

Question: There are a few views that gather and analyze data from several nodes to form a budget based on their workflow. These views have a "total" area (defined as a custom content field within the view), which calculates the the total amount of money allocated by each node.

Each node is also associated with a team object, and what I want to accomplish is to get the "total" field from each view to act as a column in another view, so we can see how much money was allocated/spent with each team.
Essentially, what I'm trying to do looks more or less like this:
<code>Team Number | View 1 Total | View 2 Total | View 3 Total | Total of the Totals
1           |          $33 |         $-10 |         $-20 |                  $3
2           |          $50 |         $-15 |         $-10 |                 $25
</code>
I've looked into trying views-field-view, but I haven't been able to find an option that allows me to select that specific row, which is created with a summarized table as the format. This is the same across all three views. How would I go about achieving this, with either views-field-view or another module? Or should I just go ahead and do this with a panel using custom PHP code?
Comment: do you got some advance?
Comment: @AdrianCidAlmaguer in some ways yes, but in others, not really. I haven't actually had much time to work on it recently, but do you know of any good tutorials for the modules you mentioned?
Comment: I just know http://cgit.drupalcode.org/views_aggregator/plain/README.txt?id=refs/heads/7.x-1.x and http://drupal.org/node/359981
Answer: You can combine the Views Field View module with the Views Aggregator Plus or with the Views Calc module.
Views Calc:

Adds simple calculations to a views table. You can SUM, AVERAGE, COUNT, MIN, MAX, or AVG selected columns. A plug
  in theme makes the view look more spreadsheet-like (right justifies
  numeric fields, shades calculated columns and rows, and underlines
  calculated rows).

Views Aggregator Plus:

In addition to what Views and Views Calc do, this module:

enumerates group members
produces tallies, i.e. textual histograms
aggregates on Views PHP code-snippet evalutations
can filter out result rows on regexp patterns
gives you sorting on Views' Math expressions
can process Webform submissions
lets you add your own custom aggregation functions

... and it puts summary statistics at the bottom of your aggregated
  table as well!


Where does SKEW Excel equation come from?

Question: I need to quote Excel's skew equation in a paper but I couldn't find any information about this equation:

$n$: size of the population
$s$: standard deviation
signed $x$: mean
Does anyone know if in statistics this equation is known with some name so I could add a quote on the paper indicating where the equation comes from?
here's the link of excel's skew article:
https://support.office.com/en-us/article/SKEW-function-bdf49d86-b1ef-4804-a046-28eaea69c9fa
Comment: See https://en.wikipedia.org/wiki/Skewness#Sample_skewness & the reference given there: Joanes & Gill (1998). "Comparing measures of sample skewness and kurtosis", *JRSS D*, **47**, 1.
Comment: $n$ is better reported as size of the sample. What you call "signed $x$" is often spoken aloud as "$x$ bar", but it is better practice to write $\bar x$ in a paper or thesis. The wording "signed $x$" makes no obvious sense here. $s$ is indeed standard deviation but for full disclosure you need to explain in turn how it is calculated, i.e. whether with $n - 1$ or with $n$ in the divisor.
Comment: @Nick Cox Yes it's x bar, i couldn't remember the exact term. Btw the standard deviation is calculated with n−1 in the divisor.
Comment: @Scortchi-ReinstateMonica: do you want to post your comment(s) as an answer? [Better to have a short answer than no answer at all.](https://stats.meta.stackexchange.com/a/5326/1352) Anyone who has a better answer can post it.
Answer: One definition of skewness is as the third standardized moment of a distribution: the ratio of the third central moment to the cube of the standard deviation (the square root of the second central moment):
$$
\frac{\operatorname{E}{(X-\operatorname{E}{X})^3}}
{\left[\operatorname{E}{(X-\operatorname{E}{X})^2}\right]^\frac{3}{2}}
$$
The corresponding property in a sample (or finite population) is given by
$$
\frac{\sum (x - \bar{x})^3/n}{\left[\sum (x - \bar{x})^2/n\right]^\frac{3}{2}},
$$
the Fisher—Pearson third standardized moment coefficient, or the Fisher–Pearson coefficient of skewness, or suchlike.
In samples of i.i.d. observations, this statistic is a consistent, though not unbiased, estimator of the skewness of the distribution from which the samples are drawn, provided of course that the first 3 moments exist. Now, the estimators of the second & third central moments that appear in the denominator & numerator are also consistent, & with biases that depend only on the sample size, $\frac{n-1}{n}$ & $\frac{(n-1)(n-2)} {n^2}$ respectively: substituting the de-biased estimators into the ratio results in
$$
\frac{\frac{n^2}{(n-1)(n-2)}\sum (x - \bar{x})^3/n}
{\left[\left(\frac{n}{n-1}\right)\sum (x - \bar{x})^2/n\right]^\frac{3}{2}}
=
\frac{n}{(n-1)(n-2)}\cdot\sum\left(\frac{x - \bar{x}}
{s}\right)^3
,$$
where $s$ is the sample standard deviation; & this is known as the adjusted Fisher–Pearson third standardized moment coefficient, &c. (I can't say I see the motive behind the adjustment, as it still doesn't give an unbiased estimator of skewness.)
See https://en.wikipedia.org/wiki/Skewness#Sample_skewness & the references given there: Joanes & Gill (1998), "Comparing measures of sample skewness and kurtosis", J. Royal Stat. Soc. D, 47 (1); &
Doane & Seward (2011), "Measuring skewness: a forgotten statistic", J. Stat. Educ., 19 (2).
Comment: History is more tangled than people want to believe, but a label Thiele-Pearson-Fisher would attribute credit a little more fairly and in time order. One of Pearson's more tangled moments [so to speak] was finding out that Thiele was there before him and giving a reference (good practice), but in such a way that implied that Thiele wasn't worth reading (poor show). The history is touched on -- and more crucially there are more references -- in https://www.stata-journal.com/article.html?article=st0204 (although I should add Picard in _Annals of Mathematical Statistics_ 1951 to the references).