Minimum value on the boundary of U help

Question:
Question:
Let $U \subset\mathbb{R}^2$  be an open and bounded set and $u\in C^2(U)\cap C(U)$ satisfy $\Delta u(x)=\frac{-1}{1+|x|}$ in $U$. Show that $u$ attains it's minimum on the boundary of $U$.

My attempt:
$$\text{Assume u attains a minimum on the interior of}\space U. \text{For some}\space(x_0,y_0)\in U.$$
$$\Rightarrow \quad  \frac{\partial u}{\partial x}(x_0,y_0)=\frac{\partial u}{\partial y} (x_0,y_0)=0 \space\text{ and }\space \frac{\partial^2 u}{\partial x^2}(x_0,y_0),\frac{\partial^2 u}{\partial y^2}(x_0,y_0)\ge0.\quad\text{So we have...}$$
$$\Rightarrow \quad\Delta u(x_0,y_0)=\frac{\partial^2 u}{\partial x^2}(x_0,y_0)+\frac{\partial^2 u}{\partial y^2}(x_0,y_0)\ge0.$$
$$\text{However we know}\space \Delta u(x)=\frac{-1}{1+|x|}\lt0\quad \forall x\in U.\text{Hence a contradiction}\therefore \text{the minimum is attained on the boundary}$$

Help!
Here is an attempt at a question I'm doing on my partial differential equations course. I am not happy with my solution as it's definitely missing bits. Any alternative solutions/hints would be greatly appreciated! :)
Comment: This proof seems completely fine to me. Maybe if you wanted to add a bit more you could say that by the extreme value theorem $u$ must attain a minimum somewhere in $\overline{U}$. Since it is not in $U$ it must be on $\partial U$ but I don't think this explanation is super necessary
Answer: $$\text{Assume u attains a minimum on the interior of}\space U. \text{For some}\space(x_0,y_0)\in U.$$
$$\Rightarrow \quad  \frac{\partial u}{\partial x}(x_0,y_0)=\frac{\partial u}{\partial y} (x_0,y_0)=0 \space\text{ and }\space \frac{\partial^2 u}{\partial x^2}(x_0,y_0),\frac{\partial^2 u}{\partial y^2}(x_0,y_0)\ge0.\quad\text{So we have...}$$
$$\Rightarrow \quad\Delta u(x_0,y_0)=\frac{\partial^2 u}{\partial x^2}(x_0,y_0)+\frac{\partial^2 u}{\partial y^2}(x_0,y_0)\ge0.$$
$\text{However we know}\space \Delta u(x)=\frac{-1}{1+|x|}\lt0\quad \forall x\in U.\text{Hence a contradiction}\therefore \text{by the maximum principle u must attain a minimum somewhere in }\overline{U}.$
$\text{Since it is not in U it must be on } \partial U$

Minimum value on the boundary of U help


Unable to disable transparent_hugepage/defrag to never in centOS 7.2

Question: I am following this link,
https://docs.mongodb.com/v3.0/tutorial/transparent-huge-pages/
I am getting the output
cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never

This is what i did
1)Create the following file at /etc/init.d/disable-transparent-hugepages:
case $1 in
  start)
    if [ -d /sys/kernel/mm/transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/transparent_hugepage
    elif [ -d /sys/kernel/mm/redhat_transparent_hugepage ]; then
      thp_path=/sys/kernel/mm/redhat_transparent_hugepage
    else
      return 0
    fi

    echo 'never' > ${thp_path}/enabled
    echo 'never' > ${thp_path}/defrag

    unset thp_path
    ;;
esac

2) run
sudo chmod 755 /etc/init.d/disable-transparent-hugepages

3) run
sudo chkconfig --add disable-transparent-hugepages

4)run
sudo mkdir /etc/tuned/no-thp

5)  Create and edit /etc/tuned/no-thp/tuned.conf so that it contains the following:
[main]
include=virtual-guest

[vm]
transparent_hugepages=never

6)run
sudo tuned-adm profile no-thp

7)
cat /sys/kernel/mm/transparent_hugepage/enabled
always madvise [never]

cat /sys/kernel/mm/transparent_hugepage/defrag
[always] madvise never

8) same result even after restart server
Please help me
Thank you
Comment: I don't understand why the mongodb documentation recommends to use a init script to make kernel parameters persistent. IMHO the correct way is to use `/etc/sysctl.conf`
Comment: `/etc/sysctl.conf` [isn't web-scale](https://www.youtube.com/watch?v=b2F-DItXtZs).
Answer: I added this in the /etc/init.d/mongod after #!/bin/bash
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
   echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
   echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi

it work fine


Big disagreement in the slope estimate when groups are treated as random vs. fixed in a mixed model

Question: I understand that we use random effects (or mixed effects) models when we believe that some model parameter(s) vary randomly across some grouping factor. I have a desire to fit a model where the response has been normalized and centered (not perfectly, but pretty close) across a grouping factor, but an independent variable x has not been adjusted in any way. This led me to the following test (using fabricated data) to ensure that I'd find the effect I was looking for if it was indeed there. I ran one mixed effects model with a random intercept (across groups defined by f) and a second fixed effect model with the factor f as a fixed effect predictor. I used the R package lmer for the mixed effect model, and the base function lm() for the fixed effect model. Following is the data and the results.
Notice that y, regardless of group, varies around 0. And that x varies consistently with y within group, but varies much more across groups than y
> data
      y   x f
1  -0.5   2 1
2   0.0   3 1
3   0.5   4 1
4  -0.6  -4 2
5   0.0  -3 2
6   0.6  -2 2
7  -0.2  13 3
8   0.1  14 3
9   0.4  15 3
10 -0.5 -15 4
11 -0.1 -14 4
12  0.4 -13 4

If you're interested in working with the data, here is dput() output:
data<-structure(list(y = c(-0.5, 0, 0.5, -0.6, 0, 0.6, -0.2, 0.1, 0.4,
-0.5, -0.1, 0.4), x = c(2, 3, 4, -4, -3, -2, 13, 14, 15, -15,
-14, -13), f = structure(c(1L, 1L, 1L, 2L, 2L, 2L, 3L, 3L, 3L,
4L, 4L, 4L), .Label = c("1", "2", "3", "4"), class = "factor")),
.Names = c("y","x","f"), row.names = c(NA, -12L), class = "data.frame")

Fitting the mixed effects model:
> summary(lmer(y~ x + (1|f),data=data))
Linear mixed model fit by REML
Formula: y ~ x + (1 | f)
   Data: data
   AIC   BIC logLik deviance REMLdev
 28.59 30.53  -10.3       11   20.59
Random effects:
 Groups   Name        Variance Std.Dev.
 f        (Intercept) 0.00000  0.00000
 Residual             0.17567  0.41913
Number of obs: 12, groups: f, 4

Fixed effects:
            Estimate Std. Error t value
(Intercept) 0.008333   0.120992   0.069
x           0.008643   0.011912   0.726

Correlation of Fixed Effects:
  (Intr)
x 0.000

I note that the intercept variance component is estimated 0, and importantly to me, x is not a significant predictor of y.
Next I fit the fixed effect model with f as a predictor instead of a grouping factor for a random intercept:
> summary(lm(y~ x + f,data=data))

Call:
lm(formula = y ~ x + f, data = data)

Residuals:
     Min       1Q   Median       3Q      Max
-0.16250 -0.03438  0.00000  0.03125  0.16250

Coefficients:
            Estimate Std. Error t value Pr(>|t|)
(Intercept) -1.38750    0.14099  -9.841 2.38e-05 ***
x            0.46250    0.04128  11.205 1.01e-05 ***
f2           2.77500    0.26538  10.457 1.59e-05 ***
f3          -4.98750    0.46396 -10.750 1.33e-05 ***
f4           7.79583    0.70817  11.008 1.13e-05 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.1168 on 7 degrees of freedom
Multiple R-squared: 0.9484, Adjusted R-squared: 0.9189
F-statistic: 32.16 on 4 and 7 DF,  p-value: 0.0001348

Now I notice that, as expected, x is a significant predictor of y.
What I am looking for is intuition regarding this difference. In what way is my thinking wrong here? Why do I incorrectly expect to find a significant parameter for x in both of these models but only actually see it in the fixed effect model?
Comment: Just want to quickly point out that something is wrong with the random effects setup given the variance on the RE = 0 (ie/ the RE explains no variation). Given that, it's not surprising the `x` variable is not significant. I suspect that is the same result (coefficients and SE) you would have gotten running `lm(y~x,data=data)`. Don't have any further time to diagnose, but wanted to point this out.
Comment: @Affine that's a good point. So I suppose my interest here is why the random effect didn't capture variation in the intercept. If you, or anyone has a comment at a later time, I welcome it! Thanks.
Answer: There are several things going on here. These are interesting issues, but it will take a fair amount of time/space to explain it all.
First of all, this all becomes a lot easier to understand if we plot the data. Here is a scatter plot where the data points are colored by group. Additionally, we have a separate group-specific regression line for each group, as well as a simple regression line (ignoring groups) in dashed bold:
plot(y ~ x, data=dat, col=f, pch=19)
abline(coef(lm(y ~ x, data=dat)), lwd=3, lty=2)
by(dat, dat$f, function(i) abline(coef(lm(y ~ x, data=i)), col=i$f))

The fixed-effect model
What the fixed-effect model is going to do with these data is fairly straightforward. The effect of $x$ is estimated "controlling for" groups. In other words, $x$ is first orthogonalized with respect to the group dummies, and then the slope of this new, orthogonalized $x$ is what is estimated. In this case, this orthogonalization is going to remove a lot of the variance in $x$ (specifically, the between-cluster variability in $x$), because the group dummies are highly correlated with $x$. (To recognize this intuitively, think about what would happen if we regressed $x$ on just the set of group dummies, leaving $y$ out of the equation. Judging from the plot above, it certainly seems that we would expect to have some high $t$-statistics on each of the dummy coefficients in this regression!)
So basically what this ends up meaning for us is that only the within-cluster variability in $x$ is used to estimate the effect of $x$. The between-cluster variability in $x$ (which, as we can see above, is substantial), is "controlled out" of the analysis. So the slope that we get from lm() is the average of the 4 within-cluster regression lines, all of which are relatively steep in this case.
The mixed model
What the mixed model does is slightly more complicated. The mixed model attempts to use both within-cluster and between-cluster variability on $x$ to estimate the effect of $x$. Incidentally this is really one of the selling points of the model, as its ability/willingness to incorporate this additional information means it can often yield more efficient estimates. But unfortunately, things can get tricky when the between-cluster effect of $x$ and the average within-cluster effect of $x$ do not really agree, as is the case here. Note: this situation is what the "Hausman test" for panel data attempts to diagnose!
Specifically, what the mixed model will attempt to do here is to estimate some sort of compromise between the average within-cluster slope of $x$ and the simple regression line that ignores the clusters (the dashed bold line). The exact point within this compromising range that mixed model settles on depends on the ratio of the random intercept variance to the total variance (also known as the intra-class correlation). As this ratio approaches 0, the mixed model estimate approaches the estimate of the simple regression line. As the ratio approaches 1, the mixed model estimate approaches the average within-cluster slope estimate.
Here are the coefficients for the simple regression model (the dashed bold line in the plot):
> lm(y ~ x, data=dat)

Call:
lm(formula = y ~ x, data = dat)

Coefficients:
(Intercept)            x
   0.008333     0.008643

As you can see, the coefficients here are identical to what we obtained in the mixed model. This is exactly what we expected to find, since as you already noted, we have an estimate of 0 variance for the random intercepts, making the previously mentioned ratio/intra-class correlation 0. So the mixed model estimates in this case are just the simple linear regression estimates, and as we can see in the plot, the slope here is far less pronounced than the within-cluster slopes.
This brings us to one final conceptual issue...
Why is the variance of the random intercepts estimated to be 0?
The answer to this question has the potential to become a little technical and difficult, but I'll try to keep it as simple and nontechnical as I can (for both our sakes!). But it will maybe still be a little long-winded.
I mentioned earlier the notion of intra-class correlation. This is another way of thinking about the dependence in $y$ (or, more correctly, the errors of the model) induced by the clustering structure. The intra-class correlation tells us how similar on average are two errors drawn from the same cluster, relative to the average similarity of two errors drawn from anywhere in the dataset (i.e., may or may not be in the same cluster). A positive intra-class correlation tells us that errors from the same cluster tend to be relatively more similar to each other; if I draw one error from a cluster and it has a high value, then I can expect above chance that the next error I draw from the same cluster will also have a high value. Although somewhat less common, intra-class correlations can also be negative; two errors drawn from the same cluster are less similar (i.e., further apart in value) than would typically be expected across the dataset as a whole. All of this intra-class correlation business is just a useful alternative way of describing the dependence in the data.
The mixed model we are considering is not using the intra-class correlation method of representing the dependence in the data. Instead it describes the dependence in terms of variance components. This is all fine as long as the intra-class correlation is positive. In those cases, the intra-class correlation can be easily written in terms of variance components, specifically as the previously mentioned ratio of the random intercept variance to the total variance. (See the wiki page on intra-class correlation for more info on this.) But unfortunately variance-components models have a difficult time dealing with situations where we have a negative intra-class correlation. After all, writing the intra-class correlation in terms of the variance components involves writing it as a proportion of variance, and proportions cannot be negative.
Judging from the plot, it looks like the intra-class correlation in these data would be slightly negative. (What I am looking at in drawing this conclusion is the fact that there is a lot of variance in $y$ within each cluster, but relatively little variance in the cluster means on $y$, so two errors drawn from the same cluster will tend to have a difference that nearly spans the range of $y$, whereas errors drawn from different clusters will tend to have a more moderate difference.) So your mixed model is doing what, in practice, mixed models often do in this case: it gives estimates that are as consistent with a negative intra-class correlation as it can muster, but it stops at the lower bound of 0 (this constraint is usually programmed into the model fitting algorithm). So we end up with an estimated random intercept variance of 0, which is still not a very good estimate, but it's as close as we can get with this variance-components type of model.
So what can we do?
One option is to just go with the fixed-effects model. This would be reasonable here because these data have two separate features that are tricky for mixed models (random group effects correlated with $x$, and negative intra-class correlation).
Another option is to use a mixed model, but set it up in such a way that we separately estimate the between- and within-cluster slopes of $x$ rather than awkwardly attempting to pool them together. At the bottom of this answer I reference two papers that talk about this strategy; I follow the approach advocated in the first paper by Bell & Jones.
To do this, we take our $x$ predictor and split it into two predictors, $x_b$ which will contain only between-cluster variation in $x$, and $x_w$ which will contain only within-cluster variation in $x$. Here's what this looks like:
> dat <- within(dat, x_b <- tapply(x, f, mean)[paste(f)])
> dat <- within(dat, x_w <- x - x_b)
> dat
      y   x f x_b x_w
1  -0.5   2 1   3  -1
2   0.0   3 1   3   0
3   0.5   4 1   3   1
4  -0.6  -4 2  -3  -1
5   0.0  -3 2  -3   0
6   0.6  -2 2  -3   1
7  -0.2  13 3  14  -1
8   0.1  14 3  14   0
9   0.4  15 3  14   1
10 -0.5 -15 4 -14  -1
11 -0.1 -14 4 -14   0
12  0.4 -13 4 -14   1
>
> mod <- lmer(y ~ x_b + x_w + (1|f), data=dat)
> mod
Linear mixed model fit by REML
Formula: y ~ x_b + x_w + (1 | f)
   Data: dat
   AIC   BIC logLik deviance REMLdev
 6.547 8.972  1.726   -23.63  -3.453
Random effects:
 Groups   Name        Variance Std.Dev.
 f        (Intercept) 0.000000 0.00000
 Residual             0.010898 0.10439
Number of obs: 12, groups: f, 4

Fixed effects:
            Estimate Std. Error t value
(Intercept) 0.008333   0.030135   0.277
x_b         0.005691   0.002977   1.912
x_w         0.462500   0.036908  12.531

Correlation of Fixed Effects:
    (Intr) x_b
x_b 0.000
x_w 0.000  0.000

A few things to notice here. First, the coefficient for $x_w$ is exactly the same as what we got in the fixed-effect model. So far so good. Second, the coefficient for $x_b$ is the slope of the regression we would get from regression $y$ on just a vector of the cluster means of $x$. As such it is not quite equivalent to the bold dashed line in our first plot, which used the total variance in $x$, but it is close. Third, although the coefficient for $x_b$ is smaller than the coefficient from the simple regression model, the standard error is also substantially smaller and hence the $t$-statistic is larger. This also is unsurprising because the residual variance is far smaller in this mixed model due to the random group effects eating up a lot of the variance that the simple regression model had to deal with.
Finally, we still have an estimate of 0 for the variance of the random intercepts, for the reasons I elaborated in the previous section. I'm not really sure what all we can do about that one at least without switching to some software other than lmer(), and I'm also not sure to what extent this is still going to be adversely affecting our estimates in this final mixed model. Maybe another user can chime in with some thoughts about this issue.
References

Bell, A., & Jones, K. (2014). Explaining fixed effects: Random effects modelling of time-series cross-sectional and panel data. Political Science Research and Methods. PDF
Bafumi, J., & Gelman, A. E. (2006). Fitting multilevel models when predictors and group effects correlate. PDF
Comment: Thanks again, @JakeWestfall. I've read over this about 3 times over the course of a few months and it's helped in various ways each time.
Comment: This is a very thoughtful and helpful response. I have not come across these references; their titles strike me as must-read at this point in my exploration. I owe you a beer!
Comment: The Bell & Jones ref was great. One thing I was waiting for, and that you might have a clue about, is whether these within-between separations extend readily to *generalized* linear mixed models. It seems like they ought to, but I thought I understood that covariate centering in a logistic regression model is not the same as the conditional logistic model, which I take to be the binary outcome analog to the fixed effect linear model. Any comments?
Comment: Wouldn't fitting a _marginal_ model allow for the negative variance that `lme` constrains by default to be >=0 ? See [this question and its selected answer](http://stats.stackexchange.com/questions/14088), i.e., fitting a compound simmetry correlation through a `gls` fit or  setting `correlation = corCompSymm(form = ~1|f)` in `lme`
Comment: @FairMiles Perhaps... why don't you give it a try and post the results in this comment thread?
Comment: +6 This is a really nice answer.
Answer: After considerable contemplation, I believe I have discovered my own answer. I believe an econometrician would define my independent variable to be endogenous and thus be correlated with both independent and the dependent variables. In this case, those variables are omitted or unobserved. However, I do observe the groupings between which the omitted variable ought to vary.
I believe the econometrician would suggest a fixed effect model. That is, a model that includes a dummy for every grouping level (or an equivalent specification that conditions the model such that many grouping dummies are not required) in this case. With a fixed effect model, the hope is that all unobserved and time-invariant variables can be controlled by conditioning out across group (or across individual) variation. Indeed, the second model in my question is precisely a fixed effect model, and as such gives the estimate I expect.
I welcome comments that will further illuminate this circumstance.
Comment: That's correct: assumption RE.1b page 292 of Woolridge ("Econometric analysis of cross section and panel data") tells us that the random effects need to be uncorrelated with the independent variables for random effects models, otherwise the FGLS estimator is inconsistent.


How to prove that these two sets are equal?

Question: I think I can prove that
$$\bigcup_{i=1}^{n}A_i\setminus\bigcap_{i=1}^{n} A_i
=(A_1\setminus A_2)\cup(A_2\setminus A_3)\cup\cdots\cup(A_{n-1}\setminus A_n)\cup(A_n\setminus A_1).$$
so,I think maybe there has(treat infinity as a circle):
$$\bigcup_{n=1}^{\infty}A_n\setminus\bigcap_{n=1}^{\infty} A_n=(A_1\setminus A_2)\cup(A_2\setminus A_3)\cup\cdots$$
but I dot't know how to prove it.
Comment: False: Take an increasing sequence , for instance.
Comment: As often, the step from finite to infinite has problems. If you look at the proof of the finite case, you'll see that you actually need the "circle" nature of the right hand side, given by the last term "closing the cycle". There is no such "closing part" in the infinite case. That means if you have an element in $A_2, A_3, A_4,...$, but not in $A_1$, then it will be in the left side set of the (supposed) equality, but not in the right side set. Again, this can be in the infinite case because there is no part that looks like $\ldots\backslash A_1$.
Comment: Why do you think they're equal?
Comment: Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking.
Answer: As mentioned in the comments, what you wrote is not quite true. However, it can be fixed as follows:
$$
\bigcup_{n=1}^\infty A_n\setminus\bigcap_{n=1}^\infty A_n=\bigcup_{n=1}^\infty (A_{n+1}\setminus A_n)\cup (A_n\setminus A_{n+1})
$$
The proof is this. If $x$ is in at least one of the $A_n$, but not all of the $A_n$, then there must exist an $i$ such that $x\in A_i$, and a $j$ such that $x\notin A_j$.  Furthermore,  $i$ and $j$ can be chosen to be consecutive natural numbers. To see this, imagine coloring all natural numbers for which $x\in A_i$ blue, and calling all natural numbers $j$ for which $x\notin A_j$ red. It is easy to see there must exist a red number next to a blue number.
However, we have no control over whether $i=j+1$ or $j=i+1$. This is why we need a union of $(A_{n+1}\setminus A_n)\cup (A_n\setminus A_{n+1})$, instead of just $A_{n+1}\setminus A_n$. In the finite case, you could "go around the circle" to force $i=j+1$.


Question regarding characters and point open topology

Question: I was wondering why the following claim is correct:
Let G* be the group of all continuous homomorphisms from the topological group G and the unit circle (call it T). Then G* is an intersection of a closed set in the point open topology of all functions from G to T and C(G,T) (set of all continuous functions from G to T).
G* is also called a character.
Thanks in advance for all the help
Answer: The fact that a (continuous) function $f$ from $G$ to $T$ is a homomorphism can be expressed as a "closed condition", as it were, in the pointwise (product) topology on $T^G$. Namely, write for a fixed pair of $g,h \in G$:
$$A(g,h) = \{f \in T^G \mid f(g)\cdot f(h) = f(gh)\} = ((m_T \circ (\pi_g \Delta \pi_h)) \Delta \pi_{gh})^{-1}[\Delta_T]\text{,}$$
where $m_T$ is the multiplication map from $T \times T$ to $T$ (which is continuous) and for any group element $t \in G$, $\pi_t: T^G \rightarrow T$ is the projection onto the element $t$ (sending $f \in T^G$ to $f(t)$), which are all continuous by definition of the pointwise topology. Also, $\Delta_T = \{(x,x): x \in T\}$ is the diagonal in $T$ which is closed (as $T$ is Hausdorff), and $\Delta$ denotes the diagonal product of maps from a common domain (which produces continuous functions from continuous functions).
To expand a bit on this: $\pi_{gh}: T^G \rightarrow T$ is a projection, as are $\pi_g : T^G \rightarrow T$ and $\pi_h: T^G \rightarrow T$. The latter two are combined into a diagonal map $\pi_g \Delta \pi_h: T^G \rightarrow T \times T$, defined by $(\pi_g \Delta \pi_h)(f) = (f(g), f(h))$ (which is continuous as $\pi_g, \pi_h$ both are; a standard fact for product spaces). The latter is composed with $m_T$ so $(m_T \circ (\pi_g \Delta \pi_h))(f) = f(g)\cdot f(h) \in T$, and this is continuous as composition of continuous maps. Now, this last map is again combined as a diagonal product with the first-mentioned projection $\pi_{gh}$, so this total map $(m_T \circ (\pi_g \Delta \pi_h))\Delta \pi_{gh}$ sends $f$ to the pair $(f(g)\cdot f(h),f(gh))$. Which lies in $\Delta_T \subset T \times T$ iff the left hand side term equals the right hand side term.
So all sets $A(g,h)$ are closed and the homomorphisms in $T^G$ is just the set $\cap_{g,h \in G} A(g,h)$, which is also closed (in the pointwise topology) as the intersection of closed sets.
Comment: Looks good... I need to digest it for a little while. Will let you know if I came across any things that I may didn't understand completely. Thanks again :)
Comment: there is something that I don't quite understand. How can I take multiplication Map of diagonal product of maps? Multiplication map expects T×T while it receives a diagonal product of elements in T^G. Can you please extend the explanation of the RHS?
Comment: @AvivEshed I explained it fully. It's a pretty standard way to see that the set where equality holds is a closed set. One could use nets as well, but many people are not familiar with those.
Comment: Yes now it is clearer for me. Thank you :)
Comment: By the way, you saw the type of questions I have, is there a book you could recommend me that deals with the types of questions I asked?
Comment: @AvivEshed Topological Function Spaces (Arhangel'skij), about (mainly) the pointwise topology or more elementary: McCoy Ntantu: Topological Properties of Spaces of Continuous Functions, parts of Engelking (general topology).


Numbers above notes in orchestral score

Question: In Tchaikovsky's Symphony No. 6 (Op.74), near the end of the first movement, at rehearsal "S" there are numbers written above the notes for the 1st violin part (ref. upper right in image).  What do those numbers mean?

I do know what numbers above notes mean in piano sheet music but not in an orchestral score.  Also, I am aware that the "3" under the beams refers to triplets.  Thanks!
Answer: It's actually pretty much exactly what you see in piano sheet music! These are just fingerings to help the first violins execute that scalar run.
Note that, in contrast to piano fingerings, 1 indicates the index finger, 2 the middle finger, etc.
The next question may then be why the fingerings are only given for the first violins. I'm not entirely, sure but the run is the same in all voices, so I assume the fingerings would be, as well. Or perhaps the run just happens to be placed more easily in the other instruments. (But I'm no string player, beware of this explanation!)
PS: Great piece!
Comment: The fingering given for Vn 1 is different from the standard fingering for a chromatic scale, and seems to be designed to accentuate the 8th-note divisions of the run. As Tim says, the notes lie differently across the strings for the other instruments, and the larger size of the violas and cellos would also affect the fingering.
Comment: Ah, [you guys](https://www.youtube.com/watch?v=MOs4vsthLD0) are no [fun](https://en.wikipedia.org/wiki/Viola_jokes)  anymore.
Comment: @alephzero: also, there's no way the violas would _actually_ play a run like that chromatically as it's written... why would he bother giving them fingerings?
Comment: @leftaroundabout Do you mean it's impossible for the violas to play this run? I think I misunderstood you.
Comment: @leftaroundabout "there's no way the violas would *actually* play a run like that chromatically as it's written" - Why not? the viola part is marked "divisi". They are not being asked to play a chromatic scale in octaves.
Comment: I've just never met a German with a sense of humor before :-)
Comment: You mean to tell me that the violists are the red-headed stepchildren of the orchestra?  I thought that distinction belonged to the [second violinists](http://kennethwoods.net/blog1/2016/06/14/second-violin-section-consider-brexit-from-leading-orchestra/). ;-)
Comment: Second violins KNOW they're failures.  Violas don't.
Comment: Except that the viol.ii are playing an octave lower, so would be using different strings, so maybe not changing at the same points as viol. i?

Numbers above notes in orchestral score


R Regressão por condição usando apply ou for

Question: Tenho a seguinte amostra:
x <- structure(list(POP = structure(c(1L, 12L, 15L, 16L, 17L, 18L,
19L, 20L, 21L, 2L, 3L, 4L, 5L, 6L, 7L, 8L, 9L, 10L, 11L, 13L,
14L), .Label = c("pop1", "pop10", "pop11", "pop12", "pop13",
"pop14", "pop15", "pop16", "pop17", "pop18", "pop19", "pop2",
"pop20", "pop21", "pop3", "pop4", "pop5", "pop6", "pop7", "pop8",
"pop9"), class = "factor"), a1 = c(91, 26.7, 51.9, 14, 0, 15.3,
34.4, 19.1, 10.2, 52.5, 43.6, 13.1, 47.1, 34.7, 0, 58.9, 66.8,
0, 0, 0, 0), a2 = c(92.9, 27.7, 54.1, 14.3, 0, 16.2, 35, 19.1,
11.1, 52.5, 44.6, 13.4, 48.7, 34.4, 0, 59.5, 72.3, 0, 0, 0, 0
), a3 = c(92.6, 27.4, 54.7, 13.7, 0, 16.2, 36, 0, 11.1, 53.2,
45.2, 13.7, 49.3, 0, 0, 59.5, 74.5, 0, 0, 0, 0), a4 = c(95.5,
28.3, 57.3, 14.6, 0, 16.9, 36.9, 0, 11.8, 56.3, 47.1, 14, 53.2,
0, 0, 62.7, 84.4, 0, 0, 0, 0), a5 = c(97.4, 28.6, 61.4, 14.3,
0, 17.5, 36.9, 0, 12.4, 55.7, 47.4, 14.6, 53.8, 0, 0, 62.4, 0,
0, 0, 0, 0), a6 = c(97.7, 29.3, 63.3, 14.6, 0, 18.5, 38.8, 0,
13.1, 57.3, 49, 15.3, 55.4, 0, 0, 62.7, 0, 0, 0, 0, 0), a7 = c(102.2,
0, 68.1, 14.6, 11.1, 20.1, 43.3, 0, 14.6, 64.9, 53.2, 0, 60.5,
0, 0, 62.7, 0, 0, 0, 0, 0), a8 = c(106.3, 0, 71.9, 14.3, 0, 19.7,
45.8, 0, 15.9, 70.7, 57.3, 0, 67.8, 0, 10.5, 0, 0, 0, 10, 0,
0), a9 = c(113.2, 0, 75.5, 15, 0, 21.7, 49, 0, 18.5, 73, 59.8,
0, 0, 0, 14.7, 0, 0, 0, 10.4, 0, 0), a10 = c(114.9, 0, 75.2,
15, 0, 22.6, 49.6, 0, 19.8, 73.8, 59.9, 0, 0, 0, 16.6, 0, 0,
10.5, 10.5, 0, 0), a11 = c(114.9, 0, 75.5, 15.1, 0, 23.2, 50.6,
0, 19.8, 74.6, 59.2, 0, 0, 0, 18.2, 0, 0, 10.5, 10.6, 0, 0),
    a12 = c(115, 0, 76, 15.9, 0, 26.1, 0, 0, 22.7, 75.4, 60.8,
    0, 0, 0, 21, 0, 0, 10.3, 11.1, 0, 0), a13 = c(115.2, 11.6,
    76, 16, 0, 26.6, 0, 0, 23.3, 75.5, 61.3, 0, 0, 0, 22.6, 0,
    0, 10.7, 11.1, 0, 0), a14 = c(0, 11.6, 77.6, 0, 0, 29.5,
    0, 0, 25.3, 76.2, 64, 0, 0, 0, 25.5, 0, 0, 11.6, 11.8, 10.2,
    11)), class = "data.frame", row.names = c(NA, -21L))

E os dados anuais:
temp <- structure(list(ano = structure(c(1L, 7L, 8L, 9L, 10L, 11L, 12L,
13L, 14L, 2L, 3L, 4L, 5L, 6L), .Label = c("a1", "a10", "a11",
"a12", "a13", "a14", "a2", "a3", "a4", "a5", "a6", "a7", "a8",
"a9"), class = "factor"), temp = c(0L, 2L, 2L, 6L, 2L, 3L, 13L,
8L, 7L, 3L, 2L, 5L, 2L, 5L)), class = "data.frame", row.names = c(NA,
-14L))

Eu consigo extrair as regressões com as funções apply, quando eu tenho os dados completos nos 14 anos, fazendo uma limpeza nos dados e mantendo só as pop que tem a série completa de 14 anos.
Porém eu queria correr a regressão nos dados que não estão completos, uso o seguinte código:
y <- temp$temp

log_x <- apply(x[-1], 2, log)

model_list <- apply(log_x, 1, function(x) lm(x ~ y))

coef_list <- t(sapply(model_list, coef))

model_smry <- lapply(model_list, summary)

a função applypara no erro do log, que resulta em  -inf já que tem valores zero na base.
tem como correr a regressão até esse ponto antes do erro e calcular a regressão com o y correspondente ao ano que parou?
Por exemplo:
Sao 14 anos ou colunas
o ano 4 tem -inf
eu calculo a regressão só com os anos 1, 2 e 3 com o y correspondente a esses anos (parando a função apply no -inf). Fazendo isso para todas as linhas.
talvez dê para fazer isso com uma função for mas eu não sei como prosseguir, se puderem ajudar a começar ou indicar algo para estudar, já vai ser uma grande ajuda.
Comment: Eu não estou conseguindo reproduzir o teu erro. Por acaso a linha `log_x <- apply(log_x[-1], 2, log)` deveria ser `log_x <- apply(base[-1], 2, log)`? Além disso, para que serve o data frame `temp`? Por favor, reveja estes detalhes e edite a pergunta de modo que ela fique reproduzível.
Comment: Opa, desculpe. Acabei de arrumar o exemplo.
Answer: Então, espero que tenha entendido corretamente. Não é o jeito mais sofisticado, mas deve funcionar.
Vejamos os dados
 x
 #     POP   a1   a2   a3   a4   a5   a6    a7    a8    a9   a10   a11   a12   a13  a14
 #1   pop1 91.0 92.9 92.6 95.5 97.4 97.7 102.2 106.3 113.2 114.9 114.9 115.0 115.2  0.0
 #2   pop2 26.7 27.7 27.4 28.3 28.6 29.3   0.0   0.0   0.0   0.0   0.0   0.0  11.6 11.6
 #3   pop3 51.9 54.1 54.7 57.3 61.4 63.3  68.1  71.9  75.5  75.2  75.5  76.0  76.0 77.6
 #4   pop4 14.0 14.3 13.7 14.6 14.3 14.6  14.6  14.3  15.0  15.0  15.1  15.9  16.0  0.0
 #5   pop5  0.0  0.0  0.0  0.0  0.0  0.0  11.1   0.0   0.0   0.0   0.0   0.0   0.0  0.0
 #6   pop6 15.3 16.2 16.2 16.9 17.5 18.5  20.1  19.7  21.7  22.6  23.2  26.1  26.6 29.5
 #7   pop7 34.4 35.0 36.0 36.9 36.9 38.8  43.3  45.8  49.0  49.6  50.6   0.0   0.0  0.0
 #8   pop8 19.1 19.1  0.0  0.0  0.0  0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0  0.0
 #9   pop9 10.2 11.1 11.1 11.8 12.4 13.1  14.6  15.9  18.5  19.8  19.8  22.7  23.3 25.3
 #10 pop10 52.5 52.5 53.2 56.3 55.7 57.3  64.9  70.7  73.0  73.8  74.6  75.4  75.5 76.2
 #11 pop11 43.6 44.6 45.2 47.1 47.4 49.0  53.2  57.3  59.8  59.9  59.2  60.8  61.3 64.0
 #12 pop12 13.1 13.4 13.7 14.0 14.6 15.3   0.0   0.0   0.0   0.0   0.0   0.0   0.0  0.0
 #13 pop13 47.1 48.7 49.3 53.2 53.8 55.4  60.5  67.8   0.0   0.0   0.0   0.0   0.0  0.0
 #14 pop14 34.7 34.4  0.0  0.0  0.0  0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0  0.0
 #15 pop15  0.0  0.0  0.0  0.0  0.0  0.0   0.0  10.5  14.7  16.6  18.2  21.0  22.6 25.5
 #16 pop16 58.9 59.5 59.5 62.7 62.4 62.7  62.7   0.0   0.0   0.0   0.0   0.0   0.0  0.0
 #17 pop17 66.8 72.3 74.5 84.4  0.0  0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0  0.0
 #18 pop18  0.0  0.0  0.0  0.0  0.0  0.0   0.0   0.0   0.0  10.5  10.5  10.3  10.7 11.6
 #19 pop19  0.0  0.0  0.0  0.0  0.0  0.0   0.0  10.0  10.4  10.5  10.6  11.1  11.1 11.8
 #20 pop20  0.0  0.0  0.0  0.0  0.0  0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0 10.2
 #21 pop21  0.0  0.0  0.0  0.0  0.0  0.0   0.0   0.0   0.0   0.0   0.0   0.0   0.0 11.0
 y <- temp$temp
 y
 # [1]  0  2  2  6  2  3 13  8  7  3  2  5  2  5
 log_x <- apply(x[-1], 2, log)

Aqui eu crio uma lista para receber os seus valores de interpolacao, que será feito por um loop (for)
 # acumula os valores de interpolacao
 model_list <- list()

Eu devo eliminar as linhas que nao tem nenhuma observacao válida
 # linhas em log_x com -Inf em todas as lacunas
 linhas <- c(3,6,9,10,11)
 # Linhas com Algum Valor (LAV)
 lav <- (1:21)[-linhas]
 lav
 # [1]  1  2  4  5  7  8 12 13 14 15 16 17 18 19 20 21

Agora eu crio um loop que i) remove as posicoes sem observacao, tanto no arquivo log_x como no y também; ii) Faz as interpolacoes
 for(i in (lav)){ # loop por linha
    # indices de coluna com valores -Inf
    indice_com_inf <- which(log_x[i,]<0)
    # novo log_x1, sem os indices de valores -Inf
    log_x1 <- log_x[i,-indice_com_inf]
    # novo y1, sem os indices de valores -Inf
    y1 <- y[-indice_com_inf]
    # novo
   model_list[[i]] <- lm(log_x1 ~ y1)
 }

Veja como fica as primeira cinco interpolacoes. Observe que, para os casos em que não houve nenhuma observação (linha 3), a lista model_list fica vazia nessa posição
head(model_list,5)
#[[1]]
#
#Call:
#lm(formula = log_x1 ~ y1)
#
#Coefficients:
#(Intercept)           y1
#   4.614607     0.005504
#
#
#[[2]]
#
#Call:
#lm(formula = log_x1 ~ y1)
#
#Coefficients:
#(Intercept)           y1
#    3.23414     -0.04457
#
#
#[[3]]
#NULL
#
#[[4]]
#
#Call:
#lm(formula = log_x1 ~ y1)
#
#Coefficients:
#(Intercept)           y1
#    2.68385      0.00109
#
#
#[[5]]
#
#Call:
#lm(formula = log_x1 ~ y1)
#
#Coefficients:
#(Intercept)           y1
#      2.407           NA

Comment: Opa, obrigado. O processo funcionou como esperado. Mas no final está omitindo os valores ````NA````, você sabe algum jeito de fazer aparecer todos na lista. No fim do loop da a seguinte mensagem ````Error in lm.fit(x, y, offset = offset, singular.ok = singular.ok, ...) : 0 (não-NA) casos````
Comment: Muito obrigado cara. Você me deu o caminho certo. Abs
Comment: Opa, beleza. Por nada! Usei `head(model_list,5)` só pra mostrar as cinco primeiras regressões. Sobre o erro indicado, aqui não apareceu mesmo. Abs
Comment: Um pergunta, quando usa o ````head(model_list,5)````, a observação ````3```` fica com valor igual a ````NULL````, tem como calcular a regressão nela? pois a mesma apresenta a série completa dos dados, no caso daria para calcular com o ````y```` e suas 14 observações. Eu tentei alterar o loop para isso, mas não consegui.
Comment: Pelo menos nos dados do exemplo que passou, a observação `3` apareceu com todas as lacunas `-Inf`. No entanto, se você tiver outros dados com valores válidos, basta incluir o índice `3` no vetor `lav` --- assim essa posição entra no loop.
Answer: eu consegui complementar o código para não dar esse erro
segue a solução da função for:
for(i in (lav)){ # loop por linha
  # indices de coluna com valores -Inf
  indice_com_inf <- which(log_x[i,]<0)
  # criar lista de x sem os -inf
  x_list[[i]] <- log_x[i,-indice_com_inf]
  # novo y1 em lista, sem os indices de valores -Inf
  y_list[[i]] <- y[-indice_com_inf]
  # condição
  if (length(x_list[[i]]) >= 3) { #condição comprimento >=3
    #rodar regressão
    model_list[[i]] <- lm(x_list[[i]] ~ y_list[[i]])
  } else {
    model_list[[i]] <- NA #se não atender a condição, não fazer nada
}}


Build out a complete main nav menu for a module - not just adding one menu link

Question: I've been finding a lot of info about how to add a menu link as part of a module.  That works fine using the route/controller & links.menu.yml file.
But I am now trying to figure out how to add a complete main menu for my module (my module is a default data & structure module).
My goal is to have x level-1 menu items and each one of those will have varying numbers of sub-menus.
Any hints or references to guides/tutorials?
Comment: If you found answers in the documentation for part of your question, please link to said documentation in your question.  Doing so helps other people who find your question and are not as far along as you.
Comment: I abandoned this method in favor of using a completely different technique.  The technique that works for me is using the "Default Content" Drupal module which lets you export content from a dev system and package that content up as a module.  When the module is enabled on a new system the previously exported content is ingested.
Answer: I've decided to go with the default_content technique in which it is possible to save off the menu items to a 'custom_module' then reload them into a new instance.
Answer: You can multiple links in the same way that you add one link.
This creates a front page link on a menu for anonymous users and a front page link on a menu for authenticated users, as well as a parent and child menu link (Fruits -> Apple) for anonymous users.
MYMODULE.links.yml:
MYMODULE.anon-home:
  title: 'Home'
  route_name: 'entity.node.canonical'
  route_parameters: { node: '1' }
  weight: 0
  menu_name: main-navigation-anon
MYMODULE.anon-fruits:
  title: 'Fruits'
  route_name: 'entity.node.canonical'
  route_parameters: { node: '4' }
  weight: 10
  menu_name: main-navigation-anon-ja
MYMODULE.anon-apples:
  title: 'Apples'
  route_name: 'entity.node.canonical'
  route_parameters: { node: '6' }
  parent: MYMODULE.anon-fruits
  weight: 0
  menu_name: main-navigation-anon-ja
MYMODULE.auth-home:
  title: 'Home'
  route_name: 'entity.node.canonical'
  route_parameters: { node: '1' }
  weight: 0
  menu_name: main-navigation-auth

Comment: Thank you Patrick for this.  I was not sure how to tackle the parent/child aspect of this.  For now I am switching to the Default Content module as a way to import but may have to come back to this if that method does not pan out.


Evaluating $\lim_{x\to1^+}\frac{\sqrt{x+1}+\sqrt{x^2 -1}-\sqrt{x^3+1}}{\sqrt{x-1}+\sqrt{x^2 +1}-\sqrt{x^4+1}}.$

Question: I don't know how to solve these kind of limit problems. I was wondering if someone could help me about it to learn them. $$\lim_{x\to 1^+}\frac{\sqrt{x+1}+\sqrt{x^2 -1}-\sqrt{x^3+1}}{\sqrt{x-1}+\sqrt{x^2 +1}-\sqrt{x^4+1}}.$$ Thanks in advance.
Answer: Hint
You can always write $f(x)-g(x)$ as $$\frac{f(x)^2-g(x)^2}{f(x)+g(x)}.$$
So, taking $$f(x)=\sqrt{x+1}+\sqrt{x^2+1}\quad \text{and}\quad g(x)=\sqrt{x^3+1},$$ at the numerator and $$f(x)=\sqrt{x-1}+\sqrt{x^2+1}\quad \text{and}\quad g(x)=\sqrt{x^4+1},$$
at the denominator should do the work.
Comment: Thank you for your help. I've got to this $\frac{-x^3+x^2+x-1+2\sqrt{x-1}(x+1)}{-x^4 +x^2 +x-1+2\sqrt{x-1}\sqrt{x^2+1}}$. How can I solve this? $f(x)$ at the numerator is $\sqrt{x+1}+\sqrt{x^2 -1}$ in the question.
Comment: Factorise $-x^3+x^2+x-1$ and $-x^4+x^2+x-1$ by $x-1$, and simplify the fraction by $\sqrt{x-1}$.
Comment: Thank you so much.
Answer: Write $x=1+t$, and use $\sqrt{A+Bt}=\sqrt{A}+\tfrac{B}{2\sqrt{A}}t+o(t)$ for $A\ne0$ to write the limit as$$\lim_{t\to0^+}\frac{\sqrt{2}(1+\tfrac12o(t))+\sqrt{2t}(1+t)^{1/2}-\sqrt{2}(1+\tfrac34t+o(t))}{\sqrt{t}+\sqrt{2}(1+\tfrac12t+o(t))-\sqrt{2}(1+t+o(t))}.$$While the constant terms in the numerator and denominator cancel, the $\sqrt{t}$ terms don't, so the limit is$$\lim_{t\to0}\frac{\sqrt{2t}}{\sqrt{t}}=\sqrt{2}.$$
Comment: Thank you very much for your nice answer.
Answer: We can rewrite the numerator as $$N=\sqrt{x-1}\sqrt{x+1}+\frac{x(1-x)(1+x)}{\sqrt{1+x}+\sqrt{1+x^3}}=\sqrt{x-1}\left(\sqrt{1+x}-\frac{x(1+x)\sqrt{x-1}}{\sqrt{1+x}+\sqrt {1+x^3}}\right)$$ and hence $N/\sqrt {x-1}\to\sqrt{2}$. Similarly one can show that if $D$ is the denominator then $D/\sqrt{x-1}\to 1$. And therefore $N/D\to\sqrt {2}$.
Most algebraic limits can be handled using simple algebraic manipulation combined with the standard algebraic limit $\lim\limits _{x\to a} \dfrac{x^n-a^n} {x-a} =na^{n-1}$.


Internal traffic card and external traffic cards on the same server... how to configure?

Question: This might sound like a noob question, but here is what I have to configure:

FreeBSD
1 server with 2 network cards
1 network card for internal IP addresses (5 of them)
1 network card for external IP addresses (3 of them)
the server is the DNS server as well as the Proxy Server and Samba server
one router Netgear SRX5308 (SNMP enabled)
A GB Cisco switch 48 ports (SNMP enabled)

I want the internal traffic (192.168..) to be routed in one card and the "external" traffic on the other network card.
my rc.conf looks something like this:
defaultrouter="174.###.49"
static_routes="office"
route_office="-net 192.0.0.0/8 192.168.1.1"
ifconfig_em0="inet 192.168.1.9 netmask 255.255.0.0 broadcast 192.168.1.255"
ifconfig_em0_alias0="inet 192.168.1.10 netmask 255.255.255.255 broadcast 192.168.1.10"
ifconfig_em0_alias1="inet 192.168.1.11 netmask 255.255.255.255 broadcast 192.168.1.11"
ifconfig_em0_alias2="inet 192.168.1.12 netmask 255.255.255.255 broadcast 192.168.1.12"
ifconfig_em0_alias3="inet 192.168.1.231 netmask 255.255.255.255 broadcast 192.168.1.231"
ifconfig_em1="inet 174.###.51 netmask 255.255.255.248 broadcast 174.###.55"
ifconfig_em1_alias0="inet 174.###.52 netmask 255.255.255.255 broadcast 174.###.52"
ifconfig_em1_alias1="inet 174.###.53 netmask 255.255.255.255 broadcast 174.###.53"

Currently everything works but I have em0 (internal) connected to the switch and em1(external) directly connected with the external line.
What I would like to do is to connect the external line to the same switch or the netgear router so I can monitor the traffic better.
I have tried to configure the router with a DMZ (174.###.51/255.255.255.252) but it didn't work.  I have also tried to set the default router to 192.168.1.1 and connect both to the switch. This worked and I was able to connect with the outside world, but the servers were not reachable from outside.
I know some routers have a "reroute" feature for the IP address.. you hit "174.###.##" and you reroute it to 192.168.1.9 ... but I can't find it on this router.
I know I could purchase a small smart switch with SNMP and it would be solved, but I believe that what I want to achieve is already possible with what I have, I just don't know how to configure it right.
keep in mind that I am converting an old network with 3 servers into one server and I cannot drop nor change the IP addresses for now.  The server is also a monitor system for other servers as well as a backup and has a small html page that needs to be accessible from everywhere)
Thank you
EDIT:
What I am trying to achieve is:
current configuration: ISP -> SERVER && INTERNAL -> SWITCH -> SERVER -> ISP
what I want is: ISP -> ROUTER -> SERVER && INTERNAL -> SWITCH -> SERVER
I also would like to keep em0 for only 192 traffic and em1 for only 174 incoming traffic and all the outgoing traffic (this is also a proxy server)
EDIT 2:
Let's see if I can explain myself better.  Sorry English is not my first language.
I want:

Outgoing traffic: em0: USER -> SWITCH -> SERVER -> ROUTER -> THE NET -> ROUTER -> SERVER -> SWITCH -> USER
Incoming traffic: em1 THE NET -> ROUTER -> SERVER

Currently I have:

outgoing: em0 USER -> SWITCH -> SERVER -> THE NET -> SERVER -> SWITCH -> USER
incoming: em1 THE NET -> SERVER

Incoming is used for backups, some http traffic, various rsync, and push monitoring (something I wrote, monitoring both ways, checking the outside server and waiting from outside server information not at the same time that the "sent" is done)
Comment: Can you perhaps draw a diagram of what your current situation is and clarify your description of what you're trying to accomplish?  I *think* what you want is traffic graphing for your server, and if that's the case you're probably making things way more complicated than they need to be...
Answer: If your netgear is not a firewall, your default needs to point to the ISP address on your em1 interface.  Your em1 can connect the ISP through the netgear switch as long as the ISP connection is bridged by that switch.
If that netgear is actually a firewall, you need to remove the 174 address from your freebsd machine, move that address to the netgear, and rely on the netgear to do NAT.  At this point, your freebsd default should point to the netgear and the netgear should default to the ISP.
As for "rerouting" to 192.168.1.9, that's called NAT; it's a common feature on firewalls, and it also happens to be in the BSD kernel.  I'm not sure why you're configuring so many 192.168.x.x addresses on em0, but it looks a little strange.  Other than these points, it's not entirely clear what else you want to do; perhaps this is a good start.
EDIT:
Since you have a real Netgear SRX5308 firewall, you need to simplify your topology.

Connect freebsd's em0 to one LAN port on the netgear
Add a default on your freebsd machine to point to the netgear's 172.16.x.x address
Connect your ISP1 uplink to the "WAN 1" port on the netgear (it has 4 WAN ports)
Connect your ISP2 uplink to the "WAN 2" port on the netgear
Assign your 174.x.x.x address to Netgear's WAN 1
Assign your 70.x.x.x address to Netgear's WAN 2
Set a default route on the netgear to point to your ISP1's router (this will need to be dynamically scripted to change in the event of a failover to the new ISP)
Set up a script to perform failover detection and reconfiguration to go to ISP2's router (or maybe use a real Cisco with EEM static routing at this point???)
Perform NAT on WAN 1 for your 172.16.1.10 addresses and services
Perform NAT on WAN 2 for your 172.16.1.10 addresses and services
Configure all clients to default through the freebsd machine, which is also acting as a router / http proxy.
Map your services to the various ISP NATs with Dynamic DNS

I am including a link to the Netgear SRX5308 documentation, which I hope helps; I'm a bit concerned that you're getting in over your head, but assuming you've tried to read the docs yourself I will answer whatever questions I can.
Comment: You need to change the address on `em1` so you can use the 174.x.x.x and 70.x.x.x addresses on the netgear.  Since you're using `em1` as the egress LAN interface, you need to assign your NAT configuration to use this address on the netgear... Most of what you said otherwise looks ok, but you have a rather complex topology for someone who is starting out with networking...
Comment: In other words I do not want the ISP cable connected to the server, but I want it connected to the router and then have the router decide where to send the traffic (192 = internal, 171.###.51-54 that specific card, everything else load balance)
Comment: If you have a netgear firewall, then yes connect the ISP cable to the firewall (and you can completely remove `em1` from the picture).  May I request that you draw a diagram of what you're trying to do, the various 192.168 / 174.x.x.x addresses involved, and also make a list of features (such as load-balancing, NAT, etc...) that you need?  It's perfectly acceptable to obscure the real 174 addresses by changing an octet or two, but we need a better description of what you're trying to do
Comment: The 192 IP addresses will SOON be removed, I am consolidating 3 different servers and until everything works I do not want to go around and change the DNS/Proxy/etc.. sadly the previous person didn't use an internal DNS and everything was configured as IP address
Comment: not sure I can design one here, but is simple (I think). current: `ISP -> SERVER && INTERNAL -> SWITCH -> SERVER -> ISP` what I want is `ISP -> ROUTER -> SERVER && INTERNAL -> SWITCH -> SERVER `  I cannot find the NAT functionality on this router and the WAN mode is set to NAT
Comment: NETGEAR ProSafe Gigabit Quad WAN SSL VPN Firewall SRX5308
Comment: OK, everything is done.. but the point 6 is what I am not able to do on this router.. and what will I do with `em1` ? as I am using this machine as proxy, i was hoping to make use of both network cards, only ONLY for internal traffic and one only for external so I can perform backups without clogging the network too much (as I am doing right now)
Comment: When you give us a diagram of what you need I can elaborate further.  What protocols are you proxying for with the freebsd box?
Comment: HTTP and HTTPS only. everything else currently goes on a different line (WAN1 on the netgear).  I would like everything else to be transferred with a failback configuration .. in other words use 174.###.## only for incoming traffic, else let the router decide which WAN to use to fetch the data. I am going to update my question further
Comment: What did you use to create the graph, I will create one right away.  yes I am well over my head with this, but I have to figure it out.  Your diagram is perfect except needs to add a WAN 70.X.X.X that goes to a different ISP (is a failover line currently used for SSH etc.)  I'll read the manual again and see if I can replicate your configuration.  Thank you very much
Comment: I used [inkscape](http://inkscape.org/) with [Cisco's icons converted to SVG](http://bucksnort.pennington.net/blog/post/svg-from-eps/)
Comment: OK, so If I understand this right:  using the names that I already have configured: Connect the switch to Lan1, using qVLan. Connect em0 to Lan2, using qVLan, connect the em1 to Lan3 using qVLan10 (NO IP Change, you wrote another internal netw. IP 172.x.x.x) and the configure the client to use as router 192.168.1.9 (server IP).
Comment: Great. I believe I understand also the reasons why and how to do it.  Thank you very much.  Yes it is complex but a man gotta do what a man gotta do :-)
Comment: you're most welcome... best of luck with your endeavors... if you run into a snag, you can always ask another question that is specific to your (new) problem
Comment: let us [continue this discussion in chat](http://chat.stackexchange.com/rooms/4333/discussion-between-fabrizio-and-mike-pennington)
Comment: Thank you. Do you think that there is way for the NetGear to send the correct Gateway ? right now it sends 192.168.1.1 where per your suggestion we want it to send 192.168.1.9 (my server IP)
Comment: I'm waiting for you in [chat](http://chat.stackexchange.com/rooms/4333/discussion-between-fabrizio-and-mike-pennington)...
Answer:
All those broadcast lines shouldn't be in there unless you have a spectacular reason for them.
It's much easier to specify the netmasks in CIDR notation, but not necessary.
Most ISPs will only enable the modem to talk to 1 MAC address. So you can't have both the Server and the Netgear router on the same external line. I'm really not sure what you'd expect to get out of that anyway.
Why do you think you need SNMP?

What you've specified in the Question should mostly be possible. I'm just not clear everything you're trying to accomplish.
Comment: How would you rewrite the lines ? not sure what you mean with point ??? their modem is connected to our router. I use SNMP to monitor the in/out traffic with MRTG


Scrolling LineChart animation with Google Charts

Question: I'm trying to create a scrolling animation with a Line Chart in Google Charts. I want to display real time data from an external data source, so my data table cannot be populated in advance and it can not be a specific size.
My general idea was to use a scrolling window (see last example here: https://developers.google.com/chart/interactive/docs/animation#Examples) and just move the window forward while removing data behind the window and add data in front of the window.
So far my progress looks like this: http://jsfiddle.net/svantetobias/knt7F/
HTML:

<input id="next" type="button" value="Next reading">

JavaScript:
// Load the Visualization API and the piechart package.
google.load('visualization', '1.0', {
    'packages': ['corechart']
});

// Set a callback to run when the Google Visualization API is loaded.
google.setOnLoadCallback(loadChart);

function loadChart() {
    // Set chart options
    var options = {
        width: 1000,
        height: 400,
        vAxis: {
            minValue: 0,
            maxValue: 100
        },
        hAxis: {
            viewWindow: {
                min: 1,
                max: 5
            }
        },
        curveType: 'none', // or 'function'
        pointSize: 5,
        series: {
            0: {
                color: 'Blue'
            },
            1: {
                color: 'Orange'
            }
        },
        animation: {
            duration: 1000,
            easing: 'linear'
        }
    };

    // Create the data table.
    var data = google.visualization.arrayToDataTable([
        ['Time', 'series1', 'series2'],
        ['2014 23/07 13:00', 700, 900],
        ['2014 23/07 14:00', 850, 900],
        ['2014 23/07 15:00', 1000, 900],
        ['2014 23/07 16:00', 1050, 900],
        ['2014 23/07 17:00', 700, 900],
        ['2014 23/07 18:00', 650, 900],
        ['2014 23/07 19:00', 700, 900],
        ['2014 23/07 20:00', 950, 900]
    ]);

    // Instantiate our chart
    var chart = new google.visualization.LineChart(document.getElementById('google_chart_div'));

    // Define button
    var button = document.getElementById('next');

    function drawChart() {
        // Disabling the button while the chart is drawing.
        button.disabled = true;
        google.visualization.events.addListener(chart, 'ready', function () {
            button.disabled = false;
        });
        // Draw chart
        chart.draw(data, options);
    }

    button.onclick = function () {
        //data.removeRow(0);
        data.insertRows(data.getNumberOfRows(), [
            ['2014 23/07 20:00', Math.floor((Math.random() * (1400 - 600)) + 600), 900]
        ]);
        options.hAxis.viewWindow.min += 1;
        options.hAxis.viewWindow.max += 1;
        drawChart();

    };
    drawChart();
}

For the first few animations it looks like I want it, but then the line starts doing weird waves. How do I make it animate properly like a scrolling window?
Answer: Your problem is that you're adding the same date over and over again, and it's causing the chart to have a hard time interpolating the result. Try http://jsfiddle.net/KaU3y/, or:
data.insertRows(data.getNumberOfRows(), [
        ['' + new Date(), Math.floor((Math.random() * (1400 - 600)) + 600), 900]
    ]);

Comment: Thanks! Since the date I write is just a string, it seems to me that it should not matter that it is the same over and over again, but maybe I just don't fully understand how the animation is calculated. Anyway, it solved the issue!


Int32 vs Int64 performance on a 64 bit platform?

Question: My question is relatively simply. On 32bit platforms it's best to use Int32 as opposed to short or long due to to the cpu processing 32 bits at a time. So on a 64 bit architecture does this mean it's faster to use longs for performance? I created a quick and dirty app that copies int and long arrays to test the benchmarks. Here is the code(I did warn it's dirty):
<code>static void Main(string[] args)
    {
        var lar = new long[256];

        for(int z = 1; z<=256;z++)
        {
            lar[z-1] = z;
        }
        var watch = DateTime.Now;
        for (int z = 0; z < 100000000; z++)
        {
            var lard = new long[256];
            lar.CopyTo(lard, 0);

        }
        var res2 = watch - DateTime.Now;

        var iar = new int[256];

        for (int z = 1; z <= 256; z++)
        {
            iar[z - 1] = z;
        }

        watch = DateTime.Now;

        for (int z = 0; z < 100000000; z++)
        {
            var iard = new int[256];
            iar.CopyTo(iar, 0);

        }

        var res1 = watch - DateTime.Now;
        Console.WriteLine(res1);
        Console.WriteLine(res2);

    }
</code>
The results it produces make long about 3 times as fast as int. Which makes me curious to whether I should start using longs for counters and such. I also did a similar counter test and long was insignificantly faster. Does anybody have any input on this? I also understand even if longs are faster they will still take up twice as much space.
Comment: For starters use StopWatch instead of DateTime.Now (more accurate for these kinds of performance tests). Secondly in the int iteration you are copying iar to itself. Not sure if that will affect anything but just in case.
Answer: No. It takes longer to do 64-bit on a 32-bit CPU because the CPU can only handle 32-bits at a time. A 64-bit CPU will just ignore the missing 32-bits.
Also, try not to preemptively optimize too much. Only optimize when there is a noticeable bottleneck.
Comment: "A 64-bit CPU will just ignore the missing 32-bits". There is no difference in speed. Anyway, if you're trying to optimize at the CPU level, don't use a language that compiles to byte-code, use assembly language or C.
Comment: I think you misunderstood what I stated. I agree that it takes longer to use 64bit sized types on a 32bit. My question is whether on a 64bit cpu I should use longs instead of ints because longs are 64bit and ints are 32bit.
Comment: Java compiles to byte code and .NET to IL. I'm just curious is all. If that's true it will just ignore then why is using shorts slower on a 32bit system. Shorts are two bytes and get padded to 32bits on a 32bit cpu. From what I understand if you use types that are less than the cpu architecture it pads it to be equal to it. Which means if you use a short(2 bytes) with a 32bit cpu it would pad the short to 32bits when it gets processed. Afterwards, when time comes to for it to be read only the first 16 bits are read. Also why is using longs in my copy example 3 times faster than using ints?
Comment: This is a continuation of my above comment. I am really just curious. Also I don't know assembly and don't prefer C or even C++ since interpreted languages are a lot simpler.
Answer: There's a similar question on this here: Will using longs instead of ints benefit in 64bit java
Typically, in a real application you're more concerned about cache misses, so this is less of a concern overall.
Comment: So this raises a couple of questions. 1) Why does my test application show longs being about 3 times faster as ints. 2) How do languages like C++ handle this since ints are 64bit in it. Do they use shorts instead of ints?


Probability question about conditional probability for uniformly distributed variables

Question: This question is a follow up of this previous question
Let us suppose that we have a sample of 3 random distinct numbers $I=\{z_1,z_2,z_3\}$ that are generated from a uniform distribution with support in $[0,1]$. Let's call $m = \max{I}$ the maximum of the randomly generated sample.
The goal
I want to compute
$$
p(z_2^{n-2}>r\, \cap\, z_2 = m \cap z_1^{n-1}\leq r)
$$
for $n=3$ and for some $0\leq r \leq 1$.
Let me call $E_1 : z_2^{n-2}>r$, $E_2 : z_2 = m $ and $E_3 :  z_1^{n-1}\leq r$.
First attempt
We can compute the probability using the PDF of the max. Indeed,
$$
p(E_1\cap E_2 \cap E_3) = \frac{1}{n} p(E_1\, \cap E_3|  E_2)
$$
which could be written as
$$
\begin{align}
n \times p(E_1\cap E_2 \cap E_3) &= \int_{r^{\frac{1}{n-2}}}^{r^{\frac{1}{n-1}}} dm \int_0^m dz_1 f_{z_2}(m)+\int_{r^{\frac{1}{n-1}}}^{1} dm \int_0^{r^{\frac{1}{n-1}}} dz_1 f_{z_2}(m)\\
&= -\frac{3 r^4}{4}-\frac{r^2}{4}+\sqrt{r}
\end{align}
$$
where $f_{z_2}(m) = n\times m^{n-1}$ is the PDF of the maximum.
The question
However, this result is wrong. I can compute $p(E_1\, \cap E_2\, \cap E_3) $ numerically on Mathematica with the following commands
checkDistribution[r_] :=
 Module[{win = 0, loss = 0, list, probability, i},
  For[i = 1, i <= 10000, i++,

(* generating the random sample of float numbers *)
   list = RandomSample[Range[300], 3]/(300) // N;

(* Checking if the condition is met; eventually, increase the variable win *)
   If[list[[2]] > list[[1]] && list[[2]] > list[[3]] &&
     list[[1]]^2 <= r && list[[2]] > r, win = win + 1];];

 (* The variable loss is the number of times the condition is not met *)
  loss = 10000 - win;

(* Compute and return the probability *)
  probability = win/(win + loss);
  Return[{r, probability}]]

(* Generate list of probabilities for different values of r *)
points = Table[checkDistribution[r], {r, 0, 1, 0.01}];

(* Plot points, wrong and correct result *)
Show[points // ListPlot, Plot[{1/3 (Sqrt[r] - r^2/4 - (3 r^4)/4), -(1/6) Sqrt[r] (-3 + r + 2 r^(5/2))}, {r, 0, 1}, PlotStyle -> {Red, Darker[Green]}]]

and I find the following result (see plot below). The dots are the numerics and the red line is the result of the integral. The green line is the solution of the probability described in the next section of the post.

So, the integral must be wrong. Where did I make the mistake? What seems wrong to me is that I am not imposing any constraint on $z_3$. If $z_2 = m$, then I should take into account that $z_3<z_2$.
The correct result
I can compute the probability by brute force. Let me call for simplicity $r_1=\sqrt{r}$ and $r_2=r$. The probability is then
$$
\begin{align}
p(E_1\cap E_2 \cap E_3) &= \int_0^1 dz_1\int_0^1 dz_2\int_0^1 dz_3 \theta(z_2-r_2)\theta(r_1-z_1)\theta(z_2-z_1)\theta(z_2-z_3)\\
&= \int_0^{z_2} dz_3 \left[ \int_0^{r_2} dz_1\int_{r_2}^1 dz_2+\int_{r_2}^{r_1} dz_1\int_{z_1}^1 dz_2\right] = -\frac{1}{6} \sqrt{r} \left(2 r^{5/2}+r-3\right)
\end{align}
$$
after I substitute the definitions of $r_1$, $r_2$. In the first line, $\theta(x)$ is the Heaviside step function.
This is the correct expression of the probability, as can be seen by the green curve in the plot.
Comment: Your formula $p(E_1 \cap E_2 \cap E_3) = \frac{1}{n} P(E_1 \cap E_3 \mid E_2)$ seems wrong, how did you get it?
Comment: I think that formula is right. It is just $p(E_1\cap E_2 \cap E_3) = p(E_2)p(E_1\, \cap E_3|  E_2) $ and $p(E_2)=p(z_2 = m) = 1/n$.
Comment: So $n = 3$? ${}$
Comment: @WilliamM. yes that's right. It's written in the question
Comment: As a general rule of thumb when asking question, be aware that whatever context or notation you are using that is very specific, we (the mathSE community) most likely will not know. For instance, you are writting $n-2$ and $n-1$ instead of $1$ and $2,$ respectively. In your edit, you wrote $\theta$ but nowhere is the definition of $\theta.$ In general, you should abstract your question so that some context is provided and your doubt is stated clearly without much baggage, which quite frankly, is just noise.
Comment: @WilliamM. thank you for your feedback - I have to say that the definition of $n$ was given from the beginning. You are right about the definition of $\theta$, which is the Heaviside step-function
Comment: I don't know about other SE users but for me, I tend to skim the question first. Then I scan for the actual question and see the few lines above and below for notation. When posts are overly long or code heavy, I skip those parts as this is a math forum and not the computer one (which is the original stackoverflow stackexchange).
Comment: I don't know Mathematica, yet I just quickly read your code, you only increase loss when the condition $list[[2]] = max$ is true. Is this correct?
Comment: @WilliamM. yes, because the code is computing the conditional probability. If I want to full probability, I just divide by 3. If I only increase `win` when `list[[2]]=max`and at the very end I set `loss = 10000-win`, I get the same result just divided by 3 (as expected)
Comment: @WilliamM. I have cleaned the code and now it should be very simple. The code is just counting how many times the condition $E_1 \cap E_2 \cap E_3$ is met. I don't see where it should be wrong.
Answer: Your notation is confusing, so I will change it to make it clear.
Let $U_1, U_2$ and $U_3$ be three independent random variables drawn from a uniform distribution on $[0, 1].$ We are interested in
$$
\lambda = \mathbf{P}(U_1 \leq b, U_2 \geq a, U_2 \geq U_1, U_2 \geq U_3),
$$
where $0 < a < b < 1.$ Conditioning on $U_2$ and then using independence, we reach
$$
\begin{align*}
\lambda &= \int\limits_a^1 du_2\ P(U_1 \leq \min(b, u_2), U_3 \leq u_2) = \int\limits_a^1 du_2\ \min(b, u_2) u_2 \\
&= \int\limits_a^b dt\ t^2 + \int\limits_b^1 dt\ bt = \dfrac{b^3-a^3}{3} + \dfrac{b(1-b^2)}{2}.
\end{align*}
$$
Upon setting $a = r$ and $b = \sqrt{r},$ the result will follow:
$$
\lambda = \dfrac{r\sqrt{r}-r^3}{3} + \dfrac{\sqrt{r}(1-r)}{2} = \dfrac{1}{2} \sqrt{r} - \dfrac{1}{6} r\sqrt{r} - \dfrac{1}{3} r^3.
$$
Comment: Are you sure your result is right? It doesn't match my final formula $-\frac{1}{6} \sqrt{r} \left(2 r^{5/2}+r-3\right)$ (and notice that my formula fits the numerical data)
Comment: I checked it twice. I did notice it doesn't match. Again, your notation is just too much to follow. Maybe your code is also wrong and you are estimating something else, IDK. I will not check your code.
Comment: There is a mistake in the second line of your answer.  $\int\limits_a^1 du_2\ \min(b, u_2) u_2 = \int_b^1 dt b t + \int_a^b dt t^2$ which gives my answer.
Comment: That's great! I was also stuck checking my own computations now. And indeed, I messed up the minimum.
Comment: I would like however to compute the probability by just using the PDF of the maximum $m$, that is $f_\text{max}(m) = 3 m^2$


A place to learn about math etymology?

Question: I was recently wondering where the word `kernel' comes from in mathematics.  I am sure the internet must know.  I did manage to find
http://www.pballew.net/etyindex.html#k
which contains the origin of many math words but it doesn't have `kernel'; it also only seems to address math words you might run into in at most a 1st or 2nd year college math course.  I'm wondering if anyone is aware of a reference that might address the origin of more modern math words (but not so modern that it doesn't discuss kernel).
EDIT: By `math etymology' I mean why a particular word was used for a certain math concept.  Of course such an explanation might involve discussing the actual etymology of the word.
Comment: Did you want to know about kernel in algebra or in analysis?
Comment: If you had typed "etymology" in the search box at the top of the page you'd have found references to Jeff Miller's list in prior posts here.
Answer: You'll want to check out Earliest Known Uses of Some of the Words of Mathematics, maintained by Jeff Miller.  In particular, an entry for 'kernel' appears here.
Comment: That earliest known use doesn't explain why the word kernel was chosen in algebra.
Comment: @KCd: That's true, nor does it give any reason to think that Pontrjagan's use was first.  I was a bit surprised that the answer was accepted.
Answer: It's unclear if you want to discuss the reason for a particular choice of a word (whether coined or borrowed), or the etymological meaning of the word. For example, "kernel" is a perfectly fine English word, refering to a whole seed of a cereal (the word coming from the Indo-European root greno-). But the etyomological origin is somewhat different from the reason why it was chosen to refer to the particular mathematical concept it refers to.
One source for the etymology (and sometimes mathematical origin) is The Words of Mathematics: An Etymological Dictionary of Mathematical Terms Used in English, by Steven Schwartzmann, published by the Mathematical Association of America. It will tell you things like what the Latin origin of "conjecture" is, and so on. It does not provide much in the way of historical mathematical origin (i.e., why the word was chosen for that particular concept). Sometimes this is clear from the origin of the word, but often this is not the case.
Comment: @solbap: Yes, it's now clear. I had high hopes for Schwartzmann's book when I bought it, but I find that it is disappointing for modern words such as kernel and coset. For "classical" words (parameter, polygon, etc) it's pretty good, though.
Comment: Hopefully I've clarified things in the question.  I meant the former.  And thanks for the answer but maybe not quite what I'm looking for.

A place to learn about math etymology?


Extrair Arquivos Especificos com C# Windows Form

Question: Boa Tarde Pessoal,
Tenho uma duvida e espero que vocês possam me ajudar.
Adicionei ao meu projeto, um arquivo ZIP com arquivos dentro.
Preciso compilar esse arquivo zip junto com o programa.
Depois de compilado o programa, ao clicar em um botão, o programa extrairá os arquivos que estão dentro do arquivo ZIP em uma pasta especifica.
Gostaria de saber qual código utilizar para realizar tal processo.
Answer: Boa tarde Andrey
O que eu faria nesse caso:

Renomearia o arquivo .zip para outra extensão. (Ex. .data, .bin, etc...)
Alteraria a propriedade "Copy to Output Directory" para "Copy Always", com isso o arquivo sempre irá para o seu diretório de output na hora do build e do publish
Agora sua aplicação pode descompactar o arquivo utilizando a classe System.IO.Compression.ZipFile(https://docs.microsoft.com/pt-br/dotnet/api/system.io.compression.zipfile?view=netframework-4.8).

Obs. Não tenho certeza de que a classe ZipFile consegue descompactar arquivos com outra extensão que não seja .zip. Caso tenha problema com isso, é só renomear o arquivo utilizando System.IO.File.Move (https://docs.microsoft.com/pt-br/dotnet/api/system.io.file.move?view=netframework-4.8)
Isso pode parecer uma gambiarra, mas não é uma prática tão incomum, afinal os próprios arquivos do nuget são .zip com outra extensão.


Possible to do some kind of statistical analysis without N?

Question: So the thing is that I got some good data for my research project, but the problem is that the data I got only have percentages and standard errors, but no population (N). I would need to do some statistical analysis, so I was wondering if the data I got is useless for this purpose?
I am aware that this might be a lame question, but I have spent a lot of hours trying to find other datasets with a population with no luck, so I am kinda desperate.
Comment: Your use of the term "population" is confusing. Do you really mean that $N$ is the *sample* size?
Comment: Yes, N is the sample size.
Answer: The estimated standard error SE = $\sqrt{\frac {\hat p (1-\hat p)}N}$. Given you have SE and $\hat p$, $N=\frac {\hat p (1-\hat p)}{\text{SE}^2}$. So if you need $N$, you can get it.
Comment: It seems your data really has problem. 0.977 means 0.977% or 97.7%? 0.98 means 0.98% or 98%?
Comment: Did you get the $N$s? So my answer is correct?


Why does removing the constant term prevent the dummy variable trap?

Question: I understand that if you have a dummy variable with $m$ categories that you should include $m-1$ categories in order to avoid perfect collinearity between regressors. However I don't understand why removing the constant term prevents the issue of perfect collinearity, because all of the categories will still sum to 1.
For example: Suppose we have a dummy variable 'gender', with the categories being male and female. If we include both categories in the model without an intercept, the model is given by $y = \beta_1male + \beta_2female$.
Don't we still have the issue of perfect collinearity because $male + female = 1$? We could rewrite this as $male = 1 - female$ so the regressors are still perfectly collinear because there is an exact linear relationship between them. How has removing the intercept helped us?
(I am yet to learn about matrix algebra, so please provide answers that do not require knowledge of matrix algebra if possible).
Answer: When we perform linear regression with the constant term (intercept), we actually are moving the origin (the anchoring point which the prediction line will come through) to the data cloud centroid (the mean). Both X variable(s) and the Y variable get centered.
Let us take your example with predictor gender making two X dummies, female and male. When they are centered (and scaled), their scalar product is $-1$. Below I'm showing the two dummies - original on the left and them after centering (and also scaling), on the right.
  Original dummies   Standardized (centered-then-scaled) dummies
   female    male           female      male
       1        0            .802       -.802
       1        0            .802       -.802
       1        0            .802       -.802
       1        0            .802       -.802
       0        1          -1.069       1.069
       0        1          -1.069       1.069
       0        1          -1.069       1.069
    scalar prod. = 0        scalar prod. = -1

   Scaled dummies
    female    male
     .500     .000
     .500     .000
     .500     .000
     .500     .000
     .000     .577
     .000     .577
     .000     .577
    scalar prod. = 0

One of the things we need in regression is to compute scalar product between the predictors.
Scalar product of centered variables is the covariance and of centered & scaled ones is the correlation. And it equals $-1$. This is the mark of their collinearity: both vectors, male and female, lie on the common straight line (and face opposite directions). Since they are collinear, one of them is redundant as a predictor, for them two span only 1D space. (It is like on the second pic here, except that X1 and X2 vectors are directed oppositely in our case.)
But when we perform linear regression without the constant term, we leave origin on its place. We force the prediction line to pierce the anchor there where it was, not at the data centroid. We don't center, neither Y nor X variables.
Since we thus don't center the dummies, we compute the scalar product between the dummies as they were, raw. But look, their scalar product is $0$, not $-1$. If we scale them and compute scalar product - it is then called cosine similarity - it'll still be $0$. The $0$ means the two vectors, male and female, are orthogonal; they do not at all lie on one same line. That means they are not collinear, they form a 2D space.
That is why we may enter both dummies as predictors in linear regression containing no intercept.
Answer:
Don't we still have the issue of perfect collinearity because  +  = 1?

You would as the levels sum to unity. But software will invariably force a referent. In R, for example, the intercept is whichever level is next in order.

How has removing the intercept helped us?

It is almost never a good idea to manually remove the intercept. You're forcing the linear relationship (approximation) to go through the origin. Here is your model:
$$
y = \beta_0 + \beta_1 \text{Gender} + \epsilon,
$$
where setting the condition that $\beta_0 = 0$ is presupposing that the expected value of your outcome $y$ when $\text{Gender} = 0$ is naught. You also may find your $R^{2}$ go through the roof, which has nothing to do with a better model fit. I suppose we should try a few models to see this in action. Here is some fake data:
library(dplyr)

set.seed(13)

n <- 20

fake_df <- data.frame(
  gender = sample(c("male", "female"), size = n, replace = TRUE),
  y = rnorm(n, 100, 20)
  ) %>%
  mutate(male = ifelse(gender == "male", 1, 0))

First, try regressing y on gender. The level denoting females is absorbed into the intercept. Note the value of each category is appended to the variable name in the model summary. See the output below:
summary(lm(y ~ gender, data = fake_df))

Coefficients:
            Estimate Std. Error t value Pr(>|t|)
(Intercept)   97.028      5.885  16.486 2.63e-12 ***
genderm       -7.190      9.948  -0.723    0.479
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 21.22 on 18 degrees of freedom
Multiple R-squared:  0.0282,    Adjusted R-squared:  -0.02579
F-statistic: 0.5224 on 1 and 18 DF,  p-value: 0.4791

Dropping the intercept, we now force a referent. Note we can achieve the same result by replacing 0 with a -1. I suppose specifying 0 after the tilde is more explicit given this demonstration. See below:
summary(lm(y ~ 0 + gender, data = fake_df))

Coefficients:
        Estimate Std. Error t value Pr(>|t|)
genderf   97.028      5.885   16.49 2.63e-12 ***
genderm   89.838      8.020   11.20 1.52e-09 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 21.22 on 18 degrees of freedom
Multiple R-squared:  0.9567,    Adjusted R-squared:  0.9518
F-statistic: 198.6 on 2 and 18 DF,  p-value: 5.403e-13

Incorporating separate categorical variables for each level without dropping the intercept results in redundancies; one level must be discarding. However, manually dropping the intercept forces a referent (i.e., male or female), which consequently shifts the origin.
In practice, you should dummy code your variables. It will clearly show what each variable denotes. The following output is equivalent to the first model:
summary(lm(y ~ male, data = fake_df))

Coefficients:
            Estimate Std. Error t value Pr(>|t|)
(Intercept)   97.028      5.885  16.486 2.63e-12 ***
male          -7.190      9.948  -0.723    0.479
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 21.22 on 18 degrees of freedom
Multiple R-squared:  0.0282,    Adjusted R-squared:  -0.02579
F-statistic: 0.5224 on 1 and 18 DF,  p-value: 0.4791

Here, male is a dummy variable. In words, males equal 1, 0 otherwise. Once we drop the intercept, we assume a restriction that we cannot know for certain is true. We assume we know the expected value of $y$ given a person is female (i.e., male == 0) is zero. We cannot know this in practice. See below:
summary(lm(y ~ 0 + male, data = fake_df))

Coefficients:
     Estimate Std. Error t value Pr(>|t|)
male    89.84      31.32   2.868  0.00984 **
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 82.87 on 19 degrees of freedom
Multiple R-squared:  0.3021,    Adjusted R-squared:  0.2654
F-statistic: 8.226 on 1 and 19 DF,  p-value: 0.009845

In sum, while we removed the collinearity problem by dropping the intercept, we introduced a whole new set of problems. Again, we often don't know the intercept is equal to 0. If it isn't, then your residuals will be biased. By leaving in the intercept, we ensure the mean of the residuals is zero.


"An existing connection was forcibly closed by the remote host" when trying to connect to azure sql server

Question: I'm trying to deploy a SQL database to my azure SQL server. When I'm trying to connect to my target server, I get the error listed below. I'm using Microsoft SQL Server management studio 18 with Windows 10 1909. Any suggestions?
===================================
Cannot connect to quickkartserver1.database.windows.net.
===================================
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.) (.Net SqlClient Data Provider)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=10054&LinkId=20476

Server Name: quickkartserver1.database.windows.net
Error Number: 10054
Severity: 20
State: 0

Program Location:
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection) at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource1 retry, DbConnectionOptions userOptions) at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at Microsoft.SqlServer.Management.Dac.DacWizard.WizardUtility.VerifyConnection(UIConnectionInfo ci, IServerType serverType)
at Microsoft.SqlServer.Management.UI.ConnectionDlg.Connector.ConnectionThreadUser()
===================================
An existing connection was forcibly closed by the remote host
Comment: Could you please clarify what kind of firewall rules are running on your azure?
Answer: I'm closing this question. I found a work around by transferring my project to a laptop that can connect to the sql server. Thank you.


Plugin que aplica zoom quando passar mouse

Question: Tenho uma página interna de produtos, o qual o layout está como abaixo:

O que preciso é que, quando a pessoa passe o mouse em cima do quadrado menor, ele mostre a imagem grande em cima e aplique um zoom quando a pessoa passar um mouse em cima da imagem grande. Estava analizando o plugin cloud-zoom.1.0.2.js, porém ele é pago. Alguém já utilizou algum parecido?
Answer: Uma breve pesquisa no Google me devolveu bons resultados:

Elevate Zoom: http://www.elevateweb.co.uk/image-zoom/examples - Zoom interno e externo, diversas customizações de posicionamento de divs, customização do cursor durante o zoom, zoom com a roda do mouse, etc. Licença Dual MIT e GPL.
Easy Zoom: http://i-like-robots.github.io/EasyZoom/ - Plugin simples com zoom em overlay e externo. Licença MIT.
SwinxyZoom: http://www.swinxyapps.com/pages/apps/swinxy-zoom/ - Plugin para Zoom interno, externo, lente e arrastando o mouse (todos com controle externo de ampliação). Licença comercial (£4.00) ou Creative Commons não comercial com atribuição.
Comment: Muito obrigado. Eu estava procurando por algum termo que me levava apenas àquele plugin que era pago. Valeu!
Answer: Pra não tornar essa pergunta baseada em opinião de qual plugin usamos, irei mostrar um exemplo:
Você pode utilizar a biblioteca Zoom do Jack Moore, existe uma documentação aqui
Código Fonte do meu exemplo:
jQuery:
$( '.smallPicture li img' ).hover(function(){
    src = $(this).attr("src");
    $( '.bigPicture img' ).attr("src", src);

});
$( '.bigPicture img').hover(function(){
    src = $(this).attr("src");
    $('.bigPicture').zoom({url: src});
});

HTML:

CSS:
.bigPicture{
    display: block;
    height:200px;
    width:200px;
}

.smallPicture li{
    margin: 0;
    padding: 0;
    max-height:90px;
    max-width:90px;
    float: left;
    display: inline;
}

Exemplo online: JSFiddle

CUIDADO:   A Zoom apenas aceita: , ,
,
. Isso
  quer dizer que não funcionará em elemento .


JQuery serialize & unserialize

Question: Anyone provide me with an example to serialize and unserialize a form in jquery?
Comment: Here's a script to help with unserialization and repopulation of the original form: https://github.com/kflorence/jquery-deserialize
Answer: http://api.jquery.com/serialize/
<code>$('#form-id').serialize()
</code>
returns a string joining all the name=value pairs. Are you aware of the api?

JQuery serialize & unserialize


Does Chi-square test for independence (sklearn.feature_selection.SelectKBest) produce incorect results?

Question: When looking for correlation between features (for feature selection), I found that sklearn implementation of Chi2 test of independence produce significantly different results from scipy.stats implementation.
My data contains 300 records, with 6 anonymized categorical features and the label. My focus is on the feature A. This data is available here in github. In the folder, see the file sample300.csv, alongside the notebook with my testing code.
For the feature A, sklearn's SelectKBest() returned the lowest ranking, suggesting there is no correlation between A and label. But scipy.stats.chi2_contingency() returned very different result, suggesting the correlation is very high.
Because of mismatch between the two, I went a long way performing a number of different tests described in detail in this article The results suggest that the scipy implementation is correct, while sklearn implementation is incorrect.
This conclusion surprising, given the popularity of sklearn.feature_selection_SelectKBest.
Why are the two implementations of chi2 producing contradicting results? Did I make a methodical error somewhere or is this really a bug? I am looking forward for some critical peer review.
Answer: The bug report mentioned in the linked article has been since closed by this commit. This wasn't a case of faulty implementation, but at worst a case of unclear documentation.
Back then, the SelectKBest function was a wrapper around the sklearn chi2 function, which does not conduct a chi-squared test of independence at all, but a sort of chi-squared goodness-of-fit test.
The purpose of the sklearn chi2 function seems to be a common source of confusion, which has been adressed in this other answer: Pearson chi2 tests of independence: differences between Scipy and Scikit-learn
While there is no inconsistency or error in the Sklearn's chi2 function once you understand how it works, it has still a quite idiosyncratic purpose and syntax. I'd recommend using scipy instead to anyone looking for something simple in Python. From my experience, their implementations of chi-squared tests are perfectly reliable, and consistent with other statistical software: chi-squared goodness-of-fit test and chi-squared test of independence.
Answer: You should go back to the literature on Chi2 tests and about what they can tell you, and in this case what they cannot tell you. It's a reasoning issue in your case.
Indeed, the test will tell you that there is a strong correlation between experience and success. But that it doesn't tell you there isn't one between education and succes doesn't necessarily mean there isn't one. You are working under the assumption that education and experience are the only determinant factors of success, which is wrong. You are not controlling for all other factors that are predictors of success, some of which might not be observable (e.g., personality traits such as conscienciousness). Many of them are strongly correlated to education and as long as you are not taking them into account, you can say nothing about the importance of education in success.
In order words, you are using this python-package and the test it uses in the wrong way.
 Update after comment : But scipy and sklearn implement chi2 in slightly different ways to begin with. This is a known difference between the two methods.  However, this does not give huge differences between the results.  (https://stackoverflow.com/questions/50932433/scipy-and-sklearn-chi2-implementations-give-different-results).
Whether A and B are education and experience or not, you should still be careful to control for all variables.
Comment: I appreciate this answer. This tells me clearly that I might have misled some readers so I want to add this clarification: The original meaning of feature A does not matter. In the article (meant for general public) I called this feature 'education' to build a story. But here let's just call it feature A and forget about its business meaning. The meaning does not matter. The question I am struggling to answer is: why two implementations of chi-square return different results?
Comment: Yes, I saw that thread too (regarding your Update note). There are a few more. I am not surprised that slight differences may exist between two implementations of the same theoretical process. I saw this often in the past with other packages too. Many things, such as the nature of floating point operations may play a role and it should be accepted.  But the difference I am seeing is so dramatic, and shifts the business conclusions so radically that I cannot just gloss over it. Heck, I feel I am doing something wrong, if I only knew what.
Answer: As follow-up to this thread I posted a bug report to Scikit-Learn.
And yes, yesterday this issue has been confirmed as the bug in Scikit-Learn. Indeed, the results of SelectKBest are incorrect, and this may possibly be impacting a large number of ML projects worldwide. I described the details and the possible temporary remedies in this article.


Start and stop one systemd unit with another

Question: I have two services A.service and B.service. I want B to be stopped when A exits/get killed/is stopped. Also, I want B to get restarted when A gets restarted. I tried out the answer given in
How to start and stop a systemd unit with another? and set my files up as follows:-
A.service
[Unit]
Description=A
Before=B.service
Requires=B.service
[Service]
ExecStart=/usr/share/A
ExecStopPost=/usr/evo/exit_handler.sh %p
Restart=always
StartLimitBurst=3
StartLimitInterval=300

B.service
[Unit]
Description=B
BindsTo=A.service

[Service]
Type=forking
ExecStart=/usr/share/B start
ExecStop=/usr/share/B stop
StartLimitBurst=5
StartLimitInterval=10
Restart=always

When I kill A or do a systemctl restart A, I see that B gets restarted. But when A exits with status 0, I don't see B getting restarted. I have enabled systemd debug loggin and I see that the state of A changes to dead but not to auto-restart
Answer: Your B unit is using BindsTo=, which is meant to track the state of a unit that may disappear.
What you want instead of this is PartOf=, where this service will exactly track the status of the named service. From the documentation:

PartOf=
Configures dependencies similar to Requires=, but limited to stopping and restarting of units. When systemd stops or restarts the units listed here, the action is propagated to this unit. Note that this is a one-way dependency — changes to this unit do not affect the listed units.

I don't think this will fix all your problems, though. I suspect you haven't carefully enough considered the actual dependencies between your two services, and will need to do some more thinking (and be able to express yourself) before you can make these units do what they need to do.
Comment: Think carefully about which service actually depends on the other, how each behaves in the absence of the other, or when the other crashes.
Comment: Thanks! I will try that out. Could you elaborate on these problems though?
Answer: In the [Unit] section PropagatesReloadTo=, ReloadPropagatedFrom=, PropagatesStopTo= and StopPropagatedFrom= can be used to define relationships like this.


Linear combination with unknown integers

Question: Suppose I have three vectors,$$\mathbf{u}=<1,3,-4,0,1>\\\mathbf{v}=<4,-1,0,0,-3>\\\mathbf{w}=<-4,3,-2,x-2y,2x>$$ where x and y are integers. How could I find the value of x and y so that w would be a linear combination of u and v?
Comment: Notice that $x-2y$ has to be $0$.
Answer: So you want $\alpha$ and $\beta$ such that
$$\mathbf{w}=\alpha \mathbf{u}+\beta \mathbf{v}.$$
This gives a system of equation :
\begin{cases}
-4 = \alpha +4\beta  \\
3 = 3\alpha -\beta\\
-2=-4\alpha \\
x-2y = 0\\
2x = \alpha -3\beta
\end{cases}
The three first equations show you that you can't have $\alpha,\beta$ such that $\mathbf{w}=\alpha \mathbf{u}+\beta \mathbf{v}.$
Therefore, there is no $x,y$ as wanted.


Como abrir nova janela somente se a mesma já não estiver aberta?

Question: A pergunta correta seria: como Abrir apenas uma instância dessa janela.
a respeito do programa é um WPF e a linguagem é VB.NET
Atualmente o código a seguir não me serve, porque se o usuário clicar 10 vezes no botão vai se abrir 10 janelas
levando em conta que Window1 é meu arquivo Window1.xaml
Dim newWindow As New Window1
newWindow.Show()

no windows forms seria só colocar window1.show direto sem serimonia, que se o form ja estivesse aberto ele vinha para cima e se o forme estivesse fechado ele reabriria, mas nada de novas janelas, já no WPF eu não consigo o mesmo resultado
Comment: Veja se [isso](https://stackoverflow.com/questions/15439440/check-if-form-is-opened) ajuda ;)
Answer: Aproveitando a indicação do colega Tuxpilgrim, veja se o seguinte código o ajuda:
Dim newWindow As Window1

newWindow = Application.OpenForms().OfType(Of Window1).FirstOrDefault

If newWindow Is Nothing Then
    newWindow = New Window1
    newWindow.Show()
Else
    newWindow.Select
End If


Asymptotic expansion of a hypergeometric function

Question: Find the asymptotic expansion of
$$
{}_2F_1\left(2v,v+n,2v+n,1-\tau/n \right), \quad n \to \infty
$$
where $v,\tau > 0$.
My first attempt was to consider a fix value $z$ and then look at the limit $z\to 1^{-}$. Using the integral representation here, one has
\begin{align*}
{}_2F_1\left(2v,v+n,2v+n,z \right) &= \frac{\Gamma(2v+n)}{\Gamma(v+n)\Gamma(v)} \int_0^1 t^{v+n}(1-t)^{v-1}(1-zt)^{-2v} dt \\ & = \frac{\Gamma(2v+n)}{\Gamma(v+n)\Gamma(v)} \int_0^{\infty} e^{-nu}q(u)du
\end{align*}
with the variable substitution $u=-\ln t$ and $q(u) = e^{-(v+1)u}(1-e^{-u})^{v-1}(1-ze^{-u})^{-2v}$. Then, by Watson's lemma, one may evaluate and e.g. the two first terms of the integral becomes
$$
\int_0^1 t^{v+n}(1-t)^{v-1}(1-zt)^{-2v} dt  \sim \frac{\Gamma(v)(1-z)^{-2v}}{n^v} - (1-z)^{-2v-1}(z(v-1)+3v+1)\frac{\Gamma(v+1)}{2n^{v+1}}
$$
Now, the issue is that from here, the expression works fine when $z$ is smaller than $1$ but in the limit $z\to 1^{-}$, the expansion fails to be useful when I compare with numerical results.
Suggestions on how to handle this are much appreciated!
Answer: Assume $\operatorname{Re}  v > 0$, $|\arg \tau|<\pi$ and $n\gg |\tau|$. By $(15.8.1)$,
$$
F(2v,v + n,2v + n,1 - \tau /n) = \left( {\frac{n}{\tau }} \right)^{2v} F(2v,v,2v + n,1 - n/\tau ).
$$
Then, by $(15.6.1)$,
\begin{align*}
\left( {\frac{n}{\tau }} \right)^{2v} F(2v,v,2v + n,1 - n/\tau ) & = \left( {\frac{n}{\tau }} \right)^{2v} \frac{{\Gamma (2v + n)}}{{\Gamma (v)\Gamma (v + n)}}\int_0^1 {\frac{{t^{v - 1} (1 - t)^{v + n - 1} }}{{(1 - (1 - n/\tau )t)^{2v } }}{\rm d}t}
\\ & = \left( {\frac{n}{\tau }} \right)^{2v} \frac{{\Gamma (2v + n)}}{{\Gamma (v)\Gamma (v + n)}}\frac{1}{{n^v  }}\int_0^n {\frac{{s^{v - 1} (1 - s/n)^{v + n - 1} }}{{(1 - s/n + s/\tau )^{2v } }}{\rm d}s} .
\end{align*}
By the dominated convergence theorem, $(13.4.4)$ and $(13.2.40)$,
\begin{align*}
\int_0^n {\frac{{s^{v - 1} (1 - s/n)^{v + n - 1} }}{{(1 - s/n + s/\tau )^{2v } }}{\rm d}s}  \to \int_0^{ + \infty } {\frac{{s^{v - 1} {\rm e}^{ - s} }}{{(1 + s/\tau )^{2v } }}{\rm d}s} & =\tau ^v \Gamma (v )\,U(v,1 - v,\tau )\\ &=
\tau ^{2v} \Gamma (v )\, U(2v,v + 1,\tau )
\end{align*}
as $n\to+\infty$, where $U$ is the Kummer function. By $(5.11.12)$,
$$
\frac{{\Gamma (2v + n)}}{{\Gamma (v + n)}} \sim n^v
$$
as $n\to+\infty$. Accordingly,
$$
F(2v,v + n,2v + n,1 - \tau /n) \sim  n^{2v} U(2v, v+1,\tau )
$$
as $n\to+\infty$.
Comment: Thank you @Gary for your solution! I found it very clean and something I can learn from on how you used the DCT!