What are common statistical sins?

Question: I'm a grad student in psychology, and as I pursue more and more independent studies in statistics, I am increasingly amazed by the inadequacy of my formal training. Both personal and second hand experience suggests that the paucity of statistical rigor in undergraduate and graduate training is rather ubiquitous within psychology. As such, I thought it would be useful for independent learners like myself to create a list of "Statistical Sins", tabulating statistical practices taught to grad students as standard practice that are in fact either superseded by superior (more powerful, or flexible, or robust, etc.) modern methods or shown to be frankly invalid. Anticipating that other fields might also experience a similar state of affairs, I propose a community wiki where we can collect a list of statistical sins across disciplines. Please, submit one "sin" per answer.
Comment: I'm aware that "sin" is possibly inflammatory and that that some aspects of statistical analysis are not black-and-white. My intention is to solicit cases where a given commonly-taught practice is pretty clearly inappropriate.
Comment: You can also add biology/life sciences students to the mix if you like ;)
Comment: maybe retitle it life science statistical sins?... or something else more specific...
Comment: @whuber There was some good answers, so I've merged them both.
Comment: Hi @Amanda, could you give some indication here of what's in the talk? No-one likes the possibility of being rick-rolled.
Comment: I just gave a talk on this subject... A link to the video follows if you are interested. http://www.youtube.com/watch?v=1SNQQvY1ESo&feature=g-upl
Comment: Applying statistics where it doesn't belong is the main sin.
Answer: Failing to look at (plot) the data.
Comment: Very, very important!
Comment: Probably the most common one.
Comment: +1 Well done!  I'm shocked this hasn't been mentioned yet.
Answer: Most interpretations of p-values are sinful! The conventional usage of p-values is badly flawed; a fact that, in my opinion, calls into question the standard approaches to the teaching of hypothesis tests and tests of significance.
Haller and Krause have found that statistical instructors are almost as likely as students to misinterpret p-values. (Take the test in their paper and see how you do.) Steve Goodman makes a good case for discarding the conventional (mis-)use of the p -value in favor of likelihoods. The Hubbard paper is also worth a look.
Haller and Krauss. Misinterpretations of significance: A problem students share with their teachers. Methods of Psychological Research (2002) vol. 7 (1) pp. 1-20 (PDF)
Hubbard and Bayarri. Confusion over Measures of Evidence (p's) versus Errors (α's) in Classical Statistical Testing. The American Statistician (2003) vol. 57 (3)
Goodman. Toward evidence-based medical statistics. 1: The P value fallacy. Ann Intern Med (1999) vol. 130 (12) pp. 995-1004 (PDF)
Also see:
Wagenmakers, E-J. A practical solution to the pervasive problems of p values. Psychonomic Bulletin & Review, 14(5), 779-804.
for some clear cut cases where even the nominally "correct" interpretation of a p-value has been made incorrect due to the choices made by the experimenter.
Update (2016): In 2016, American Statistical Association issued a statement on p-values, see here. This was, in a way, a response to the "ban on p-values" issued by a psychology journal about a year earlier.
Comment: @Michael There are alternative, more generous interpretations of that kind of reporting.  For example, the author might be aware that readers might want to apply their own thresholds of significance and therefore do the flagging of p-values to help them out.  Alternatively, the author might be aware of possible multiple-comparisons problems and use the differing levels in a Bonferroni-like adjustment.  Perhaps some portion of the blame for misuse of p-values should be laid at the feet of the reader, not the author.
Comment: +1, but I would like to make some critical comments.  Regarding the opening line, one could just as well say that "almost all" (in the measure theoretic sense) interpretations of *any* well-defined concept are incorrect, because only one is correct.  Second, to what do you refer when you say "the conventional usage" and "standard approaches"? These vague references sound like a straw man.  They do not accord with what one can find in the literature on statistics education, for example.
Comment: @Whuber I agree entirely, but only that what you suggest is true in some small fraction of cases (a restricted version of 'entirely'). There are some journals that specify that p values should be reported at one, two or three star levels rather than exact values, so those journals share some responsibility for the outcome. However, both that ill-considered requirement and the apparently naive use of p values might be a result of the lack of a clear explanation of the differences between error rates and evidence in the several introductory statistics texts that are on my shelves.
Comment: @Whuber Have a look at the Goodman paper. It accords pretty well with my experience in the field of pharmacology.
Methods say "Results where P<0.05 were taken as statistical significant" and then results are presented with + for p<0.05, ++ for p<0.01 and +++ for p<0.0001. The statement implies the control of error rates a la Neyman and Pearson, but the use of different levels of p suggest Fisher's approach where the p value is an index of the strength of evidence against the null hypothesis. As Goodman points out, you cannot simultaneously control error rates and assess strength of evidence.
Comment: Sadly, my medical boards had a question which encouraged misinterpretation of p-values.  And they refused to correct it even after I contested in a letter.  Insanity.
Comment: @Michael (+1) I added links to abstracts and ungated PDFs. Hope you don't mind.
Comment: @Chi Thanks! I should have done that myself. Next time...
Comment: @Michael All good points; thank you.  And thank you for sharing the references: they make good reading (even though the papers addressed to medical practitioners belabor their arguments).
Comment: @Michael: (+1). The Goodman article was especially insightful in supporting your argument.
Comment: See also: Gigerenzer, G., Krauss, S., & Vitouch, O. (2004). The null ritual. The Sage book of quantitative methodology for the social sciences, 391-408. http://library.mpib-berlin.mpg.de/ft/gg/GG_Null_2004.pdf
Comment: The Haller and Krauss links go to "Aufgerufene Seite unbekannt (404 page not found)"
Answer: The most dangerous trap I encountered when working on a predictive model is not to reserve a test dataset early on so as to dedicate it to the "final" performance evaluation.
It's really easy to overestimate the predictive accuracy of your model if you have a chance to somehow use the testing data when tweaking the parameters, selecting the prior, selecting the learning algorithm stopping criterion...
To avoid this issue, before starting your work on a new dataset you should split your data as:

development set
evaluation set

Then split your development set as a "training development set" and "testing development set" where you use the training development set to train various models with different parameters and select the bests according to there performance on the testing development set. You can also do grid search with cross validation but only on the development set. Never use the evaluation set while model selection is not 100% done.
Once you are confident with the model selection and parameters, perform a 10 folds cross-validation on the evaluation set to have an idea of the "real" predictive accuracy of the selected model.
Also if your data is temporal, it is best to choose the development / evaluation split on a time code: "It's hard to make predictions - especially about the future."
Comment: In general it takes an enormous dataset for data splitting to be reliable.  That's why stringent internal validation with the bootstrap is so attractive.
Comment: I agree with this in principle but in the case of a small data set (I often have only 20-40 cases) use of a separate evaluation set is not practical. Nested cross-validation can get around this but may lead to pessimistic estimates on small data sets
Comment: Especially when the development set is past data and the evaluation set future data. Why not, after all model tuning, train the final model with it's fixed parameters on the entire development set and predict the entire evaluation set with it. In a real scenario, you couldn't cross validate through future data the way you describe anyway, so you would use all relevant past data.
Answer: Reporting p-values when you did data-mining (hypothesis discovery) instead of statistics (hypothesis testing).
Comment: Can you (or someone) elaborate?
Comment: see https://en.wikipedia.org/wiki/Data_dredging
Comment: What about p-values corrected for multiple hypothesis testing (with some flavour of Bonferroni method or a more advanced correction)? I would tend to think it is fine, even in the context of data mining?
Comment: I like the general idea, but it's a distortion to equate statistics with hypothesis testing when the latter is a subset of the former.
Answer: A few mistakes that bother me:

Assuming unbiased estimators are always better than biased estimators.
Assuming that a high $R^2$ implies a good model, low $R^2$ implies a bad model.
Incorrectly interpreting/applying correlation.
Reporting point estimates without standard error.
Using methods which assume some sort of Multivariate Normality (such as Linear Discriminant Analysis) when more robust, better performing, non/semiparametric methods are available.
Using p-value as a measure of strength between a predictor and the response, rather than as a measure of how much evidence there is of some relationship.
Comment: Would you break these out into separate options?
Answer: Testing the hypotheses $H_0:  \mu=0$ versus $H_1: \mu\neq 0$
 (for example in a Gaussian setting)
to justify that $\mu=0$ in a model (i.e mix "$H_0$ is not rejected" and "$H_0$ is true").
A very good example of that type of (very bad) reasoning is when you test whether the variances of two Gaussians are equal (or not) before testing if their mean are equal or not with the assumption of equal variance.
Another example occurs when you test normality (versus non normality) to justify normality. Every statistician has done that in is life ? it is baaad :) (and should push people to check robustness to non Gaussianity)
Comment: The same logic (taking "absence of evidence in favor H1" as "evidence of absence of H1") essentially underlies all goodness-of-fit tests. The reasoning also often crops up when people state "the test was non significant, we can therefore conclude there is no effect of factor X / no influence of variable Y". I guess the sin is less severe if accompanied by reasoning about the test's power (e.g., a-priori estimation of sample size to reach a certain power given a certain relevant effect size).
Comment: I try to be statistically literate and still fall for this one from time to time.

What are the alternatives? Change your model so the old null becomes $H_1$? The only other option I can think of is power your study enough that a failure to reject the null is _in practice_ close enough to confirming the null. E.g. if you want to make sure that adding a reagent to your cells won't kill off more than 2% of them, power to a satisfactory false negative rate.
Comment: Great!! Yes, this drives me crazy..
Comment: If you do not make any concideration about the power, I would say claming $H_0$ is true when it is not rejected is very very bad while claming $H_1$ is true while $H_0$ is rejected is just a little wrong :).
Comment: @DocBuckets equivalence testing with two one sided tests is more rigorous than the power based approach. But you need to set a minimum relevant effect size below which you can speak of practical equivalence.
Answer: Not really answering the question, but there's an entire book on this subject:
Phillip I. Good, James William Hardin (2003). Common errors in statistics (and how to avoid them). Wiley. ISBN 9780471460688
Comment: +1  I made sure to read this book shortly after it came out.  I get plenty of opportunities to make statistical mistakes so I'm always grateful to have them pointed out *before* I make them!
Answer: interpreting Probability(data | hypothesis) as Probability(hypothesis | data) without the application of Bayes' theorem.
Comment: http://en.wikipedia.org/wiki/Prosecutor%27s_fallacy
Answer: Ritualized Statistics.
This "sin" is when you apply whatever thing you were taught, regardless of its appropriateness, because it's how things are done. It's statistics by rote, one level above letting the machine choose your statistics for you.
Examples are Intro to Statistics-level students trying to make everything fit into their modest t-test and ANOVA toolkit, or any time one finds oneself going "Oh, I have categorical data, I should use X" without ever stopping to look at the data, or consider the question being asked.
A variation on this sin involves using code you don't understand to produce output you only kind of understand, but know "the fifth column, about 8 rows down" or whatever is the answer you're supposed to be looking for.
Comment: Unfortunately, if you aren't interested in statistical inference, or are scarce on time and/or resources, the ritual does seem very appealling...
Comment: To me Epigrad's description is of someone who cares inordinately about inference and neglects things such as reflection, discovery, and consideration of causality.
Answer: Dichotomization of a continuous predictor variable to either "simplify" analysis or to solve for the "problem" of non-linearity in the effect of the continuous predictor.
Comment: I don't think this is really a "sin" as the results obtained are not wrong. However, it does throw away a lot of useful information so is not good practice.
Comment: @Iterator you start to get at the real reason to aggregate (to two or more categories), which is **because one has *a priori* theoretical reasons to believe that variance is meaningfully compartmentalized into those categories**. For example, we do this all the time by assuming that collections of a trillion or so cells comprise *an individual*, or that a contiguous 24-hour period here on Earth is meaningfully interpreted as a unit. But arbitrarily aggregation does not just "throw out" information (e.g. statistical power), but can lead to (serious) biases about relationships between phenomena.
Comment: +1 and it becomes a serious sin when they start choosing the dichotomization cutoff so that it optimizes some sort of difference which is then tested.
Comment: This isn't even a sin if there are two or more distinct populations.  Suppose you have separable classes or sub-populations, then it can make sense to discretize.  A very trivial example: Would I rather use indicators for site/location/city/country or lat/long?
Comment: Along these lines, using extreme groups designs over-estimates effect sizes whereas the use of a mean or median split under-estimates effect sizes.
Comment: This one really bugs me.  My clients do this all the time.  And when I point out the error, they understand, but insist on doing it anyway
Comment: @Iterator I for one would rather use lat/long if I had them, and the patience to interpret the results carefully. It could be quite interesting to find fine-grained / dimensional differences within countries or even cities, and it could help reduce residuals if analyzing something that changes dramatically across a border. E.g., even analyses of pro-Palestinian liberation attitudes might be more or less polarized closer to the border. Just calling it Palestine vs. Israel is a rather clumsy way to dumb down results, and I don't see what else is achieved beyond that...Less time learning stats?
Answer: Maybe stepwise regression and other forms of testing after model selection.
Selecting independent variables for modelling without having any a priori hypothesis behind the existing relationships can lead to logical fallacies or spurious correlations, among other mistakes.
Useful references (from a biological/biostatistical perspective):

Kozak, M., & Azevedo, R. (2011). Does using stepwise variable selection to build sequential path analysis models make sense? Physiologia plantarum, 141(3), 197–200. doi:10.1111/j.1399-3054.2010.01431.x
Whittingham, M. J., Stephens, P., Bradbury, R. B., & Freckleton, R. P. (2006). Why do we still use stepwise modelling in ecology and behaviour? The Journal of animal ecology, 75(5), 1182–9. doi:10.1111/j.1365-2656.2006.01141.x
Frank Harrell, Regression Modeling Strategies, Springer 2001.
Answer: Something I see a surprising amount in conference papers and even journals is making multiple comparisons (e.g. of bivariate correlations) and then reporting all the p<.05s as "significant" (ignoring the rightness or wrongness of that for the moment).
I know what you mean about psychology graduates, as well- I've finished a PhD in psychology and I'm still only just learning really. It's quite bad, I think psychology needs to take quantitative data analysis more seriously if we're going to use it (which, clearly, we should)
Comment: This is particularly important. I remember reading a study about whether Ramadan was bad for babies whose mothers were fasting. It looked plausible (less food, lower birth weight), but then I looked at the appendix. Thousands of hypotheses, and a few percent of them were in the "significant" range. You get weird "conclusions" like "it's bad for the kid if Ramadan is the 2nd, 4th or 6th month".
Answer: Being exploratory but pretending to be confirmatory. This can happen when one is modifying the analysis strategy (i.e. model fitting, variable selection and so on) data driven or result driven but not stating this openly and then only reporting the "best" (i.e. with smallest p-values) results as if it had been the only analysis. This also pertains to the point if multiple testing that Chris Beeley made and results in a high false positive rate in scientific reports.
Answer: The one that I see quite often and always grinds my gears is the assumption that a statistically significant main effect in one group and a non-statistically significant main effect in another group implies a significant effect x group interaction.
Answer: Correlation implies causation, which is not as bad as accepting the Null Hypothesis.
Comment: google makes $65B a year not caring about the difference...
Comment: I agree with your points and they all are valid. But does Google's profit imply: correlation => causation?
Comment: Google makes all that money not caring about causation at all.  Indeed, why would it?  Prediction is the thing...
Comment: I think it is very wrong to say that folks at Google do not care about causality at all. Google has run more experiments (to test the predictive models, but also in other domains) than probably any other entity in the history of science. For example, they (in)famously tested [41 shades of blue for the toolbar](https://stopdesign.com/archive/2009/03/20/goodbye-google.html).
Comment: but sometimes... sometimes the potential directions of causation have highly disparate probabilities.  I'm certainly not going to think that a correlation between age and height could be caused by the height... or some intervening variable either.  Also, I think that this is one that behavioural science training is generally quite sensitive to.
Comment: indeed, inferring something from `A and B are correlated` usually only see `A causes B` but not `B causes A`...(and forget about `C` which causes `A` and `B`)
Answer: Especially in epidemiology and public health - using arithmetic instead of logarithmic scale when reporting graphs of relative measures of association (hazard ratio, odds ratio or risk ratio).
More information here.
Comment: Not to mention not labeling them at all http://xkcd.com/833/
Answer: Analysis of rate data (accuracy, etc) using ANOVA, thereby assuming that rate data has Gaussian distributed error when it's actually binomially distributed.
Dixon (2008) provides a discussion of the consequences of this sin and exploration of more appropriate analysis approaches.
Comment: How much does this decrease the power of the analysis? In what conditions is it most problematic?
In many cases deviations from the assumptions of ANOVA do not substantially affect the outcomes to an important extent.
Comment: But in short, it is most problematic when probabilities observed are low or high as the range of values are constricted and unable to meet Gaussian assumptions.
Comment: What is the alternative do the ANOVA procedure?
Comment: @Michael Lew & Henrik: I just updated this entry to include a link to Dixon (2008)
Comment: This is only as bad as the normal approximation to the binomial - should be fine, provided that each case is weighted by the denominator used in calculating the rate. Would expect it to perform poorly for rates below 10% and above 90%.
Answer: A current popular one is plotting 95% confidence intervals around the raw performance values in repeated measures designs when they only relate to the variance of an effect.  For example, a plot of reaction times in a repeated measures design with confidence intervals where the error term is derived from the MSE of a repeated measures ANOVA.  These confidence intervals don't represent anything sensible.  They certainly don't represent anything about the absolute reaction time.  You could use the error term to generate confidence intervals around the effect but that is rarely done.
Comment: Is there a standard article that can be cited to dissuade reviewers from demanding this all-too-common practice?
Comment: The only critique I know is Blouin & Riopelle (2005) but they don't get to the heart of the matter.  I generally don't insist on not showing them but doing something correct as in the effect graphs of Masson & Loftus (2003, see figure 4, right panel... if they were removed from the left one you'd have done it right).
Comment: Just to be clear, the problem with those CI's is that they're purely used for inferential reasons with respect to differences among conditions and therefore are worse even than PLSD... in fact I prefer them.  At least they're honest.
Answer: While I can relate to much of what Michael Lew says, abandoning p-values in favor of likelihood ratios still misses a more general problem--that of overemphasizing probabilistic results over effect sizes, which are required to give a result substantive meaning.  This type of error comes in all shapes and sizes and I find it to be the most insidious statistical mistake.  Drawing on J. Cohen and M. Oakes and others, I've written a piece on this at here.
Comment: I'm actually unclear as to how a likelihood ratio (LR) does not achieve everything that an effect size achieves, while also employing an easily interpretable scale (the data contains X times more evidence for Y than for Z). An effect size is usually just some form of ratio of explained to unexplained variability, and (in the nested case) the LR is the ratio of unexplained variability between a model that has an effect and one that doesn't. Shouldn't there at least be a strong correlation between effect size and LR, and if so, what is lost by moving to the likelihood ratio scale?
Comment: Mike -  You've got me interested, but do your points extend to effect sizes as simple as mean differences between groups?  These can be easily interpreted by a lay person and can also be assigned confidence intervals.
Comment: Ah, so by effect size, you mean absolute effect size, a value that is meaningless unto itself, but that can be made meaningful by transformation into relative effect size (by dividing by some measure of variability, as I mentioned), or by computing a confidence interval for the absolute effect size. My argument above applies to the merits of LRs vs relative effect sizes. There may utility to computing effect CIs in cases where the actual value of the effect is of interest (eg. prediction), but I still stand by the LR as a more intuitive scale for talking about evidence for/against effects.
Comment: I guess the use of LRs vs CIs will likely vary according to the context, which may be usefully summarized as follows: More exploratory stages of science, where theories are roughly characterized by the existence/absence of phenomena, may prefer LRs to quantify evidence. On the other hand, CIs may be preferred in more advanced stages of science, where theories are sufficiently refined to permit nuanced prediction including ranges of expected effects or, conversely, when different ranges of effect magnitudes support different theories. Finally, predictions generated from any model need CIs.
Comment: @rolando2 - You still want a likelihood ratio, but when there is a substantive value that has meaning, you should really be testing on this value rather than on $0$.  So if $|\beta|=1$ has physical meaning in terms of the coefficient, then you should really be testing for $|\beta|>1$ vs $|\beta|\leq 1$.  And not $\beta=0$ vs $\beta\neq 0$
Answer: My intro psychometrics course in undergrad spent at least two weeks teaching how to perform a stepwise regression. Is there any situation where stepwise regression is a good idea?
Comment: Perhaps the sin is doing statistical tests on a model obtained via stepwise regression.
Comment: "Good idea" depends on the situation.  When you want to maximize prediction it isn't a horrible idea - though it may lead to over fitting.  There are some rare cases where it is inevitable - where there is no theory to guide the model selection.  I wouldn't count stepwise regression as a "sin" but using it when theory is sufficient to drive model selection is.
Comment: It's fine if you use cross-validation, and don't extrapolate. Don't publish the p-values though, as they are meaningless.
Comment: I'm working on a project that uses stepwise regression.  The reason is because I have D >> N, where D is dimensionality and N is sample size (thus ruling out using one model with all the variables), subsets of the features are highly correlated with each other, I want a statistically principled way of selecting maybe 2-3 "best" features, and I don't intend to report the P-values, at least without some kind of fairly conservative correction.
Answer: Failing to test the assumption that error is normally distributed and has constant variance between treatments.  These assumptions aren't always tested, thus least-squares model fitting is probably often used when it is actually inappropriate.
Comment: What's inappropriate about least squares estimation when the data are non-normal or heteroskedastic? It is not fully efficient, but it is still unbiased and consistent.
Comment: No, it is unbiased, but the variance is larger than if you used a more efficient method for the reasons you explain. Yes, the prediction intervals are wrong.
Comment: Yes (I was using biased in a colloquial rather than a statistical sense to mean the model was systematically biased towards observations in high-variance regions of the feature space - mea culpa!) - it would be more accurate to say that the higher variance means there is an increased chance of getting a poor model using a finite dataset.  That seems a reasonable answer to your question. I don't really view unbiasedness as being that much of a comfort - what is important is that the model should give good predictions on the data I actually have and often the variance is more important.
Comment: If the data are heteroscedastic you can end up with very innacurate out of sample predictions because the regression model will try too hard to minimise the error on samples in areas with high variance and not hard enough on samples from areas of low variance.  This means you can end up with a very badly biased model.  It also means that the error bars on the predictions will be wrong.
Answer: This may be more of a pop-stats answer than what you're looking for, but:
Using the mean as an indicator of location when data is highly skewed.
This isn't necessarily a problem, if you and your audience knows what you're talking about, but this generally isn't the case, and the median is often likely to give a better idea of what's going on.
My favourite example is mean wages, which are usually reported as "average wages". Depending on the income/wealth inequality in a country, this can be vastly different from the median wage, which gives a much better indicator for where people are at in real life. For example, in Australia, where we have relatively low inequality, the median is 10-15% lower than the mean. In the US the difference is much starker, the median is less than 70% of the mean, and the gap is increasing.
Reporting on the "average" (mean) wage results in a rosier picture than is warranted, and could also give a large number of people the false impression that they aren't earning as much as "normal" people.
Comment: This is not just related to skewness, but is a general problem that the mean, or any other measure of central tendency is not enough without considering dispersion.  For example, if the medians of two groups were equal, but the inter quartile range was 100 times as big for one population.  Just looking at the median, you would say they're the "same population distribution", when in reality they would be very different.  Not to mention multiple modes creating problems...
Comment: There's a semi-related discussion of this as it applies to trend analysis here: https://tamino.wordpress.com/2012/03/29/to-robust-or-not-to-robust-that-is-the-question/
Comment: But, for some purposes mean **is** relevant: wage is an **extensive** variable, meaning that sums of wages are meaningful. For questions where total wage income of some (sub)group is relevant, means are the right thing: The total can be recovered from the mean, not from the median.
Comment: @kjetilbhalvorsen: Why not just use the total then?
Comment: @naught101: Because diffwrent (sub)groups generaly will have diferent $n$s.
Answer: My old stats prof had a "rule of thumb" for dealing with outliers: If you see an outlier on your scatterplot, cover it up with your thumb :)
Comment: This is akin to Winsorization which isn't too terrible.
Answer: Requesting, and perhaps obtaining The Flow Chart: That graphical thing where you say what the level of your variables are and what sort of relationship you're looking for, and you follow the arrows down to get a Brand Name Test or a Brand Name Statistic.  Sometimes offered with mysterious 'parametric' and 'non-parametric' paths.
Answer: That the p-value is the probability that the null hypothesis is true and (1-p) is the probability that the alternative hypothesis is true, of that failing to reject the null hypothesis means the alternative hypothesis is false etc.
Comment: (here you go)[http://www.ece.uvic.ca/~bctill/papers/mocap/Aitkin_1997.pdf]  personally, while I do find it interesting, I struggle with the question of why the posterior distribution of the likelihood ratio is the quantity of interest.
Comment: Interestingly, Atkin shows thhe pvalue is the posterior probability that the likelihood ratio is less than $1$ (for the fixed data that was observed)
Comment: Interesting, can you give me a reference to read up about it?
Answer: In similar vein to @dirkan - The use of p-values as a formal measure of evidence of the null hypothesis being true.  It does have some good heuristic and intuitively good features, but is essentially an incomplete measure of evidence because it makes no reference to the alternative hypothesis.  While the data may be unlikely under the null (leading to a small p-value), the data may be even more unlikely under the alternative hypothesis.
The other problem with p-values, which also relates to some styles of hypothesis testing, is there is no principle telling you which statistic you should choose, apart from the very vague "large value" $\rightarrow$ "unlikely if null hypothesis is true".  Once again, you can see the incompleteness showing up, for you should also have "large value" $\rightarrow$ "likely if alternative hypothesis is true" as an additional heuristic feature of the test statistic.
Comment: I am not answering because I don't want to go to the trouble of thinking one up and for that matter wading through all the ones already given to make sure I don't repeat one!  But I think i can be helpful.  There is a book by Good and Hardin called "Common Errors in Statistics and How to Avoid Them." You can find a lot of great examples there.  It is a popular book that is already going into its fourth edition.
Comment: Also Altman's book with Chapman & Hall/CRC "Practical Statistics in Medical Research" has a chapter on the medical literature where many statistical sins are revealed that occurred in published papers.
Answer: Using pie charts to illustrate relative frequencies. More here.
Comment: Would be good to include some reasoning on-site.
Answer: Using statistics/probability in hypothesis testing to measure the "absolute truth".  Statistics simply cannot do this, they can only be of use in deciding between alternatives, which must be specified from "outside" the statistical paradigm.  Statements such as "the null hypothesis is proved true by the statistics" are just incorrect; statistics can only tell you "the null hypothesis is favoured by the data, compared to the alternative hypothesis".  If you then assume that either the null hypothesis or the alternative must be true, you can say "the null proved true", but this is only a trivial consequence of your assumption, not anything demonstrated by the data.
Answer: Repeating the same or similar experiment over 20 times on the same data and then reporting a statistically significant result with $\alpha = 0.05$.  Incidentally there is a comic about this one.
And similarly to (or almost the same as) @ogrisel's answer, performing a Grid search and reporting only the best result.
Comment: I think you meant to link to a different comic, though that's an immortal one.
Comment: Possibly, if I remember well enough what I had in mind back then: https://xkcd.com/882/
Answer: (With a bit of luck this will be controversial.)
Using a Neyman-Pearson approach to statistical analysis of scientific experiments. Or, worse, using an ill-defined hybrid of Neyman-Pearson and Fisher.
Comment: sorry to be ignorant, but what's wrong with a Neyman-Pearson construction for the analysis of (the outcome of) scientific experiments ?
Comment: @Andre I think this remark may be closely related to another one offered by @Michael Lew elsewhere in this thread (http://stats.stackexchange.com/questions/4551/what-are-common-statistical-sins/4567#4567 ).
Answer: Perhaps the poor teaching of statistics to end consumers. The fact is that most courses have given a medieval menu, not including new theoretical developments, computational and best practices, insufficient teaching of modern and complete analysis of real data sets, at least in poor and developing countries, what is the situation in developed countries?
Comment: The situation in developed countries is exactly the same.
Answer: In psychology, the cardinal sin (for me) is the use of principal components analysis to examine the hypothesised latent structure underlying a psychometric test.
Not testing for normality before using tests which assume this.
Comment: Take a look at the sin I have already proposed about testing. If you do the test and do not reject normality, it does not mean that you have a normal sample... it only means that you cannot say the sample is not normal. sin !
Comment: https://stats.stackexchange.com/questions/2492/is-normality-testing-essentially-useless ... I especially recommend Harvey's answer there.
Answer: Temptation to use advanced statistical methods without understanding them, just because they sound impressive or because they happen to better support researcher's initial hypothesis.
When one uses an advanced method he or she should have solid reasons as to why the method is appropriate.
Answer: Probably not as applicable to psych stats (or is it? I'm not sure) but failing to account for a split plot design in an analysis of an experiment.  I've seem way too many people do this.
Comment: A pre-post, experimental-control group design is extremely common in psychology. I agree that few people seem to be aware of the comparatively complicated and strict assumptions. Mixed models often seem to be beyond the statistical horizon.
Answer: I would say, doing tests and regressions on a small set of data.
Edit: Without looking at the confidence intervals, or when the confidence intervals/error bars are not easy to calculate.
Comment: Perhaps I don't see why this is such a problem. Hypothesis testing a small sample size using a normal distribution, sure, but using a more conservative/nonparametric test, is this so bad?
Comment: Isn't performing a test implicitly looking at the confidence intervals?  Perhaps it would be that the sin test-wise is ignoring the power of the test?
Comment: I agree that using a more conservative model to fit the data is the best we can do. But in any case you will have to trust this model. It will be a fitting, not a model. A model requires a representative set of data otherwise it may not work in the future.
Comment: If you use Bayesian regression then the error bars also indicate the uncertainty due to the finite nature of the dataset (given the prior), you only trust the model as far as the error bars suggest you ought to trust it. If you don't have enough data to make a useful inference it will generally be evident in the posterior distributions for the parameters and/or predictions.  The usual frequentist error bars will probably say pretty much the same thing.  At the end of the day, sometimes only a small dataset is available, it just limits the confidence in your conlcusions.
Comment: Agreed for the Bayesian regression. Thanks for pointing that out. But if you have two points that form a straight line, how do you calculate the frequentist error bars? And let's say that you have enough points to calculate the frequentist error bars, from how many points can you trust them (should we use the error bars of the error bars?)
Comment: Sorry, I am not that familiar with the limitations of frequentist error bars (I only mentioned them so as not to appear bigoted ;o).  IIRC frequentist error bars for ridge regression are very similar to the Bayesian ones for a fixed value of the ridge parameter (a full Bayesian analysis would marginalise over the ridge parameter as well).
Answer: Rush into modeling before spending enough time on understanding and preprocessing the data.
Comment: @gung I tried to answer the question the same way many others have done and considering what the asker is asking for. I think elaborating the idea would be kind of repeating myself or I should start talking about "how to understand/preprocess the data" which is not what the question is about.
Comment: @Aliweb, that's fair. I only said "might"; if you can't go further w/o repeating yourself or moving off topic, then you're best staying put.
Comment: I upvoted the answer though I bet many of us would benefit from seeing an example or 2.
Comment: This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - [From Review](/review/low-quality-posts/125465)
Comment: This is probably adequate, IMO, given the context of the thread to which it was posted. I think it's OK. @Aliweb, you might want to develop / elaborate the idea a little, though.
Comment: @kjetilbhalvorsen This exactly answers the question. The author is asking for some statistical sins and if you read the question, my answer couldn't be seen as a critic to the author.
Answer: Application of least-squares minimization when maximum-likelihood procedures exist.
Comment: @MikeLawrence - "maximum likelihood" = "weighted least squares" in many cases.  even maximum entropy is approximately least squares (when the initial measure isn't too far from the optimum measure).  You could do a lot worse than least squares...
Comment: Would you please explain the consequences of this sin?
Comment: If the data are generated by a process with a heteroscedastic noise process, the regression model is likely to give very inacurate out-of-sample predictions.
Comment: This entry was originally inspired by the observation that some folks estimate non-linear psychometric functions by minimizing least squares. For example, Murd et al (2009, http://www.perceptionweb.com/abstract.cgi?id=p6145 , free pdf available by googling the title) fit a probit function through data by minimizing least-squares.
Comment: So, should the "answer" be amended to "application of least-squares minimization on heteroscedatic data"?
Comment: if the noise process is skewed but homoscedastic then it is still inappropriate if you need the error bars.
Answer: Using Analysis of Covariance (ANCOVA) to try to "control for" or "regress out" the influence of a covariate that is known to be correlated with, or affect the influence of, other predictor variables. More discussion at this question: Checking factor/covariate independence in ANCOVA
Answer: Interpreting a $100\alpha \%$ Confidence Interval $I$ as the probability of finding the "real" parameter inside the interval.
The most common case is when someone calculates this C.I. ($I$) and interprets the number $\alpha$ as the probability of finding the "true mean" say, $\mu$, inside the interval, i.e., interpreting the C.I. as $P(\mu \in I)=\alpha$.
Comment: Is this such a bad thing? I understand the usual argument of "the mean is either in the interval or it isn't", or at least I think I do. But the endpoints of the confidence interval are random variables, so why is it wrong to talk about the probability that they take values above and below the true mean?
Comment: Thanks for the explanation, I think I understand now. I wasn't suggesting that a particular realisation of a 95% confidence interval has 95% chance of containing the true value, although I didn't make that clear. What I meant was that saying "the probability that the (generic) interval contains the true value is 0.95" seems to me to be equivalent to saying "if repeated many times, 95% of the intervals will contain the true value".
Comment: It IS bad because you are giving a probability statement that doesn't exist. The phrase "the true population mean $\mu$ is either in the interval or isn't" states a beautiful fact: $P(\mu \in I)$ is either 1 or 0.

On the other hand, recall that what you calculate when creating confidence intervals is $P(L_1<\bar{X}-\mu<L_2)=\alpha$, where $\bar{X}$ is a STATISTIC (i.e. a function of random variables) and is, therefore, the random variable on which you are calculating the probability. The 100$\alpha$% confidence interval that you calculate is one of many other (random) intervals that...
Comment: ...might "appear" as you sample from the population. Simply put, $I$ is one realization of many random intervals (say, $I_r$) that are generated as you sample from the population. You can only say that $I_r$ is a range in which the mean will occur 95% of the time, but that says nothing about your particular realization (or estimation) of interval $I$ that one usually calculates, and, therefore, says nothing about the probability of $I$ containing $\mu$.
Comment: Oh, yes! That is in fact true :-). Just a misunderstanding then.
Answer: Over-interpreting OLS regression in the presence of known outliers.  If you know that there are particular data in your dataset which are generated by a different process to the process that generates most of the data, and this different process generates wildly different results which show up as outliers, then you have to be very careful in interpreting the model output because the outliers often do substantially move the OLS results.  That's not to say OLS is bad, just that you need to think about the data when interpreting the results.
What's worse is that we often have "never throw away outliers" as common advice to early students. Sometimes it translates into an attitude of keeping the data, warts and all, without really discussing anomalies and outliers.
Better advice might be: "use a mixture model" or "use Huber/quantile-based/other robust techniques" or "go Bayes and use a hierarchical model".  But everyone should at least learn to just "reanalyse without the suspect outliers and print both analyses and show us a plot" or even "talk qualitatively for a bit about outliers in the conclusion of your paper and suggest it might be a good idea to redo the experiment with fewer foul-ups".
Comment: Hah. I already added this as a comment to my answer, but it's more relevant to this answer: https://tamino.wordpress.com/2012/03/29/to-robust-or-not-to-robust-that-is-the-question/ discusses situations where OLS may be better than robust regression, even in cases with (apparent) outliers.
Answer: Interpreting a statistically significant result as "meaningfully large".
Answer: This isn't generally considered a sin but I hope it will be one day: using a bad model that doesn't describe reality just because it's "interpretable."
Answer: Not paying attention to levels of measurement, and treating polytomous nominal scales as though they were ordinal, interval, or ratio scales (Ouch).
Answer: Completely forgetting about checking calibration or normalization, when datasets come for different sensors, different times, different observers.
Answer: Specifically in psychology, and even more so in marketing, the technique of partial least squares (PLS) is used to "fit" structural equation models and path models, despite being deficient on almost any imaginable performance metric. See McIntosh, Edwards and Antonakis (2014 ORM), Rönkkö, McIntosh and Antonakis (2015 PID) and/or Rönkkö, McIntosh, Antonakis and Edwards (2016 JOM) for detailed treatment, including spelling out some natural requirements like bias and consistency, and demonstration of how PLS fails them (compared to other regression-type methods such as Bollen's model-implied instrumental variables). (I don't know how substitutable the papers are for one another, though; they must cover very similar topics, but may be aimed at somewhat different audiences.)
Comment: Didn't you just list a different paper from the chemometrics literature somewhere? It might be worth adding to the list.
Comment: Good point -- it was @amoeba who was familiar with the chemometrics literature; I am not qualified to speak on that. My understanding is that it is used with much less fanfare there than in psych and marketing, just to honestly reduce dimensionality rather than to claim that you found some underlying factors and quantified them perfectly.
Answer: Using technical replication instead of true replication, and similarly, using MSE as the denominator in a nested ANOVA F-statistic.

What are common statistical sins?


Redirecionamento htaccess

Question: Eu tenho o seguinte redirecionamento:
RewriteRule ([^/]*)\/([^/]*) http://ip/~user/codigo.php?nome=$1&numero=$2

Para gerar a url:

http://www.site.com.br/stackoverflow/123456

Mas existem outras pastas, como por ex: assets/css/main.css e outras como /css/nome/outro.css e estas estão sendo redirecionadas para:

Ex: http://www.site.com.br/codigo.php?nome=assets/css&numero=main.css

Como resolver o problema?
Tentei algo como:
RewriteRule ^assets/(.*)$ http://www.site.com.br/assets/$

Observação: existem outras pastas, além do exemplo assets e algumas delas possuem subpastas e outras não, ou seja, não existe um padrão.
Answer: Consegui uma solução para o meu problema.
Adicionei o seguinte:
RewriteRule ^(assets|css|images|js|fonts) - [L]

Antes do redirecionamento:
RewriteRule ([^/]*)\/([^/]*) http://ip/~user/codigo.php?nome=$1&numero=$2

E funcionou perfeitamente.
Para quem estiver com o mesmo problema, esta é a solução.

Redirecionamento htaccess


Issue using infercnvpy.io.genomic_position_from_gtf

Question: I'm trying to use the scanpy plugin to infer copy number variation (CNV) from single-cell transcriptomics data.
When trying to annotate genomic positions in Jupyter using infercnvpy, I get the following error. How can I fix things?

AttributeError                            Traceback (most recent call last)
Cell In[28], line 2
1 gtf_file=r'G:\gencode.v38.annotation.gtf'
2 cnv.io.genomic_position_from_gtf(gtf_file, adata=adata, gtf_gene_id='gene_name', inplace=True)
File ~\Anaconda3\envs\spapros\lib\site-packages\infercnvpy\io_genepos.py:41, in genomic_position_from_gtf(gtf_file, adata, gtf_gene_id, adata_gene_id, inplace)
11 def genomic_position_from_gtf(
12     gtf_file: Union[Path, str],
13     adata: Union[AnnData, None] = None,
(...)
17     inplace: bool = True,
18 ) -> Union[pd.DataFrame, None]:
19     """Get genomic gene positions from a GTF file.
20
21     The GTF file needs to match the genome annotation used for your single cell dataset.
(...)
39         If True, add the annotations directly to adata, otherwise return a dataframe.
40     """
41     gtf = gtfparse.read_gtf(
42         gtf_file, usecols=["seqname", "feature", "start", "end", "gene_id", "gene_name"], result_type="pandas"
43     )
44     gtf = (
45         gtf.loc[
46             gtf["feature"] == "gene",
(...)
50         .rename(columns={"seqname": "chromosome"})
51     )
53     gene_ids_adata = (adata.var_names if adata_gene_id is None else adata.var[adata_gene_id]).values
File ~\Anaconda3\envs\spapros\lib\site-packages\gtfparse\read_gtf.py:254, in read_gtf(filepath_or_buffer, expand_attribute_column, infer_biotype_column, column_converters, usecols, features, result_type)
251     raise ValueError("GTF file does not exist: %s" % filepath_or_buffer)
253 if expand_attribute_column:
254     result_df = parse_gtf_and_expand_attributes(
255         filepath_or_buffer,
256         restrict_attribute_columns=usecols,
257         features=features)
258 else:
259     result_df = parse_gtf(result_df, features=features)
File ~\Anaconda3\envs\spapros\lib\site-packages\gtfparse\read_gtf.py:189, in parse_gtf_and_expand_attributes(filepath_or_buffer, restrict_attribute_columns, features)
166 def parse_gtf_and_expand_attributes(
167         filepath_or_buffer,
168         restrict_attribute_columns=None,
169         features=None):
170     """
171     Parse lines into column->values dictionary and then expand
172     the 'attribute' column into multiple columns. This expansion happens
(...)
187         Ignore entries which don't correspond to one of the supplied features
188     """
189     df = parse_gtf(
190         filepath_or_buffer=filepath_or_buffer,
191         features=features,
192         split_attributes=True)
193     if type(restrict_attribute_columns) is str:
194         restrict_attribute_columns = {restrict_attribute_columns}
File ~\Anaconda3\envs\spapros\lib\site-packages\gtfparse\read_gtf.py:155, in parse_gtf(filepath_or_buffer, split_attributes, features, fix_quotes_columns)
150 def parse_gtf(
151         filepath_or_buffer,
152         split_attributes=True,
153         features=None,
154         fix_quotes_columns=["attribute"]):
155     df_lazy = parse_with_polars_lazy(
156         filepath_or_buffer=filepath_or_buffer,
157         split_attributes=split_attributes,
158         features=features,
159         fix_quotes_columns=fix_quotes_columns)
160     return df_lazy.collect()
File ~\Anaconda3\envs\spapros\lib\site-packages\gtfparse\read_gtf.py:87, in parse_with_polars_lazy(filepath_or_buffer, split_attributes, features, fix_quotes_columns)
80 def parse_with_polars_lazy(
81         filepath_or_buffer,
82         split_attributes=True,
(...)
85     # use a global string cache so that all strings get intern'd into
86     # a single numbering system
87     polars.toggle_string_cache(True)
88     kwargs = dict(
89         has_header=False,
90         sep="\t",
(...)
103             "frame": polars.UInt32,
104         })
105     try:
AttributeError: module 'polars' has no attribute 'toggle_string_cache'

I've run the code below. I'm using the latest GENCODE GTF.

import infercnvpy as cnv
import scanpy as sc
import matplotlib.pyplot as plt
import pandas as pd
adata=sc.read(r'G:\data.h5ad')
sc.pp.log1p(adata)
gtf_file=r'G:\gencode.v44.annotation.gtf'
cnv.io.genomic_position_from_gtf(gtf_file, adata=adata, gtf_gene_id='gene_name', inplace=True)`

I'm doing this so I can get an output along the following lines, and proceed to running inferCNV

adata.var.loc[:, ["ensg", "chromosome", "start", "end"]].head()

    ensg    chromosome  start   end
symbol
AL645933.5  ENSG00000288587.1   chr6    31400702    31463705
AC010184.1  ENSG00000288585.1   chr3    141449745   141456434
AC023296.1  ENSG00000288580.1   chr8    2923568 2926689
AL117334.2  ENSG00000288577.1   chr20   3406380 3410036
AC107294.4  ENSG00000288576.1   chr3    184778723   184780720

Answer: This looks like an error that's from read_gtf in the gtfparse library. I'm getting the same error with the latest version (which switched to using polars). Downgrading to an earlier version with pip install gtfparse==1.3.0 fixed the issue for me.
Comment: I've created an issue on the gtfparse github repo for this: https://github.com/openvax/gtfparse/issues/41


User-based removal of previous version in Installer Project

Question: How can I create an MSI Installer which lets the user decide whether a previous version should be retained or not?
I've set the current installer's UpgradeCode to be the same as the previous version, as I've read in an article.
I've tried setting RemovePreviousVersions to True but it uninstalls the previous version silently; is there any way to make the user decide about it?
The idea is, the user should be able to:

Install the latest software version
Install the latest software version over a previous one
and lastly; Install the latest software version side by side with the previous one.

Update
Just an info, I'm not knowledgeable of the tools, I'm just trying out Installer Project, but I'm willing to learn another tool if necessary, as long as the output is an MSI.
Update#2
I was able to do it in Advanced Installer but it is a paid feature, so... I'm thinking maybe I can also do it in Installer Project or something. Anyone?
Comment: Is it the solution you want to get like Stein's suggestion? Would you please share the latest information in your side?
Comment: sorry for the late reply, I will reassess the situation and update my question if necessary. as for now, what's in my question is what I need to happen.
Comment: It looks like **Advanced Installer** uses the **multi-instance transform feature** to accomplish their support for multiple installation instances. This is advanced indeed. I have mentioned this concept in my linked answer below - you can do it in WiX, but it is a lot of work and complicated to test. I have not tested the functionality much in Advanced Installer, but I am sure it works well unless you use problematic constructs that hit restrictions and limitations of the underlying technology. I would test different upgrade scenarios.
Comment: thank you for your support! I guess I'll have to dig deeper. :|
Answer: Paradigmatitis: This requirement does not work well with the MSI paradigm. In order to support side-by-side deployment of different versions both the setup itself and the application must be tweaked to co-exist peacefully so they don't overwrite the same data files and registry keys unexpectedly, don't fight over file associations, etc...
Nice-to-Have?: Is this an absolute requirement or a "nice to have" issue? If I were to implement this I would essentially make each setup version independent of the older ones and maybe use a custom action to trigger the uninstall of the older version, or add temporary rows to the upgrade table. Not trivial. Not rocket science. Not something I have ever tried. So you see the dilemma in making a suggestion.
Side-By-Side: In order to make each setup "side-by-side" capable, I would use WiX's auto-guids and a "moving target" target folder with the version number embedded in the installation folder name. I would also likely set a new upgrade code for each version, although you can make do without that as well. It is generally good to keep the upgrade code the same to identify related products.

Blast from the Past: There are some other possibilities. You could use multi-instance transforms, you could use virtualization. I have written about this before here: Installing Multiple Instances by different msi having same Package Code. Please give it a skim.
Comment: thank you. I will have to reassess the situation considering your answer. yes, it is a requirement from the client.
Comment: it seems that WiX is too overkill for me. time to negotiate lol.
Comment: Maybe your clients have App-V or similar virtualization technologies available?
Comment: I don't know. I'm sorry, I'm just a member of a team, and I don't think they would want to dig that deep. :(((
Answer: In my opinion, the only way you can do this is to have two MSI files. They both will have new ProductCodes, and they are:

Which has the same UpgradeCode and sets the VS RemovePreviousVersions to true to do the replacement upgrade.
Has a different UpgradeCode and is therefore a new product that will install while the previous one is still there.

Then you need a launcher program that asks the user which is required, an upgrade or a side-by-side, and it launches the required one.
The basic problem is that the install might not be "side-by-side" it might be "on top of". What prevents the files in the new one replacing the existing ones in the other installed product? What if the shortcuts have identical names, and how does the user know which to use? Do you need to prevent two versions of the app running at the same time? Are there any "single use" items in the install, such as services (can't have two of the same name) or named events, mutexes and so on? What will be the upgrade strategy when wo versions are installed?


What do you call a parameter that is estimated from historical values?

Question: There are several methods to estimate parameters in a model (MLE, MAP, GMM). Does the process of estimating a parameter from historical data have a name?
Comment: Your title and body are asking different questions. The *process* is called "estimation". An *estimated parameter* is called an "estimate", or a "parameter estimate". The formula or algorithm by which you compute it is called an "estimator". E.g. I might estimate a population mean, $\mu$ by a sample mean, $\bar X$. Then $\bar X$ is called an estimator, and the value it takes on a given sample ($\bar x = 113.4$, say) is the estimate of $\mu$.
Answer: No. It doesn't have a special name, because parameters are always estimated from historical values. How else can they be estimated?


Menu sort by year field

Question: I'm created a content type and have got field_year. I want, sort my contents by field_year on my sidebar. How can I do this?
Comment: Are your field `field_year` integer? http://i.imgur.com/u4Wc4.png
Answer: I see you have added views tag views-filters, so, I think, you don't mind to list your content with Views.
If your field field_year is integer it is really easy to sort your content:

Some notes:

If you need block, just create Block display in Views. New block will be available on admin/structure/block page.
Add fields you want. Here I'm showing only title as a link to the original piece of content.
Remove all sorts and add your own by clicking on the Add button. It's very easy to find your field by it's name or machine name.

Result:

Yes, active class is added automatically.
Views module has tons of settings. To learn more please take a look at "Taming the Beast: Learn Views with NodeOne" series.
Comment: Please, explain why it was downvoted.

Menu sort by year field


Cannot post new content after installing varnish

Question: Our drupal 7 site was running so slow it was almost unresponsive, so I had to install varnish 2.1.5 this weekend. I got it up and running, and everything is now lightning fast, users can login and everything else is good... except that none of our authors can post new content.
When new content is posted, whether it's from the admin overlay or the actual node/add/news path, the URL just reloads and nothing happens. The form data is all in the Request Payload, the SESSION cookie is set, Varnish supposedly isn't caching... and yet nothing happens. I even installed the varnish module for drupal, but that only seems to handle reporting, and not actually doing anything.
Here's my default.vcl file.
I'm not seeing anything suspect in the vcl, but it certainly seems to be screwing something up.
Edit: I should point out that I don't have any issues changing settings in admin, or doing anything else, other than posting content, so it's not like all forms are broken. It might have something to do with ckeditor which is only present on the new content pages, but that seems like a stretch to me.
Edit 2: Realized I can create new blocks as admin, which uses the ckeditor which means that doesn't have anything to do with it. No new entries are getting put inserted into the node table and there's nothing suspicious in the watchdog logs.
Comment: are the Nodes being stored in the database? Does watchdog report any errors, or your status page? Are there any errors in your apache logs?
Comment: Nodes are not being stored in the database. The recent log messages don't show anything errors when I try and post. There also aren't any errors in the apache logs.
Answer: I finally found a solution. Inside my default.vcl file I added the following block at the top of sub vcl_recv:
sub vcl_recv {

  # forward request directly to Apache if SESSION cookie is set.
  if (req.http.Cookie ~ "(SESS[a-zA-Z0-9]*)=") {
    return (pass);
  }

  ... # whatever else you need to do in vcl_recv
}

Basically I'm just checking to see if my session cookie is set (anyone else reading this might have one formatted differently) and if so, forwarding it to Apache. This seems to have fixed the problems as new content can be posted again. Not really sure why the elaborate cookie filtering I had in place (and which was working in every other case except posting new node content) didn't work, but this seems to be the solution, even if it feels a little heavy handed.
Answer: Not sure if these will help you at all, but I've had my share of tangling with varnish and a few things that have helped me are:
Install the Varnish module if you haven' yet.
You might want to also look into using secure pages to force drupal to grab any admin or node forms in https (note you will need to enable ssl on your server if you haven't done so already). I had an issue myself with bots trying to login to my site. I discovered that by using https I could bypass the cache servers. Might be worth a try to see if that clears up your issues.
Comment: I have the varnish module installed, but it doesn't seem to do much other than tell me varnish is running and then give me stats on cache hit/misses. I don't really see how secure pages would benefit me either, and we don't have SSL installed on this server.
Comment: Using SSL will cause the site to talk directly to the server, bypassing varnish. So if node/add was under an https, the form would never be cached via varnish. However, as you don't have SSL, you would need to install that for this answer to help at all.
Comment: Even if I did have SSL, our writers wouldn't be able to publish anything through the admin toolbar overlay (which wouldn't be on SSL) and I'm told that's where they do all their work.


Finding $b-a$ for positive integer $a$, $b$ satisfying $\sum_{x=1}^\infty\frac{3x^2+12x+16}{(x(x+1)(x+2)(x+3)( x+4))^3}=\frac1{4(a!)^b}$

Question:
$$
\sum_{x = 1}^{\infty}\frac{3x^{2} + 12x + 16}
{\left[\vphantom{A^{A}}x\left(x + 1\right)\left(x + 2\right)
\left(x + 3\right)\left(x + 4\right)\right]^{\, 3}} =
\frac{1}{4\left(a!\right)^{b}}
$$
Compute $b-a$ if $b$ and $a$ are positive integers.

I asked my teacher to help me in solving this sum. But, unfortunately, he said I can't. it is a very hard question, So, I hope you can help me in solving this problem.
Comment: Finding the answer is much easier than designing the question.
Comment: Nice problem ...
Comment: Where did you find this Problem ,
Answer: The answer is $\color{green}{-1}$.
Indeed, the sum converges very quickly (the terms are $\Theta(x^{-13})$) and the inverses of the partial sums are
$$55741.9354839\\
55312.3888560\\
55297.2897327\\
55296.1612133\\
55296.0276428\\
55296.0059708\\
55296.0015387\\
55296.0004559\\
55296.0001513\\
55296.0000551\\
\cdots$$
Obviously, this tends to $4\cdot4!^3$.
Comment: Unexpectedly, yes. Fixing.
Comment: not an algerbraic way :/ but nice breakthru
Comment: you mean the answer is -1
Comment: @Idle001: it doesn't need to be much algebraic as it is given that $a$ and $b$ are integers. For rigor, one should show that among the few possibilities for this order of magnitude, no other can be that close. The most "dangerous" is $4\cdot5!^2=57600$.
Comment: Speaking of unexpected, the partial sums also [have](https://www.wolframalpha.com/input/?i=sum+%28%283y%5E2%2B4%29%2F%28y%28y%5E2-1%29%28y%5E2-4%29%29%5E3%29+for+y+%3D+3+to+n) a surprisingly "nice" form, where $y=x+2$ and $M=(n - 1) n (n + 1) (n + 2)\,$.

$$
\sum_{y=3}^n \frac{3 y^2 + 4}{\left(y (y^2 - 1) (y^2 - 4)\right)^3}
 = \frac{(n - 2) (n + 3) (n^2 + n + 4)(M^2 + 24 M + 576)}{55296\, M^3}
$$


What angle does minute hand and hour hand clock inclined to each other at $2:25$

Question: What angle does minute hand and hour hand clock inclined to each other at $2:25$
My Attempt:
The hour hand of a clock rotate throufh an angle of $30°$ in $1$ hour,
So,
At $2$o'clock, $2$ hrs$\equiv 60°$
Again,
The minute hand of a clock rotate through an angle of $6°$ in $1$ minute.
So, At $2:25$, i.e, $25$min$\equiv 150°$
What should I do further?
Answer: You're correct in thinking that the minute hand will be at 150°, but the hour hand moves from 2:00 to 2:25, no?
You can think about 2:25 as being 2.416666 hours. Thus, 2.41666 x 30° = 72.5°.
So, minute hand at 150°, hour hand at 72.5°, what is the angle between the two?
Comment: how did you get $2.416666...$??
Comment: 0.41666 = 25/60. This is because the hour hand lies at 60° at 2:00, but as time goes on the hour hand continues to move. So, at 2:25, it is 25/60 = .41666 of an hour further. Each hour it moves 30°, so from 2:00 to 2:25 it moves .41666 x 30° = 12.5°.
Comment: I would have done this just slightly differently:  In the 25 minutes after 2 the hour hand will have moved 25/60= 5/12 of the 30 degree so an additional (5/12)(30)= 25/2 degrees.
Comment: @user247327 I think this is just a matter of preference.
Answer: Time 2 hrs 25 minutes. Converting into hours $2\frac{25}{60} = 2 \frac5{12} = \frac {29}{12}$
Angle made by hour hand in $\frac {29}{12}$ hrs $= \frac{360}{12} \times \frac{29}{12} = \frac {145}{2} = 72.5°$
Angle made by minute hand in 25 min $=  \frac{360}{60} \times 25 = 150°$
Difference in angle $= 150° - 72.5° = 77.5°$
Answer: I'd envision it like so:

The blue arc represents a rotation of $2/12$ of a full rotation, or $60^{\circ}$ since a full rotation is $360^{\circ}$.
The green segment represents a rotation in the opposite direction of $(1/12)-(25/60)\times(1/12)$ of a full rotation or $17.5^{\circ}$; the $1/12$ represents the rotation from the three o'clock hour back to the two o'clock hour, while the $(25/60)\times(1/12)$ represents the proportion that the hour hand moves as the time changes from 2:00 to 2:25.
Taken together, the angle between the two is $60^{\circ}+17.5^{\circ}$ or $77.5^{\circ}$.
Comment: [+1] for the clock... and the explanation.
Answer: You're so close!
As you say, the hour hand moves 30 degrees in 1 hour, hence 0.5° per minute, and therefore 12.5° from where it was at 2pm, which was at 60° from 'zero'. So at 2:25 it is at 72.5° from 'zero'.
And, like you say, the minute hand is at 150°. So just subtract 72.5° from 150°, which is 77.5° difference!
Comment: I believe you're 1 degrees off
Comment: Hello bro, 150 - 72.5 = 77.5 $\ne$ 78.5
Comment: @mrnovice KanwaljitSingh Wow .... Blunder! Thanks for correcting me. Back to grade school ...
Comment: @mrnovice what for what?


Erro de conexão smtp com C#(autenticado)

Question: Segue abaixo o Script utilizado ao tentar enviar ocorre um erro: Falha a uma chamada SSPI. o Cliente e o Servidor não podem se comunicar porque não possuem um algoritmo em comum.
string CorpoEmail = file;
    MailMessage mailMessage = new MailMessage();
    // Endereco que irá aparecer no e-mail do usuário
    mailMessage.From = new MailAddress("firstname.lastname@example.com", "Fale Conosco");
    // Destinatarios do e-mail, para incluir mais de um basta separar por ponto e virgula
    mailMessage.To.Add(destinatario);
    mailMessage.Subject = assunto;
    mailMessage.IsBodyHtml = true;
    // Conteudo do corpo do e-mail
    mailMessage.Body = CorpoEmail.ToString();
    mailMessage.Priority = MailPriority.High;
    //smtp do e-mail que irá enviar
    SmtpClient smtpClient = new SmtpClient();
    smtpClient.EnableSsl = true;
    smtpClient.Host = "smtp.host.com.br";
    smtpClient.Port = 587;

    smtpClient.UseDefaultCredentials = false;
    //credenciais da conta que utilizará para enviar o e-mail
    smtpClient.Credentials = new
    NetworkCredential("firstname.lastname@example.com", "senha");
    smtpClient.Send(mailMessage);
    return true;

Comment: O erro não está no código, mas na comunicação entre o servidor onde a aplicação está rodando e o servidor smtp. Para ter certeza disso pode enviar um e-mail usando uma conta qualquer do gmail, por exemplo. Quanto a comunicação entre os computadores, por algum motivo o servidor deve estar barrando, será necessários mais informações sobre eles. Veja: https://technet.microsoft.com/en-us/library/dd197582(v=ws.10).aspx
Comment: Estava realizando alguns testes aqui e fiz um exemplo com o Python usando a classe SMTP dele e conseguir realizar o Envio do e-mail será que tem alguma configuração que posso fazer no C# para conseguir enviar ?
Comment: Já tentou remover o Ssl pra fazer um teste? `smtpClient.EnableSsl = false;`
Comment: Sim, tentei ocorre outro erro dizendo que a conexão requer starttls, usando a porta 25 consigo enviar normalmente, só que preciso enviar pela porta segura do Servidor
Comment: Veja se algo [dessa resposta](http://stackoverflow.com/questions/34449779/security-exception-port-587-smtppermission-email-send-by-gmail-in-asp-net-c-s/34450051#34450051) do SO ajuda.
Answer: Aparentemente você esta tentando fazer uma chamada com SSL/TLS usando uma porta não segura (587), tente desativar a função SSL/TLS, para isso, substitua esse valor:
smtpClient.EnableSsl = true;

Por esse:
smtpClient.EnableSsl = false;

Isso deve resolver seu problema, se o erro persistir, verifique se o host esta correto e ativo em "smtpClient.Host".


Apache is not running from XAMPP Control Panel ( Error: Apache shutdown unexpectedly. This may be due to a blocked port)

Question: I have installed XAMPP (xampp-win32-1.8.2-0-VC9-installer.exe) on Windows 7 successfully. But unfortunately, the following error was found during running Apache from XAMPP Control Panel:
5:38:38 PM  [Apache]    Error: Apache shutdown unexpectedly.
5:38:38 PM  [Apache]    This may be due to a blocked port, missing dependencies,
5:38:38 PM  [Apache]    improper privileges, a crash, or a shutdown by another method.
5:38:38 PM  [Apache]    Press the Logs button to view error logs and check
5:38:38 PM  [Apache]    the Windows Event Viewer for more clues
5:38:38 PM  [Apache]    If you need more help, copy and post this
5:38:38 PM  [Apache]    entire log window on the forums

Comment: Most probably, default port 80 is occupied by another application
Comment: Note that the control panel doesn't necessarily give these details, it might just say "Apache startet [Port 80]" and not actually starting the server. Resolution is the same, though.
Comment: Most of the case is because of Skype, Scroll down got see my anwser
Answer: There are many possible answers for this problem. The most common and most likely is that you're running another program which is blocking port 80 or 443. If you've installed Skype, then you've found your problem! Change apache's port settings to 81 and apache will work. There's a good tutorial on that To check this you can open up your command line by clicking the start menu, and typing 'cmd', and enter the command
    netstat -nab

this wil return a list of programs that will vaguely resemble this pattern
    [someprogram.exe]
    UDP     [fe80::numbers:numbers:numbers:numbers%numbers]:portnumber

You need to find a line (or lines) ending in :80 and terminate them in order to start apache. If there is no line ending in :80, there are more things you can do.
First, navigate to xampp's directory (default is c:\xampp) and double click apache_start.bat. This will open up a comand line and return more detailed errors about why apache can't run. Mostly, be looking for syntax errors that you could've created by editing your httpd.conf, or httpd-ssl.conf files. This is very easy to do if you've edited it and are a new user.
If still this fails, your last hope is to check the apache error log by clicking on the logs tab in apache's row in the xampp control panel and clicking error log.
If none of this works, don't give up! You got this!
Edit: If you change the port of apache, you will also have to go into httpd.conf (located in xampp/apache/conf) and near line 184, replace
ServerName localhost:80
with
ServerName localhost:81
It is also possible to specify port 81 in the url of your localhost, i.e.
localhost:81/my_project.php
Comment: I have changed port as 81 instead of 80. Apache is not started when I'm signed in at Skype. The error is 443 is occupied. So I'm doing well by running Apache before logged in at Skype. So sequence is: First Run Apache then log in to Skype
Comment: I have modified line Listen 443 as Listen 444 on httpd-ssl.conf file. So Apache is running even during logging in to Skype. So Apache is runnin on port 81, 444. Nice... Thanks Timmay again.
Comment: Try doing Run as Administrator during xampp control it worked for me, i dint have skype or any other application using port 80.
Comment: `apache_start.bat` solved my problem. You should have mentioned it first :)
Comment: When I start Apache it's running as: PID(s): 5316 & 5340 Port(s): 81, 443
Comment: Ridiculous to me that skype occupies port 80. Anyway to change this prevent it from ever taking 80? or maybe fixing it permanently to another port?
Comment: For me, modifying the line: **DocumentRoot "/xampp/htdocs"** accordingly fixed the issue.
Comment: Yippee, YEs I have changed the port number to 81 in httpd.config file and it works great.
Comment: Worked for me too.. it was due to skype.. Thanks
Comment: This is not a "solution", but a patch/hack
Comment: I think the biggest issue for myself was that I had a site map configured on my server that I had recently removed.
Answer: 1. Go in xampp/apache/conf/httpd.conf and open it.
In the httpd.conf file at line 176 Replace

ServerName localhost:80
with
ServerName localhost:81
  It will work.

Or 2. Even if the above procedure doesn't work. Then in the same file (httpd.conf) at line 45 replace
   #Listen 0.0.0.0:80
   #Listen [::]:80
   Listen 80

with
  #Listen 0.0.0.0:81
  #Listen [::]:81
  Listen 81

Comment: Also, I checked Apache and MySQL, which I shouldn't have done, because windows had them already.  I unchecked them and all is well.  Thank you.
Comment: Works, but sucks also. You don't want to have to browse to `localhost:81`
Comment: Thanks it works with me. Yes you are right, you have to change the port number of server and the listen. Thanks a lot for the help
Answer: XAMPP Control Panel under Windows does not always reflect what is actually going on, unless you start it by "Run as administrator".
Comment: This was also my issue on Windows 10
Answer: Go in xampp/apache/conf/httpd.conf and open it. Then just chang 2 lines
Listen 80
to
Listen 81

And
ServerName localhost:80
to
ServerName localhost:81

Then start using admin privileges.
As I am working in a corporate environment where developers faces firewall issues, none of the other answers resolved my issue.
As the port is not used by Skype, but by some other internal applications, I followed the below steps to resolve the issue:
Step 1 - From the XAMPP Control Panel, under Apache, click the Config button, and select the Apache (httpd.conf).
Inside the httpd.conf file, somehow I found a line that says:
Listen 80
And change the 80 into any number / port you want. In my scenario I'm using port 8080.
Listen 8080
Still from the httpd.conf file,
You should also do this in the same process
Still from the httpd-ssl.conf file, find another line that says
ServerName localhost:443
And change 443 to 4433.
ServerName localhost:4433
Remember to save the httpd.conf and httpd-ssl.conf files after performing some changes. Then restart the Apache service.
Comment: i too had the problem of running apache server.i changed the port number but its not working.plz help me out.
Comment: after change port restart pc and try again or replace port 81 with 82 or 83 and so on
Comment: you also need to change the httpd-ssl.config file too for changing 443 default ssl port for apache.
Comment: ServerName doesn't need the port number
Answer: Have you executed "setup_xampp.bat" script? It's inside XAMPP folder and it must be executed every time you change XAMPP folder.
Comment: this works for me as i am running windows server 2012 R2 so when i refreshed my windows my XAMPP installation was not in C drive after fresh installation i just ran setup_xampp.bat and it configured every thing successfully thanks cheers!
Answer: In my case the problem was that both port 80 and 443 were in use:
Steps to use to fix it are :

Open xampp and click on config button
Now click on ( Appache )httpd.conf (Open in notepad or other editor)
Now click ctrl + h.
Find 80 and replace with 8080
Now save and now click on Appache(httpd-ssl.conf).
Now find 443 and replace with 4430.
Now your xampp must be working fine as both these code are never in use by other programs on your system.

Now your localhost will be available as localhost:8080
Answer: Accompanying Timmay's answer, You need to do two changes-
Listen 80 --> Listen 81 (near line 58)
ServerName localhost:80 -->  ServerName localhost:81 (near line 218)
Answer: If you are installed Skype, Please check this option.

Another case is Windows 10
Check this:

Go to Start, type in services.msc
Scroll down in the Services window
to find the World Wide Web Publishing Service.
Right-click on it, and select Stop or Disable it if you just want to use XAMPP only.
Answer: I have installed VMWare Workstation. So, It was causing the error.
Services.msc and stopped the 'Workstation' Services.

This has solved my problems.
Thanks
Comment: I had the same issue, that this solution rescue me. Thanks
Answer: Check if you have Skype installed on your machine.
Login and go to Tools - Options - Advanced - Connection and uncheck the box which says use port 80
--
Check if Apache service is already installed by firing up services.msc from run command prompt.
How to delete a service from command prompt?
sc delete "serviceName"
Remember serviceName should be replaced by exact name of the Apache service as shown is services list.
Check if IIS is running and taking up port 80. If so, disable it.
--
Check if AVP (Kaspersky) is running and taking up port 80.
If so add httpd.exe as an exception to allowed programs.
--
Hope it helps.
Answer: go to C:xampp\apache\conf\extra\httpd-ssl.conf
 Find the line where it says Listen 443, change it to Listen 4330 and restart your computer

[![enter image description here][2]][2]
Answer: i have found that similar issue on my system, and that was from skype installed before xampp installed. i got similar error. for fixing the error i followed these,

logged out to skype for a while ,
restarted apache from xampp control panel,
checked on browser, whether it worked or not, by http://localhost/
got it worked,
signed in again to skype,
all working great, as simple as that

i wasn't need nothing to install or uninstall, and this worked for me in less then 1 minute.
cheers
Comment: Yes, it should work. The port which is being by Skype XAMPP also tries to use the same port. So, when you logout skype the problem wouldn't happen
Answer: If You installed SQL Express or any .Net Server then you need to stop.
open cmd in administrator mode and type this line ...
net stop Was
now start apache
Answer: The Best way to do so:
The other methods explained above will get you stuck at a lot of places
Don't go for changing the port
2 Step Process
1) Open Command Prompt as Administrator
2) type net stop http  (If it says it doesn't identify the keyword, then it is only because your Environmental Variable's PATH doesn't contain path to Program Files/System32 you can search on how to do it )
press Y at every place it asks you to, don't worry you are not stopping any important process just some process which took your port. And that process will again take over your port once you are not working.
Answer: If you face this issue directly after a complete new installation on Windows:
It seems like the setup program already starts the http.exe process and blocks the initial port 80 but does not reflect this state in the control panel.
To verify, just test for a running server in your browser. Type into your browser address bar:

localhost

If this displays the XAMPP dashboard, you're fine.
Alternatively, check the Task Manager for a running 'Apache HTTP Server' (httpd.exe) process.
You could stop the apache process with the xampp_stop.exe in your xampp base folder. Then, the XAMPP control panel should work as expected.
Answer: There can be lots of methods to solve this problem, but here is simplest one:
GO to XAMPP-control and...

Run as administrator

That's all..
This is the Golden Point for any such Abnormality.
Concept behind the work
Actually all the services in Xampp need Ports dependency.
What happens is, When there is no special powers given to xampp, it only look for some predefined ports to run those services. And, if in case, those ports are somehow already busy... eek! the service couldn't be started.
But if we give superpower to our Xampp-control (by running as administrator), it will somehow manage and for certainly on earth will run the services on the ports. And triumph! You made it.
Permanent tip for my dear Brother and Sisters
To do the efforts one and for all, follow these steps:

right-click on xampp-control.exe file and go to properties.
Go to Compatibility Tab.
In the settings below, choose the checkbox Run this program as an administrator.
Apply the changes. And you are done.

Now, every time you run the application, it will run with the Administrator status and You don't need to take care about the ports at all.
Answer: For my case, I didn't have htdocs folder in xampp folder. It seems that it requires htdocs folder to run so you can create an empty htdocs folder in the xampp folder.
Answer: Run these commands in terminal and everything will work fine:
sudo /etc/init.d/apache2 stop
sudo /opt/lampp/lampp start

Answer: I have a solution. I had this problem and research a solution, but i did not succeed. So i downloaded a newer version of XAMPP and clicked on the option netstats within the program.There he gave me a list of programs and the ports they used and so I looked and had no program using port 80, but apache beyond 80 also uses port 443... and there was a program called Pando Media Boster this door, I started the task manager and finished the process of pando Average boster. Hope it helped :).
Answer: I also faced the same problem. And I found an easy and fast solution.
The only thing you need to do is to run XAMPP server as administrator everytime.

enter image description here
Answer: Probably you change configuration file in "httpd-ssl.conf"
<VirtualHost _default_:443>
DocumentRoot "D:/Server/xServer"
ServerName xyz.abc.com
SSLCertificateFile "conf/ssl.crt/xyz.crt"
SSLCertificateKeyFile "conf/ssl.key/sftaps.in.key"
</VirtualHost>

May be you change certificate name or something in Apache folder.
Answer: Even if you've configured Apache to listen on another port, you will still get this error if another program is using the default SSL port 443.
What you also need to edit is the http-ssl.conf file and alter the line
Listen 443 and change the port number there.
Answer: just seeing this now since I have the same problem, but changing the port or any other answer didn't work for me.
Here's what was the problem - I've installed XAMPP to a custom location (eg. D:\Programming\XAMPP). Now, since the config files in xampp have simple locations (/xampp/mysql/data etc.) my services couldn't start.
So, I just had to rename all of those locations from /xampp/mysql/data to D:/Programming/XAMPP/mysql/data and now it's working.
Answer: for those of you who just manually activated windows defender Ransomware protection; it could be that your xampp folder or c:\ drive has been listed in the protected folder, and httpd.exe, php.exe  was blocked from accessing it.
Answer: While it is most-likely the port blocking issue, you can always check if the settings of apache are correct:

Open command prompt and navigate to your apache installation bin folder: cd C:/xampp/apache/bin

Then run the following command to see if the syntax is OK:
httpd.exe -t
Answer: It can also be due to the DocumentRoot parameter. In my case, port 80 was not a problem. The default DocumentRoot path and all virtual roots should actually exist and be correctly specified in the xampp\apache\conf\httpd.conf file in the DocumentRoot section (from line 252).
Depending on the installation location, it may look like this:
...
DocumentRoot "C:/xampp/htdocs"

<Directory "C:/xampp/htdocs">
    ...
</Directory>
...


Downloading subtitles using youtube_dl

Question: I am looking to download a video with subtitles using the Youtube_dl library. Currently, I am able to download a single video at a time but I am unable to download subtitles with it.
Currently, my implementation is:
import youtube_dl

link = input('Please enter a url link:\n')

youtube_dl_options = {}

with youtube_dl.YoutubeDL(youtube_dl_options) as youtube_dl_client:
    youtube_dl_client.download([link])

I would like to be able to download the subtitle as well as the video with it.
Comment: Did you check the documentation of youtube_dl?
Answer: The youtube_dl project is hosted on github (https://github.com/rg3/youtube-dl/blob/master/youtube_dl/YoutubeDL.py)
Looking at the YoutubeDL module it looks like there are a bunch of options (see lines 142-298, the one you want is on line 183).
You can pass the option using the dictionary ydl_opts
Try changing ydl_opts to this:
ydl_opts = {"writesubtitles": True}

Downloading subtitles using youtube_dl


Relations between the maximum matching, minimum vertex cover, maximum independent set, and maximum vertex biclique for a bipartite graph

Question: From Wikipedia:

König's theorem states that, in bipartite graphs, the maximum matching
  is equal in size to the minimum vertex cover. Via this result, the
  minimum vertex cover, maximum independent set, and maximum vertex
  biclique problems may be solved in polynomial time for bipartite
  graphs.

König's theorem states about the relation between sizes of the maximum matching
and of the minimum vertex cover, not about conversion between any two of the four: the maximum matching, minimum vertex cover, maximum independent set, and maximum vertex biclique. So I wonder how to understand the sentence in bold?
Thanks!
Answer: König's theorem says that two (normally different) problems--min vertex cover and max matching--become the same on bipartite graphs. The wikipedia page for König's theorem gives an example of the conversion.  The other two problems are equivalent to these two.
Min vertex cover is trivially the same as max independent set (a set of vertices forms a min cover iff all vertices not in the set are independent; see the wikipedia page for vertex cover for more details).
Every independent set induces a clique in the complement graph (or a biclique in the case of bipartite graphs) so this problem too easily reduces from the others.
Comment: Thanks! (1) I wonder how a independent set induces a biclique in the case of bipartite graphs? (2) Also for conversion between maximum matching and minimum vertex cover, Wikipedia only has one direction, and I feel the description there is not easy to picture, so wonder if there are other more clear sources for the conversions of two directions?


Reading from a binary file when closing and opening it

Question: I'm trying to read from a binary file by closing and opening it but it seems like it doesn't work.
When I change it to wb+ and use the commented out fseek instead of closing and opening it does read. What am I doing wrong with closing and opening the file?
int main(){
    FILE * tfp = fopen("test.bin", "wb");
    char src[] = "1233 asd 333";
    fputs(src, tfp);

    char aw[20];

    //fseek(tfp, SEEK_SET, 0);
    fcloseall;

    tfp = fopen("test.bin", "rb");
    fread(aw, sizeof(char), 20, tfp);

    fcloseall;
    getchar();
}

Comment: `fread(&aw, sizeof(int), 20, tfp);` --> `fread(aw, sizeof(char), 20, tfp);`
Comment: and `fread(&aw, ...` -> `fread(aw, ...`
Comment: also add error checking and turn on compiler warnings!
Comment: Still doesn't work. @AlterMann
Comment: Why `sizeof(int)`? you want 20 char's so it should be `sizeof(char)`
Comment: @PaulR Still doesn't work.
Comment: You have multiple problems with the code - you're going to need to fix all of them before it "works".
Comment: Also, it worked fine with the above code when I used the seek instead of closing and opening...
Comment: You mean it *appeared* to "work fine".
Comment: LOL, I'll check all the warnings now. @PaulR
Comment: @user3121023 yeah I just saw that too in the warnings... this is embarrassing. That was it...
Comment: BTW, why not use the `&`? @PaulR
Comment: `aw` is already a pointer.
Answer: The problem was fcloseall; instead of fcloseall();


can a method parameter pass an object by reference but be read-only?

Question: C#: can you make it so that a method parameter passes an object by reference but is read-only?
eg:
void MyMethod(int x, int y, read-only MyObject obj)

where obj is an object reference but this object cannot be modified during the method.
Can this be achieved in C#?
Comment: That question asks why const parameters are not allowed.  My question asks whether a read-only parameter is possible in C#. I don't consider it a duplicate.
Comment: possible duplicate of [Why const parameters are not allowed in C#](http://stackoverflow.com/questions/3263001/why-const-parameters-are-not-allowed-in-c)
Answer: No.  C# has no direct analogue to C++ const (its own const is something different).  A common C# pattern for this is to pass in a interface, such as IEnumerable, that does not permit modifications.  You can also create an immutable copy or wrapper.
Comment: `IEnumerable` is an example.  Think of the difference between `IEnumerable` and `List`.  You can clearly modify a `List`, but if you use it as an `IEnumerable` (which it implements), all you can do is access elements in order (`MoveNext`<->`Current`).  You can make your own interfaces with similar read-only properties.
Comment: Can you elaborate?  Would I need to make MyObject implement the IEnumerable interface?
Comment: +1, this is the same as my answer, I didn't see it. But I'll leave mine there as the "long version". :)
Answer: If the class of the object you're passing was written by you, then you're in luck.
Ask yourself: if C# had a const feature, what operations on the object would I expect to be banned through a const reference to my class?
Then define an interface that leaves out the banned operations.
For example:
class MyClass
{
    public string GetSomething() { ... }

    public void Clobber() { ... }

    public int Thing { get { ... } set { ... } }
}

The corresponding "const" interface might be:
interface IConstMyClass
{
    public string GetSomething() { ... }

    public int Thing { get { ... } }
}

Now amend the class:
class MyClass : IConstMyClass
{

Now you can use IConstMyClass to mean const MyClass.
 void MyMethod(int x, int y, IConstMyClass obj)

Note: there will be those who will tell you that this isn't enough. What if MyMethod casts back to MyClass? But ignore them. Ultimately the implementor can use reflection to get around any aspect of the type system - see this amusing example.
The only option to stop reflection attacks is the trivial approach: make a totally disconnected clone.
Comment: Although another answer is essentially the same, I really appreciate the extra effort to explain it so well in a way that a CPP programmer would understand.  This answer is an outstanding effort which is very helpful.
Comment: @shawn1874 - thanks, what a great bit of feedback! :)
Answer: This is not possible in C#.
You can prevent this by passing in an immutable object.
Comment: How you pass it is different from immutability, the two are completely orthogonal in the case of objects.
Answer: There is no mechanism that does this for you.
Either pass a throwaway copy, or build immutability, even if temporary, into the class itself.
Comment: You mean like a clone of the original object?
Comment: Yes, exactly, if that is feasible. If you do, then changes doesn't matter.
Comment: What is the overhead of making your class implement the ICloneable interface?
Comment: I wouldn't, that is, I would make something similar, but I wouldn't implement ICloneable. It is a broken contract. As for overhead, it's another method, and depending on how the class has been written you might have to change parts of it to accomodate cloning. Runtime overhead should be zero though.
Answer: why don't you make a copy of that object and do whatever you want with that copy while your obj remains not modified.
See here how to clone your object: Deep cloning objects
Comment: @Craig - the cost of temporary reference object allocation on the CLR is incredibly small, closer to stack allocation than C++ heap allocation. http://smellegantcode.wordpress.com/2009/03/01/the-amazing-speed-of-the-net-garbage-collector/
Comment: One reason why you might not want to make a copy is because you're worried about the performance cost of making a copy.
Comment: I would prefer a solution that doesn't increase memory costs.
Comment: Another problem with that suggestion is that the coder who writes the "receiving" method may assume that the state changes they cause on the object will be permanent, when in fact they are going to be thrown away.
Comment: @Daniel: wouldn't it be a copy of the whole object, not just the reference?
Comment: @Daniel: I was hoping a modifier such as const or readonly could be used, which would alert the next coder who saw the method.
Comment: @Craig Johnston - "reference object" is what the CLR calls an object allocated from the GC heap, so yes, I'm talking about copying the object. The point is that you may be worrying about nothing. If it is expensive then the memory allocation won't be the expensive part - the cost is more likely to be in having to do a deep copy (which for some objects can involve modifying state external to the program, e.g. an object that encapsulates a temporary file).
Comment: @Craig - the type of the reference tells the coder what they can do to the object it refers to. It makes no difference whether this is done using a modifier keyword or a distinct hand-written interface. (Well, the difference is that you have to write the interface by hand, but otherwise its exactly the same).


Using bootstrap popover in angularjs

Question: I like to use Popover in my AngularJS application and have included ui-bootstrap for this, but I get an injection error:
Error: [$injector:unpr] Unknown provider: ui.bootstrapProvider <- ui.bootstrap

In my index.html

In my controller class:
angular
    .module('app')
    .controller('TeamsController', TeamsController);

TeamsController.$inject = ['Flash', '$scope', 'ui.bootstrap'];
function TeamsController(Flash, $scope, $modal)
{
 //Code here
}

I cant really figure out how to do this correctly.
Answer: You have to include it as a dependency to your app:
angular.module('myModule', ['ui.bootstrap']);

More info on the Angular UI page.
Update
Working plunker. Note that I have removed the Flash dependency because I don't know what it is, you must add it yourself back in the script.
Comment: I tried this, 'angular
    .module('app', ['ui.bootstrap'])
    .controller('TeamsController', TeamsController);'  but then my site would not load at all...
Comment: What version of angular are you using? And there are any console errors?
Comment: No errors at all, just no page... using code.angularjs.org/1.2.20/angular.js
Comment: Have you tried [this](http://plnkr.co/edit/oLRP76D8hsz9mt95Pz74?p=preview) plunker? It's also on the Angular UI page..
Comment: I did, tried some more, but got rid of it when updating my angular-version, hopefully I can get it to work now! Thanks!

Using bootstrap popover in angularjs