Is there an easy way to write a generator to generate all lists that are k elements long, where each element ranges from 1 to n?  So if k=3 and n=3, it would generate  [1,1,1] [1,1,2] [1,1,3] [1,2,1] [1,2,2] [1,2,3] [1,3,1] ... [3,3,1] [3,3,2] [3,3,3]
How can I get the Cartesian product (every possible combination of values) from a group of lists?  Input:   somelists = [    [1, 2, 3],    ['a', 'b'],    [4, 5] ]   Desired output:  [(1, 'a', 4), (1, 'a', 5), (1, 'b', 4), (1, 'b', 5), (2, 'a', 4), (2, 'a', 5) ...]
I can show this best by a picture:    This cross also shows when I export it as raster or pdf. What is it and how can I get rid of it?  I am using Qgis 2.4 and the map was done with the help of the Grass plugin AniMove on Linux Mint. Align cout format as table's columns I'm pretty sure this is a simple question in regards to formatting but here's what I want to accomplish:  I want to output data onto the screen using cout.  I want to output this in the form of a table format.  What I mean by this is the columns and rows should be properly aligned.  Example:  Test                 1 Test2                2 Iamlongverylongblah  2 Etc                  1   I am only concerned with the individual line so my line to output now (not working) is  cout &lt;&lt; var1 &lt;&lt; "\t\t" &lt;&lt; var2 &lt;&lt; endl;  Which gives me something like:  Test                 1 Test2                  2 Iamlongverylongblah         2 Etc                  1 Is right hand rule arbitrary? In definition of vector multiplication, the direction of the resulting vector is given by the right hand rule. However I don't know any mathematical requirement to pick right hand instead of left for this purpose. Is there any? Riemann integrabilty of an indicator function Consider the following function on $[0,1]$:   $$f(x)=\begin{cases}1&amp;x\in\{a_1,a_2,\dots,a_n\}\\0 &amp;\text{otherwise}\end{cases}$$   The $a_i$ are fixed and all in $[0,1]$. Determine whether $f$ is Riemintegrable or not.   By the Riemann&ndash;Lebesgue criterion $f$ is Riemann integrable. How to prove directly? Choosing between LM and GLM for a log-transformed response variable I'm trying to understand the philosophy behind using a Generalized Linear Model (GLM) vs a Linear Model (LM). I've created an example data set below where:  $$\log(y) = x + \varepsilon $$   The example does not have the error $\varepsilon$ as a function of the magnitude of $y$, so I would assume that a linear model of the log-transformed y would be the best. In the example below, this is indeed the case (I think) - since the AIC of the LM on the log-transformed data is lowest. The AIC of the Gamma distribution GLM with a log-link function has a lower sum of squares (SS), but the additional degrees of freedom result in a slightly higher AIC. I was surprised that the Gaussian distribution AIC is so much higher (even though the SS is the lowest of the models).   I am hoping to get some advice on when one should approach GLM models - i.e. is there something I should look for in my LM model fit residuals to tell me that another distribution is more appropriate? Also, how should one proceed in selecting an appropriate distribution family.   Many thanks in advance for your help.  [EDIT]: I have now adjusted the summary statistics so that the SS of the log-transformed linear model is comparable to the GLM models with the log-link function. A graph of the statistics is now shown.  Example  set.seed(1111) n &lt;- 1000 y &lt;- rnorm(n, mean=0, sd=1) y &lt;- exp(y) hist(y, n=20) hist(log(y), n=20)  x &lt;- log(y) - rnorm(n, mean=0, sd=1) hist(x, n=20)  df  &lt;- data.frame(y=y, x=x) df2 &lt;- data.frame(x=seq(from=min(df$x), to=max(df$x),,100))   #models mod.name &lt;- "LM" assign(mod.name, lm(y ~ x, df)) summary(get(mod.name)) plot(y ~ x, df) lines(predict(get(mod.name), newdata=df2) ~ df2$x, col=2)  mod.name &lt;- "LOG.LM" assign(mod.name, lm(log(y) ~ x, df)) summary(get(mod.name)) plot(y ~ x, df) lines(exp(predict(get(mod.name), newdata=df2)) ~ df2$x, col=2)  mod.name &lt;- "LOG.GAUSS.GLM" assign(mod.name, glm(y ~ x, df, family=gaussian(link="log"))) summary(get(mod.name)) plot(y ~ x, df) lines(predict(get(mod.name), newdata=df2, type="response") ~ df2$x, col=2)  mod.name &lt;- "LOG.GAMMA.GLM" assign(mod.name, glm(y ~ x, df, family=Gamma(link="log"))) summary(get(mod.name)) plot(y ~ x, df) lines(predict(get(mod.name), newdata=df2, type="response") ~ df2$x, col=2)  #Results model.names &lt;- list("LM", "LOG.LM", "LOG.GAUSS.GLM", "LOG.GAMMA.GLM")  plot(y ~ x, df, log="y", pch=".", cex=3, col=8) lines(predict(LM, newdata=df2) ~ df2$x, col=1, lwd=2) lines(exp(predict(LOG.LM, newdata=df2)) ~ df2$x, col=2, lwd=2) lines(predict(LOG.GAUSS.GLM, newdata=df2, type="response") ~ df2$x, col=3, lwd=2) lines(predict(LOG.GAMMA.GLM, newdata=df2, type="response") ~ df2$x, col=4, lwd=2) legend("topleft", legend=model.names, col=1:4, lwd=2, bty="n")   res.AIC &lt;- as.matrix(     data.frame(         LM=AIC(LM),         LOG.LM=AIC(LOG.LM),         LOG.GAUSS.GLM=AIC(LOG.GAUSS.GLM),         LOG.GAMMA.GLM=AIC(LOG.GAMMA.GLM)     ) )  res.SS &lt;- as.matrix(     data.frame(         LM=sum((predict(LM)-y)^2),         LOG.LM=sum((exp(predict(LOG.LM))-y)^2),         LOG.GAUSS.GLM=sum((predict(LOG.GAUSS.GLM, type="response")-y)^2),         LOG.GAMMA.GLM=sum((predict(LOG.GAMMA.GLM, type="response")-y)^2)     ) )  res.RMS &lt;- as.matrix(     data.frame(         LM=sqrt(mean((predict(LM)-y)^2)),         LOG.LM=sqrt(mean((exp(predict(LOG.LM))-y)^2)),         LOG.GAUSS.GLM=sqrt(mean((predict(LOG.GAUSS.GLM, type="response")-y)^2)),         LOG.GAMMA.GLM=sqrt(mean((predict(LOG.GAMMA.GLM, type="response")-y)^2))     ) )  png("stats.png", height=7, width=10, units="in", res=300) #x11(height=7, width=10) par(mar=c(10,5,2,1), mfcol=c(1,3), cex=1, ps=12) barplot(res.AIC, main="AIC", las=2) barplot(res.SS, main="SS", las=2) barplot(res.RMS, main="RMS", las=2) dev.off() How do I get powdered mammoth tusk? Am I missing something? I can find plenty of tusks, but I just don't know if I can make them into powder myself or do I have to find them for sale? This is Baby Rudin exercise 7 of Chapter 3. Prove that the convergence of $\sum{a_n}$ implies the convergence of $\sum{\sqrt {a_k} \over k}$ if $a_n \ge 0$.  Proof:  I will attempt to show that the cauchy criterion is met so $${\sum_{k=n}^m {\sqrt {a_k} \over k}} \le \epsilon $$ for all $n,m \le N_1$. Im disregarding the absolute value since its all positive terms.   Since $\sum{a_n}$ converges, we know that the $\lim \limits_{n \to \infty} a_n =0$ So there exists some $N_2$ such that for all $n \ge N_2$, $$   a_n \lt \ {{(m-n)}^2k^2(\epsilon)^2} $$ I am again disregarding the absolute values because its always positive Let N=max{$N_1,N_2$} then for all $n,m \ge N$ $$\sum_{k=n}^m {\sqrt {a_k} \over k} \le \sum_{k=n}^m {\sqrt {{(m-n)}^2k^2(\epsilon)^2} \over k} \le \sum_{k=n}^m{(m-n)(\epsilon)} = \epsilon $$  Maybe this is just crazy, should I just use Cauchy-Schwarz inequality and forget about this or could I possibly make this method work? Is there any evidence or reason why FIFA is so against adding instant replay to soccer? I find myself seeing many unlucky or just plain wrong decisions made by refs that could be corrected with instant replay. A non-trivial, non-negative, function bounded below by its derivative with $f(0)=0$? I did not know what to search to see if this existed elsewhere. But, I could not find it. Here's the question:  Does there exist a continuously differentiable function, $f: [0,1] \rightarrow [0, \infty)$, such that the following hold? (i) $f(0) = 0$ (ii) $f'(x) \le c f(x)$ for all $x$ ($c$ is a fixed constant) (iii) $f \not\equiv 0$  This was a fun problem someone asked me a long time ago. I have always been convinced there is no such function, but I cannot prove it. I have mainly tried using the mean value theorem (in multiple forms), and re-wording the problem in terms of the integral of a continuous function to no avail. I spent some time trying to use (ii), the definition of derivative, and squeeze theorem, but no luck. After much time trying to prove non-existence, I spent a little time trying to find such a function... also with no luck. This problems ability to avoid being solved has since taken away the original fun and replaced it with a twinge of annoyance. Content type permission to specific users How do I set content permission so that specific content types become visible/usable to the admin user only, while other content types may be visible by other user roles?  After I added new content types, I checked the rebuild permissions.   Content access is working fine but the problem seems to be the fact that the enw content types aren't made visible / accessible to the other roles... Have the guys from the show Impractical Jokers gotten into any major trouble because of the nature of their show?   Eg: have they been physically assaulted or has anyone thrown a law suit on them? Is it safe to give out one's bank account number? I'm managing the utility of the house and I'm sharing with another person. He asks me to provide my bank account number, so that he can transfer his money to my account when paying the utility.    I wonder if it is safe to give out my bank account number?   For example, if I'm correct, many online payments just need the account number to draw money out of it. Is giving out the bank account number safer than handing a check to another person, since there is also the account number printed on the check? Is there something wrong with VertexConnectivity What's the purpose (if any) of "javascript:" in event handler tags? I've been making a concerted effort to improve my javascript skills lately by reading as much javascript code as I can. In doing this I've sometimes seen the javascript: prefix appended to the front of event handler attributes in HTML element tags. What's the purpose of this prefix? Basically, is there any appreciable difference between:  onchange="javascript: myFunction(this)"   and  onchange="myFunction(this)"   ? Suppose I have BaseClass with public methods A and B, and I create DerivedClass through inheritance.  e.g.  public DerivedClass : BaseClass {}   Now I want to develop a method C in DerivedClass that uses A and B.  Is there a way I can override methods A and B to be private in DerivedClass so that only method C is exposed to someone who wants to use my DerivedClass? OK, I've been having weird problems for the last 1/2 hour trying to  on StackOverflow, and I keep getting this result (on Firefox 3.6)     The connection was reset      The connection to the server was reset while the page was loading.         The site could be temporarily unavailable or too busy. Try again in a few        moments.   If you are unable to load any pages, check your computer's network        connection.   If your computer or network is protected by a firewall or proxy, make sure        that Firefox is permitted to access the Web.      The problem seems to occur when I try to post some code with 'd--- table' in it, where 'd---' is replaced by the word drop.  I cannot post the following 3 lines, in either SO or this site, if they include the well-known SQL statements DROP.  stat.executeUpdate('d--- table if exists people;'); stat.executeUpdate('create table people (name, occupation);'); prep = conn.prepareStatement(...     'insert into people values (?, ?);');   test again:  'dro* table' 'drop ball' drop the table drop fable drop    t*ble droptable   drop a table  The evil words for me are "drop" and "table"... how come you guys can post? :(  edit: Could someone please suggest another online site that is not stackoverflow that is a quick way to try out a POST request of a text field?  UPDATE: Never mind. I don't know what the answer is, but the same problem occurs on Google's website. So it's not stackoverflow. Now to go to my IT Dept... Let $f:S^{2n} \rightarrow S^{2n}$ be a continuous map. Show that          there exists $x \in S^{2n}$, such that $f(x) =x$ or $f(x) = -x$;   any continous map $g: \mathbb R P^{2n} \rightarrow \mathbb RP^{2n}$ has a fixed point;      I think 1 implies 2. So, how can I find an $x$ in 1?  Thanks for the help. Polynomial in $n$ variables Let $f$ be polynomial in $n$ variables. If we have $f(a_1,\ldots,a_n) = 0, a_i \in S_i$ and $S_1,\ldots,S_n$ are infinite subsets of a field $k$, how can I show that $f=0$? Why is 4 not an instance of Number? "thanks for flagging" popup gets messed up when the comment is automatically deleted For some comments, the comment is automatically deleted when you raise a flag. This includes certain keywords and short +1 comments. But when you raise that flag with the new comment flag interface, the "thanks for flagging" shows up in the top right when the comment is deleted:      As opposed to what happens when you raise a flag on a comment that doesn't auto-delete: