idx
int64
1
56k
question
stringlengths
15
155
answer
stringlengths
2
29.2k
question_cut
stringlengths
15
100
answer_cut
stringlengths
2
200
conversation
stringlengths
47
29.3k
conversation_cut
stringlengths
47
301
12,601
When are Bayesian methods preferable to Frequentist?
The Bayesian approach to hypothesis testing is a lot more intuitive. Suppose you wish to calculate a two-sample T-test. You can use the T-statistic to do this and then find the p-value. One can argue this is not a very intuitive method, it is very ad hoc, and very specific to the problem. The Bayesian approach is to simply treat the two parameters as distributions. Once you feed the data into your problem you will get your posterior distributions. Now you can run some simulations to see how frequently your hypothesis is true in the space-of-all-possibilities. Interesting, the probability you will get from this method will be consistent with the non-Bayesian t-test method. However, this Bayesian approach is more intuitive to understand and can easily generalize to hypothesis tests which violate the assumptions of the t-test.
When are Bayesian methods preferable to Frequentist?
The Bayesian approach to hypothesis testing is a lot more intuitive. Suppose you wish to calculate a two-sample T-test. You can use the T-statistic to do this and then find the p-value. One can argue
When are Bayesian methods preferable to Frequentist? The Bayesian approach to hypothesis testing is a lot more intuitive. Suppose you wish to calculate a two-sample T-test. You can use the T-statistic to do this and then find the p-value. One can argue this is not a very intuitive method, it is very ad hoc, and very specific to the problem. The Bayesian approach is to simply treat the two parameters as distributions. Once you feed the data into your problem you will get your posterior distributions. Now you can run some simulations to see how frequently your hypothesis is true in the space-of-all-possibilities. Interesting, the probability you will get from this method will be consistent with the non-Bayesian t-test method. However, this Bayesian approach is more intuitive to understand and can easily generalize to hypothesis tests which violate the assumptions of the t-test.
When are Bayesian methods preferable to Frequentist? The Bayesian approach to hypothesis testing is a lot more intuitive. Suppose you wish to calculate a two-sample T-test. You can use the T-statistic to do this and then find the p-value. One can argue
12,602
When are Bayesian methods preferable to Frequentist?
Imagine you estimate a probability that AC Milan beats Real Madrid and they have played 3 games in their current line-up. All 3 games were won by Real Madrid. Then a frequentist says that Milan can never beat Real Madrid, which makes no sense. A Bayesian might take a prior from the previous seasons, which would result in some positive posterior probability for Milan.
When are Bayesian methods preferable to Frequentist?
Imagine you estimate a probability that AC Milan beats Real Madrid and they have played 3 games in their current line-up. All 3 games were won by Real Madrid. Then a frequentist says that Milan can ne
When are Bayesian methods preferable to Frequentist? Imagine you estimate a probability that AC Milan beats Real Madrid and they have played 3 games in their current line-up. All 3 games were won by Real Madrid. Then a frequentist says that Milan can never beat Real Madrid, which makes no sense. A Bayesian might take a prior from the previous seasons, which would result in some positive posterior probability for Milan.
When are Bayesian methods preferable to Frequentist? Imagine you estimate a probability that AC Milan beats Real Madrid and they have played 3 games in their current line-up. All 3 games were won by Real Madrid. Then a frequentist says that Milan can ne
12,603
Euclidean distance score and similarity
The inverse is to change from distance to similarity. The 1 in the denominator is to make it so that the maximum value is 1 (if the distance is 0). The square root - I am not sure. If distance is usually larger than 1, the root will make large distances less important; if distance is less than 1, it will make large distances more important.
Euclidean distance score and similarity
The inverse is to change from distance to similarity. The 1 in the denominator is to make it so that the maximum value is 1 (if the distance is 0). The square root - I am not sure. If distance is usua
Euclidean distance score and similarity The inverse is to change from distance to similarity. The 1 in the denominator is to make it so that the maximum value is 1 (if the distance is 0). The square root - I am not sure. If distance is usually larger than 1, the root will make large distances less important; if distance is less than 1, it will make large distances more important.
Euclidean distance score and similarity The inverse is to change from distance to similarity. The 1 in the denominator is to make it so that the maximum value is 1 (if the distance is 0). The square root - I am not sure. If distance is usua
12,604
Euclidean distance score and similarity
To measure the distance and similarity (in the semantic sense) the first thing to check is if you are moving in a Euclidean space or not. An empirical way to verify this is to estimate the distance of a pair of values ​​for which you know the meaning.
Euclidean distance score and similarity
To measure the distance and similarity (in the semantic sense) the first thing to check is if you are moving in a Euclidean space or not. An empirical way to verify this is to estimate the distance of
Euclidean distance score and similarity To measure the distance and similarity (in the semantic sense) the first thing to check is if you are moving in a Euclidean space or not. An empirical way to verify this is to estimate the distance of a pair of values ​​for which you know the meaning.
Euclidean distance score and similarity To measure the distance and similarity (in the semantic sense) the first thing to check is if you are moving in a Euclidean space or not. An empirical way to verify this is to estimate the distance of
12,605
Euclidean distance score and similarity
As you mentioned you know the calculation of Euclidence distance so I am explaining the second formula. Euclidean formula calculates the distance, which will be smaller for people or items who are more similar. Like if they are the same then the distance is 0 and totally different then higher than 0. However, we need a function that gives a higher value. This can be done by adding 1 to the function(so you don't get a division-by-zero error and the maximum value remains 1) and inverting it. Like if distance 0 then the similarity score 1/1=1 Let say the Euclidean distance between item 1 and item 2 is 4 and between item 1 and item 3 is 0 (means they are 100% similar). These are the distance of items in a virtual space. smaller the distance value means they are near to each other means more likely to similar. Now we want numerical value such that it gives a higher number if they are much similar. So we can inverse distance value. But what if we have distance is 0 that's why we add 1 in the denominator. so similarity score for item 1 and 2 is 1/(1+4) = 0.2 and for item1 and item 3 is 1/(1+0) = 1
Euclidean distance score and similarity
As you mentioned you know the calculation of Euclidence distance so I am explaining the second formula. Euclidean formula calculates the distance, which will be smaller for people or items who are mor
Euclidean distance score and similarity As you mentioned you know the calculation of Euclidence distance so I am explaining the second formula. Euclidean formula calculates the distance, which will be smaller for people or items who are more similar. Like if they are the same then the distance is 0 and totally different then higher than 0. However, we need a function that gives a higher value. This can be done by adding 1 to the function(so you don't get a division-by-zero error and the maximum value remains 1) and inverting it. Like if distance 0 then the similarity score 1/1=1 Let say the Euclidean distance between item 1 and item 2 is 4 and between item 1 and item 3 is 0 (means they are 100% similar). These are the distance of items in a virtual space. smaller the distance value means they are near to each other means more likely to similar. Now we want numerical value such that it gives a higher number if they are much similar. So we can inverse distance value. But what if we have distance is 0 that's why we add 1 in the denominator. so similarity score for item 1 and 2 is 1/(1+4) = 0.2 and for item1 and item 3 is 1/(1+0) = 1
Euclidean distance score and similarity As you mentioned you know the calculation of Euclidence distance so I am explaining the second formula. Euclidean formula calculates the distance, which will be smaller for people or items who are mor
12,606
Euclidean distance score and similarity
Euclidean is basically calculate the dissimilarity of two vectors, because it'll return 0 if two vectors are similar. While Cosine Similarity gives 1 in return to similarity. Somewhat the writer on that book wants a similarity-based measure, but he wants to use Euclidean. So, in order to get a similarity-based distance, he flipped the formula and added it with 1, so that it gives 1 when two vectors are similar. Go give it a check, try it with 2 vectors contain same values.
Euclidean distance score and similarity
Euclidean is basically calculate the dissimilarity of two vectors, because it'll return 0 if two vectors are similar. While Cosine Similarity gives 1 in return to similarity. Somewhat the writer on th
Euclidean distance score and similarity Euclidean is basically calculate the dissimilarity of two vectors, because it'll return 0 if two vectors are similar. While Cosine Similarity gives 1 in return to similarity. Somewhat the writer on that book wants a similarity-based measure, but he wants to use Euclidean. So, in order to get a similarity-based distance, he flipped the formula and added it with 1, so that it gives 1 when two vectors are similar. Go give it a check, try it with 2 vectors contain same values.
Euclidean distance score and similarity Euclidean is basically calculate the dissimilarity of two vectors, because it'll return 0 if two vectors are similar. While Cosine Similarity gives 1 in return to similarity. Somewhat the writer on th
12,607
Plotting confidence intervals for the predicted probabilities from a logistic regression
The code you used estimates a logistic regression model using the glm function. You didn't include data, so I'll just make some up. set.seed(1234) mydat <- data.frame( won=as.factor(sample(c(0, 1), 250, replace=TRUE)), bid=runif(250, min=0, max=1000) ) mod1 <- glm(won~bid, data=mydat, family=binomial(link="logit")) A logistic regression model models the relationship between a binary response variable and, in this case, one continuous predictor. The result is a logit-transformed probability as a linear relation to the predictor. In your case, the outcome is a binary response corresponding to winning or not winning at gambling and it is being predicted by the value of the wager. The coefficients from mod1 are given in logged odds (which are difficult to interpret), according to: $$\text{logit}(p)=\log\left(\frac{p}{(1-p)}\right)=\beta_{0}+\beta_{1}x_{1}$$ To convert logged odds to probabilities, we can translate the above to $$p=\frac{\exp(\beta_{0}+\beta_{1}x_{1})}{(1+\exp(\beta_{0}+\beta_{1}x_{1}))}$$ You can use this information to set up the plot. First, you need a range of the predictor variable: plotdat <- data.frame(bid=(0:1000)) Then using predict, you can obtain predictions based on your model preddat <- predict(mod1, newdata=plotdat, se.fit=TRUE) Note that the fitted values can also be obtained via mod1$fitted By specifying se.fit=TRUE, you also get the standard error associated with each fitted value. The resulting data.frame is a matrix with the following components: the fitted predictions (fit), the estimated standard errors (se.fit), and a scalar giving the square root of the dispersion used to compute the standard errors (residual.scale). In the case of a binomial logit, the value will be 1 (which you can see by entering preddat$residual.scale in R). If you want to see an example of what you've calculated so far, you can type head(data.frame(preddat)). The next step is to set up the plot. I like to set up a blank plotting area with the parameters first: with(mydat, plot(bid, won, type="n", ylim=c(0, 1), ylab="Probability of winning", xlab="Bid")) Now you can see where it is important to know how to calculate the fitted probabilities. You can draw the line corresponding to the fitted probabilities following the second formula above. Using the preddat data.frame you can convert the fitted values to probabilities and use that to plot a line against the values of your predictor variable. with(preddat, lines(0:1000, exp(fit)/(1+exp(fit)), col="blue")) Finally, answer your question, the confidence intervals can be added to the plot by calculating the probability for the fitted values +/- 1.96 times the standard error: with(preddat, lines(0:1000, exp(fit+1.96*se.fit)/(1+exp(fit+1.96*se.fit)), lty=2)) with(preddat, lines(0:1000, exp(fit-1.96*se.fit)/(1+exp(fit-1.96*se.fit)), lty=2)) The resulting plot (from the randomly generated data) should look something like this: For expediency's sake, here's all the code in one chunk: set.seed(1234) mydat <- data.frame( won=as.factor(sample(c(0, 1), 250, replace=TRUE)), bid=runif(250, min=0, max=1000) ) mod1 <- glm(won~bid, data=mydat, family=binomial(link="logit")) plotdat <- data.frame(bid=(0:1000)) preddat <- predict(mod1, newdata=plotdat, se.fit=TRUE) with(mydat, plot(bid, won, type="n", ylim=c(0, 1), ylab="Probability of winning", xlab="Bid")) with(preddat, lines(0:1000, exp(fit)/(1+exp(fit)), col="blue")) with(preddat, lines(0:1000, exp(fit+1.96*se.fit)/(1+exp(fit+1.96*se.fit)), lty=2)) with(preddat, lines(0:1000, exp(fit-1.96*se.fit)/(1+exp(fit-1.96*se.fit)), lty=2)) (Note: This is a heavily edited answer in an attempt to make it more relevant to stats.stackexchange.)
Plotting confidence intervals for the predicted probabilities from a logistic regression
The code you used estimates a logistic regression model using the glm function. You didn't include data, so I'll just make some up. set.seed(1234) mydat <- data.frame( won=as.factor(sample(c(0, 1)
Plotting confidence intervals for the predicted probabilities from a logistic regression The code you used estimates a logistic regression model using the glm function. You didn't include data, so I'll just make some up. set.seed(1234) mydat <- data.frame( won=as.factor(sample(c(0, 1), 250, replace=TRUE)), bid=runif(250, min=0, max=1000) ) mod1 <- glm(won~bid, data=mydat, family=binomial(link="logit")) A logistic regression model models the relationship between a binary response variable and, in this case, one continuous predictor. The result is a logit-transformed probability as a linear relation to the predictor. In your case, the outcome is a binary response corresponding to winning or not winning at gambling and it is being predicted by the value of the wager. The coefficients from mod1 are given in logged odds (which are difficult to interpret), according to: $$\text{logit}(p)=\log\left(\frac{p}{(1-p)}\right)=\beta_{0}+\beta_{1}x_{1}$$ To convert logged odds to probabilities, we can translate the above to $$p=\frac{\exp(\beta_{0}+\beta_{1}x_{1})}{(1+\exp(\beta_{0}+\beta_{1}x_{1}))}$$ You can use this information to set up the plot. First, you need a range of the predictor variable: plotdat <- data.frame(bid=(0:1000)) Then using predict, you can obtain predictions based on your model preddat <- predict(mod1, newdata=plotdat, se.fit=TRUE) Note that the fitted values can also be obtained via mod1$fitted By specifying se.fit=TRUE, you also get the standard error associated with each fitted value. The resulting data.frame is a matrix with the following components: the fitted predictions (fit), the estimated standard errors (se.fit), and a scalar giving the square root of the dispersion used to compute the standard errors (residual.scale). In the case of a binomial logit, the value will be 1 (which you can see by entering preddat$residual.scale in R). If you want to see an example of what you've calculated so far, you can type head(data.frame(preddat)). The next step is to set up the plot. I like to set up a blank plotting area with the parameters first: with(mydat, plot(bid, won, type="n", ylim=c(0, 1), ylab="Probability of winning", xlab="Bid")) Now you can see where it is important to know how to calculate the fitted probabilities. You can draw the line corresponding to the fitted probabilities following the second formula above. Using the preddat data.frame you can convert the fitted values to probabilities and use that to plot a line against the values of your predictor variable. with(preddat, lines(0:1000, exp(fit)/(1+exp(fit)), col="blue")) Finally, answer your question, the confidence intervals can be added to the plot by calculating the probability for the fitted values +/- 1.96 times the standard error: with(preddat, lines(0:1000, exp(fit+1.96*se.fit)/(1+exp(fit+1.96*se.fit)), lty=2)) with(preddat, lines(0:1000, exp(fit-1.96*se.fit)/(1+exp(fit-1.96*se.fit)), lty=2)) The resulting plot (from the randomly generated data) should look something like this: For expediency's sake, here's all the code in one chunk: set.seed(1234) mydat <- data.frame( won=as.factor(sample(c(0, 1), 250, replace=TRUE)), bid=runif(250, min=0, max=1000) ) mod1 <- glm(won~bid, data=mydat, family=binomial(link="logit")) plotdat <- data.frame(bid=(0:1000)) preddat <- predict(mod1, newdata=plotdat, se.fit=TRUE) with(mydat, plot(bid, won, type="n", ylim=c(0, 1), ylab="Probability of winning", xlab="Bid")) with(preddat, lines(0:1000, exp(fit)/(1+exp(fit)), col="blue")) with(preddat, lines(0:1000, exp(fit+1.96*se.fit)/(1+exp(fit+1.96*se.fit)), lty=2)) with(preddat, lines(0:1000, exp(fit-1.96*se.fit)/(1+exp(fit-1.96*se.fit)), lty=2)) (Note: This is a heavily edited answer in an attempt to make it more relevant to stats.stackexchange.)
Plotting confidence intervals for the predicted probabilities from a logistic regression The code you used estimates a logistic regression model using the glm function. You didn't include data, so I'll just make some up. set.seed(1234) mydat <- data.frame( won=as.factor(sample(c(0, 1)
12,608
Plotting confidence intervals for the predicted probabilities from a logistic regression
Here's a modification of @smillig's solution. I use tidyverse tools here, and also use the linkinv function that is a part of the GLM model object mod1. That way, you don't have to manually invert the logistic function, and this approach will work regardless of what specific GLM you fit. library(tidyverse) library(magrittr) set.seed(1234) # create fake data on gambling. Does prob win depend on bid size? mydat <- data.frame( won=as.factor(sample(c(0, 1), 250, replace=TRUE)), bid=runif(250, min=0, max=1000) ) # logistic regression model: mod1 <- glm(won~bid, data=mydat, family=binomial(link="logit")) # new predictor values to use for prediction: plotdat <- data.frame(bid=(0:1000)) # df with predictions, lower and upper limits of CIs: preddat <- predict(mod1, type = "link", newdata=plotdat, se.fit=TRUE) %>% as.data.frame() %>% mutate(bid = (0:1000), # model object mod1 has a component called linkinv that # is a function that inverts the link function of the GLM: lower = mod1$family$linkinv(fit - 1.96*se.fit), point.estimate = mod1$family$linkinv(fit), upper = mod1$family$linkinv(fit + 1.96*se.fit)) # plotting with ggplot: preddat %>% ggplot(aes(x = bid, y = point.estimate)) + geom_line(colour = "blue") + geom_ribbon(aes(ymin = lower, ymax = upper), alpha = 0.5) + scale_y_continuous(limits = c(0,1))
Plotting confidence intervals for the predicted probabilities from a logistic regression
Here's a modification of @smillig's solution. I use tidyverse tools here, and also use the linkinv function that is a part of the GLM model object mod1. That way, you don't have to manually invert the
Plotting confidence intervals for the predicted probabilities from a logistic regression Here's a modification of @smillig's solution. I use tidyverse tools here, and also use the linkinv function that is a part of the GLM model object mod1. That way, you don't have to manually invert the logistic function, and this approach will work regardless of what specific GLM you fit. library(tidyverse) library(magrittr) set.seed(1234) # create fake data on gambling. Does prob win depend on bid size? mydat <- data.frame( won=as.factor(sample(c(0, 1), 250, replace=TRUE)), bid=runif(250, min=0, max=1000) ) # logistic regression model: mod1 <- glm(won~bid, data=mydat, family=binomial(link="logit")) # new predictor values to use for prediction: plotdat <- data.frame(bid=(0:1000)) # df with predictions, lower and upper limits of CIs: preddat <- predict(mod1, type = "link", newdata=plotdat, se.fit=TRUE) %>% as.data.frame() %>% mutate(bid = (0:1000), # model object mod1 has a component called linkinv that # is a function that inverts the link function of the GLM: lower = mod1$family$linkinv(fit - 1.96*se.fit), point.estimate = mod1$family$linkinv(fit), upper = mod1$family$linkinv(fit + 1.96*se.fit)) # plotting with ggplot: preddat %>% ggplot(aes(x = bid, y = point.estimate)) + geom_line(colour = "blue") + geom_ribbon(aes(ymin = lower, ymax = upper), alpha = 0.5) + scale_y_continuous(limits = c(0,1))
Plotting confidence intervals for the predicted probabilities from a logistic regression Here's a modification of @smillig's solution. I use tidyverse tools here, and also use the linkinv function that is a part of the GLM model object mod1. That way, you don't have to manually invert the
12,609
What is a tight lower bound on the coupon collector time?
I'm providing this as a second answer since the analysis is completely elementary and provides exactly the desired result. Proposition For $c > 0$ and $n \geq 1$, $$ \mathbb{P}(T < n \log n - c n ) < e^{-c} \>. $$ The idea behind the proof is simple: Represent the time until all coupons are collected as $T = \sum_{i=1}^n T_i$, where $T_i$ is the time that the $i$th (heretofore) unique coupon is collected. The $T_i$ are geometric random variables with mean times of $\frac{n}{n-i+1}$. Apply a version of the Chernoff bound and simplify. Proof For any $t$ and any $s > 0$, we have that $$ \mathbb{P}(T < t) = \mathbb{P}( e^{-s T} > e^{-s t} ) \leq e^{s t} \mathbb{E} e^{-s T} \> . $$ Since $T = \sum_i T_i$ and the $T_i$ are independent, we can write $$ \mathbb{E} e^{-s T} = \prod_{i=1}^n \mathbb{E} e^{- s T_i} $$ Now since $T_i$ is geometric, let's say with probability of success $p_i$, then a simple calculation shows $$ \mathbb{E} e^{-s T_i} = \frac{p_i}{e^s - 1 + p_i} . $$ The $p_i$ for our problem are $p_1 = 1$, $p_2 = 1 - 1/n$, $p_3 = 1 - 2/n$, etc. Hence, $$ \prod_{i=1}^n \mathbb{E} e^{-s T_i} = \prod_{i=1}^n \frac{i/n}{e^s - 1 + i/n}. $$ Let's choose $s = 1/n$ and $t = n \log n - c n$ for some $c > 0$. Then $$ e^{s t} = n e^{-c} $$ and $e^s = e^{1/n} \geq 1 + 1/n$, yielding $$ \prod_{i=1}^n \frac{i/n}{e^s - 1 + i/n} \leq \prod_{i=1}^n \frac{i}{i+1} = \frac{1}{n+1} \> . $$ Putting this together, we get that $$ P(T < n \log n - c n) \leq \frac{n}{n+1} e^{-c} < e^{-c} $$ as desired.
What is a tight lower bound on the coupon collector time?
I'm providing this as a second answer since the analysis is completely elementary and provides exactly the desired result. Proposition For $c > 0$ and $n \geq 1$, $$ \mathbb{P}(T < n \log n - c n ) <
What is a tight lower bound on the coupon collector time? I'm providing this as a second answer since the analysis is completely elementary and provides exactly the desired result. Proposition For $c > 0$ and $n \geq 1$, $$ \mathbb{P}(T < n \log n - c n ) < e^{-c} \>. $$ The idea behind the proof is simple: Represent the time until all coupons are collected as $T = \sum_{i=1}^n T_i$, where $T_i$ is the time that the $i$th (heretofore) unique coupon is collected. The $T_i$ are geometric random variables with mean times of $\frac{n}{n-i+1}$. Apply a version of the Chernoff bound and simplify. Proof For any $t$ and any $s > 0$, we have that $$ \mathbb{P}(T < t) = \mathbb{P}( e^{-s T} > e^{-s t} ) \leq e^{s t} \mathbb{E} e^{-s T} \> . $$ Since $T = \sum_i T_i$ and the $T_i$ are independent, we can write $$ \mathbb{E} e^{-s T} = \prod_{i=1}^n \mathbb{E} e^{- s T_i} $$ Now since $T_i$ is geometric, let's say with probability of success $p_i$, then a simple calculation shows $$ \mathbb{E} e^{-s T_i} = \frac{p_i}{e^s - 1 + p_i} . $$ The $p_i$ for our problem are $p_1 = 1$, $p_2 = 1 - 1/n$, $p_3 = 1 - 2/n$, etc. Hence, $$ \prod_{i=1}^n \mathbb{E} e^{-s T_i} = \prod_{i=1}^n \frac{i/n}{e^s - 1 + i/n}. $$ Let's choose $s = 1/n$ and $t = n \log n - c n$ for some $c > 0$. Then $$ e^{s t} = n e^{-c} $$ and $e^s = e^{1/n} \geq 1 + 1/n$, yielding $$ \prod_{i=1}^n \frac{i/n}{e^s - 1 + i/n} \leq \prod_{i=1}^n \frac{i}{i+1} = \frac{1}{n+1} \> . $$ Putting this together, we get that $$ P(T < n \log n - c n) \leq \frac{n}{n+1} e^{-c} < e^{-c} $$ as desired.
What is a tight lower bound on the coupon collector time? I'm providing this as a second answer since the analysis is completely elementary and provides exactly the desired result. Proposition For $c > 0$ and $n \geq 1$, $$ \mathbb{P}(T < n \log n - c n ) <
12,610
What is a tight lower bound on the coupon collector time?
Although @cardinal has already given an answer that gives precisely the bound I was looking for, I have found a similar Chernoff-style argument that can give a stronger bound: Proposition: $$ Pr (T \leq n \log n - c n) \leq \exp(- \frac{3c^2}{\pi^2} ) \> . $$ (this is stronger for $c > \frac{\pi^2}{3}$ ) Proof: As in @cardinal's answer, we can use the fact that $T$ is a sum of independent geometric random variables $T_i$ with success probabilities $p_i = 1 - i/n$. It follows that $E[T_i] = 1/p_i$ and $E[T] = \sum_{i=1}^{n} E[T_i] = n \sum_{i=1}^n \frac{1}{i}\geq n \log n$. Define now new variables $S_i : = T_i - E[T_i]$, and $S : = \sum_i S_i$. We can then write $$ \Pr (T \leq n \log n - c n) \leq \Pr (T \leq E[T] - c n) = \Pr (S \leq - c n) $$ $$ = \Pr\left(\exp(-s S ) \geq \exp( s cn) \right) \leq e^{-s c n} E\left[ e^{-s S} \right] $$ Computing the averages, we have $$ E[e^{-s S}] = \prod_i E[e^{-s S_i}] = \prod_i \frac{e^{s / p_i} } {1 + \frac{1}{p_i} (e^s -1)} \leq e^{\frac{1}{2}s^2\sum_i p_i^{-2}} $$ where the inequality follows from the facts that $e^s - 1\geq s$ and also $\frac{e^z}{1+z}\leq e^{\frac{1}{2}z^2}$ for $z\geq 0$. Thus, since $\sum_i p_i ^{-2} = n^2 \sum_{i=1}^{n-1} \frac{1}{i^2} \leq n^2 \pi^2/6$, we can write \begin{align*} \Pr( T \leq n \log n - c n ) \leq e^{\frac{1}{12} (n \pi s)^2 - s c n}. \end{align*} Minimizing over $s>0$, we finally obtain $$ \Pr( T \leq n\log n -cn ) \leq e^{-\frac{3 c^2 }{\pi^2}} $$
What is a tight lower bound on the coupon collector time?
Although @cardinal has already given an answer that gives precisely the bound I was looking for, I have found a similar Chernoff-style argument that can give a stronger bound: Proposition: $$ Pr (T \
What is a tight lower bound on the coupon collector time? Although @cardinal has already given an answer that gives precisely the bound I was looking for, I have found a similar Chernoff-style argument that can give a stronger bound: Proposition: $$ Pr (T \leq n \log n - c n) \leq \exp(- \frac{3c^2}{\pi^2} ) \> . $$ (this is stronger for $c > \frac{\pi^2}{3}$ ) Proof: As in @cardinal's answer, we can use the fact that $T$ is a sum of independent geometric random variables $T_i$ with success probabilities $p_i = 1 - i/n$. It follows that $E[T_i] = 1/p_i$ and $E[T] = \sum_{i=1}^{n} E[T_i] = n \sum_{i=1}^n \frac{1}{i}\geq n \log n$. Define now new variables $S_i : = T_i - E[T_i]$, and $S : = \sum_i S_i$. We can then write $$ \Pr (T \leq n \log n - c n) \leq \Pr (T \leq E[T] - c n) = \Pr (S \leq - c n) $$ $$ = \Pr\left(\exp(-s S ) \geq \exp( s cn) \right) \leq e^{-s c n} E\left[ e^{-s S} \right] $$ Computing the averages, we have $$ E[e^{-s S}] = \prod_i E[e^{-s S_i}] = \prod_i \frac{e^{s / p_i} } {1 + \frac{1}{p_i} (e^s -1)} \leq e^{\frac{1}{2}s^2\sum_i p_i^{-2}} $$ where the inequality follows from the facts that $e^s - 1\geq s$ and also $\frac{e^z}{1+z}\leq e^{\frac{1}{2}z^2}$ for $z\geq 0$. Thus, since $\sum_i p_i ^{-2} = n^2 \sum_{i=1}^{n-1} \frac{1}{i^2} \leq n^2 \pi^2/6$, we can write \begin{align*} \Pr( T \leq n \log n - c n ) \leq e^{\frac{1}{12} (n \pi s)^2 - s c n}. \end{align*} Minimizing over $s>0$, we finally obtain $$ \Pr( T \leq n\log n -cn ) \leq e^{-\frac{3 c^2 }{\pi^2}} $$
What is a tight lower bound on the coupon collector time? Although @cardinal has already given an answer that gives precisely the bound I was looking for, I have found a similar Chernoff-style argument that can give a stronger bound: Proposition: $$ Pr (T \
12,611
What is a tight lower bound on the coupon collector time?
Important Note: I've decided to remove the proof I gave originally in this answer. It was longer, more computational, used bigger hammers, and proved a weaker result as compared to the other proof I've given. All around, an inferior approach (in my view). If you're really interested, I suppose you can look at the edits. The asymptotic results that I originally quoted and which are still found below in this answer do show that as $n \to \infty$ we can do a bit better than the bound proved in the other answer, which holds for all $n$. The following asymptotic results hold $$ \mathbb{P}(T > n \log n + c n ) \to 1 - e^{-e^{-c}} $$ and $$ \mathbb{P}(T \leq n \log n - c n ) \to e^{-e^c} \>. $$ The constant $c \in \mathbb{R}$ and the limits are taken as $n \to \infty$. Note that, though they're separated into two results, they're pretty much the same result since $c$ is not constrained to be nonnegative in either case. See, e.g., Motwani and Raghavan, Randomized Algorithms, pp. 60--63 for a proof. Also: David kindly provides a proof for his stated upper bound in the comments to this answer.
What is a tight lower bound on the coupon collector time?
Important Note: I've decided to remove the proof I gave originally in this answer. It was longer, more computational, used bigger hammers, and proved a weaker result as compared to the other proof I'v
What is a tight lower bound on the coupon collector time? Important Note: I've decided to remove the proof I gave originally in this answer. It was longer, more computational, used bigger hammers, and proved a weaker result as compared to the other proof I've given. All around, an inferior approach (in my view). If you're really interested, I suppose you can look at the edits. The asymptotic results that I originally quoted and which are still found below in this answer do show that as $n \to \infty$ we can do a bit better than the bound proved in the other answer, which holds for all $n$. The following asymptotic results hold $$ \mathbb{P}(T > n \log n + c n ) \to 1 - e^{-e^{-c}} $$ and $$ \mathbb{P}(T \leq n \log n - c n ) \to e^{-e^c} \>. $$ The constant $c \in \mathbb{R}$ and the limits are taken as $n \to \infty$. Note that, though they're separated into two results, they're pretty much the same result since $c$ is not constrained to be nonnegative in either case. See, e.g., Motwani and Raghavan, Randomized Algorithms, pp. 60--63 for a proof. Also: David kindly provides a proof for his stated upper bound in the comments to this answer.
What is a tight lower bound on the coupon collector time? Important Note: I've decided to remove the proof I gave originally in this answer. It was longer, more computational, used bigger hammers, and proved a weaker result as compared to the other proof I'v
12,612
What is a tight lower bound on the coupon collector time?
Benjamin Doerr gives (in the chapter " Analyzing Randomized Search Heuristics: Tools from Probability Theory" in the book "Theory of Randomized Search Heuristics", see the link for an online PDF) a somewhat simple proof of Proposition Let $T$ be the stopping time of the coupon collection process. Then $\Pr[T\le (1-\epsilon)(n-1)\ln n]\le e^{-n^{\epsilon}}$. This seems to give the desired asymptotics (from @cardinal's second answer), but with the advantage of being true for all $n$ and $\epsilon$. Here is a proof sketch. Proof Sketch: Let $X_i$ be the event that the $i$-th coupon is collected in the first $t$ draws. Thus, $\Pr[X_i=1]=(1-1/n)^t$. The key fact is that the $X_i$ are negatively correlated, for any $I\subseteq[n]$, $\Pr[\forall i\in I, X_i=1]\le\prod_{i\in I}\Pr[X_i=1]$. Intuitively, this is fairly clear, as knowing that the $i$-th coupon in the first $t$ draws would make it less likely that the $j$-th coupon is also drawn in the first $t$ draws. One can prove the claim, but enlarging the set $I$ by 1 at each step. Then it reduces to showing that $\Pr[\forall i\in I, X_i=1|X_j=1]\le\Pr[\forall i\in I,X_i=1]$, for $j\notin I$. Equivalently, by averaging, it reduces to showing that $\Pr[\forall i\in I, X_i=1|X_j=0]\ge\Pr[\forall i\in I,X_i=1]$. Doerr only gives an intuitive argument for this. One avenue to a proof is as follows. One can observe that conditioned on the $j$ coupon coming after all of the coupons in $I$, that the probability of drawing a new coupon from $I$ after drawing $k$ so far is now $\frac{|I|-k}{n-1}$, instead of the previous $\frac{|I|-k}{n}$. So decomposing the time to collect all coupons as a sum of geometric random variables, we can see that conditioning on the $j$-coupon coming after $I$ increases the success probabilities, and thus doing the conditioning only makes it more likely to collect the coupons earlier (by stochastic dominance: each geometric random variable is increased, in terms of stochastic dominance, by the conditioning, and this dominance can then be applied to the sum). Given this negative correlation, it follows that $\Pr[T\le (1-\epsilon)(n-1)\ln n]\le (1-(1-1/n)^t)^n$, which gives the desired bound with $t=(1-\epsilon)(n-1)\ln n$. Note added in proof: The link above is outdated. A new version of this result with a complete proof (that is, including the negative-correlation statement) can be found in Theorem 1.9.3 in B. Doerr. Probabilistic Tools for the Analysis of Randomized Optimization Heuristics. In B. Doerr and F. Neumann, editors, Theory of Evolutionary Computation: Recent Developments in Discrete Optimization, pages 1-87. Springer, 2020.
What is a tight lower bound on the coupon collector time?
Benjamin Doerr gives (in the chapter " Analyzing Randomized Search Heuristics: Tools from Probability Theory" in the book "Theory of Randomized Search Heuristics", see the link for an online PDF) a so
What is a tight lower bound on the coupon collector time? Benjamin Doerr gives (in the chapter " Analyzing Randomized Search Heuristics: Tools from Probability Theory" in the book "Theory of Randomized Search Heuristics", see the link for an online PDF) a somewhat simple proof of Proposition Let $T$ be the stopping time of the coupon collection process. Then $\Pr[T\le (1-\epsilon)(n-1)\ln n]\le e^{-n^{\epsilon}}$. This seems to give the desired asymptotics (from @cardinal's second answer), but with the advantage of being true for all $n$ and $\epsilon$. Here is a proof sketch. Proof Sketch: Let $X_i$ be the event that the $i$-th coupon is collected in the first $t$ draws. Thus, $\Pr[X_i=1]=(1-1/n)^t$. The key fact is that the $X_i$ are negatively correlated, for any $I\subseteq[n]$, $\Pr[\forall i\in I, X_i=1]\le\prod_{i\in I}\Pr[X_i=1]$. Intuitively, this is fairly clear, as knowing that the $i$-th coupon in the first $t$ draws would make it less likely that the $j$-th coupon is also drawn in the first $t$ draws. One can prove the claim, but enlarging the set $I$ by 1 at each step. Then it reduces to showing that $\Pr[\forall i\in I, X_i=1|X_j=1]\le\Pr[\forall i\in I,X_i=1]$, for $j\notin I$. Equivalently, by averaging, it reduces to showing that $\Pr[\forall i\in I, X_i=1|X_j=0]\ge\Pr[\forall i\in I,X_i=1]$. Doerr only gives an intuitive argument for this. One avenue to a proof is as follows. One can observe that conditioned on the $j$ coupon coming after all of the coupons in $I$, that the probability of drawing a new coupon from $I$ after drawing $k$ so far is now $\frac{|I|-k}{n-1}$, instead of the previous $\frac{|I|-k}{n}$. So decomposing the time to collect all coupons as a sum of geometric random variables, we can see that conditioning on the $j$-coupon coming after $I$ increases the success probabilities, and thus doing the conditioning only makes it more likely to collect the coupons earlier (by stochastic dominance: each geometric random variable is increased, in terms of stochastic dominance, by the conditioning, and this dominance can then be applied to the sum). Given this negative correlation, it follows that $\Pr[T\le (1-\epsilon)(n-1)\ln n]\le (1-(1-1/n)^t)^n$, which gives the desired bound with $t=(1-\epsilon)(n-1)\ln n$. Note added in proof: The link above is outdated. A new version of this result with a complete proof (that is, including the negative-correlation statement) can be found in Theorem 1.9.3 in B. Doerr. Probabilistic Tools for the Analysis of Randomized Optimization Heuristics. In B. Doerr and F. Neumann, editors, Theory of Evolutionary Computation: Recent Developments in Discrete Optimization, pages 1-87. Springer, 2020.
What is a tight lower bound on the coupon collector time? Benjamin Doerr gives (in the chapter " Analyzing Randomized Search Heuristics: Tools from Probability Theory" in the book "Theory of Randomized Search Heuristics", see the link for an online PDF) a so
12,613
Expected number of tosses till first head comes up
This can be answered using the geometric distribution as follows: The number of failures k - 1 before the first success (heads) with a probability of success p ("heads") is given by: $$p(X=k)=(1−p)^{k−1}p$$ with k being the total number of tosses including the first 'heads' that terminates the experiment. And the expected value of X for a given p is $1/p=2$. The derivation of the expected value can be found here. The last steps left implicit should be as follows: $\frac{d}{dr} \frac{1}{1-r} = \frac{1}{(1-r)^2}$ to be plugged into the expression: $E(X) = \frac{p}{1-p} \sum\limits_{x = 1}^{\infty}x\ r^x = \frac{p}{1-p}\ r\ (\frac{d}{dr} \frac{1}{1-r})= \frac{p}{1-p}\ r\ \frac{1}{(1-r)^2}$. With $r = 1 - p$, it simplifies to $E(X) = \frac{1}{p}$, justifying its use above.] Alternatively, we could use the negative binomial distribution interpreted as the number of failures before the first success. The probability mass function is given as the p(number of failures, n, before attaining r successes | given a certain probability, p, of success in each Bernoulli trial): $$p(n;r,p) ={n+r-1\choose r-1} p^r (1-p)^n$$ The expectation for number of trials, n + r is given by the general formula: $$\frac{r}{(1-p)}$$ Given our known parameters: r = 1 and p = 0.5, $$E(n + r; 1,0.5) =\frac{r}{1-p} = \frac{1}{1-0.5} = 2$$ Hence we can expect to make two tosses before getting the first head with the the expected number of tails being $E(n+r) - r = 1$. We can run a Monte Carlo simulation to prove it: set.seed(1) p <- 1/2 reps <- 10000 # Total number of simulations. tosses_to_HEAD <- 0 # Setting up an empty vector to add output to. for (i in 1:reps) { head <- 0 # Set the variable 'head' to 0 with every loop. counter <- 0 # Same forlocal variable 'counter'. while (head == 0) { head <- head + rbinom(1, 1, p) # Toss a coin and add to 'head' counter <- counter + 1 # Add 1 to 'counter' } tosses_to_HEAD[i] <- counter # Append number in counter after getting heads. } mean(tosses_to_HEAD) [1] 2.0097
Expected number of tosses till first head comes up
This can be answered using the geometric distribution as follows: The number of failures k - 1 before the first success (heads) with a probability of success p ("heads") is given by: $$p(X=k)=(1−p)^{k
Expected number of tosses till first head comes up This can be answered using the geometric distribution as follows: The number of failures k - 1 before the first success (heads) with a probability of success p ("heads") is given by: $$p(X=k)=(1−p)^{k−1}p$$ with k being the total number of tosses including the first 'heads' that terminates the experiment. And the expected value of X for a given p is $1/p=2$. The derivation of the expected value can be found here. The last steps left implicit should be as follows: $\frac{d}{dr} \frac{1}{1-r} = \frac{1}{(1-r)^2}$ to be plugged into the expression: $E(X) = \frac{p}{1-p} \sum\limits_{x = 1}^{\infty}x\ r^x = \frac{p}{1-p}\ r\ (\frac{d}{dr} \frac{1}{1-r})= \frac{p}{1-p}\ r\ \frac{1}{(1-r)^2}$. With $r = 1 - p$, it simplifies to $E(X) = \frac{1}{p}$, justifying its use above.] Alternatively, we could use the negative binomial distribution interpreted as the number of failures before the first success. The probability mass function is given as the p(number of failures, n, before attaining r successes | given a certain probability, p, of success in each Bernoulli trial): $$p(n;r,p) ={n+r-1\choose r-1} p^r (1-p)^n$$ The expectation for number of trials, n + r is given by the general formula: $$\frac{r}{(1-p)}$$ Given our known parameters: r = 1 and p = 0.5, $$E(n + r; 1,0.5) =\frac{r}{1-p} = \frac{1}{1-0.5} = 2$$ Hence we can expect to make two tosses before getting the first head with the the expected number of tails being $E(n+r) - r = 1$. We can run a Monte Carlo simulation to prove it: set.seed(1) p <- 1/2 reps <- 10000 # Total number of simulations. tosses_to_HEAD <- 0 # Setting up an empty vector to add output to. for (i in 1:reps) { head <- 0 # Set the variable 'head' to 0 with every loop. counter <- 0 # Same forlocal variable 'counter'. while (head == 0) { head <- head + rbinom(1, 1, p) # Toss a coin and add to 'head' counter <- counter + 1 # Add 1 to 'counter' } tosses_to_HEAD[i] <- counter # Append number in counter after getting heads. } mean(tosses_to_HEAD) [1] 2.0097
Expected number of tosses till first head comes up This can be answered using the geometric distribution as follows: The number of failures k - 1 before the first success (heads) with a probability of success p ("heads") is given by: $$p(X=k)=(1−p)^{k
12,614
Expected number of tosses till first head comes up
Model the game by drawing a ticket out of a box. There are two kinds of tickets. On one is written "Stop, you tossed heads"; on the other is written "Continue, you tossed tails." The expected number of additional tosses in the first case is $0$ while the expected number of additional tosses in the second case is $x$, say--we don't know it yet and have to figure it out. Write these expectations on their respective tickets: these are the values of the tickets. The three things we do know are: The chance of drawing a "Stop" ticket (with value $0$) is $p$. The chance of drawing a "Continue" ticket (with value $x$) is $1-p$. The expectation of this single draw is, by definition, the sum of the probability-weighted values on all kinds of tickets: $$p\times 0 + (1-p)\times x = (1-p)x.$$ Let us interpret this number: it is the expected number of additional tosses that will be needed until a head appears. Since draws of tickets correspond to coin tosses, adding in the one draw needed to obtain a ticket gives us the expected number of tosses--which is just $x$ itself. Equating these two expressions, $$x = 1 + (1-p)x.$$ Solving for $x$ answers the first question. Since the number of tails is always one less than the number of draws, the expected number of tails also must be one less than the expected number of draws. Therefore $x-1$ answers the second question. A second intuitively clear solution can be obtained by contemplating a very long sequence of $n$ tosses. How many games were played? Answer: the number of heads (plus one more incomplete game if the sequence ends with a series of tails). How many heads are expected? Answer: $pn$. Call this number $h$. The Weak Law of Large Numbers asserts that the actual number of heads is highly likely to be very close to $pn$ provided $n$ is sufficiently large. Therefore the average game length $x$, given by some number between $n/h$ and $n/(h+1)$, will be arbitrarily close to $n/(pn)$, whence it must equal $x$ itself. This leads to an extremely efficient way to simulate the distribution of game lengths. Here is R code. It records "heads" as true values in a boolean array and computes the tosses between successive true values. p <- 1/3 # Set the chance of heads tosses <- runif(1e6) < p # Make a million tosses sim <- diff(c(TRUE, which(tosses))) # Compute game lengths hist(sim, xlab="Game length", main="Distribution") # Graph their distribution mean(sim) # Report the average length When I ran this code after setting the seed to $17$ (set.seed(17)), the output differed from $x$ by only a tiny amount.
Expected number of tosses till first head comes up
Model the game by drawing a ticket out of a box. There are two kinds of tickets. On one is written "Stop, you tossed heads"; on the other is written "Continue, you tossed tails." The expected numbe
Expected number of tosses till first head comes up Model the game by drawing a ticket out of a box. There are two kinds of tickets. On one is written "Stop, you tossed heads"; on the other is written "Continue, you tossed tails." The expected number of additional tosses in the first case is $0$ while the expected number of additional tosses in the second case is $x$, say--we don't know it yet and have to figure it out. Write these expectations on their respective tickets: these are the values of the tickets. The three things we do know are: The chance of drawing a "Stop" ticket (with value $0$) is $p$. The chance of drawing a "Continue" ticket (with value $x$) is $1-p$. The expectation of this single draw is, by definition, the sum of the probability-weighted values on all kinds of tickets: $$p\times 0 + (1-p)\times x = (1-p)x.$$ Let us interpret this number: it is the expected number of additional tosses that will be needed until a head appears. Since draws of tickets correspond to coin tosses, adding in the one draw needed to obtain a ticket gives us the expected number of tosses--which is just $x$ itself. Equating these two expressions, $$x = 1 + (1-p)x.$$ Solving for $x$ answers the first question. Since the number of tails is always one less than the number of draws, the expected number of tails also must be one less than the expected number of draws. Therefore $x-1$ answers the second question. A second intuitively clear solution can be obtained by contemplating a very long sequence of $n$ tosses. How many games were played? Answer: the number of heads (plus one more incomplete game if the sequence ends with a series of tails). How many heads are expected? Answer: $pn$. Call this number $h$. The Weak Law of Large Numbers asserts that the actual number of heads is highly likely to be very close to $pn$ provided $n$ is sufficiently large. Therefore the average game length $x$, given by some number between $n/h$ and $n/(h+1)$, will be arbitrarily close to $n/(pn)$, whence it must equal $x$ itself. This leads to an extremely efficient way to simulate the distribution of game lengths. Here is R code. It records "heads" as true values in a boolean array and computes the tosses between successive true values. p <- 1/3 # Set the chance of heads tosses <- runif(1e6) < p # Make a million tosses sim <- diff(c(TRUE, which(tosses))) # Compute game lengths hist(sim, xlab="Game length", main="Distribution") # Graph their distribution mean(sim) # Report the average length When I ran this code after setting the seed to $17$ (set.seed(17)), the output differed from $x$ by only a tiny amount.
Expected number of tosses till first head comes up Model the game by drawing a ticket out of a box. There are two kinds of tickets. On one is written "Stop, you tossed heads"; on the other is written "Continue, you tossed tails." The expected numbe
12,615
Expected number of tosses till first head comes up
Let X be the number of coin flips required until a head is obtained. So, we need to calculate E(X) (i.e. expected value of X). We can condition E(X) on whatever our first flip is. Let E(X|H) denote the number of remaining coin flips given I got a head on the first flip. Similarly, let E(X|T) denote the number of remaining coin flips given I got a tail on the first flip. By first step conditioning, we have $E(X) = \frac{1}{2} * (1 + E(X|H)) + \frac{1}{2} * (1 + E(X|T))$ Now, as $E(X|H)$ denoted the remaining flips after receiving head on the first, it will be equal to 0 as I don't need to flip after getting 1 head. And, $E(X|T) = E(X)$, as we did not make any progress towards getting 1 head. So, $E(X) = \frac{1}{2} * (1 + 0) + \frac{1}{2} * (1 + E(X))$ => $E(X) = 2$
Expected number of tosses till first head comes up
Let X be the number of coin flips required until a head is obtained. So, we need to calculate E(X) (i.e. expected value of X). We can condition E(X) on whatever our first flip is. Let E(X|H) denote th
Expected number of tosses till first head comes up Let X be the number of coin flips required until a head is obtained. So, we need to calculate E(X) (i.e. expected value of X). We can condition E(X) on whatever our first flip is. Let E(X|H) denote the number of remaining coin flips given I got a head on the first flip. Similarly, let E(X|T) denote the number of remaining coin flips given I got a tail on the first flip. By first step conditioning, we have $E(X) = \frac{1}{2} * (1 + E(X|H)) + \frac{1}{2} * (1 + E(X|T))$ Now, as $E(X|H)$ denoted the remaining flips after receiving head on the first, it will be equal to 0 as I don't need to flip after getting 1 head. And, $E(X|T) = E(X)$, as we did not make any progress towards getting 1 head. So, $E(X) = \frac{1}{2} * (1 + 0) + \frac{1}{2} * (1 + E(X))$ => $E(X) = 2$
Expected number of tosses till first head comes up Let X be the number of coin flips required until a head is obtained. So, we need to calculate E(X) (i.e. expected value of X). We can condition E(X) on whatever our first flip is. Let E(X|H) denote th
12,616
Which notation and why: $\text{P}()$, $\Pr()$, $\text{Prob}()$, or $\mathbb{P}()$
Stylistic conventions, mainly, but with some underlying rationale. $\mathbb{P}()$ and $\Pr()$ can be seen as two ways to "free up" the letter $\text{P}$ for other use—it is used to denote other things than "probability", for example in research with complicated and extensive notation where one starts to exhaust available letters. $\mathbb{P}()$ requires special fonts, which is a disadvantage. $\Pr()$ may be useful when the author would want the reader to think of probability in abstract and general terms, using the second lower-capital letter "$r$" to disassociate the symbol as a whole from the usual way we write up functions. For example, some problems are solved when one remembers that the cumulative distribution function of a random variable can be written and treated as a probability of an "inequality-event", and apply the basic probability rules rather than functional analysis. In some cases, one may also see $\text {Prob}()$, again, usually in the beginning of an argument that will end up in a specific formulation of how this probability is functionally determined. The italics version $P()$ is also used, and also in lower-case form, $p()$—this last version is especially used when discussing discrete random variables (where the probability mass function is a probability). $\pi(\;,\;)$ is used for conditional ("transition") probabilities in Markov Theory.
Which notation and why: $\text{P}()$, $\Pr()$, $\text{Prob}()$, or $\mathbb{P}()$
Stylistic conventions, mainly, but with some underlying rationale. $\mathbb{P}()$ and $\Pr()$ can be seen as two ways to "free up" the letter $\text{P}$ for other use—it is used to denote other things
Which notation and why: $\text{P}()$, $\Pr()$, $\text{Prob}()$, or $\mathbb{P}()$ Stylistic conventions, mainly, but with some underlying rationale. $\mathbb{P}()$ and $\Pr()$ can be seen as two ways to "free up" the letter $\text{P}$ for other use—it is used to denote other things than "probability", for example in research with complicated and extensive notation where one starts to exhaust available letters. $\mathbb{P}()$ requires special fonts, which is a disadvantage. $\Pr()$ may be useful when the author would want the reader to think of probability in abstract and general terms, using the second lower-capital letter "$r$" to disassociate the symbol as a whole from the usual way we write up functions. For example, some problems are solved when one remembers that the cumulative distribution function of a random variable can be written and treated as a probability of an "inequality-event", and apply the basic probability rules rather than functional analysis. In some cases, one may also see $\text {Prob}()$, again, usually in the beginning of an argument that will end up in a specific formulation of how this probability is functionally determined. The italics version $P()$ is also used, and also in lower-case form, $p()$—this last version is especially used when discussing discrete random variables (where the probability mass function is a probability). $\pi(\;,\;)$ is used for conditional ("transition") probabilities in Markov Theory.
Which notation and why: $\text{P}()$, $\Pr()$, $\text{Prob}()$, or $\mathbb{P}()$ Stylistic conventions, mainly, but with some underlying rationale. $\mathbb{P}()$ and $\Pr()$ can be seen as two ways to "free up" the letter $\text{P}$ for other use—it is used to denote other things
12,617
Which notation and why: $\text{P}()$, $\Pr()$, $\text{Prob}()$, or $\mathbb{P}()$
I've seen all three used in different undergrad classes and as far as I know, they're stylistic differences and all represent probability as you're thinking of it. One other notation I've seen is in Sheldon Ross's "Introduction to Probability Theory", where $\mathbf{P}$ represents a probability matrix. He also uses $\pi_i$ as a notation for limiting probability, which a sequence of probabilities $(p_i)$ converges to.
Which notation and why: $\text{P}()$, $\Pr()$, $\text{Prob}()$, or $\mathbb{P}()$
I've seen all three used in different undergrad classes and as far as I know, they're stylistic differences and all represent probability as you're thinking of it. One other notation I've seen is in S
Which notation and why: $\text{P}()$, $\Pr()$, $\text{Prob}()$, or $\mathbb{P}()$ I've seen all three used in different undergrad classes and as far as I know, they're stylistic differences and all represent probability as you're thinking of it. One other notation I've seen is in Sheldon Ross's "Introduction to Probability Theory", where $\mathbf{P}$ represents a probability matrix. He also uses $\pi_i$ as a notation for limiting probability, which a sequence of probabilities $(p_i)$ converges to.
Which notation and why: $\text{P}()$, $\Pr()$, $\text{Prob}()$, or $\mathbb{P}()$ I've seen all three used in different undergrad classes and as far as I know, they're stylistic differences and all represent probability as you're thinking of it. One other notation I've seen is in S
12,618
Which notation and why: $\text{P}()$, $\Pr()$, $\text{Prob}()$, or $\mathbb{P}()$
This makes me think of Meyn and Tweedie's book. They use $P$ to denote the transition kernel for a Markov chain, and $\mathsf{P}$ for the law of the entire chain on $\mathsf{X}^{\infty}$. This answer is specific to Markov chains, but the distinction is obviously important. The difference between $P$ and $\mathbb{P}$ (and $E$ and $\mathbb{E}$) from book to book, is just for aesthetic appeal, in my opinion. I can't generalize where I see $\Pr()$ or $\text{Prob}()$, really.
Which notation and why: $\text{P}()$, $\Pr()$, $\text{Prob}()$, or $\mathbb{P}()$
This makes me think of Meyn and Tweedie's book. They use $P$ to denote the transition kernel for a Markov chain, and $\mathsf{P}$ for the law of the entire chain on $\mathsf{X}^{\infty}$. This answer
Which notation and why: $\text{P}()$, $\Pr()$, $\text{Prob}()$, or $\mathbb{P}()$ This makes me think of Meyn and Tweedie's book. They use $P$ to denote the transition kernel for a Markov chain, and $\mathsf{P}$ for the law of the entire chain on $\mathsf{X}^{\infty}$. This answer is specific to Markov chains, but the distinction is obviously important. The difference between $P$ and $\mathbb{P}$ (and $E$ and $\mathbb{E}$) from book to book, is just for aesthetic appeal, in my opinion. I can't generalize where I see $\Pr()$ or $\text{Prob}()$, really.
Which notation and why: $\text{P}()$, $\Pr()$, $\text{Prob}()$, or $\mathbb{P}()$ This makes me think of Meyn and Tweedie's book. They use $P$ to denote the transition kernel for a Markov chain, and $\mathsf{P}$ for the law of the entire chain on $\mathsf{X}^{\infty}$. This answer
12,619
How does logistic regression use the binomial distribution?
Suppose you observe several nests at different mean daily temperatures $t$. How does the probability $\pi(t)$ of nest success depend on the temperature $t$? (If nests are independent, the number of nests with success at temperature $t$ is then binomially distributed with $n$ equal to the number of nests observed and success probability $\pi(t)$.) Logistic regression is one approach (using the logistic function) of specifying the success probability as a function of temperature via stretching and shifting the logistic curve, with the amount of stretching and shifting required to be estimated from the data.
How does logistic regression use the binomial distribution?
Suppose you observe several nests at different mean daily temperatures $t$. How does the probability $\pi(t)$ of nest success depend on the temperature $t$? (If nests are independent, the number of ne
How does logistic regression use the binomial distribution? Suppose you observe several nests at different mean daily temperatures $t$. How does the probability $\pi(t)$ of nest success depend on the temperature $t$? (If nests are independent, the number of nests with success at temperature $t$ is then binomially distributed with $n$ equal to the number of nests observed and success probability $\pi(t)$.) Logistic regression is one approach (using the logistic function) of specifying the success probability as a function of temperature via stretching and shifting the logistic curve, with the amount of stretching and shifting required to be estimated from the data.
How does logistic regression use the binomial distribution? Suppose you observe several nests at different mean daily temperatures $t$. How does the probability $\pi(t)$ of nest success depend on the temperature $t$? (If nests are independent, the number of ne
12,620
How does logistic regression use the binomial distribution?
Without equations? Yikes. Let's see: The logistic regression model is literally a model for the $p$ parameter of a binomial distribution; with a continuous predictor, each point can have its own distribution. (In the cases where the observations are 0-1, we deal with the Bernoulli special case; this is a common situation.) The $n$ is given, not modelled. So the result is, with a model relating the $p_i$'s and a known $n_i$, we can model binomial data in terms of a predictor that describes the mean (and variance) via its model for $p$. The model may be fit via maximum likelihood estimation, but because of its special form (exponential family), ML is relatively "nice". Because the logistic link is canonical for the binomial family, it's even nicer, since the sufficient statistics are of very simple form - this makes it convenient for dealing with large samples, or even to develop 'online' algorithms. Of course, $p$, being a probability, lies between 0 and 1. This, naturally, means that when we write a model for it in terms of some other variable, that model should not crash through those limits, so as the independent variable gets sufficiently large or small, the relationship must bend to stay inside the bounds. With logistic regression, that curve (the link function) is a logistic function. Other functions are possible, and many packages implement several (R has three suitable ones built into its glm functionality if I recall right). No equality symbols were harmed in the making of this post.
How does logistic regression use the binomial distribution?
Without equations? Yikes. Let's see: The logistic regression model is literally a model for the $p$ parameter of a binomial distribution; with a continuous predictor, each point can have its own distr
How does logistic regression use the binomial distribution? Without equations? Yikes. Let's see: The logistic regression model is literally a model for the $p$ parameter of a binomial distribution; with a continuous predictor, each point can have its own distribution. (In the cases where the observations are 0-1, we deal with the Bernoulli special case; this is a common situation.) The $n$ is given, not modelled. So the result is, with a model relating the $p_i$'s and a known $n_i$, we can model binomial data in terms of a predictor that describes the mean (and variance) via its model for $p$. The model may be fit via maximum likelihood estimation, but because of its special form (exponential family), ML is relatively "nice". Because the logistic link is canonical for the binomial family, it's even nicer, since the sufficient statistics are of very simple form - this makes it convenient for dealing with large samples, or even to develop 'online' algorithms. Of course, $p$, being a probability, lies between 0 and 1. This, naturally, means that when we write a model for it in terms of some other variable, that model should not crash through those limits, so as the independent variable gets sufficiently large or small, the relationship must bend to stay inside the bounds. With logistic regression, that curve (the link function) is a logistic function. Other functions are possible, and many packages implement several (R has three suitable ones built into its glm functionality if I recall right). No equality symbols were harmed in the making of this post.
How does logistic regression use the binomial distribution? Without equations? Yikes. Let's see: The logistic regression model is literally a model for the $p$ parameter of a binomial distribution; with a continuous predictor, each point can have its own distr
12,621
How does logistic regression use the binomial distribution?
Your model assumes the success of a nest can be viewed as a gamble: God flips a loaded coin with sides labeled "success" and "failure." The outcome of the flip for one nest is independent of the outcome of the flip for any other nest. The birds do have something going for them, though: the coin might heavily favor success at some temperatures compared to others. Thus, when you have the chance to observe nests at a given temperature, the number of successes equals the number of successful flips of the same coin--the one for that temperature. The corresponding Binomial distribution describes the chances of successes. That is, it establishes the probability of zero successes, of one, of two, ... and so on through the number of nests. One reasonable estimate of the relationship between the temperature and how God loads the coins is given by the proportion of successes observed at that temperature. This is the Maximum Likelihood estimate (MLE). For example, suppose you observe $7$ nests at a temperature of $10$ degrees and $3$ of those nests are successful. The MLE is $3/7.$ That is, we estimate that God's coin has a $3/7$ chance of showing success. The corresponding Binomial distribution is plotted in the first row of the figure (see below) under the heading "10 Degrees." It represents the chances with the heights of vertical line segments. The red segment corresponds to the observed value of $3$ successes. The temperatures must vary in your data. As a running example, let's suppose that at temperatures $5,10,15,20$ degrees you observed $0,3,2,3$ successes among $2,7,5,3$ nests. This dataset is plotted by the gray circles in the "Fit" panels of the figure. The height of a circle represents its success rate. The circle areas are proportional to the numbers of nests (thereby emphasizing the data with more nests). The top row of the figure shows the MLEs at each of the four observed temperatures. The red curve in the "Fit" panel traces out how the coin is loaded, depending on temperature. By construction, this trace passes through each of the data points. (What it does at intermediate temperatures is unknown; I have crudely connected the values to emphasize this point.) This "saturated" model is not very useful, precisely because it gives us no basis to estimate how God will load the coins at intermediate temperatures. To do that, we need to suppose there is some kind of "trend" curve that relates coin loadings to temperature. The bottom row of the figure fits such a trend. The trend is limited in what it can do: when plotted in appropriate ("log odds") coordinates, as shown in the "Logit Response" panels at left, it can only follow a straight line. Any such straight line determines the loading of the coin at all temperatures, as shown by the corresponding curved line in the "Fit" panels. That loading, in turn, determines the Binomial distributions at all temperatures. The bottom row plots those distributions for the temperatures where nests were observed. (The dashed black lines mark the expected values of the distributions, helping to identify them fairly precisely. You don't see those lines in the top row of the figure because they coincide with the red segments.) Now a tradeoff must be made: the line might pass closely to some of the data points, only to veer far from others. This causes the corresponding Binomial distribution to assign lower probabilities to most of the observed values than before. You can see this clearly at 10 degrees and 15 degrees: the probability of the observed values is not the highest possible probability, nor is it close to the values assigned in the upper row. Logistic regression slides and wiggles the possible lines around (in the coordinate system used by the "Logit Response" panels), converts their heights into Binomial probabilities (the "Fit" panels), assesses the chances assigned to the observations (the four right panels), and chooses the line that gives the best combination of those chances. What is "best"? Simply that the combined probability of all the data is as large as possible. In this way no single probability (the red segments) is allowed to be truly tiny, but usually most of the probabilities will not be as high as they were in the saturated model. Here is one iteration of the logistic regression search where the line was rotated downwards: First, notice what stayed the same: the gray points in the "Fit" scatterplot are fixed because they represent the data. Likewise, the ranges of values and the horizontal positions of the red segments in the four Binomial plots also are fixed, because they also represent the data. However, this new line loads the coins in a radically different way. In so doing, it changes the four Binomial distributions (the gray segments). For instance, it gives the coin about a 70% success rate at a temperature of $10$ degrees, corresponding to a distribution whose probabilities are highest for 4 to 6 successes. This line actually does a great job of fitting the data for $15$ degrees but a terrible job of fitting the other data. (At 5 and 20 degrees the Binomial probabilities assigned to the data are so tiny you cannot even see the red segments.) Overall, this is a much worse fit than the ones shown in the first figure. I hope this discussion has helped you develop a mental image of the Binomial probabilities changing as the line is varied, all the while keeping the data the same. The line fit by logistic regression attempts to make those red bars overall as high as possible. Thus, the relationship between logistic regression and the family of Binomial distributions is deep and intimate. Appendix: R code to produce the figures # # Create example data. # X <- data.frame(temperature=c(5,10,15,20), nests=c(2,7,5,3), successes=c(0,3,2,3)) # # A function to plot a Binomial(n,p) distribution and highlight the value `k0`. # plot.binom <- function(n, p, k0, highlight="#f02020", ...) { plot(0:n, dbinom(0:n, n, p), type="h", yaxt="n", xlab="Trials", ylab="Probability", ...) abline(v = p*n, lty=3, lwd=2) if(!missing(k0)) lines(rep(k0,2), c(0, dbinom(k0,n,p)), lwd=2, col=highlight) } # # A function to convert from probability to log odds. # logit <- function(p) log(p) - log(1-p) # # Fit a saturated model, then the intended model. # # Ordinarily the formula for the saturated model would be in the form # `... ~ factor(temperature)`, but the following method makes it possible to # plot the predicted values in a visually effective way. # fit.0 <- glm(cbind(successes, nests-successes) ~ factor(round(temperature/5)), data=X, family=binomial) summary(fit.0) fit <- glm(cbind(successes, nests-successes) ~ temperature, data=X, family=binomial) summary(fit) # # Plot both fits, one per row. # lfits <- list(fit.0, fit) par.old <- par(mfrow=c(length(lfits), nrow(X)+2)) for (fit in lfits) { # # Construct arrays of plotting points. # X$p.hat <- predict(fit, type="response") Y <- data.frame(temperature = seq(min(X$temperature), max(X$temperature), length.out=101)) Y$p.hat <- predict(fit, type="response", newdata=Y) # Probability Y$lambda.hat <- predict(fit, type="link", newdata=Y) # Log odds # # Plot the fit in terms of log odds. # with(Y, plot(temperature, lambda.hat, type="n", yaxt="n", bty="n", main="Logit Response", ylab=expression(hat(lambda)))) if (isTRUE(diff(range(Y$lambda.hat)) < 6)) { # Draw gridlines and y-axis labels p <- c( .10, .25, .5, .75, .9) q <- logit(p) suppressWarnings(rug(q, side=2)) abline(h=q, col="#d0d0d0") mtext(signif(p, 2), at=q, side=2, cex=0.6) } with(Y, lines(temperature, lambda.hat, lwd=2, col="#f02020")) # # Plot the data and the fit in terms of probability. # with(X, plot(temperature, successes/nests, ylim=0:1, cex=sqrt(nests), pch=21, bg="Gray", main="Fit")) with(Y, lines(temperature, p.hat, col="#f02020", lwd=2)) # # Plot the Binomial distributions associated with each row of the data. # apply(X, 1, function(x) plot.binom(x[2], x[4], x[3], bty="n", lwd=2, col="Gray", main=paste(x[1], "Degrees"))) } par(mfrow=par.old)
How does logistic regression use the binomial distribution?
Your model assumes the success of a nest can be viewed as a gamble: God flips a loaded coin with sides labeled "success" and "failure." The outcome of the flip for one nest is independent of the outc
How does logistic regression use the binomial distribution? Your model assumes the success of a nest can be viewed as a gamble: God flips a loaded coin with sides labeled "success" and "failure." The outcome of the flip for one nest is independent of the outcome of the flip for any other nest. The birds do have something going for them, though: the coin might heavily favor success at some temperatures compared to others. Thus, when you have the chance to observe nests at a given temperature, the number of successes equals the number of successful flips of the same coin--the one for that temperature. The corresponding Binomial distribution describes the chances of successes. That is, it establishes the probability of zero successes, of one, of two, ... and so on through the number of nests. One reasonable estimate of the relationship between the temperature and how God loads the coins is given by the proportion of successes observed at that temperature. This is the Maximum Likelihood estimate (MLE). For example, suppose you observe $7$ nests at a temperature of $10$ degrees and $3$ of those nests are successful. The MLE is $3/7.$ That is, we estimate that God's coin has a $3/7$ chance of showing success. The corresponding Binomial distribution is plotted in the first row of the figure (see below) under the heading "10 Degrees." It represents the chances with the heights of vertical line segments. The red segment corresponds to the observed value of $3$ successes. The temperatures must vary in your data. As a running example, let's suppose that at temperatures $5,10,15,20$ degrees you observed $0,3,2,3$ successes among $2,7,5,3$ nests. This dataset is plotted by the gray circles in the "Fit" panels of the figure. The height of a circle represents its success rate. The circle areas are proportional to the numbers of nests (thereby emphasizing the data with more nests). The top row of the figure shows the MLEs at each of the four observed temperatures. The red curve in the "Fit" panel traces out how the coin is loaded, depending on temperature. By construction, this trace passes through each of the data points. (What it does at intermediate temperatures is unknown; I have crudely connected the values to emphasize this point.) This "saturated" model is not very useful, precisely because it gives us no basis to estimate how God will load the coins at intermediate temperatures. To do that, we need to suppose there is some kind of "trend" curve that relates coin loadings to temperature. The bottom row of the figure fits such a trend. The trend is limited in what it can do: when plotted in appropriate ("log odds") coordinates, as shown in the "Logit Response" panels at left, it can only follow a straight line. Any such straight line determines the loading of the coin at all temperatures, as shown by the corresponding curved line in the "Fit" panels. That loading, in turn, determines the Binomial distributions at all temperatures. The bottom row plots those distributions for the temperatures where nests were observed. (The dashed black lines mark the expected values of the distributions, helping to identify them fairly precisely. You don't see those lines in the top row of the figure because they coincide with the red segments.) Now a tradeoff must be made: the line might pass closely to some of the data points, only to veer far from others. This causes the corresponding Binomial distribution to assign lower probabilities to most of the observed values than before. You can see this clearly at 10 degrees and 15 degrees: the probability of the observed values is not the highest possible probability, nor is it close to the values assigned in the upper row. Logistic regression slides and wiggles the possible lines around (in the coordinate system used by the "Logit Response" panels), converts their heights into Binomial probabilities (the "Fit" panels), assesses the chances assigned to the observations (the four right panels), and chooses the line that gives the best combination of those chances. What is "best"? Simply that the combined probability of all the data is as large as possible. In this way no single probability (the red segments) is allowed to be truly tiny, but usually most of the probabilities will not be as high as they were in the saturated model. Here is one iteration of the logistic regression search where the line was rotated downwards: First, notice what stayed the same: the gray points in the "Fit" scatterplot are fixed because they represent the data. Likewise, the ranges of values and the horizontal positions of the red segments in the four Binomial plots also are fixed, because they also represent the data. However, this new line loads the coins in a radically different way. In so doing, it changes the four Binomial distributions (the gray segments). For instance, it gives the coin about a 70% success rate at a temperature of $10$ degrees, corresponding to a distribution whose probabilities are highest for 4 to 6 successes. This line actually does a great job of fitting the data for $15$ degrees but a terrible job of fitting the other data. (At 5 and 20 degrees the Binomial probabilities assigned to the data are so tiny you cannot even see the red segments.) Overall, this is a much worse fit than the ones shown in the first figure. I hope this discussion has helped you develop a mental image of the Binomial probabilities changing as the line is varied, all the while keeping the data the same. The line fit by logistic regression attempts to make those red bars overall as high as possible. Thus, the relationship between logistic regression and the family of Binomial distributions is deep and intimate. Appendix: R code to produce the figures # # Create example data. # X <- data.frame(temperature=c(5,10,15,20), nests=c(2,7,5,3), successes=c(0,3,2,3)) # # A function to plot a Binomial(n,p) distribution and highlight the value `k0`. # plot.binom <- function(n, p, k0, highlight="#f02020", ...) { plot(0:n, dbinom(0:n, n, p), type="h", yaxt="n", xlab="Trials", ylab="Probability", ...) abline(v = p*n, lty=3, lwd=2) if(!missing(k0)) lines(rep(k0,2), c(0, dbinom(k0,n,p)), lwd=2, col=highlight) } # # A function to convert from probability to log odds. # logit <- function(p) log(p) - log(1-p) # # Fit a saturated model, then the intended model. # # Ordinarily the formula for the saturated model would be in the form # `... ~ factor(temperature)`, but the following method makes it possible to # plot the predicted values in a visually effective way. # fit.0 <- glm(cbind(successes, nests-successes) ~ factor(round(temperature/5)), data=X, family=binomial) summary(fit.0) fit <- glm(cbind(successes, nests-successes) ~ temperature, data=X, family=binomial) summary(fit) # # Plot both fits, one per row. # lfits <- list(fit.0, fit) par.old <- par(mfrow=c(length(lfits), nrow(X)+2)) for (fit in lfits) { # # Construct arrays of plotting points. # X$p.hat <- predict(fit, type="response") Y <- data.frame(temperature = seq(min(X$temperature), max(X$temperature), length.out=101)) Y$p.hat <- predict(fit, type="response", newdata=Y) # Probability Y$lambda.hat <- predict(fit, type="link", newdata=Y) # Log odds # # Plot the fit in terms of log odds. # with(Y, plot(temperature, lambda.hat, type="n", yaxt="n", bty="n", main="Logit Response", ylab=expression(hat(lambda)))) if (isTRUE(diff(range(Y$lambda.hat)) < 6)) { # Draw gridlines and y-axis labels p <- c( .10, .25, .5, .75, .9) q <- logit(p) suppressWarnings(rug(q, side=2)) abline(h=q, col="#d0d0d0") mtext(signif(p, 2), at=q, side=2, cex=0.6) } with(Y, lines(temperature, lambda.hat, lwd=2, col="#f02020")) # # Plot the data and the fit in terms of probability. # with(X, plot(temperature, successes/nests, ylim=0:1, cex=sqrt(nests), pch=21, bg="Gray", main="Fit")) with(Y, lines(temperature, p.hat, col="#f02020", lwd=2)) # # Plot the Binomial distributions associated with each row of the data. # apply(X, 1, function(x) plot.binom(x[2], x[4], x[3], bty="n", lwd=2, col="Gray", main=paste(x[1], "Degrees"))) } par(mfrow=par.old)
How does logistic regression use the binomial distribution? Your model assumes the success of a nest can be viewed as a gamble: God flips a loaded coin with sides labeled "success" and "failure." The outcome of the flip for one nest is independent of the outc
12,622
What happens when you apply SVD to a collaborative filtering problem? What is the difference between the two?
$\DeclareMathOperator*{\argmin}{arg\,min}$ Ok, when you say SVD, presumably you're talking about truncated SVD (where you only keep the $k$ biggest singular values). There are two different ways to look at the truncated SVD of a matrix. One is the standard definition: First you do the SVD: $\underset{n\times m}{X} = \underset{n\times n}{U} \overset{n\times m}{\Sigma} \underset{m\times m}{V^T}$, where $U$ and $V$ are rotation matrices, and $\Sigma$ has the singular values along the diagonal. Then you pick the top $k$ singular values, zero out the rest, and hack off irrelevant rows and columns to make a $k$-rank approximation to the original: $X \approx \tilde{X} = \underset{n\times k}{\tilde{U}} \overset{k\times k}{\tilde{\Sigma}} \underset{k\times m}{\tilde{V}^T}$ This is all fine and dandy (and easy to implement in R or matlab), but it doesn't make sense when talking about matrices with missing values. However, there's an interesting property of the $k$-truncated SVD--It's the best $k$-rank approximation to the original! That is: $ \tilde{X} = \argmin_{B : rank(B)=k} \displaystyle\sum\limits_{i,j} (X_{ij} - B_{ij})^2$ This property seems easy to generalize to the missing value case. Basically you're looking for a $k$-rank matrix that minimizes the element-wise mean squared error across the known entries of the original matrix. That is, when you're training the system, you ignore all of the missing values. (For tips on how you might actually go about finding a $k$-rank approximation, here are some places to look). Then, once you've come up with a suitably "close" $k$-rank approximation to the original, you use it to fill in the missing values. That is, if $X_{ij}$ was missing, then you fill in $\tilde{X}_{ij}$. Tada! You are now done.
What happens when you apply SVD to a collaborative filtering problem? What is the difference between
$\DeclareMathOperator*{\argmin}{arg\,min}$ Ok, when you say SVD, presumably you're talking about truncated SVD (where you only keep the $k$ biggest singular values). There are two different ways to lo
What happens when you apply SVD to a collaborative filtering problem? What is the difference between the two? $\DeclareMathOperator*{\argmin}{arg\,min}$ Ok, when you say SVD, presumably you're talking about truncated SVD (where you only keep the $k$ biggest singular values). There are two different ways to look at the truncated SVD of a matrix. One is the standard definition: First you do the SVD: $\underset{n\times m}{X} = \underset{n\times n}{U} \overset{n\times m}{\Sigma} \underset{m\times m}{V^T}$, where $U$ and $V$ are rotation matrices, and $\Sigma$ has the singular values along the diagonal. Then you pick the top $k$ singular values, zero out the rest, and hack off irrelevant rows and columns to make a $k$-rank approximation to the original: $X \approx \tilde{X} = \underset{n\times k}{\tilde{U}} \overset{k\times k}{\tilde{\Sigma}} \underset{k\times m}{\tilde{V}^T}$ This is all fine and dandy (and easy to implement in R or matlab), but it doesn't make sense when talking about matrices with missing values. However, there's an interesting property of the $k$-truncated SVD--It's the best $k$-rank approximation to the original! That is: $ \tilde{X} = \argmin_{B : rank(B)=k} \displaystyle\sum\limits_{i,j} (X_{ij} - B_{ij})^2$ This property seems easy to generalize to the missing value case. Basically you're looking for a $k$-rank matrix that minimizes the element-wise mean squared error across the known entries of the original matrix. That is, when you're training the system, you ignore all of the missing values. (For tips on how you might actually go about finding a $k$-rank approximation, here are some places to look). Then, once you've come up with a suitably "close" $k$-rank approximation to the original, you use it to fill in the missing values. That is, if $X_{ij}$ was missing, then you fill in $\tilde{X}_{ij}$. Tada! You are now done.
What happens when you apply SVD to a collaborative filtering problem? What is the difference between $\DeclareMathOperator*{\argmin}{arg\,min}$ Ok, when you say SVD, presumably you're talking about truncated SVD (where you only keep the $k$ biggest singular values). There are two different ways to lo
12,623
What happens when you apply SVD to a collaborative filtering problem? What is the difference between the two?
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. It seems like there are a lot of approaches on how to deal with missing values. The following paper with review in Section 1.3 may be a good starting point.
What happens when you apply SVD to a collaborative filtering problem? What is the difference between
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
What happens when you apply SVD to a collaborative filtering problem? What is the difference between the two? Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. It seems like there are a lot of approaches on how to deal with missing values. The following paper with review in Section 1.3 may be a good starting point.
What happens when you apply SVD to a collaborative filtering problem? What is the difference between Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
12,624
What happens when you apply SVD to a collaborative filtering problem? What is the difference between the two?
I need more reputation to comment on Stumpy Joe Pete's answer therefore I post this as an answer. Stumpy thanks for the answer although I think it needs a bit of clarification. Particularly I mean this sentence: Basically you're looking for a k-rank matrix that minimizes the element-wise mean squared error across the known entries of the original matrix. First - wouldnt the highest rank always minimize this, or actually reconstruct the original X matrix? Secondly - Why would you only take the known entries. Intuitively it makes sense, but the procedure is actually also fitting the empty places which were replaced with some reasonable numbers. My approach would be to carry out something like a cross validation: Fill in the empty places with 0s or means or another reasonable number. Replace one of the n known elements with 0 or a reasonable number Carry out SVD reconstruction of rank k Check the value of the known reconstructed element. repeat for all possible known elements and calculate MSE repeat for all possible k and choose the one with lowest MSE.
What happens when you apply SVD to a collaborative filtering problem? What is the difference between
I need more reputation to comment on Stumpy Joe Pete's answer therefore I post this as an answer. Stumpy thanks for the answer although I think it needs a bit of clarification. Particularly I mean thi
What happens when you apply SVD to a collaborative filtering problem? What is the difference between the two? I need more reputation to comment on Stumpy Joe Pete's answer therefore I post this as an answer. Stumpy thanks for the answer although I think it needs a bit of clarification. Particularly I mean this sentence: Basically you're looking for a k-rank matrix that minimizes the element-wise mean squared error across the known entries of the original matrix. First - wouldnt the highest rank always minimize this, or actually reconstruct the original X matrix? Secondly - Why would you only take the known entries. Intuitively it makes sense, but the procedure is actually also fitting the empty places which were replaced with some reasonable numbers. My approach would be to carry out something like a cross validation: Fill in the empty places with 0s or means or another reasonable number. Replace one of the n known elements with 0 or a reasonable number Carry out SVD reconstruction of rank k Check the value of the known reconstructed element. repeat for all possible known elements and calculate MSE repeat for all possible k and choose the one with lowest MSE.
What happens when you apply SVD to a collaborative filtering problem? What is the difference between I need more reputation to comment on Stumpy Joe Pete's answer therefore I post this as an answer. Stumpy thanks for the answer although I think it needs a bit of clarification. Particularly I mean thi
12,625
Computing standard error in weighted mean estimation
I ran into the same issue recently. The following is what I found: Unlike a simple random sample with equal weights, there is no widely accepted definition of standard error of the weighted mean. These days, it would be straight-forward to do a bootstrap and obtain the empirical distribution of the mean, and based on that estimate the standard error. What if one wanted to use a formula to do this estimation? The main reference is this paper, by Donald F. Gatz and Luther Smith, where 3 formula based estimators are compared with bootstrap results. The best approximation to the bootstrap result comes from Cochran (1977): $(SEM_w)^2={\dfrac{n}{(n-1)(\sum {P_i})^2}}[\sum (P_i X_i-\bar{P}\bar{X}_w)^2-2 \bar{X}_w \sum (P_i-\bar{P})(P_i X_i-\bar{P}\bar{X}_w)+\bar{X}^2_w \sum (P_i-\bar{P})^2]$ The following is the corresponding R code that came from this R listserve thread. weighted.var.se <- function(x, w, na.rm=FALSE) # Computes the variance of a weighted mean following Cochran 1977 definition { if (na.rm) { w <- w[i <- !is.na(x)]; x <- x[i] } n = length(w) xWbar = weighted.mean(x,w,na.rm=na.rm) wbar = mean(w) out = n/((n-1)*sum(w)^2)*(sum((w*x-wbar*xWbar)^2)-2*xWbar*sum((w-wbar)*(w*x-wbar*xWbar))+xWbar^2*sum((w-wbar)^2)) return(out) } Hope this helps!
Computing standard error in weighted mean estimation
I ran into the same issue recently. The following is what I found: Unlike a simple random sample with equal weights, there is no widely accepted definition of standard error of the weighted mean. The
Computing standard error in weighted mean estimation I ran into the same issue recently. The following is what I found: Unlike a simple random sample with equal weights, there is no widely accepted definition of standard error of the weighted mean. These days, it would be straight-forward to do a bootstrap and obtain the empirical distribution of the mean, and based on that estimate the standard error. What if one wanted to use a formula to do this estimation? The main reference is this paper, by Donald F. Gatz and Luther Smith, where 3 formula based estimators are compared with bootstrap results. The best approximation to the bootstrap result comes from Cochran (1977): $(SEM_w)^2={\dfrac{n}{(n-1)(\sum {P_i})^2}}[\sum (P_i X_i-\bar{P}\bar{X}_w)^2-2 \bar{X}_w \sum (P_i-\bar{P})(P_i X_i-\bar{P}\bar{X}_w)+\bar{X}^2_w \sum (P_i-\bar{P})^2]$ The following is the corresponding R code that came from this R listserve thread. weighted.var.se <- function(x, w, na.rm=FALSE) # Computes the variance of a weighted mean following Cochran 1977 definition { if (na.rm) { w <- w[i <- !is.na(x)]; x <- x[i] } n = length(w) xWbar = weighted.mean(x,w,na.rm=na.rm) wbar = mean(w) out = n/((n-1)*sum(w)^2)*(sum((w*x-wbar*xWbar)^2)-2*xWbar*sum((w-wbar)*(w*x-wbar*xWbar))+xWbar^2*sum((w-wbar)^2)) return(out) } Hope this helps!
Computing standard error in weighted mean estimation I ran into the same issue recently. The following is what I found: Unlike a simple random sample with equal weights, there is no widely accepted definition of standard error of the weighted mean. The
12,626
Computing standard error in weighted mean estimation
The variance of your estimate given the $w_i$ is $$ \frac{\sum w_i^2 Var(X)}{(\sum w_i)^2} = Var(X) \frac{\sum w_i^2 }{(\sum w_i)^2}. $$ Because your estimate is unbiased for any $w_i$, the variance of its conditional mean is zero. Hence, the variance of your estimate is $$ Var(X) \mathbb{E}\left(\frac{\sum w_i^2 }{(\sum w_i)^2}\right) $$ With all the data observed, this would be easy to estimate empirically. But with only a measure of location of the $X_i$ observed, and not their spread, I don't see how it's going to be possible to get an estimate of $Var(X)$, without making rather severe assumptions.
Computing standard error in weighted mean estimation
The variance of your estimate given the $w_i$ is $$ \frac{\sum w_i^2 Var(X)}{(\sum w_i)^2} = Var(X) \frac{\sum w_i^2 }{(\sum w_i)^2}. $$ Because your estimate is unbiased for any $w_i$, the variance
Computing standard error in weighted mean estimation The variance of your estimate given the $w_i$ is $$ \frac{\sum w_i^2 Var(X)}{(\sum w_i)^2} = Var(X) \frac{\sum w_i^2 }{(\sum w_i)^2}. $$ Because your estimate is unbiased for any $w_i$, the variance of its conditional mean is zero. Hence, the variance of your estimate is $$ Var(X) \mathbb{E}\left(\frac{\sum w_i^2 }{(\sum w_i)^2}\right) $$ With all the data observed, this would be easy to estimate empirically. But with only a measure of location of the $X_i$ observed, and not their spread, I don't see how it's going to be possible to get an estimate of $Var(X)$, without making rather severe assumptions.
Computing standard error in weighted mean estimation The variance of your estimate given the $w_i$ is $$ \frac{\sum w_i^2 Var(X)}{(\sum w_i)^2} = Var(X) \frac{\sum w_i^2 }{(\sum w_i)^2}. $$ Because your estimate is unbiased for any $w_i$, the variance
12,627
Computing standard error in weighted mean estimation
@Ming K 's equation is not working for me. @Hugh mentioned Hmisc::wtd.var(x, w), but this is for variance, if you are wondering about weighted standard error, this would be useful. But read assumption and equation here, following $$ \sigma _{x}^{-} = \sigma \sqrt{\sum_{i=1}^{n}\omega _{i}^{'2}} $$ For your convenient, I copy them here. wtd.stderror <- function(x, weights){ var <- Hmisc::wtd.var(x, weights) weights <- sum( (weights / sum(weights))^2 ) sqrt(var*weights) } But I am not sure whether this will work for dateset with a Bernoulli distribution
Computing standard error in weighted mean estimation
@Ming K 's equation is not working for me. @Hugh mentioned Hmisc::wtd.var(x, w), but this is for variance, if you are wondering about weighted standard error, this would be useful. But read assumptio
Computing standard error in weighted mean estimation @Ming K 's equation is not working for me. @Hugh mentioned Hmisc::wtd.var(x, w), but this is for variance, if you are wondering about weighted standard error, this would be useful. But read assumption and equation here, following $$ \sigma _{x}^{-} = \sigma \sqrt{\sum_{i=1}^{n}\omega _{i}^{'2}} $$ For your convenient, I copy them here. wtd.stderror <- function(x, weights){ var <- Hmisc::wtd.var(x, weights) weights <- sum( (weights / sum(weights))^2 ) sqrt(var*weights) } But I am not sure whether this will work for dateset with a Bernoulli distribution
Computing standard error in weighted mean estimation @Ming K 's equation is not working for me. @Hugh mentioned Hmisc::wtd.var(x, w), but this is for variance, if you are wondering about weighted standard error, this would be useful. But read assumptio
12,628
When is a repeated measures ANOVA preferred over a mixed-effects model?
I'm not totally sure what actual model "repeated measures ANOVA" describes, but I think one general issue is whether to put random effects of any kind in a model rather than e.g. just adjust variance estimates to cover the induced dependencies (as in the Panel Corrected Standard Errors vs multilevel models debate in time series cross-sectional data analysis). So I'll have a go at that question first, then address yours. Fixed and Random Effects Two complementary principles about when to use a random rather than fixed effect are the following: Represent a thing (subject, stimulus type, etc.) with a random effect when you are interested using the model to generalise to other instances of that thing not included in the current analysis, e.g. other subject or other stimulus types. If not use a fixed effect. Represent a thing with a random effect when you think that for any instance of the thing, other instances in the data set are potentially informative about it. If you expect no such informativeness, then use a fixed effect. Both motivate explicitly including subject random effects: you are usually interested in human populations in general and the elements of each subject's response set are correlated, predictable from each other and therefore informative about each other. It is less clear for things like stimuli. If there will only ever be three types of stimuli then 1. will motivate a fixed effect and 2. will make the decision depend on the nature of the stimuli. Your questions One reason to use a mixed model over a repeated effects ANOVA is that the former are considerably more general, e.g. they work equally easily with balanced and unbalanced designs and they are easily extended to multilevel models. In my (admittedly limited) reading on classical ANOVA and its extensions, mixed models seem to cover all the special cases that ANOVA extensions do. So I actually can't think of a statistical reason to prefer repeated measures ANOVA. Others may be able to help here. (A familiar sociological reason is that your field prefers to read about methods its older members learnt in graduate school, and a practical reason is that it might take a bit longer to learn how to use mixed models than a minor extension of ANOVA.) Note A caveat for using random effects, most relevant for non-experimental data, is that to maintain consistency you have to either assume that the random effects are uncorrelated with the model's fixed effects, or add fixed effect means as covariates for the random effect (discussed e.g. in Bafumi and Gelman's paper).
When is a repeated measures ANOVA preferred over a mixed-effects model?
I'm not totally sure what actual model "repeated measures ANOVA" describes, but I think one general issue is whether to put random effects of any kind in a model rather than e.g. just adjust variance
When is a repeated measures ANOVA preferred over a mixed-effects model? I'm not totally sure what actual model "repeated measures ANOVA" describes, but I think one general issue is whether to put random effects of any kind in a model rather than e.g. just adjust variance estimates to cover the induced dependencies (as in the Panel Corrected Standard Errors vs multilevel models debate in time series cross-sectional data analysis). So I'll have a go at that question first, then address yours. Fixed and Random Effects Two complementary principles about when to use a random rather than fixed effect are the following: Represent a thing (subject, stimulus type, etc.) with a random effect when you are interested using the model to generalise to other instances of that thing not included in the current analysis, e.g. other subject or other stimulus types. If not use a fixed effect. Represent a thing with a random effect when you think that for any instance of the thing, other instances in the data set are potentially informative about it. If you expect no such informativeness, then use a fixed effect. Both motivate explicitly including subject random effects: you are usually interested in human populations in general and the elements of each subject's response set are correlated, predictable from each other and therefore informative about each other. It is less clear for things like stimuli. If there will only ever be three types of stimuli then 1. will motivate a fixed effect and 2. will make the decision depend on the nature of the stimuli. Your questions One reason to use a mixed model over a repeated effects ANOVA is that the former are considerably more general, e.g. they work equally easily with balanced and unbalanced designs and they are easily extended to multilevel models. In my (admittedly limited) reading on classical ANOVA and its extensions, mixed models seem to cover all the special cases that ANOVA extensions do. So I actually can't think of a statistical reason to prefer repeated measures ANOVA. Others may be able to help here. (A familiar sociological reason is that your field prefers to read about methods its older members learnt in graduate school, and a practical reason is that it might take a bit longer to learn how to use mixed models than a minor extension of ANOVA.) Note A caveat for using random effects, most relevant for non-experimental data, is that to maintain consistency you have to either assume that the random effects are uncorrelated with the model's fixed effects, or add fixed effect means as covariates for the random effect (discussed e.g. in Bafumi and Gelman's paper).
When is a repeated measures ANOVA preferred over a mixed-effects model? I'm not totally sure what actual model "repeated measures ANOVA" describes, but I think one general issue is whether to put random effects of any kind in a model rather than e.g. just adjust variance
12,629
When is a repeated measures ANOVA preferred over a mixed-effects model?
If your participants see the exact same pictures in each condition (which is obviously not the case in your original example because each category will presumably contain different pictures), an ANOVA on the cell means probably tells you exactly what you want to know. One reason to prefer it is that it's somewhat easier to understand and communicate (including to reviewers when you will try to publish your study). But basically yes, if you run experiments where a number of people have to do something in response to a few conditions (e.g. pictures categories) with repeated trials in each condition, it's always the case that you have two sources of variability. Researchers in some fields (e.g. psycholinguistics) routinely use multilevel models (or some other older alternatives like Clark's F1/F2 analysis) precisely for that reason whereas other fields (e.g. a lot of work in mainstream experimental psychology) basically ignore the issue (for no other reason that being able to get away with it, from what I can tell). This paper also discusses this question: Raaijmakers, J.G.W., Schrijnemakers, J.M.C., & Gremmen, F. (1999). How to Deal with "The Language-as-Fixed-Effect Fallacy": Common Misconceptions and Alternative Solutions. Journal of Memory and Language, 41 (3), 416-426.
When is a repeated measures ANOVA preferred over a mixed-effects model?
If your participants see the exact same pictures in each condition (which is obviously not the case in your original example because each category will presumably contain different pictures), an ANOVA
When is a repeated measures ANOVA preferred over a mixed-effects model? If your participants see the exact same pictures in each condition (which is obviously not the case in your original example because each category will presumably contain different pictures), an ANOVA on the cell means probably tells you exactly what you want to know. One reason to prefer it is that it's somewhat easier to understand and communicate (including to reviewers when you will try to publish your study). But basically yes, if you run experiments where a number of people have to do something in response to a few conditions (e.g. pictures categories) with repeated trials in each condition, it's always the case that you have two sources of variability. Researchers in some fields (e.g. psycholinguistics) routinely use multilevel models (or some other older alternatives like Clark's F1/F2 analysis) precisely for that reason whereas other fields (e.g. a lot of work in mainstream experimental psychology) basically ignore the issue (for no other reason that being able to get away with it, from what I can tell). This paper also discusses this question: Raaijmakers, J.G.W., Schrijnemakers, J.M.C., & Gremmen, F. (1999). How to Deal with "The Language-as-Fixed-Effect Fallacy": Common Misconceptions and Alternative Solutions. Journal of Memory and Language, 41 (3), 416-426.
When is a repeated measures ANOVA preferred over a mixed-effects model? If your participants see the exact same pictures in each condition (which is obviously not the case in your original example because each category will presumably contain different pictures), an ANOVA
12,630
When is a repeated measures ANOVA preferred over a mixed-effects model?
Never. A repeated measures ANOVA is one type, probably the simplest, of mixed effects model. I would recommend not even learning repeated measures except to know how to fit one as a mixed effects, but to learn mixed effects methods. It takes more effort as they can't be understood as recipes but are much more powerful as they can be expanded to multiple random effects, different correlation structures and handle missing data. See Gueorguieva, R., & Krystal, J. H. (2011). Move over ANOVA. Arch Gen Psychiatry, 61, 310–317. http://doi.org/10.1001/archpsyc.61.3.310
When is a repeated measures ANOVA preferred over a mixed-effects model?
Never. A repeated measures ANOVA is one type, probably the simplest, of mixed effects model. I would recommend not even learning repeated measures except to know how to fit one as a mixed effects, but
When is a repeated measures ANOVA preferred over a mixed-effects model? Never. A repeated measures ANOVA is one type, probably the simplest, of mixed effects model. I would recommend not even learning repeated measures except to know how to fit one as a mixed effects, but to learn mixed effects methods. It takes more effort as they can't be understood as recipes but are much more powerful as they can be expanded to multiple random effects, different correlation structures and handle missing data. See Gueorguieva, R., & Krystal, J. H. (2011). Move over ANOVA. Arch Gen Psychiatry, 61, 310–317. http://doi.org/10.1001/archpsyc.61.3.310
When is a repeated measures ANOVA preferred over a mixed-effects model? Never. A repeated measures ANOVA is one type, probably the simplest, of mixed effects model. I would recommend not even learning repeated measures except to know how to fit one as a mixed effects, but
12,631
Combining machine learning models
It actually boils down to one of the "3B" techniques: bagging, boosting or blending. In bagging, you train a lot of classifiers on different subsets of object and combine answers by average for regression and voting for classification (there are some other options for more complex situations, but I'll skip it). Vote proportion/variance can be interpreted as error approximation since the individual classifiers are usually considered independent. RF is in fact a bagging ensemble. Boosting is a wider family of methods, however their main point is that you build next classifier on the residuals of the former, this way (in theory) gradually increasing accuracy by highlighting more and more subtle interactions. The predictions are thus usually combined by summing them up, something like calculating a value of a function in x by summing values of its Taylor series' elements for x. Most popular versions are (Stochastic) Gradient Boosting (with nice mathematical foundation) and AdaBoost (well known, in fact a specific case of GB). From a holistic perspective, decision tree is a boosting of trivial pivot classifiers. Blending is an idea of nesting classifiers, i.e. running one classifier on an information system made of predictions of other classifiers. As so, it is a very variable method and certainly not a defined algorithm; may require a lot of objects (in most cases the "blender" classifier must be trained on a set of objects which were not used to build the partial classifiers to avoid embarrassing overfit). The predictions of partial classifiers are obviously combined by melding them into an information system which is predicted by the blender.
Combining machine learning models
It actually boils down to one of the "3B" techniques: bagging, boosting or blending. In bagging, you train a lot of classifiers on different subsets of object and combine answers by average for regres
Combining machine learning models It actually boils down to one of the "3B" techniques: bagging, boosting or blending. In bagging, you train a lot of classifiers on different subsets of object and combine answers by average for regression and voting for classification (there are some other options for more complex situations, but I'll skip it). Vote proportion/variance can be interpreted as error approximation since the individual classifiers are usually considered independent. RF is in fact a bagging ensemble. Boosting is a wider family of methods, however their main point is that you build next classifier on the residuals of the former, this way (in theory) gradually increasing accuracy by highlighting more and more subtle interactions. The predictions are thus usually combined by summing them up, something like calculating a value of a function in x by summing values of its Taylor series' elements for x. Most popular versions are (Stochastic) Gradient Boosting (with nice mathematical foundation) and AdaBoost (well known, in fact a specific case of GB). From a holistic perspective, decision tree is a boosting of trivial pivot classifiers. Blending is an idea of nesting classifiers, i.e. running one classifier on an information system made of predictions of other classifiers. As so, it is a very variable method and certainly not a defined algorithm; may require a lot of objects (in most cases the "blender" classifier must be trained on a set of objects which were not used to build the partial classifiers to avoid embarrassing overfit). The predictions of partial classifiers are obviously combined by melding them into an information system which is predicted by the blender.
Combining machine learning models It actually boils down to one of the "3B" techniques: bagging, boosting or blending. In bagging, you train a lot of classifiers on different subsets of object and combine answers by average for regres
12,632
Combining machine learning models
The expression "combining models" is vague, but my guess is that you are asking about ensemble learning methods. The best reference to learn about them is perhaps Rich Caruana's papers: http://www.cs.cornell.edu/~caruana/ctp/ct.papers/caruana.icml04.icdm06long.pdf There is no actual code in this paper, but the algorithm is clearly described, so you shouldn't have any problem coding it in any language you prefer.
Combining machine learning models
The expression "combining models" is vague, but my guess is that you are asking about ensemble learning methods. The best reference to learn about them is perhaps Rich Caruana's papers: http://www.cs
Combining machine learning models The expression "combining models" is vague, but my guess is that you are asking about ensemble learning methods. The best reference to learn about them is perhaps Rich Caruana's papers: http://www.cs.cornell.edu/~caruana/ctp/ct.papers/caruana.icml04.icdm06long.pdf There is no actual code in this paper, but the algorithm is clearly described, so you shouldn't have any problem coding it in any language you prefer.
Combining machine learning models The expression "combining models" is vague, but my guess is that you are asking about ensemble learning methods. The best reference to learn about them is perhaps Rich Caruana's papers: http://www.cs
12,633
Combining machine learning models
After looking around for a bit with the help of the above answers, I realized what my problem was. I had been trying to use the predictions of other models in the same model as was used to predict them. In other words if I had 5 variables when I ran the kNN model, I'd add a new variable with the predictions of the kNN model and make a model with 6 variables when I ran the random Forest model. I found that instead the results from the models should be segmented and run as a separate model. So I'd create predictions from various models (knn, RF, svd, etc.) then run a separate combining/blending/stacking model using just the predictions as variables and the classifications as what to predict. I think some of my problems were that in combining the predictions with the other variables, there may have been some overfitting or multicollinearity but I'm not certain. Someone else might be able to weigh in better on what I was doing wrong. Anyways thanks to everyone for their help.
Combining machine learning models
After looking around for a bit with the help of the above answers, I realized what my problem was. I had been trying to use the predictions of other models in the same model as was used to predict th
Combining machine learning models After looking around for a bit with the help of the above answers, I realized what my problem was. I had been trying to use the predictions of other models in the same model as was used to predict them. In other words if I had 5 variables when I ran the kNN model, I'd add a new variable with the predictions of the kNN model and make a model with 6 variables when I ran the random Forest model. I found that instead the results from the models should be segmented and run as a separate model. So I'd create predictions from various models (knn, RF, svd, etc.) then run a separate combining/blending/stacking model using just the predictions as variables and the classifications as what to predict. I think some of my problems were that in combining the predictions with the other variables, there may have been some overfitting or multicollinearity but I'm not certain. Someone else might be able to weigh in better on what I was doing wrong. Anyways thanks to everyone for their help.
Combining machine learning models After looking around for a bit with the help of the above answers, I realized what my problem was. I had been trying to use the predictions of other models in the same model as was used to predict th
12,634
Combining machine learning models
Good publication for combining multiple predictors is: Taraba (2023), "Optimal blending of multiple independent prediction models", Front. Artif. Intell., 6. It contains formulas for combining the models based on their variances as well as formula for the variance of the final blend. It also provides upper estimate based on maximum variance of all models. All with proofs :) \begin{equation} {y}_{B,j} = \sum_{k=1}^{N} \hat{\alpha_k} {y}_{k,j} \end{equation} Having $N$ independent models with normal distributions $R_{k} \sim \mathcal{N}(0,\sigma_k^2)$ for $k \in [1,N]$, we get an optimal blend with parameters \begin{equation} \hat{\alpha_k} = \frac{\prod_{\substack{j=1 \\ j \ne k}}^N \sigma_j^2}{\sum_{i=1}^{N} \prod_{\substack{j=1 \\ j \ne i}}^N \sigma_j^2}, \end{equation} and these independent models form normal distribution $\mathcal{N}(0,\sigma_B^2)$, which has variance \begin{equation} \sigma_B^2 = \frac{\prod_{j=1}^N \sigma_j^2}{\sum_{i=1}^{N} \prod_{\substack{j=1 \\ j \ne i}}^N \sigma_j^2}. \end{equation} Having $N$ independent models with normal distributions $R_{k} \sim \mathcal{N}(0,\sigma_k^2)$ for $k \in [1,N]$ and their variances $\sigma_k^2 \leq \sigma_M^2$, where $\sigma_M^2$ is their maximum variance, combining them optimally with coefficients from previous formula, their combined variance is $\sigma_B^2 \leq \frac{\sigma_M^2}{N}$.
Combining machine learning models
Good publication for combining multiple predictors is: Taraba (2023), "Optimal blending of multiple independent prediction models", Front. Artif. Intell., 6. It contains formulas for combining the mod
Combining machine learning models Good publication for combining multiple predictors is: Taraba (2023), "Optimal blending of multiple independent prediction models", Front. Artif. Intell., 6. It contains formulas for combining the models based on their variances as well as formula for the variance of the final blend. It also provides upper estimate based on maximum variance of all models. All with proofs :) \begin{equation} {y}_{B,j} = \sum_{k=1}^{N} \hat{\alpha_k} {y}_{k,j} \end{equation} Having $N$ independent models with normal distributions $R_{k} \sim \mathcal{N}(0,\sigma_k^2)$ for $k \in [1,N]$, we get an optimal blend with parameters \begin{equation} \hat{\alpha_k} = \frac{\prod_{\substack{j=1 \\ j \ne k}}^N \sigma_j^2}{\sum_{i=1}^{N} \prod_{\substack{j=1 \\ j \ne i}}^N \sigma_j^2}, \end{equation} and these independent models form normal distribution $\mathcal{N}(0,\sigma_B^2)$, which has variance \begin{equation} \sigma_B^2 = \frac{\prod_{j=1}^N \sigma_j^2}{\sum_{i=1}^{N} \prod_{\substack{j=1 \\ j \ne i}}^N \sigma_j^2}. \end{equation} Having $N$ independent models with normal distributions $R_{k} \sim \mathcal{N}(0,\sigma_k^2)$ for $k \in [1,N]$ and their variances $\sigma_k^2 \leq \sigma_M^2$, where $\sigma_M^2$ is their maximum variance, combining them optimally with coefficients from previous formula, their combined variance is $\sigma_B^2 \leq \frac{\sigma_M^2}{N}$.
Combining machine learning models Good publication for combining multiple predictors is: Taraba (2023), "Optimal blending of multiple independent prediction models", Front. Artif. Intell., 6. It contains formulas for combining the mod
12,635
What is the difference between "testing of hypothesis" and "test of significance"?
Significance testing is what Fisher devised and hypothesis testing is what Neyman and Pearson devised to replace significance testing. They are not the same and are mutually incompatible to an extent that would surprise most users of null hypothesis tests. Fisher's significance tests yield a p value that represents how extreme the observations are under the null hypothesis. That p value is an index of evidence against the null hypothesis and is the level of significance. Neyman and Pearson's hypothesis tests set up both a null hypothesis and an alternative hypothesis and work as a decision rule for accepting the null hypothesis. Briefly (there is more to it than I can put here) you choose an acceptable rate of false positive inference, alpha (usually 0.05), and either accept or reject the null based on whether the p value is above or below alpha. You have to abide by the statistical test's decision if you wish to protect against false positive errors. Fisher's approach allows you to take anything you like into account in interpreting the result, for example pre-existing evidence can be informally taken into account in the interpretation and presentation of the result. In the N-P approach that can only be done in the experimental design stage, and seems to be rarely done. In my opinion the Fisherian approach is more useful in basic bioscientific work than is the N-P approach. There is a substantial literature about inconsistencies between significance testing and hypothesis testing and about the unfortunate hybridisation of the two. You could start with this paper: Goodman, Toward evidence-based medical statistics. 1: The P value fallacy. https://pubmed.ncbi.nlm.nih.gov/10383371/
What is the difference between "testing of hypothesis" and "test of significance"?
Significance testing is what Fisher devised and hypothesis testing is what Neyman and Pearson devised to replace significance testing. They are not the same and are mutually incompatible to an extent
What is the difference between "testing of hypothesis" and "test of significance"? Significance testing is what Fisher devised and hypothesis testing is what Neyman and Pearson devised to replace significance testing. They are not the same and are mutually incompatible to an extent that would surprise most users of null hypothesis tests. Fisher's significance tests yield a p value that represents how extreme the observations are under the null hypothesis. That p value is an index of evidence against the null hypothesis and is the level of significance. Neyman and Pearson's hypothesis tests set up both a null hypothesis and an alternative hypothesis and work as a decision rule for accepting the null hypothesis. Briefly (there is more to it than I can put here) you choose an acceptable rate of false positive inference, alpha (usually 0.05), and either accept or reject the null based on whether the p value is above or below alpha. You have to abide by the statistical test's decision if you wish to protect against false positive errors. Fisher's approach allows you to take anything you like into account in interpreting the result, for example pre-existing evidence can be informally taken into account in the interpretation and presentation of the result. In the N-P approach that can only be done in the experimental design stage, and seems to be rarely done. In my opinion the Fisherian approach is more useful in basic bioscientific work than is the N-P approach. There is a substantial literature about inconsistencies between significance testing and hypothesis testing and about the unfortunate hybridisation of the two. You could start with this paper: Goodman, Toward evidence-based medical statistics. 1: The P value fallacy. https://pubmed.ncbi.nlm.nih.gov/10383371/
What is the difference between "testing of hypothesis" and "test of significance"? Significance testing is what Fisher devised and hypothesis testing is what Neyman and Pearson devised to replace significance testing. They are not the same and are mutually incompatible to an extent
12,636
What is the difference between "testing of hypothesis" and "test of significance"?
In many cases, these two statements mean the same thing. However, they can also be quite different. Testing a hypothesis consists of first saying what you believe will occur with some phenomenon, then developing some kind of test for this phenomenon, and then determining whether or not the phenomenon actually occurred. In many cases, testing of a hypothesis need not involve any kind of statistical test. I am reminded of this quote by the physicist Ernest Rutherford - If your experiment needs statistics, you ought to have done a better experiment. That being said, testing of hypotheses normally does use some kind of statistical tool. In contrast, testing of significance is a purely statistical concept. In essence, one has two hypotheses - the null hypothesis, which states that there is no difference between your two (or more) collections of data. The alternative hypothesis is that there is a difference between your two samples that did not occur by chance. Based on the design of your study, you then compare the two (or more) samples using a statistical test, which gives you a number, which you then compare to a reference distribution (like the normal, t, or F distributions) and if this test statistic exceeds a critical value, you reject the null hypothesis and conclude that there is a difference between the two (or more) samples. This criterion is normally that the probability of the difference occurring by chance is less than one in twenty (p<0.05), though others are sometimes used.
What is the difference between "testing of hypothesis" and "test of significance"?
In many cases, these two statements mean the same thing. However, they can also be quite different. Testing a hypothesis consists of first saying what you believe will occur with some phenomenon, then
What is the difference between "testing of hypothesis" and "test of significance"? In many cases, these two statements mean the same thing. However, they can also be quite different. Testing a hypothesis consists of first saying what you believe will occur with some phenomenon, then developing some kind of test for this phenomenon, and then determining whether or not the phenomenon actually occurred. In many cases, testing of a hypothesis need not involve any kind of statistical test. I am reminded of this quote by the physicist Ernest Rutherford - If your experiment needs statistics, you ought to have done a better experiment. That being said, testing of hypotheses normally does use some kind of statistical tool. In contrast, testing of significance is a purely statistical concept. In essence, one has two hypotheses - the null hypothesis, which states that there is no difference between your two (or more) collections of data. The alternative hypothesis is that there is a difference between your two samples that did not occur by chance. Based on the design of your study, you then compare the two (or more) samples using a statistical test, which gives you a number, which you then compare to a reference distribution (like the normal, t, or F distributions) and if this test statistic exceeds a critical value, you reject the null hypothesis and conclude that there is a difference between the two (or more) samples. This criterion is normally that the probability of the difference occurring by chance is less than one in twenty (p<0.05), though others are sometimes used.
What is the difference between "testing of hypothesis" and "test of significance"? In many cases, these two statements mean the same thing. However, they can also be quite different. Testing a hypothesis consists of first saying what you believe will occur with some phenomenon, then
12,637
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot product or the sum of element-wise multiplication?
Any given layer in a CNN has typically 3 dimensions (we'll call them height, width, depth). The convolution will produce a new layer with a new (or same) height, width and depth. The operation however is performed differently on the height/width and differently on the depth and this is what I think causes confusion. Let's first see how the convolution operation on the height and width of the input matrix. This case is performed exactly as depicted in your image and is most certainly an element-wise multiplication of the two matrices. In theory: Two-dimensional (discrete) convolutions are calculated by the formula below: $$C \left[ m, n \right] = \sum_u \sum_υ A \left[ m + u, n + υ\right] \cdot B \left[ u, υ \right]$$ As you can see each element of $C$ is calculated as the sum of the products of a single element of $A$ with a single element of $B$. This means that each element of $C$ is computed from the sum of the element-wise multiplication of $A$ and $B$. In practice: You could test the above example with any number of packages (I'll use scipy): import numpy as np from scipy.signal import convolve2d A = np.array([[1,1,1,0,0],[0,1,1,1,0],[0,0,1,1,1],[0,0,1,1,0],[0,1,1,0,0]]) B = np.array([[1,0,1],[0,1,0],[1,0,1]]) C = convolve2d(A, B, 'valid') print(C) The code above will produce: [[4 3 4] [2 4 3] [2 3 4]] Now, the convolution operation on the depth of the input can actually be considered as a dot product as each element of the same height/width is multiplied with the same weight and they are summed together. This is most evident in the case of 1x1 convolutions (typically used to manipulate the depth of a layer without changing it's dimensions). This, however, is not part of a 2D convolution (from a mathematical viewpoint) but something convolutional layers do in CNNs. Notes: 1: That being said I think most of the sources you provided have misleading explanations to say the least and are not correct. I wasn't aware so many sources have this operation (which is the most essential operation in CNNs) wrong. I guess it has something to do with the fact that convolutions sum the product between scalars and the product between two scalars is also called a dot product. 2: I think that the first reference refers to a Fully Connected layer instead of a Convolutional layer. If that is the case, a FC layer does perform the dot product as stated. I don't have the rest of the context to confirm this. tl;dr The image you provided is 100% correct on how the operation is performed, however this is not the full picture. CNN layers have 3 dimensions, two of which are handled as depicted. My suggestion would be to check up on how convolutional layers handle the depth of the input (the simplest case you could see are 1x1 convolutions).
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot pr
Any given layer in a CNN has typically 3 dimensions (we'll call them height, width, depth). The convolution will produce a new layer with a new (or same) height, width and depth. The operation however
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot product or the sum of element-wise multiplication? Any given layer in a CNN has typically 3 dimensions (we'll call them height, width, depth). The convolution will produce a new layer with a new (or same) height, width and depth. The operation however is performed differently on the height/width and differently on the depth and this is what I think causes confusion. Let's first see how the convolution operation on the height and width of the input matrix. This case is performed exactly as depicted in your image and is most certainly an element-wise multiplication of the two matrices. In theory: Two-dimensional (discrete) convolutions are calculated by the formula below: $$C \left[ m, n \right] = \sum_u \sum_υ A \left[ m + u, n + υ\right] \cdot B \left[ u, υ \right]$$ As you can see each element of $C$ is calculated as the sum of the products of a single element of $A$ with a single element of $B$. This means that each element of $C$ is computed from the sum of the element-wise multiplication of $A$ and $B$. In practice: You could test the above example with any number of packages (I'll use scipy): import numpy as np from scipy.signal import convolve2d A = np.array([[1,1,1,0,0],[0,1,1,1,0],[0,0,1,1,1],[0,0,1,1,0],[0,1,1,0,0]]) B = np.array([[1,0,1],[0,1,0],[1,0,1]]) C = convolve2d(A, B, 'valid') print(C) The code above will produce: [[4 3 4] [2 4 3] [2 3 4]] Now, the convolution operation on the depth of the input can actually be considered as a dot product as each element of the same height/width is multiplied with the same weight and they are summed together. This is most evident in the case of 1x1 convolutions (typically used to manipulate the depth of a layer without changing it's dimensions). This, however, is not part of a 2D convolution (from a mathematical viewpoint) but something convolutional layers do in CNNs. Notes: 1: That being said I think most of the sources you provided have misleading explanations to say the least and are not correct. I wasn't aware so many sources have this operation (which is the most essential operation in CNNs) wrong. I guess it has something to do with the fact that convolutions sum the product between scalars and the product between two scalars is also called a dot product. 2: I think that the first reference refers to a Fully Connected layer instead of a Convolutional layer. If that is the case, a FC layer does perform the dot product as stated. I don't have the rest of the context to confirm this. tl;dr The image you provided is 100% correct on how the operation is performed, however this is not the full picture. CNN layers have 3 dimensions, two of which are handled as depicted. My suggestion would be to check up on how convolutional layers handle the depth of the input (the simplest case you could see are 1x1 convolutions).
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot pr Any given layer in a CNN has typically 3 dimensions (we'll call them height, width, depth). The convolution will produce a new layer with a new (or same) height, width and depth. The operation however
12,638
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot product or the sum of element-wise multiplication?
I believe the key is that when the filter is convolving some part of the image (the "receptive field") each number in the filter (i.e. each weight) is first flattened into vector format. Likewise, the pixels of the image are also flattened into vector format. THEN, the dot product is calculated. Which is the exact same thing as finding the sum of the element-by-element (element-wise) multiplication. Of course, these flattened vectors can also be combined in a matrix format, as the below image shows. In this case then true matrix multiplication can be used, but it's important to note that the flattening the image pixels from each convolution and also the weights filter is the precursor. image credit: TensorFlow and Deep Learning without a PhD, Part 1 (Google Cloud Next '17)
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot pr
I believe the key is that when the filter is convolving some part of the image (the "receptive field") each number in the filter (i.e. each weight) is first flattened into vector format. Likewise, th
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot product or the sum of element-wise multiplication? I believe the key is that when the filter is convolving some part of the image (the "receptive field") each number in the filter (i.e. each weight) is first flattened into vector format. Likewise, the pixels of the image are also flattened into vector format. THEN, the dot product is calculated. Which is the exact same thing as finding the sum of the element-by-element (element-wise) multiplication. Of course, these flattened vectors can also be combined in a matrix format, as the below image shows. In this case then true matrix multiplication can be used, but it's important to note that the flattening the image pixels from each convolution and also the weights filter is the precursor. image credit: TensorFlow and Deep Learning without a PhD, Part 1 (Google Cloud Next '17)
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot pr I believe the key is that when the filter is convolving some part of the image (the "receptive field") each number in the filter (i.e. each weight) is first flattened into vector format. Likewise, th
12,639
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot product or the sum of element-wise multiplication?
The operation is called convolution which involves a sum of element by element multiplication, which in turn is the same as a dot product on multidimensional matrices which ML folks call tensors. If you write it as a loop, it'll look like this pseudo Python code: for i in 0:3: for j in 0:3: s = 0 for k in 0:3: for l in 0:3: s += A[i+k,j+l]*C[k,l] Z[i,j] = s Here A is your 5x5 input matrix, C is 3x3 filter and Z is 3x3 output matrix. The subtle difference with a dot product is that usually a dot product is on the entire vectors, while in convolution you do dot product on the moving subset (window) of the input matrix, you could write it as follows to replace the innermost two nested loops in the code above: Z[i,j] = dot(A[i:i+2,j:j+2],C)
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot pr
The operation is called convolution which involves a sum of element by element multiplication, which in turn is the same as a dot product on multidimensional matrices which ML folks call tensors. If y
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot product or the sum of element-wise multiplication? The operation is called convolution which involves a sum of element by element multiplication, which in turn is the same as a dot product on multidimensional matrices which ML folks call tensors. If you write it as a loop, it'll look like this pseudo Python code: for i in 0:3: for j in 0:3: s = 0 for k in 0:3: for l in 0:3: s += A[i+k,j+l]*C[k,l] Z[i,j] = s Here A is your 5x5 input matrix, C is 3x3 filter and Z is 3x3 output matrix. The subtle difference with a dot product is that usually a dot product is on the entire vectors, while in convolution you do dot product on the moving subset (window) of the input matrix, you could write it as follows to replace the innermost two nested loops in the code above: Z[i,j] = dot(A[i:i+2,j:j+2],C)
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot pr The operation is called convolution which involves a sum of element by element multiplication, which in turn is the same as a dot product on multidimensional matrices which ML folks call tensors. If y
12,640
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot product or the sum of element-wise multiplication?
Both element-wise and dot product interpretations are correct. When you convolve two tensors, X of shape (h, w, d) and Y of shape (h, w, d), you're doing element-wise multiplication. It's, however, the same as the dot product of X and Y transpose. You can expand the math equation, the shapes and subscripts match.
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot pr
Both element-wise and dot product interpretations are correct. When you convolve two tensors, X of shape (h, w, d) and Y of shape (h, w, d), you're doing element-wise multiplication. It's, however, th
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot product or the sum of element-wise multiplication? Both element-wise and dot product interpretations are correct. When you convolve two tensors, X of shape (h, w, d) and Y of shape (h, w, d), you're doing element-wise multiplication. It's, however, the same as the dot product of X and Y transpose. You can expand the math equation, the shapes and subscripts match.
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot pr Both element-wise and dot product interpretations are correct. When you convolve two tensors, X of shape (h, w, d) and Y of shape (h, w, d), you're doing element-wise multiplication. It's, however, th
12,641
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot product or the sum of element-wise multiplication?
"What operation is actually used (element-by-element multiplication or the dot product?) and what is the primary difference?" The actual operation is called a convolution defined as: $$ J(x,y) = K * I = \sum_{n,m}K(n,m)I(x-n,y-m) $$ Where $J$ is the convolved signal, $K$ is the kernel, $I$ is the input signal, and $n,m$ are the kernel indexes. We see by the input signal indexing $I(x-n,y-m)$ that both input signal axes are "flipped". As an aside, the kernel (a.k.a. filter) could be flipped instead. Back to your question: From the Numpy docs: the dot product numpy.dot "Returns the dot product of a and b. If a and b are both scalars or both 1-D arrays then a scalar is returned; otherwise an array is returned. (...)" While the sum of the element-wise multiplication returns a scalar. Making use of a previous reply - if we look at the two regions in the example: import numpy as np from scipy.signal import convolve2d A = np.array([[1,1,1], [0,1,1], [0,0,1]]) B = np.array([[1,0,1], [0,1,0], [1,0,1]]) Dot product (returns ndarray): print(np.dot(A,B)) [[2 1 2] [1 1 1] [1 0 1]] Sum of element-wise multiplication (returns scalar); print(np.sum(np.multiply(A,B))) 4 And that is the primary difference. For good measure, a convolution: D = convolve2d(A, B, 'valid') print(D) [[4]] which in this case is equal to sum of element-wise multiplication of image patch and filter. A convolution can be equivalent to sum of element-wise multiplication if the filter is symmetric, which is the case in deeplearning.ai example given. This will not be the case for asymmetric filters: B2 = np.array([[1,0,0], [0,1,0], [1,0,1]]) print(np.sum(np.multiply(A,B2))) print(convolve2d(A, B2, 'valid')) 3 [[4]] where sum of element-wise multiplication returns 3 and convolution returns 4, albeit as numpy.ndarray data type. Note the discussion on flattened arrays - TensorFlow and Deep Learning without a PhD, Part 1 (Google Cloud Next '17) - applies to fully-connected, not convolutional layers. 2020 are you still reading? :D
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot pr
"What operation is actually used (element-by-element multiplication or the dot product?) and what is the primary difference?" The actual operation is called a convolution defined as: $$ J(x,y) = K * I
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot product or the sum of element-wise multiplication? "What operation is actually used (element-by-element multiplication or the dot product?) and what is the primary difference?" The actual operation is called a convolution defined as: $$ J(x,y) = K * I = \sum_{n,m}K(n,m)I(x-n,y-m) $$ Where $J$ is the convolved signal, $K$ is the kernel, $I$ is the input signal, and $n,m$ are the kernel indexes. We see by the input signal indexing $I(x-n,y-m)$ that both input signal axes are "flipped". As an aside, the kernel (a.k.a. filter) could be flipped instead. Back to your question: From the Numpy docs: the dot product numpy.dot "Returns the dot product of a and b. If a and b are both scalars or both 1-D arrays then a scalar is returned; otherwise an array is returned. (...)" While the sum of the element-wise multiplication returns a scalar. Making use of a previous reply - if we look at the two regions in the example: import numpy as np from scipy.signal import convolve2d A = np.array([[1,1,1], [0,1,1], [0,0,1]]) B = np.array([[1,0,1], [0,1,0], [1,0,1]]) Dot product (returns ndarray): print(np.dot(A,B)) [[2 1 2] [1 1 1] [1 0 1]] Sum of element-wise multiplication (returns scalar); print(np.sum(np.multiply(A,B))) 4 And that is the primary difference. For good measure, a convolution: D = convolve2d(A, B, 'valid') print(D) [[4]] which in this case is equal to sum of element-wise multiplication of image patch and filter. A convolution can be equivalent to sum of element-wise multiplication if the filter is symmetric, which is the case in deeplearning.ai example given. This will not be the case for asymmetric filters: B2 = np.array([[1,0,0], [0,1,0], [1,0,1]]) print(np.sum(np.multiply(A,B2))) print(convolve2d(A, B2, 'valid')) 3 [[4]] where sum of element-wise multiplication returns 3 and convolution returns 4, albeit as numpy.ndarray data type. Note the discussion on flattened arrays - TensorFlow and Deep Learning without a PhD, Part 1 (Google Cloud Next '17) - applies to fully-connected, not convolutional layers. 2020 are you still reading? :D
In a convolutional neural network (CNN), when convolving the image, is the operation used the dot pr "What operation is actually used (element-by-element multiplication or the dot product?) and what is the primary difference?" The actual operation is called a convolution defined as: $$ J(x,y) = K * I
12,642
Does "curse of dimensionality" really exist in real data?
This paper(1) discusses the blessing of non-uniformity as a counterpoint to the curse of dimensionality. The main idea is that data are not uniformly dispersed within the feature space, so one can gain traction by identifying the ways in which the data are organized. (1) Pedro Domingos, "A Few Useful Things to Know about Machine Learning"
Does "curse of dimensionality" really exist in real data?
This paper(1) discusses the blessing of non-uniformity as a counterpoint to the curse of dimensionality. The main idea is that data are not uniformly dispersed within the feature space, so one can gai
Does "curse of dimensionality" really exist in real data? This paper(1) discusses the blessing of non-uniformity as a counterpoint to the curse of dimensionality. The main idea is that data are not uniformly dispersed within the feature space, so one can gain traction by identifying the ways in which the data are organized. (1) Pedro Domingos, "A Few Useful Things to Know about Machine Learning"
Does "curse of dimensionality" really exist in real data? This paper(1) discusses the blessing of non-uniformity as a counterpoint to the curse of dimensionality. The main idea is that data are not uniformly dispersed within the feature space, so one can gai
12,643
Does "curse of dimensionality" really exist in real data?
Curse of dimensionality in machine learning is more often the problem of exploding empty space between the few data points that you have. Low manifold data can make it even worse. Here is an example setup with 10000 samples where I try to do kNN with 1 neighbor. from numpy.random import normal from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import precision_score import matplotlib.pyplot as plt import numpy as np from math import sqrt from scipy.special import gamma N=10000 N_broad=2 scale=20 dims=[] precs=[] def avg_distance(k): return sqrt(2)*gamma((k+1)/2)/gamma(k/2) for dim in range(N_broad+1,30): clf = KNeighborsClassifier(1, n_jobs=-1) X_train=np.hstack([normal(size=(N,N_broad)), normal(size=(N,dim-N_broad))/avg_distance(dim-N_broad)/scale]) y_train=(X_train[:,N_broad]>0).astype(int) clf.fit(X_train, y_train) X_test=np.hstack([normal(size=(N,N_broad)), normal(size=(N,dim-N_broad))/avg_distance(dim-N_broad)/scale]) y_test=(X_test[:,N_broad]>0).astype(int) y_test_pred=clf.predict(X_test) prec=precision_score(y_test, y_test_pred) dims.append(dim) precs.append(prec) print(dim, prec) plt.plot(dims, precs) plt.ylim([0.5,1]) plt.xlabel("Dimension") plt.ylabel("Precision") plt.title("kNN(1) on {} samples".format(N)) plt.show() You didn't like fully uniform distributions, so I've made this a 2D manifold with smaller dimensions (reduced by scale) sprinkled around the 2D plane of the first two coordinates. As it happens, one of the smaller dimensions is predictive (the label is 1 when that dimension is positive). The precision drops rapidly with increasing dimension. Of course, precision=0.5 would be random guessing. With a decision surface, which is more complicating than a plane, it would get even worse. It's like the kNN balls are too sparse to be helpful at probing a smooth hyperplane. With higher dimensions they feel increasingly more lonely. On the other hand, methods like SVM have a global view and do much better.
Does "curse of dimensionality" really exist in real data?
Curse of dimensionality in machine learning is more often the problem of exploding empty space between the few data points that you have. Low manifold data can make it even worse. Here is an example s
Does "curse of dimensionality" really exist in real data? Curse of dimensionality in machine learning is more often the problem of exploding empty space between the few data points that you have. Low manifold data can make it even worse. Here is an example setup with 10000 samples where I try to do kNN with 1 neighbor. from numpy.random import normal from sklearn.neighbors import KNeighborsClassifier from sklearn.metrics import precision_score import matplotlib.pyplot as plt import numpy as np from math import sqrt from scipy.special import gamma N=10000 N_broad=2 scale=20 dims=[] precs=[] def avg_distance(k): return sqrt(2)*gamma((k+1)/2)/gamma(k/2) for dim in range(N_broad+1,30): clf = KNeighborsClassifier(1, n_jobs=-1) X_train=np.hstack([normal(size=(N,N_broad)), normal(size=(N,dim-N_broad))/avg_distance(dim-N_broad)/scale]) y_train=(X_train[:,N_broad]>0).astype(int) clf.fit(X_train, y_train) X_test=np.hstack([normal(size=(N,N_broad)), normal(size=(N,dim-N_broad))/avg_distance(dim-N_broad)/scale]) y_test=(X_test[:,N_broad]>0).astype(int) y_test_pred=clf.predict(X_test) prec=precision_score(y_test, y_test_pred) dims.append(dim) precs.append(prec) print(dim, prec) plt.plot(dims, precs) plt.ylim([0.5,1]) plt.xlabel("Dimension") plt.ylabel("Precision") plt.title("kNN(1) on {} samples".format(N)) plt.show() You didn't like fully uniform distributions, so I've made this a 2D manifold with smaller dimensions (reduced by scale) sprinkled around the 2D plane of the first two coordinates. As it happens, one of the smaller dimensions is predictive (the label is 1 when that dimension is positive). The precision drops rapidly with increasing dimension. Of course, precision=0.5 would be random guessing. With a decision surface, which is more complicating than a plane, it would get even worse. It's like the kNN balls are too sparse to be helpful at probing a smooth hyperplane. With higher dimensions they feel increasingly more lonely. On the other hand, methods like SVM have a global view and do much better.
Does "curse of dimensionality" really exist in real data? Curse of dimensionality in machine learning is more often the problem of exploding empty space between the few data points that you have. Low manifold data can make it even worse. Here is an example s
12,644
Does "curse of dimensionality" really exist in real data?
Consider for example time series (and images, and audio). Sensor readings (Internet of Things) are very common. The curse of dimensionality is much more common than you think. There is a large redundancy there, but also a lot of noise. The problem is that many people simply avoid these challenges of real data, and only use the same cherryupicked UCI data sets over and over again.
Does "curse of dimensionality" really exist in real data?
Consider for example time series (and images, and audio). Sensor readings (Internet of Things) are very common. The curse of dimensionality is much more common than you think. There is a large redunda
Does "curse of dimensionality" really exist in real data? Consider for example time series (and images, and audio). Sensor readings (Internet of Things) are very common. The curse of dimensionality is much more common than you think. There is a large redundancy there, but also a lot of noise. The problem is that many people simply avoid these challenges of real data, and only use the same cherryupicked UCI data sets over and over again.
Does "curse of dimensionality" really exist in real data? Consider for example time series (and images, and audio). Sensor readings (Internet of Things) are very common. The curse of dimensionality is much more common than you think. There is a large redunda
12,645
Does "curse of dimensionality" really exist in real data?
There is a wonderful article, "Statistical Modeling: the two cultures", by Breiman. He explains the two groups of scientists who deal with data and how each of them look at "dimensionality". The answer to your question is "it depends" in which group you are. Check the paper out.
Does "curse of dimensionality" really exist in real data?
There is a wonderful article, "Statistical Modeling: the two cultures", by Breiman. He explains the two groups of scientists who deal with data and how each of them look at "dimensionality". The answe
Does "curse of dimensionality" really exist in real data? There is a wonderful article, "Statistical Modeling: the two cultures", by Breiman. He explains the two groups of scientists who deal with data and how each of them look at "dimensionality". The answer to your question is "it depends" in which group you are. Check the paper out.
Does "curse of dimensionality" really exist in real data? There is a wonderful article, "Statistical Modeling: the two cultures", by Breiman. He explains the two groups of scientists who deal with data and how each of them look at "dimensionality". The answe
12,646
Deriving the bivariate Poisson distribution
In a slide presentation, Karlis and Ntzoufras define a bivariate Poisson as the distribution of $(X,Y)=(X_1+X_0,X_2+X_0)$ where the $X_i$ independently have Poisson $\theta_i$ distributions. Recall that having such a distribution means $$\Pr(X_i=k) = e^{-\theta_i}\frac{\theta_i^k}{k!}$$ for $k=0, 1, 2, \ldots.$ The event $(X,Y)=(x,y)$ is the disjoint union of the events $$(X_0,X_1,X_2) = (i,x-i,y-i)$$ for all $i$ that make all three components non-negative integers, from which we may deduce that $0 \le i \le \min(x,y)$. Because the $X_i$ are independent their probabilities multiply, whence $$F_{(\theta_0,\theta_1,\theta_2)}(x,y)=\Pr((X,Y)=(x,y)) \\= \sum_{i=0}^{\min(x,y)} \Pr(X_0=i)\Pr(X_1=x-i)\Pr(X_2=y-i).$$ This is a formula; we are done. But to see that it is equivalent to the formula in the question, use the definition of the Poisson distribution to write these probabilities in terms of the parameters $\theta_i$ and (assuming neither of $\theta_1,\theta_2$ is zero) re-work it algebraically to look as much as possible like the product $\Pr(X_1=x)\Pr(X_2=y)$: $$\eqalign{ F_{(\theta_0,\theta_1,\theta_2)}(x,y)&= \sum_{i=0}^{\min(x,y)} \left( e^{-\theta_0} \frac{\theta_0^i}{i!}\right) \left( e^{-\theta_1} \frac{\theta_1^{x-i}}{(x-i)!}\right) \left( e^{-\theta_2} \frac{\theta_2^{y-i}}{(y-i)!}\right) \\ &=e^{-(\theta_1+\theta_2)}\frac{\theta_1^x}{x!}\frac{\theta_2^y}{y!}\left(e^{-\theta_0}\sum_{i=0}^{\min(x,y)} \frac{\theta_0^i}{i!}\frac{x!\theta_1^{-i}}{(x-i)!}\frac{y!\theta_2^{-i}}{(y-i)!}\right). }$$ If you really want to--it is somewhat suggestive--you can re-express the terms in the sum using the binomial coefficients $\binom{x}{i}=x!/((x-i)!i!)$ and $\binom{y}{i}$, yielding $$F_{(\theta_0,\theta_1,\theta_2)}(x,y) = e^{-(\theta_0+\theta_1+\theta_2)}\frac{\theta_1^x}{x!}\frac{\theta_2^y}{y!}\sum_{i=0}^{\min(x,y)}i!\binom{x}{i}\binom{y}{i}\left(\frac{\theta_0}{\theta_1\theta_2}\right)^i,$$ exactly as in the question. Generalization to multivariate scenarios could proceed in several ways, depending on the flexibility needed. The simplest would contemplate the distribution of $$(X_1+X_0, X_2+X_0, \ldots, X_d+X_0)$$ for independent Poisson distributed variates $X_0, X_1, \ldots,X_d$. For more flexibility additional variables could be introduced. For instance, use independent Poisson $\eta_i$ variables $Y_1, \ldots, Y_d$ and consider the multivariate distribution of the $X_i + (Y_i + Y_{i+1} + \cdots + Y_d)$, $i=1, 2, \ldots, d.$
Deriving the bivariate Poisson distribution
In a slide presentation, Karlis and Ntzoufras define a bivariate Poisson as the distribution of $(X,Y)=(X_1+X_0,X_2+X_0)$ where the $X_i$ independently have Poisson $\theta_i$ distributions. Recall th
Deriving the bivariate Poisson distribution In a slide presentation, Karlis and Ntzoufras define a bivariate Poisson as the distribution of $(X,Y)=(X_1+X_0,X_2+X_0)$ where the $X_i$ independently have Poisson $\theta_i$ distributions. Recall that having such a distribution means $$\Pr(X_i=k) = e^{-\theta_i}\frac{\theta_i^k}{k!}$$ for $k=0, 1, 2, \ldots.$ The event $(X,Y)=(x,y)$ is the disjoint union of the events $$(X_0,X_1,X_2) = (i,x-i,y-i)$$ for all $i$ that make all three components non-negative integers, from which we may deduce that $0 \le i \le \min(x,y)$. Because the $X_i$ are independent their probabilities multiply, whence $$F_{(\theta_0,\theta_1,\theta_2)}(x,y)=\Pr((X,Y)=(x,y)) \\= \sum_{i=0}^{\min(x,y)} \Pr(X_0=i)\Pr(X_1=x-i)\Pr(X_2=y-i).$$ This is a formula; we are done. But to see that it is equivalent to the formula in the question, use the definition of the Poisson distribution to write these probabilities in terms of the parameters $\theta_i$ and (assuming neither of $\theta_1,\theta_2$ is zero) re-work it algebraically to look as much as possible like the product $\Pr(X_1=x)\Pr(X_2=y)$: $$\eqalign{ F_{(\theta_0,\theta_1,\theta_2)}(x,y)&= \sum_{i=0}^{\min(x,y)} \left( e^{-\theta_0} \frac{\theta_0^i}{i!}\right) \left( e^{-\theta_1} \frac{\theta_1^{x-i}}{(x-i)!}\right) \left( e^{-\theta_2} \frac{\theta_2^{y-i}}{(y-i)!}\right) \\ &=e^{-(\theta_1+\theta_2)}\frac{\theta_1^x}{x!}\frac{\theta_2^y}{y!}\left(e^{-\theta_0}\sum_{i=0}^{\min(x,y)} \frac{\theta_0^i}{i!}\frac{x!\theta_1^{-i}}{(x-i)!}\frac{y!\theta_2^{-i}}{(y-i)!}\right). }$$ If you really want to--it is somewhat suggestive--you can re-express the terms in the sum using the binomial coefficients $\binom{x}{i}=x!/((x-i)!i!)$ and $\binom{y}{i}$, yielding $$F_{(\theta_0,\theta_1,\theta_2)}(x,y) = e^{-(\theta_0+\theta_1+\theta_2)}\frac{\theta_1^x}{x!}\frac{\theta_2^y}{y!}\sum_{i=0}^{\min(x,y)}i!\binom{x}{i}\binom{y}{i}\left(\frac{\theta_0}{\theta_1\theta_2}\right)^i,$$ exactly as in the question. Generalization to multivariate scenarios could proceed in several ways, depending on the flexibility needed. The simplest would contemplate the distribution of $$(X_1+X_0, X_2+X_0, \ldots, X_d+X_0)$$ for independent Poisson distributed variates $X_0, X_1, \ldots,X_d$. For more flexibility additional variables could be introduced. For instance, use independent Poisson $\eta_i$ variables $Y_1, \ldots, Y_d$ and consider the multivariate distribution of the $X_i + (Y_i + Y_{i+1} + \cdots + Y_d)$, $i=1, 2, \ldots, d.$
Deriving the bivariate Poisson distribution In a slide presentation, Karlis and Ntzoufras define a bivariate Poisson as the distribution of $(X,Y)=(X_1+X_0,X_2+X_0)$ where the $X_i$ independently have Poisson $\theta_i$ distributions. Recall th
12,647
Deriving the bivariate Poisson distribution
Here is a way to derive the bivariate poisson distribution. Let $X_0, X_1, X_2$ be independent poisson random variables with parameters $\theta_0, \theta_1, \theta_2$. Then we define $Y_1=X_0+X_1, Y_2 = X_0+X_2$. The variable $X_0$, common to both $Y_1$ an $Y_2$, causes the pair $(Y_1, Y_2)$ to be correlated. Then we must calculate the probability mass funtion: $$ \begin{align} P(Y_1=y_1, Y_2=y_2) &= P(X_0+X_1=y_1, X_0+X_2=y_2) \\ &= \sum_{x_0=0}^{\min(y_1, y_2)} P(X_0=x_0) P(X_1=y_1-x_0) P(X_2=y_2-y_0) \\ &= \sum_{x_0=0}^{\min(y_1, y_2)} e^{-\theta_0} \frac{{\theta_0}^{x_0}}{x_0!} e^{-\theta_1} \frac{{\theta_1}^{y_1-x_0}}{(y_1-x_0)!} e^{-\theta_2} \frac{{\theta_2}^{y_2-x_0}}{(y_2-x_0)!} \\ &= e^{-\theta_0-\theta_1-\theta_2} {\theta_1}^{y_1} {\theta_2}^{y_2} \sum_{x_0=0}^{\min(y_1,y_2)} \left(\frac{\theta_0}{\theta_1 \theta_2}\right)^{x_0} x_0! \binom{y_1}{x_0} \binom{y_2}{x_0} \end{align} $$ Hope this helps!
Deriving the bivariate Poisson distribution
Here is a way to derive the bivariate poisson distribution. Let $X_0, X_1, X_2$ be independent poisson random variables with parameters $\theta_0, \theta_1, \theta_2$. Then we define $Y_1=X_0+X_1, Y_
Deriving the bivariate Poisson distribution Here is a way to derive the bivariate poisson distribution. Let $X_0, X_1, X_2$ be independent poisson random variables with parameters $\theta_0, \theta_1, \theta_2$. Then we define $Y_1=X_0+X_1, Y_2 = X_0+X_2$. The variable $X_0$, common to both $Y_1$ an $Y_2$, causes the pair $(Y_1, Y_2)$ to be correlated. Then we must calculate the probability mass funtion: $$ \begin{align} P(Y_1=y_1, Y_2=y_2) &= P(X_0+X_1=y_1, X_0+X_2=y_2) \\ &= \sum_{x_0=0}^{\min(y_1, y_2)} P(X_0=x_0) P(X_1=y_1-x_0) P(X_2=y_2-y_0) \\ &= \sum_{x_0=0}^{\min(y_1, y_2)} e^{-\theta_0} \frac{{\theta_0}^{x_0}}{x_0!} e^{-\theta_1} \frac{{\theta_1}^{y_1-x_0}}{(y_1-x_0)!} e^{-\theta_2} \frac{{\theta_2}^{y_2-x_0}}{(y_2-x_0)!} \\ &= e^{-\theta_0-\theta_1-\theta_2} {\theta_1}^{y_1} {\theta_2}^{y_2} \sum_{x_0=0}^{\min(y_1,y_2)} \left(\frac{\theta_0}{\theta_1 \theta_2}\right)^{x_0} x_0! \binom{y_1}{x_0} \binom{y_2}{x_0} \end{align} $$ Hope this helps!
Deriving the bivariate Poisson distribution Here is a way to derive the bivariate poisson distribution. Let $X_0, X_1, X_2$ be independent poisson random variables with parameters $\theta_0, \theta_1, \theta_2$. Then we define $Y_1=X_0+X_1, Y_
12,648
Generate pairs of random numbers uniformly distributed and correlated
I'm not aware of a universal method to generate correlated random variables with any given marginal distributions. So, I'll propose an ad hoc method to generate pairs of uniformly distributed random variables with a given (Pearson) correlation. Without loss of generality, I assume that the desired marginal distribution is standard uniform (i.e., the support is $[0, 1]$). The proposed approach relies on the following: a) For standard uniform random variables $U_1$ and $U_2$ with respective distribution functions $F_1$ and $F_2$, we have $F_i(U_i) = U_i$, for $i = 1, 2$. Thus, by definition Spearman's rho is $$ \rho_{\rm S}(U_1, U_2) = {\rm corr}(F_1(U_1), F_2(U_2)) = {\rm corr}(U_1, U_2) . $$ So, Spearman's rho and Pearson's correlation coefficient are equal (sample versions might however differ). b) If $X_1, X_2$ are random variables with continuous margins and Gaussian copula with (Pearson) correlation coefficient $\rho$, then Spearman's rho is $$ \rho_{\rm S}(X_1, X_2) = \frac{6}{\pi} \arcsin \left(\frac{\rho}{2}\right) . $$ This makes it easy to generate random variables that have a desired value of Spearman's rho. The approach is to generate data from the Gaussian copula with an appropriate correlation coefficient $\rho$ such that the Spearman's rho corresponds to the desired correlation for the uniform random variables. Simulation algorithm Let $r$ denote the desired level of correlation, and $n$ the number of pairs to be generated. The algorithm is: Compute $\rho = 2\sin (r \pi/6)$. Generate a pair of random variables from the Gaussian copula (e.g., with this approach) Repeat step 2 $n$ times. Example The following code is an example of implementation of this algorithm using R with a target correlation $r = 0.6$ and $n = 500$ pairs. ## Initialization and parameters set.seed(123) r <- 0.6 # Target (Spearman) correlation n <- 500 # Number of samples ## Functions gen.gauss.cop <- function(r, n){ rho <- 2 * sin(r * pi/6) # Pearson correlation P <- toeplitz(c(1, rho)) # Correlation matrix d <- nrow(P) # Dimension ## Generate sample U <- pnorm(matrix(rnorm(n*d), ncol = d) %*% chol(P)) return(U) } ## Data generation and visualization U <- gen.gauss.cop(r = r, n = n) pairs(U, diag.panel = function(x){ h <- hist(x, plot = FALSE) rect(head(h$breaks, -1), 0, tail(h$breaks, -1), h$counts/max(h$counts))}) In the figure below, the diagonal plots show histograms of variables $U_1$ and $U_2$, and off-diagonal plots show scatter plots of $U_1$ and $U_2$. By constuction, the random variables have uniform margins and a correlation coefficient (close to) $r$. But due to the effect of sampling, the correlation coefficient of the simulated data is not exactly equal to $r$. cor(U)[1, 2] # [1] 0.5337697 Note that the gen.gauss.cop function should work with more than two variables simply by specifying a larger correlation matrix. Simulation study The following simulation study repeated for target correlation $r= -0.5, 0.1, 0.6$ suggests that the distribution of the correlation coefficient converges to the desired correlation as the sample size $n$ increases. ## Simulation set.seed(921) r <- 0.6 # Target correlation n <- c(10, 50, 100, 500, 1000, 5000); names(n) <- n # Number of samples S <- 1000 # Number of simulations res <- sapply(n, function(n, r, S){ replicate(S, cor(gen.gauss.cop(r, n))[1, 2]) }, r = r, S = S) boxplot(res, xlab = "Sample size", ylab = "Correlation") abline(h = r, col = "red")
Generate pairs of random numbers uniformly distributed and correlated
I'm not aware of a universal method to generate correlated random variables with any given marginal distributions. So, I'll propose an ad hoc method to generate pairs of uniformly distributed random v
Generate pairs of random numbers uniformly distributed and correlated I'm not aware of a universal method to generate correlated random variables with any given marginal distributions. So, I'll propose an ad hoc method to generate pairs of uniformly distributed random variables with a given (Pearson) correlation. Without loss of generality, I assume that the desired marginal distribution is standard uniform (i.e., the support is $[0, 1]$). The proposed approach relies on the following: a) For standard uniform random variables $U_1$ and $U_2$ with respective distribution functions $F_1$ and $F_2$, we have $F_i(U_i) = U_i$, for $i = 1, 2$. Thus, by definition Spearman's rho is $$ \rho_{\rm S}(U_1, U_2) = {\rm corr}(F_1(U_1), F_2(U_2)) = {\rm corr}(U_1, U_2) . $$ So, Spearman's rho and Pearson's correlation coefficient are equal (sample versions might however differ). b) If $X_1, X_2$ are random variables with continuous margins and Gaussian copula with (Pearson) correlation coefficient $\rho$, then Spearman's rho is $$ \rho_{\rm S}(X_1, X_2) = \frac{6}{\pi} \arcsin \left(\frac{\rho}{2}\right) . $$ This makes it easy to generate random variables that have a desired value of Spearman's rho. The approach is to generate data from the Gaussian copula with an appropriate correlation coefficient $\rho$ such that the Spearman's rho corresponds to the desired correlation for the uniform random variables. Simulation algorithm Let $r$ denote the desired level of correlation, and $n$ the number of pairs to be generated. The algorithm is: Compute $\rho = 2\sin (r \pi/6)$. Generate a pair of random variables from the Gaussian copula (e.g., with this approach) Repeat step 2 $n$ times. Example The following code is an example of implementation of this algorithm using R with a target correlation $r = 0.6$ and $n = 500$ pairs. ## Initialization and parameters set.seed(123) r <- 0.6 # Target (Spearman) correlation n <- 500 # Number of samples ## Functions gen.gauss.cop <- function(r, n){ rho <- 2 * sin(r * pi/6) # Pearson correlation P <- toeplitz(c(1, rho)) # Correlation matrix d <- nrow(P) # Dimension ## Generate sample U <- pnorm(matrix(rnorm(n*d), ncol = d) %*% chol(P)) return(U) } ## Data generation and visualization U <- gen.gauss.cop(r = r, n = n) pairs(U, diag.panel = function(x){ h <- hist(x, plot = FALSE) rect(head(h$breaks, -1), 0, tail(h$breaks, -1), h$counts/max(h$counts))}) In the figure below, the diagonal plots show histograms of variables $U_1$ and $U_2$, and off-diagonal plots show scatter plots of $U_1$ and $U_2$. By constuction, the random variables have uniform margins and a correlation coefficient (close to) $r$. But due to the effect of sampling, the correlation coefficient of the simulated data is not exactly equal to $r$. cor(U)[1, 2] # [1] 0.5337697 Note that the gen.gauss.cop function should work with more than two variables simply by specifying a larger correlation matrix. Simulation study The following simulation study repeated for target correlation $r= -0.5, 0.1, 0.6$ suggests that the distribution of the correlation coefficient converges to the desired correlation as the sample size $n$ increases. ## Simulation set.seed(921) r <- 0.6 # Target correlation n <- c(10, 50, 100, 500, 1000, 5000); names(n) <- n # Number of samples S <- 1000 # Number of simulations res <- sapply(n, function(n, r, S){ replicate(S, cor(gen.gauss.cop(r, n))[1, 2]) }, r = r, S = S) boxplot(res, xlab = "Sample size", ylab = "Correlation") abline(h = r, col = "red")
Generate pairs of random numbers uniformly distributed and correlated I'm not aware of a universal method to generate correlated random variables with any given marginal distributions. So, I'll propose an ad hoc method to generate pairs of uniformly distributed random v
12,649
Generate pairs of random numbers uniformly distributed and correlated
Intuitively, $u_1$ is $U(0,1)$ because $u_1$ equals $w_1$ [which is $U(0,1)$] if $I = 1$, and $u_1$ equals $w_2$ [which is $U(0,1)$] if $I = 0$, so $u_1$ is $U(0,1)$ in either case. The same for $u_2$. As for the correlation: $E(u_1 u_2) = E[I w_1 + (1-I) w_2][I w_1 + (1-I) w_3]$ Expanding this, note first that $I(I-1)=0$, $I^2=I$, and $(1-I)^2=(1-I)$ because $I$ is always either $0$ or $1$. Note also that $I$ is independent of the $w$'s, which are also independent of each other. So: $E(u_1 u_2) = E(I)E(w_1^2) + E(1-I)E(w_2)E(w_3)$ $=pE(w_1^2)+(1-p)/4$ From the fact that $V(w_1)=1/12$, we get $E(w_1^2)=1/3$, so $E(u_1 u_2) = p/12 + 1/4$, that is: $cov(u_1 u_2) = p/12$. Since $V(u_1)=V(u_2)=1/12$, we get finally that $cor(u_1, u_2) = p$.
Generate pairs of random numbers uniformly distributed and correlated
Intuitively, $u_1$ is $U(0,1)$ because $u_1$ equals $w_1$ [which is $U(0,1)$] if $I = 1$, and $u_1$ equals $w_2$ [which is $U(0,1)$] if $I = 0$, so $u_1$ is $U(0,1)$ in either case. The same for $u_2
Generate pairs of random numbers uniformly distributed and correlated Intuitively, $u_1$ is $U(0,1)$ because $u_1$ equals $w_1$ [which is $U(0,1)$] if $I = 1$, and $u_1$ equals $w_2$ [which is $U(0,1)$] if $I = 0$, so $u_1$ is $U(0,1)$ in either case. The same for $u_2$. As for the correlation: $E(u_1 u_2) = E[I w_1 + (1-I) w_2][I w_1 + (1-I) w_3]$ Expanding this, note first that $I(I-1)=0$, $I^2=I$, and $(1-I)^2=(1-I)$ because $I$ is always either $0$ or $1$. Note also that $I$ is independent of the $w$'s, which are also independent of each other. So: $E(u_1 u_2) = E(I)E(w_1^2) + E(1-I)E(w_2)E(w_3)$ $=pE(w_1^2)+(1-p)/4$ From the fact that $V(w_1)=1/12$, we get $E(w_1^2)=1/3$, so $E(u_1 u_2) = p/12 + 1/4$, that is: $cov(u_1 u_2) = p/12$. Since $V(u_1)=V(u_2)=1/12$, we get finally that $cor(u_1, u_2) = p$.
Generate pairs of random numbers uniformly distributed and correlated Intuitively, $u_1$ is $U(0,1)$ because $u_1$ equals $w_1$ [which is $U(0,1)$] if $I = 1$, and $u_1$ equals $w_2$ [which is $U(0,1)$] if $I = 0$, so $u_1$ is $U(0,1)$ in either case. The same for $u_2
12,650
Generate pairs of random numbers uniformly distributed and correlated
Here is one easy method for positive correlation: Let $(u_1, u_2) = Iw_1 + (1-I) (w_2, w_3)$, where $w_1, w_2,$ and $w_3$ are independent $U(0,1)$ and $I$ is Bernoulli($p$). $u_1$ and $u_2$ will then have $U(0,1)$ distributions with correlation $p$. This extends immediately to $k$-tuples of uniforms with compound symmetric variance matrix. If you want pairs with negative correlation, use $(u_1, u_2) = I(w_1, 1-w_1) + (1-I)(w_2, w_3)$, and the correlation will be $-p$.
Generate pairs of random numbers uniformly distributed and correlated
Here is one easy method for positive correlation: Let $(u_1, u_2) = Iw_1 + (1-I) (w_2, w_3)$, where $w_1, w_2,$ and $w_3$ are independent $U(0,1)$ and $I$ is Bernoulli($p$). $u_1$ and $u_2$ will the
Generate pairs of random numbers uniformly distributed and correlated Here is one easy method for positive correlation: Let $(u_1, u_2) = Iw_1 + (1-I) (w_2, w_3)$, where $w_1, w_2,$ and $w_3$ are independent $U(0,1)$ and $I$ is Bernoulli($p$). $u_1$ and $u_2$ will then have $U(0,1)$ distributions with correlation $p$. This extends immediately to $k$-tuples of uniforms with compound symmetric variance matrix. If you want pairs with negative correlation, use $(u_1, u_2) = I(w_1, 1-w_1) + (1-I)(w_2, w_3)$, and the correlation will be $-p$.
Generate pairs of random numbers uniformly distributed and correlated Here is one easy method for positive correlation: Let $(u_1, u_2) = Iw_1 + (1-I) (w_2, w_3)$, where $w_1, w_2,$ and $w_3$ are independent $U(0,1)$ and $I$ is Bernoulli($p$). $u_1$ and $u_2$ will the
12,651
Generate pairs of random numbers uniformly distributed and correlated
From brillant answer to this topic by @QuantIbex some time has passed. Perhaps a fairly new module / library in R will allow someone to get the above a little easier. You can read the detailed documentation of the possibilities that offers simstudy. A definite advantage of this library is that the solution is generalized, that is, it allows for the determination of many variables with a given correlation. # initiate variables samples = 1000 number_of_items = 4 # get library library(simstudy) # make vector of means=0 for all variables; note, that for every variable it can be different, this case is just for simplicity mu<-rep(0,number_of_items) # for normal distribution params1 is mean, params2 is the variance # (that is, the square of the standard deviation); For most simulation # studies, we are interested in the value 1 (variance and deviation, # for a value of 1 it is the same). The vector mu + 1 will give the # vector as many values of 1 for the standard deviation as we want. # so, code below generates distributions with a mean of 0 and # standard deviation of 1 df = genCorGen(samples, nvars = number_of_items, params1 = mu, params2 = (mu+1), dist = "normal", rho = .7, corstr = "cs", wide = TRUE) # for uniform distribution params1 is minimum, params2 is maximum df = genCorGen(samples, nvars = number_of_items, params1 = mu, params2 = (mu+1), dist = "uniform", rho = .7, corstr = "cs", wide = TRUE) # this function generates a slightly unfriendly object that we will # simply convert into a "nicer" class df = as.data.frame(df[,-1]) #one can check result with: plot(df) cor(df) > V1 V2 V3 V4 > V1 1.0000000 0.6896261 0.6916389 0.7098661 > V2 0.6896261 1.0000000 0.6858251 0.6965890 > V3 0.6916389 0.6858251 1.0000000 0.6755568 > V4 0.7098661 0.6965890 0.6755568 1.0000000 Of course, the library itself allows you to write better and shorter code, but I thought that a simple solution with a description might be useful to someone.
Generate pairs of random numbers uniformly distributed and correlated
From brillant answer to this topic by @QuantIbex some time has passed. Perhaps a fairly new module / library in R will allow someone to get the above a little easier. You can read the detailed documen
Generate pairs of random numbers uniformly distributed and correlated From brillant answer to this topic by @QuantIbex some time has passed. Perhaps a fairly new module / library in R will allow someone to get the above a little easier. You can read the detailed documentation of the possibilities that offers simstudy. A definite advantage of this library is that the solution is generalized, that is, it allows for the determination of many variables with a given correlation. # initiate variables samples = 1000 number_of_items = 4 # get library library(simstudy) # make vector of means=0 for all variables; note, that for every variable it can be different, this case is just for simplicity mu<-rep(0,number_of_items) # for normal distribution params1 is mean, params2 is the variance # (that is, the square of the standard deviation); For most simulation # studies, we are interested in the value 1 (variance and deviation, # for a value of 1 it is the same). The vector mu + 1 will give the # vector as many values of 1 for the standard deviation as we want. # so, code below generates distributions with a mean of 0 and # standard deviation of 1 df = genCorGen(samples, nvars = number_of_items, params1 = mu, params2 = (mu+1), dist = "normal", rho = .7, corstr = "cs", wide = TRUE) # for uniform distribution params1 is minimum, params2 is maximum df = genCorGen(samples, nvars = number_of_items, params1 = mu, params2 = (mu+1), dist = "uniform", rho = .7, corstr = "cs", wide = TRUE) # this function generates a slightly unfriendly object that we will # simply convert into a "nicer" class df = as.data.frame(df[,-1]) #one can check result with: plot(df) cor(df) > V1 V2 V3 V4 > V1 1.0000000 0.6896261 0.6916389 0.7098661 > V2 0.6896261 1.0000000 0.6858251 0.6965890 > V3 0.6916389 0.6858251 1.0000000 0.6755568 > V4 0.7098661 0.6965890 0.6755568 1.0000000 Of course, the library itself allows you to write better and shorter code, but I thought that a simple solution with a description might be useful to someone.
Generate pairs of random numbers uniformly distributed and correlated From brillant answer to this topic by @QuantIbex some time has passed. Perhaps a fairly new module / library in R will allow someone to get the above a little easier. You can read the detailed documen
12,652
Parameters without defined priors in Stan
From (an earlier version of) the Stan reference manual: Not specifying a prior is equivalent to specifying a uniform prior. A uniform prior is only proper if the parameter is bounded[...] Improper priors are also allowed in Stan programs; they arise from unconstrained parameters without sampling statements. In some cases, an improper prior may lead to a proper posterior, but it is up to the user to guarantee that constraints on the parameter(s) or the data ensure the propriety of the posterior. (See also section C.3 in the 1.0.1 version). The underlying reason this is okay in Stan but not in BUGS might have to do with the fact that in BUGS, your model "program" is specifying a formal graphical model, while in Stan you're writing a little function to calculate the joint probability density function. Not specifying a proper prior for all variables might screw up the nice formal properties of graphical models. However, for Hamiltonian MC you just need to (numerically) calculate the joint density function. A flat (even improper) prior only contributes a constant term to the density, and so as long as the posterior is proper (finite total probability mass)—which it will be with any reasonable likelihood function—it can be completely ignored in the HMC scheme.
Parameters without defined priors in Stan
From (an earlier version of) the Stan reference manual: Not specifying a prior is equivalent to specifying a uniform prior. A uniform prior is only proper if the parameter is bounded[...] Improper pr
Parameters without defined priors in Stan From (an earlier version of) the Stan reference manual: Not specifying a prior is equivalent to specifying a uniform prior. A uniform prior is only proper if the parameter is bounded[...] Improper priors are also allowed in Stan programs; they arise from unconstrained parameters without sampling statements. In some cases, an improper prior may lead to a proper posterior, but it is up to the user to guarantee that constraints on the parameter(s) or the data ensure the propriety of the posterior. (See also section C.3 in the 1.0.1 version). The underlying reason this is okay in Stan but not in BUGS might have to do with the fact that in BUGS, your model "program" is specifying a formal graphical model, while in Stan you're writing a little function to calculate the joint probability density function. Not specifying a proper prior for all variables might screw up the nice formal properties of graphical models. However, for Hamiltonian MC you just need to (numerically) calculate the joint density function. A flat (even improper) prior only contributes a constant term to the density, and so as long as the posterior is proper (finite total probability mass)—which it will be with any reasonable likelihood function—it can be completely ignored in the HMC scheme.
Parameters without defined priors in Stan From (an earlier version of) the Stan reference manual: Not specifying a prior is equivalent to specifying a uniform prior. A uniform prior is only proper if the parameter is bounded[...] Improper pr
12,653
Parameters without defined priors in Stan
From the Stan reference v1.0.2 (pg 6, footnote 1) If no prior were specified in the model block, the constraints on theta ensure it falls between 0 and 1, providing theta an implicit uniform prior. For parameters with no prior specified and unbounded support, the result is an improper prior. Stan accepts improper priors, but posteriors must be proper in order for sampling to succeed. Both mu and sigma have improper uniform priors. Under the hood, mu and sigma are treated differently. sigma is defined with a lower bound; Stan samples from log(sigma) (with a Jacobian adjustment for the transformation). For more details on transformations, see Chapter 27 (pg 153).
Parameters without defined priors in Stan
From the Stan reference v1.0.2 (pg 6, footnote 1) If no prior were specified in the model block, the constraints on theta ensure it falls between 0 and 1, providing theta an implicit uniform prior. F
Parameters without defined priors in Stan From the Stan reference v1.0.2 (pg 6, footnote 1) If no prior were specified in the model block, the constraints on theta ensure it falls between 0 and 1, providing theta an implicit uniform prior. For parameters with no prior specified and unbounded support, the result is an improper prior. Stan accepts improper priors, but posteriors must be proper in order for sampling to succeed. Both mu and sigma have improper uniform priors. Under the hood, mu and sigma are treated differently. sigma is defined with a lower bound; Stan samples from log(sigma) (with a Jacobian adjustment for the transformation). For more details on transformations, see Chapter 27 (pg 153).
Parameters without defined priors in Stan From the Stan reference v1.0.2 (pg 6, footnote 1) If no prior were specified in the model block, the constraints on theta ensure it falls between 0 and 1, providing theta an implicit uniform prior. F
12,654
How would you design a machine learning system to play Angry Birds?
Assuming you could get the right hooks into the software (or you work with your own mock-up), some things would be easy here, and some less so. This is quite a tough problem I think. As carlosdc mentioned, Reinforcement Learning (RL) is one possible avenue, although I'm not sure it's the right one. When you begin, you have to define what your state space, action space, transition dynamics, and reward function are. The state/action spaces can be continuous or discrete, and the transition dynamics could be given by the problem or modelled mathematically. Finally the reward function may be given a-priori, or may be sampled (with or without noise). The action space is simple: it's simply the direction and power that you shoot the current bird at. For the human, this is a discrete problem (the mouse/touchscreen is a digital input device) - let's say (for example) there are 32 possible directions and 10 possible powers, giving 320 possible actions. The reward function is also fairly easy to derive: the goal is to get rid of all of the pigs with the fewest number of birds (OK so there extra points for other things but let's ignore that for now). The best thing would be if we knew the actual function that generates points from killing pigs (depends on the size of pig etc IIRC) - but for a single level this could be modelled perfectly. The state space and transition dynamics are much more difficult. In order to model this correctly, we'd have to know the entire layout of the map and the physics of the game. The transition dynamics say "If I am in state x and I perform action y, I will land in state z". You can see the difficulty of this, firstly as the complex physics of the system mean that this will be extremely difficult to model accurately, and secondly as there are so many possible resultant states after even the first round (320), and this is if we assume there is no stochasticity in the physics engine, which from having played it I suspect there is. I think at this stage you would give up and go home. Another approach is to treat it like a human does at the very start - i.e. trial and error. The human, at least to begin with, fires virtually randomly (although with a fairly strong prior to send the birds towards the pigs, but this can easily be coded in), until a range of good actions are found. This is more like the multi-armed bandit setting. The "arms" of the bandits here are the possible actions. The algorithm tries to balance exploration and exploitation - i.e. exploring the action space and exploiting good actions when they're found. For this you don't need to know anything about the underlying dynamics - you only need to know about actions and rewards. To do it fully you would have to have an arm for each possible action over all the rounds (e.g. you have 5 birds * 320 action = 320^5 = approx 10^12 actions), so the action space is very large! However you could use some tricks to improve this if you know a little bit about the state space. For example, you could probably rule out actions that send the bird away from the pigs, down into the ground, or without enough power to reach any of them. Also you only need to reach the 5th bird if you haven't killed the pigs in the previous rounds, so a proportion of the action states aren't actually possible. This is somewhat reminiscent of the approach used in the algorithm MoGo, which is a computer programme for playing Go based on Upper Confidence bounds applied to Trees, one approach to solving the multi-armed bandit problem.
How would you design a machine learning system to play Angry Birds?
Assuming you could get the right hooks into the software (or you work with your own mock-up), some things would be easy here, and some less so. This is quite a tough problem I think. As carlosdc menti
How would you design a machine learning system to play Angry Birds? Assuming you could get the right hooks into the software (or you work with your own mock-up), some things would be easy here, and some less so. This is quite a tough problem I think. As carlosdc mentioned, Reinforcement Learning (RL) is one possible avenue, although I'm not sure it's the right one. When you begin, you have to define what your state space, action space, transition dynamics, and reward function are. The state/action spaces can be continuous or discrete, and the transition dynamics could be given by the problem or modelled mathematically. Finally the reward function may be given a-priori, or may be sampled (with or without noise). The action space is simple: it's simply the direction and power that you shoot the current bird at. For the human, this is a discrete problem (the mouse/touchscreen is a digital input device) - let's say (for example) there are 32 possible directions and 10 possible powers, giving 320 possible actions. The reward function is also fairly easy to derive: the goal is to get rid of all of the pigs with the fewest number of birds (OK so there extra points for other things but let's ignore that for now). The best thing would be if we knew the actual function that generates points from killing pigs (depends on the size of pig etc IIRC) - but for a single level this could be modelled perfectly. The state space and transition dynamics are much more difficult. In order to model this correctly, we'd have to know the entire layout of the map and the physics of the game. The transition dynamics say "If I am in state x and I perform action y, I will land in state z". You can see the difficulty of this, firstly as the complex physics of the system mean that this will be extremely difficult to model accurately, and secondly as there are so many possible resultant states after even the first round (320), and this is if we assume there is no stochasticity in the physics engine, which from having played it I suspect there is. I think at this stage you would give up and go home. Another approach is to treat it like a human does at the very start - i.e. trial and error. The human, at least to begin with, fires virtually randomly (although with a fairly strong prior to send the birds towards the pigs, but this can easily be coded in), until a range of good actions are found. This is more like the multi-armed bandit setting. The "arms" of the bandits here are the possible actions. The algorithm tries to balance exploration and exploitation - i.e. exploring the action space and exploiting good actions when they're found. For this you don't need to know anything about the underlying dynamics - you only need to know about actions and rewards. To do it fully you would have to have an arm for each possible action over all the rounds (e.g. you have 5 birds * 320 action = 320^5 = approx 10^12 actions), so the action space is very large! However you could use some tricks to improve this if you know a little bit about the state space. For example, you could probably rule out actions that send the bird away from the pigs, down into the ground, or without enough power to reach any of them. Also you only need to reach the 5th bird if you haven't killed the pigs in the previous rounds, so a proportion of the action states aren't actually possible. This is somewhat reminiscent of the approach used in the algorithm MoGo, which is a computer programme for playing Go based on Upper Confidence bounds applied to Trees, one approach to solving the multi-armed bandit problem.
How would you design a machine learning system to play Angry Birds? Assuming you could get the right hooks into the software (or you work with your own mock-up), some things would be easy here, and some less so. This is quite a tough problem I think. As carlosdc menti
12,655
How would you design a machine learning system to play Angry Birds?
Cool question! It seems like this question is about the natural technique for this type of problem. I think think the natural technique for this type of problem is reinforcement learning (RL). RL is about how an agent ought to take actions in an environment so as to maximize some notion of cumulative reward. Perhaps the best known algorithm for RL is Q-learning. I think this is the first question in this site about reinforcement learning. I think what you're asking is true if you try to approach this as classification/regression, but those do not seem like the right tool for this problem. This is naturally a RL problem where sequences of actions and outcomes need to be taken into account.
How would you design a machine learning system to play Angry Birds?
Cool question! It seems like this question is about the natural technique for this type of problem. I think think the natural technique for this type of problem is reinforcement learning (RL). RL is a
How would you design a machine learning system to play Angry Birds? Cool question! It seems like this question is about the natural technique for this type of problem. I think think the natural technique for this type of problem is reinforcement learning (RL). RL is about how an agent ought to take actions in an environment so as to maximize some notion of cumulative reward. Perhaps the best known algorithm for RL is Q-learning. I think this is the first question in this site about reinforcement learning. I think what you're asking is true if you try to approach this as classification/regression, but those do not seem like the right tool for this problem. This is naturally a RL problem where sequences of actions and outcomes need to be taken into account.
How would you design a machine learning system to play Angry Birds? Cool question! It seems like this question is about the natural technique for this type of problem. I think think the natural technique for this type of problem is reinforcement learning (RL). RL is a
12,656
How would you design a machine learning system to play Angry Birds?
Check here how others are doing it or participate yourself: Angry Birds AI Challenge http://ai2012.web.cse.unsw.edu.au/abc.html
How would you design a machine learning system to play Angry Birds?
Check here how others are doing it or participate yourself: Angry Birds AI Challenge http://ai2012.web.cse.unsw.edu.au/abc.html
How would you design a machine learning system to play Angry Birds? Check here how others are doing it or participate yourself: Angry Birds AI Challenge http://ai2012.web.cse.unsw.edu.au/abc.html
How would you design a machine learning system to play Angry Birds? Check here how others are doing it or participate yourself: Angry Birds AI Challenge http://ai2012.web.cse.unsw.edu.au/abc.html
12,657
How would you design a machine learning system to play Angry Birds?
just mentioned this over in meta. there was a pioneering use of genetic algorithms by Koza to solve the video game Pacman. he constructed algorithmic primitives that could sense and act. as I recall these were combined in Lisp-like trees to create larger algorithms. crossover with Lisp trees involves substituting or exchanging subtrees that represent the algorithm expressions. the success function is something like "dots eaten" or "dots plus ghosts eaten" or "time stayed alive". there is still some work in this area. there is a koza ref in this paper following. training time may be very long and "convergence" very gradual for these types of problems. Learning to Play Pac-Man: An Evolutionary, Rule-based Approach by Gallagher and Ryan
How would you design a machine learning system to play Angry Birds?
just mentioned this over in meta. there was a pioneering use of genetic algorithms by Koza to solve the video game Pacman. he constructed algorithmic primitives that could sense and act. as I recall t
How would you design a machine learning system to play Angry Birds? just mentioned this over in meta. there was a pioneering use of genetic algorithms by Koza to solve the video game Pacman. he constructed algorithmic primitives that could sense and act. as I recall these were combined in Lisp-like trees to create larger algorithms. crossover with Lisp trees involves substituting or exchanging subtrees that represent the algorithm expressions. the success function is something like "dots eaten" or "dots plus ghosts eaten" or "time stayed alive". there is still some work in this area. there is a koza ref in this paper following. training time may be very long and "convergence" very gradual for these types of problems. Learning to Play Pac-Man: An Evolutionary, Rule-based Approach by Gallagher and Ryan
How would you design a machine learning system to play Angry Birds? just mentioned this over in meta. there was a pioneering use of genetic algorithms by Koza to solve the video game Pacman. he constructed algorithmic primitives that could sense and act. as I recall t
12,658
What does "vanilla" mean?
Vanilla means standard, usual, or unmodified version of something. Vanilla gradient descent means the basic gradient descent algorithm without any bells or whistles. There are many variants on gradient descent. In usual gradient descent (also known as batch gradient descent or vanilla gradient descent), the gradient is computed as the average of the gradient of each datapoint. $$\nabla f = \frac{1}{n}\sum_i \nabla \text{loss}(x_i)$$ In stochastic gradient descent with a batch size of one, we might estimate the gradient as $$\nabla f \approx \nabla \text{loss}(x^*)$$, where $x^*$ is randomly sampled from our entire dataset. It is a variant of normal gradient descent, so it wouldn't be vanilla gradient descent. However, since even stochastic gradient descent has many variants, you might call this "vanilla stochastic gradient descent", when comparing it to other fancier SGD alternatives, for example, SGD with momentum.
What does "vanilla" mean?
Vanilla means standard, usual, or unmodified version of something. Vanilla gradient descent means the basic gradient descent algorithm without any bells or whistles. There are many variants on gradie
What does "vanilla" mean? Vanilla means standard, usual, or unmodified version of something. Vanilla gradient descent means the basic gradient descent algorithm without any bells or whistles. There are many variants on gradient descent. In usual gradient descent (also known as batch gradient descent or vanilla gradient descent), the gradient is computed as the average of the gradient of each datapoint. $$\nabla f = \frac{1}{n}\sum_i \nabla \text{loss}(x_i)$$ In stochastic gradient descent with a batch size of one, we might estimate the gradient as $$\nabla f \approx \nabla \text{loss}(x^*)$$, where $x^*$ is randomly sampled from our entire dataset. It is a variant of normal gradient descent, so it wouldn't be vanilla gradient descent. However, since even stochastic gradient descent has many variants, you might call this "vanilla stochastic gradient descent", when comparing it to other fancier SGD alternatives, for example, SGD with momentum.
What does "vanilla" mean? Vanilla means standard, usual, or unmodified version of something. Vanilla gradient descent means the basic gradient descent algorithm without any bells or whistles. There are many variants on gradie
12,659
Why is skewed data not preferred for modelling?
When removing skewness, transformations are attempting to make the dataset follow the Gaussian distribution. The reason is simply that if the dataset can be transformed to be statistically close enough to a Gaussian dataset, then the largest set of tools possible are available to them to use. Tests such as the ANOVA, $t$-test, $F$-test, and many others depend on the data having constant variance ($\sigma^2$) or follow a Gaussian distribution.1 There are models that are more robust1 (such as using Levine's test instead of Bartlett's test), but most tests and models which work well with other distributions require that you know what distribution you are working with and are typically only appropriate for a single distribution as well. To quote the NIST Engineering Statistics Handbook: In regression modeling, we often apply transformations to achieve the following two goals: to satisfy the homogeneity of variances assumption for the errors. to linearize the fit as much as possible. Some care and judgment is required in that these two goals can conflict. We generally try to achieve homogeneous variances first and then address the issue of trying to linearize the fit. and in another location A model involving a response variable and a single independent variable has the form: $$Y_i=f\left(X_i\right)+E_i$$ where $Y$ is the response variable, $X$ is the independent variable, $f$ is the linear or non-linear fit function, and $E$ is the random component. For a good model, the error component should behave like: random drawings (i.e., independent); from a fixed distribution; with fixed location; and with fixed variation. In addition, for fitting models it is usually further assumed that the fixed distribution is normal and the fixed location is zero. For a good model the fixed variation should be as small as possible. A necessary component of fitting models is to verify these assumptions for the error component and to assess whether the variation for the error component is sufficiently small. The histogram, lag plot, and normal probability plot are used to verify the fixed distribution, location, and variation assumptions on the error component. The plot of the response variable and the predicted values versus the independent variable is used to assess whether the variation is sufficiently small. The plots of the residuals versus the independent variable and the predicted values is used to assess the independence assumption. Assessing the validity and quality of the fit in terms of the above assumptions is an absolutely vital part of the model-fitting process. No fit should be considered complete without an adequate model validation step. (abbreviated) citations for claims: Breyfogle III, Forrest W. Implementing Six Sigma Pyzdek, Thomas. The Six Sigma Handbook Montgomery, Douglas C. Introduction to Statistical Quality Control Ed. Cubberly, Willaim H and Bakerjan, Ramon. Tool and Manufacturing Engineers Handbook: Desktop Edition
Why is skewed data not preferred for modelling?
When removing skewness, transformations are attempting to make the dataset follow the Gaussian distribution. The reason is simply that if the dataset can be transformed to be statistically close enou
Why is skewed data not preferred for modelling? When removing skewness, transformations are attempting to make the dataset follow the Gaussian distribution. The reason is simply that if the dataset can be transformed to be statistically close enough to a Gaussian dataset, then the largest set of tools possible are available to them to use. Tests such as the ANOVA, $t$-test, $F$-test, and many others depend on the data having constant variance ($\sigma^2$) or follow a Gaussian distribution.1 There are models that are more robust1 (such as using Levine's test instead of Bartlett's test), but most tests and models which work well with other distributions require that you know what distribution you are working with and are typically only appropriate for a single distribution as well. To quote the NIST Engineering Statistics Handbook: In regression modeling, we often apply transformations to achieve the following two goals: to satisfy the homogeneity of variances assumption for the errors. to linearize the fit as much as possible. Some care and judgment is required in that these two goals can conflict. We generally try to achieve homogeneous variances first and then address the issue of trying to linearize the fit. and in another location A model involving a response variable and a single independent variable has the form: $$Y_i=f\left(X_i\right)+E_i$$ where $Y$ is the response variable, $X$ is the independent variable, $f$ is the linear or non-linear fit function, and $E$ is the random component. For a good model, the error component should behave like: random drawings (i.e., independent); from a fixed distribution; with fixed location; and with fixed variation. In addition, for fitting models it is usually further assumed that the fixed distribution is normal and the fixed location is zero. For a good model the fixed variation should be as small as possible. A necessary component of fitting models is to verify these assumptions for the error component and to assess whether the variation for the error component is sufficiently small. The histogram, lag plot, and normal probability plot are used to verify the fixed distribution, location, and variation assumptions on the error component. The plot of the response variable and the predicted values versus the independent variable is used to assess whether the variation is sufficiently small. The plots of the residuals versus the independent variable and the predicted values is used to assess the independence assumption. Assessing the validity and quality of the fit in terms of the above assumptions is an absolutely vital part of the model-fitting process. No fit should be considered complete without an adequate model validation step. (abbreviated) citations for claims: Breyfogle III, Forrest W. Implementing Six Sigma Pyzdek, Thomas. The Six Sigma Handbook Montgomery, Douglas C. Introduction to Statistical Quality Control Ed. Cubberly, Willaim H and Bakerjan, Ramon. Tool and Manufacturing Engineers Handbook: Desktop Edition
Why is skewed data not preferred for modelling? When removing skewness, transformations are attempting to make the dataset follow the Gaussian distribution. The reason is simply that if the dataset can be transformed to be statistically close enou
12,660
Why is skewed data not preferred for modelling?
This is mostly true for parametric models. As Tavrock said, having a response variable that's not skewed makes Gaussian approximation of parameter estimation work better, this because symmetric distribution converge much faster than skewed ones to Gaussian. This means that, if you have skewed data, transforming it will make smaller dataset least for using appropriately confidence intervals and tests on parameters (prediction intervals still won't be valid, because even if your data is now symmetric, you couldn't say it's normal, only parameters estimations will converge to Gaussian). This whole speech is about conditioned distribution of response variable, you could say: about errors. Nonetheless if you have a variable that seems skewed when you look at his unconditioned distribution, that could likely mean that it has a skewed conditioned distribution. fitting a model on your data will clear your mind on it. In decision trees I'll first point one thing: there's no point on transforming skewed explanatory variables, monotonic functions won't change a thing; this can be useful on linear models, but's not on decision trees. This said, CART models use analysis of variance to perform spits, and variance is very sensible to outliers and skewed data, this is the reason why transforming your response variable can considerably improve your model accuracy.
Why is skewed data not preferred for modelling?
This is mostly true for parametric models. As Tavrock said, having a response variable that's not skewed makes Gaussian approximation of parameter estimation work better, this because symmetric distri
Why is skewed data not preferred for modelling? This is mostly true for parametric models. As Tavrock said, having a response variable that's not skewed makes Gaussian approximation of parameter estimation work better, this because symmetric distribution converge much faster than skewed ones to Gaussian. This means that, if you have skewed data, transforming it will make smaller dataset least for using appropriately confidence intervals and tests on parameters (prediction intervals still won't be valid, because even if your data is now symmetric, you couldn't say it's normal, only parameters estimations will converge to Gaussian). This whole speech is about conditioned distribution of response variable, you could say: about errors. Nonetheless if you have a variable that seems skewed when you look at his unconditioned distribution, that could likely mean that it has a skewed conditioned distribution. fitting a model on your data will clear your mind on it. In decision trees I'll first point one thing: there's no point on transforming skewed explanatory variables, monotonic functions won't change a thing; this can be useful on linear models, but's not on decision trees. This said, CART models use analysis of variance to perform spits, and variance is very sensible to outliers and skewed data, this is the reason why transforming your response variable can considerably improve your model accuracy.
Why is skewed data not preferred for modelling? This is mostly true for parametric models. As Tavrock said, having a response variable that's not skewed makes Gaussian approximation of parameter estimation work better, this because symmetric distri
12,661
Why is skewed data not preferred for modelling?
When is skewness a bad thing to have? Symmetric distributions (generally but not always: e.g., not for the Cauchy distribution) have median, mode and mean very close to each other. So consider, if we want to measure the location of a population, it is useful to have the median, mode and mean close to each other. For example, if we take the logarithm of the distribution of income, we reduce the skewness enough that we can get useful models of location of income. However, we will still have a heavier right tail than we really want. To reduce that further, we might use a Pareto distribution. The Pareto distribution is similar to a log-log transformation of the data. Now both the Pareto and log-normal distributions have difficulty on the low end of the income scale. For example, both suffer from $\ln 0=-\infty$. The treatment of this problem is covered in power transforms. Example from 25 incomes in kilo dollars purloined from the www. k$ lnk$ 28 3.33220451 29 3.36729583 35 3.555348061 42 3.737669618 42 3.737669618 44 3.784189634 50 3.912023005 52 3.951243719 54 3.988984047 56 4.025351691 59 4.077537444 78 4.356708827 84 4.430816799 90 4.49980967 95 4.553876892 101 4.615120517 108 4.682131227 116 4.753590191 121 4.795790546 122 4.804021045 133 4.890349128 150 5.010635294 158 5.062595033 167 5.117993812 235 5.459585514 The skewness of the first column is 0.99, and of the second is -0.05. The first column is not likely normal (Shapiro-Wilk p=0.04) and the second not significantly not normal (p=0.57). First column Mean 90.0 (95% CI, 68.6 to 111.3) Median 84.0 (95.7% CI, 52.0 to 116.0) Second col Exp(Mean) 76.7 (95% CI, 60.2 to 97.7) Exp(Median) 84.0 (95.7% CI, 52.0 to 116.0) So, the question is, if you are a random person having one of the earnings listed, what are you likely to earn? Is it reasonable to conclude that you would earn 90k or more than the median of 84k? Or is it more likely to conclude that even the median is biased as a measure of location and that the $\exp[\text{mean}\ln(k\$)]\text{ }$ of 76.7 k, which is less than the median, is also more reasonable as an estimate? Obviously, the log-normal here is a better model and the mean logarithm gives us a better measure of location. That this is well known, if not entirely understood, is illustrated by the phrase "I anticipate getting a 5-figure salary."
Why is skewed data not preferred for modelling?
When is skewness a bad thing to have? Symmetric distributions (generally but not always: e.g., not for the Cauchy distribution) have median, mode and mean very close to each other. So consider, if we
Why is skewed data not preferred for modelling? When is skewness a bad thing to have? Symmetric distributions (generally but not always: e.g., not for the Cauchy distribution) have median, mode and mean very close to each other. So consider, if we want to measure the location of a population, it is useful to have the median, mode and mean close to each other. For example, if we take the logarithm of the distribution of income, we reduce the skewness enough that we can get useful models of location of income. However, we will still have a heavier right tail than we really want. To reduce that further, we might use a Pareto distribution. The Pareto distribution is similar to a log-log transformation of the data. Now both the Pareto and log-normal distributions have difficulty on the low end of the income scale. For example, both suffer from $\ln 0=-\infty$. The treatment of this problem is covered in power transforms. Example from 25 incomes in kilo dollars purloined from the www. k$ lnk$ 28 3.33220451 29 3.36729583 35 3.555348061 42 3.737669618 42 3.737669618 44 3.784189634 50 3.912023005 52 3.951243719 54 3.988984047 56 4.025351691 59 4.077537444 78 4.356708827 84 4.430816799 90 4.49980967 95 4.553876892 101 4.615120517 108 4.682131227 116 4.753590191 121 4.795790546 122 4.804021045 133 4.890349128 150 5.010635294 158 5.062595033 167 5.117993812 235 5.459585514 The skewness of the first column is 0.99, and of the second is -0.05. The first column is not likely normal (Shapiro-Wilk p=0.04) and the second not significantly not normal (p=0.57). First column Mean 90.0 (95% CI, 68.6 to 111.3) Median 84.0 (95.7% CI, 52.0 to 116.0) Second col Exp(Mean) 76.7 (95% CI, 60.2 to 97.7) Exp(Median) 84.0 (95.7% CI, 52.0 to 116.0) So, the question is, if you are a random person having one of the earnings listed, what are you likely to earn? Is it reasonable to conclude that you would earn 90k or more than the median of 84k? Or is it more likely to conclude that even the median is biased as a measure of location and that the $\exp[\text{mean}\ln(k\$)]\text{ }$ of 76.7 k, which is less than the median, is also more reasonable as an estimate? Obviously, the log-normal here is a better model and the mean logarithm gives us a better measure of location. That this is well known, if not entirely understood, is illustrated by the phrase "I anticipate getting a 5-figure salary."
Why is skewed data not preferred for modelling? When is skewness a bad thing to have? Symmetric distributions (generally but not always: e.g., not for the Cauchy distribution) have median, mode and mean very close to each other. So consider, if we
12,662
Why is skewed data not preferred for modelling?
I believe this is very much an artifact of the tradition to revert to Gaussians due to their nice properties. But there are nice distributional alternatives, e. g. the generalized gamma that encompasses a host of different skewed distributional shapes and forms
Why is skewed data not preferred for modelling?
I believe this is very much an artifact of the tradition to revert to Gaussians due to their nice properties. But there are nice distributional alternatives, e. g. the generalized gamma that encompas
Why is skewed data not preferred for modelling? I believe this is very much an artifact of the tradition to revert to Gaussians due to their nice properties. But there are nice distributional alternatives, e. g. the generalized gamma that encompasses a host of different skewed distributional shapes and forms
Why is skewed data not preferred for modelling? I believe this is very much an artifact of the tradition to revert to Gaussians due to their nice properties. But there are nice distributional alternatives, e. g. the generalized gamma that encompas
12,663
Why is skewed data not preferred for modelling?
I think that it's not just modeling but our brains are not used to work with highly skewed data. For instance, it's well known in behavioral finance that we're not good at estimating the very low or high probabilities.
Why is skewed data not preferred for modelling?
I think that it's not just modeling but our brains are not used to work with highly skewed data. For instance, it's well known in behavioral finance that we're not good at estimating the very low or h
Why is skewed data not preferred for modelling? I think that it's not just modeling but our brains are not used to work with highly skewed data. For instance, it's well known in behavioral finance that we're not good at estimating the very low or high probabilities.
Why is skewed data not preferred for modelling? I think that it's not just modeling but our brains are not used to work with highly skewed data. For instance, it's well known in behavioral finance that we're not good at estimating the very low or h
12,664
Why is skewed data not preferred for modelling?
Like other readers have said, some more background on what you are planning to achieve with your data would be helpful. That being said, there are two important doctrines in the realm of statistics known as the central limit theorem and the law of large numbers. That is to say, that the more observations one has, the more a dataset is expected to approximate a normal distribution, one with an equal mean, median and mode. Under the law of large numbers, it is expected that the deviation between the expected and the actual value will eventually drop to zero given sufficient observations. Therefore, a normal distribution allows the researcher to make more accurate predictions about a population if the underlying distribution is known. Skewness is when a distribution deviates from this, i.e. a deviation could be positively or negatively skewed. However, the central limit theorem argues that given a large enough set of observations, the result will be an approximately normal distribution. So, if the distribution is not normal, it is always recommended to gather more data first before attempting to change the underlying structure of the distribution via the transformation procedures you mentioned.
Why is skewed data not preferred for modelling?
Like other readers have said, some more background on what you are planning to achieve with your data would be helpful. That being said, there are two important doctrines in the realm of statistics kn
Why is skewed data not preferred for modelling? Like other readers have said, some more background on what you are planning to achieve with your data would be helpful. That being said, there are two important doctrines in the realm of statistics known as the central limit theorem and the law of large numbers. That is to say, that the more observations one has, the more a dataset is expected to approximate a normal distribution, one with an equal mean, median and mode. Under the law of large numbers, it is expected that the deviation between the expected and the actual value will eventually drop to zero given sufficient observations. Therefore, a normal distribution allows the researcher to make more accurate predictions about a population if the underlying distribution is known. Skewness is when a distribution deviates from this, i.e. a deviation could be positively or negatively skewed. However, the central limit theorem argues that given a large enough set of observations, the result will be an approximately normal distribution. So, if the distribution is not normal, it is always recommended to gather more data first before attempting to change the underlying structure of the distribution via the transformation procedures you mentioned.
Why is skewed data not preferred for modelling? Like other readers have said, some more background on what you are planning to achieve with your data would be helpful. That being said, there are two important doctrines in the realm of statistics kn
12,665
Why is skewed data not preferred for modelling?
Mostly of the results are based on Gaussian assumptions. If you have a skewed distribution, you don't have a Gaussian distribution, so maybe you should try desperately to turn it into that. BUT of course, you can try with GLM.
Why is skewed data not preferred for modelling?
Mostly of the results are based on Gaussian assumptions. If you have a skewed distribution, you don't have a Gaussian distribution, so maybe you should try desperately to turn it into that. BUT of cou
Why is skewed data not preferred for modelling? Mostly of the results are based on Gaussian assumptions. If you have a skewed distribution, you don't have a Gaussian distribution, so maybe you should try desperately to turn it into that. BUT of course, you can try with GLM.
Why is skewed data not preferred for modelling? Mostly of the results are based on Gaussian assumptions. If you have a skewed distribution, you don't have a Gaussian distribution, so maybe you should try desperately to turn it into that. BUT of cou
12,666
Nystroem Method for Kernel Approximation
Let's derive the Nyström approximation in a way that should make the answers to your questions clearer. The key assumption in Nyström is that the kernel function is of rank $m$. (Really we assume that it's approximately of rank $m$, but for simplicity let's just pretend it's exactly rank $m$ for now.) That means that any kernel matrix is going to have rank at most $m$, and in particular $$ K = \begin{bmatrix} k(x_1, x_1) & \dots & k(x_1, x_n) \\ \vdots & \ddots & \vdots \\ k(x_n, x_1) & \dots & k(x_n, x_n) \end{bmatrix} ,$$ is rank $m$. Therefore there are $m$ nonzero eigenvalues, and we can write the eigendecomposition of $K$ as $$K = U \Lambda U^T$$ with eigenvectors stored in $U$, of shape $n \times m$, and eigenvalues arranged in $\Lambda$, an $m \times m$ diagonal matrix. So, let's pick $m$ elements, usually uniformly at random but possibly according to other schemes – all that matters in this simplified version is that $K_{11}$ be of full rank. Once we do, just relabel the points so that we end up with the kernel matrix in blocks: $$ K = \begin{bmatrix} K_{11} & K_{21}^T \\ K_{21} & K_{22} \end{bmatrix} ,$$ where we evaluate each entry in $K_{11}$ (which is $m \times m$) and $K_{21}$ ($(n-m) \times m$), but don't want to evaluate any entries in $K_{22}$. Now, we can split up the eigendecomposition according to this block structure too: \begin{align} K &= U \Lambda U^T \\&= \begin{bmatrix}U_1 \\ U_2\end{bmatrix} \Lambda \begin{bmatrix}U_1 \\ U_2\end{bmatrix}^T \\&= \begin{bmatrix} U_1 \Lambda U_1^T & U_1 \Lambda U_2^T \\ U_2 \Lambda U_1^T & U_2 \Lambda U_2^T \end{bmatrix} ,\end{align} where $U_1$ is $m \times m$ and $U_2$ is $(n-m) \times m$. But note that now we have $K_{11} = U_1 \Lambda U_1^T$. So we can find $U_1$ and $\Lambda$ by eigendecomposing the known matrix $K_{11}$. We also know that $K_{21} = U_2 \Lambda U_1^T$. Here, we know everything in this equation except $U_2$, so we can solve for what eigenvalues that implies: right-multiply both sides by $(\Lambda U_1^T)^{-1} = U_1 \Lambda^{-1}$ to get $$ U_2 = K_{21} U_1 \Lambda^{-1} .$$ Now we have everything we need to evaluate $K_{22}$: \begin{align} K_{22} &= U_2 \Lambda U_2^T \\&= \left(K_{21} U_1 \Lambda^{-1}\right) \Lambda \left(K_{21} U_1 \Lambda^{-1}\right)^T \\&= K_{21} U_1 (\Lambda^{-1} \Lambda) \Lambda^{-1} U_1^T K_{21}^T \\&= K_{21} U_1 \Lambda^{-1} U_1^T K_{21}^T \\&= K_{21} K_{11}^{-1} K_{21}^T \tag{*} \\&= \left( K_{21} K_{11}^{-\frac12} \right) \left( K_{21} K_{11}^{-\frac12} \right)^T \tag{**} .\end{align} In (*), we've found a version of the Nyström embedding you might have seen simply as the definition. This tells us the effective kernel values that we're imputing for the block $K_{22}$. In (**), we see that the feature matrix $K_{21} K_{11}^{-\frac12}$, which is shape $(n-m) \times m$, corresponds to these imputed kernel values. If we use $K_{11}^{\frac12}$ for the $m$ points, we have a set of $m$-dimensional features $$ \Phi = \begin{bmatrix} K_{11}^{\frac12} \\ K_{21} K_{11}^{-\frac12} \end{bmatrix} .$$ We can just quickly verify that $\Phi$ corresponds to the correct kernel matrix: \begin{align} \Phi \Phi^T &= \begin{bmatrix} K_{11}^{\frac12} \\ K_{21} K_{11}^{-\frac12} \end{bmatrix} \begin{bmatrix} K_{11}^{\frac12} \\ K_{21} K_{11}^{-\frac12} \end{bmatrix}^T \\&=\begin{bmatrix} K_{11}^{\frac12} K_{11}^{\frac12} & K_{11}^{\frac12} K_{11}^{-\frac12} K_{21}^T \\ K_{21} K_{11}^{-\frac12} K_{11}^{\frac12} & K_{21} K_{11}^{-\frac12} K_{11}^{-\frac12} K_{21}^T \end{bmatrix} \\&=\begin{bmatrix} K_{11} & K_{21}^T \\ K_{21} & K_{21} K_{11}^{-1} K_{21}^T \end{bmatrix} \\&= K .\end{align} So, all we need to do is train our regular learning model with the $m$-dimensional features $\Phi$. This will be exactly the same (under the assumptions we've made) as the kernelized version of the learning problem with $K$. Now, for an individual data point $x$, the features in $\Phi$ correspond to $$ \phi(x) = \begin{bmatrix} k(x, x_1) & \dots & k(x, x_m) \end{bmatrix} K_{11}^{-\frac12} .$$ For a point $x$ in partition 2, the vector $\begin{bmatrix} k(x, x_1) & \dots & k(x, x_m) \end{bmatrix}$ is just the relevant row of $K_{21}$, so that stacking these up gives us $K_{21} K_{11}^{-\frac12}$ – so $\phi(x)$ agrees for points in partition 2. It also works in partition 1: there, the vector is a row of $K_{11}$, so stacking them up gets $K_{11} K_{11}^{-\frac12} = K_{11}^{\frac12}$, again agreeing with $\Phi$. So...it's still true for an unseen-at-training-time test point $x_\text{new}$. You just do the same thing: $$ \Phi_\text{test} = K_{\text{test},1} K_{11}^{-\frac12} .$$ Because we assumed the kernel is rank $m$, the matrix $\begin{bmatrix}K_{\text{train}} & K_{\text{train,test}} \\ K_{\text{test,train}} & K_{\text{test}} \end{bmatrix}$ is also of rank $m$, and the reconstruction of $K_\text{test}$ is still exact by exactly the same logic as for $K_{22}$. Above, we assumed that the kernel matrix $K$ was exactly rank $m$. This is not usually going to be the case; for a Gaussian kernel, for example, $K$ is always rank $n$, but the latter eigenvalues typically drop off pretty quickly, so it's going to be close to a matrix of rank $m$, and our reconstructions of $K_{21}$ or $K_{\text{test},1}$ are going to be close to the true values but not exactly the same. They'll be better reconstructions the closer the eigenspace of $K_{11}$ gets to that of $K$ overall, which is why choosing the right $m$ points is important in practice. Note also that if $K_{11}$ has any zero eigenvalues, you can replace inverses with pseudoinverses and everything still works; you just replace $K_{21}$ in the reconstruction with $K_{21} K_{11}^\dagger K_{11}$. You can use the SVD instead of the eigendecomposition if you'd like; since $K$ is psd, they're the same thing, but the SVD might be a little more robust to slight numerical error in the kernel matrix and such, so that's what scikit-learn does. scikit-learn's actual implementation does this, though it uses $\max(\lambda_i, 10^{-12})$ in the inverse instead of the pseudoinverse.
Nystroem Method for Kernel Approximation
Let's derive the Nyström approximation in a way that should make the answers to your questions clearer. The key assumption in Nyström is that the kernel function is of rank $m$. (Really we assume that
Nystroem Method for Kernel Approximation Let's derive the Nyström approximation in a way that should make the answers to your questions clearer. The key assumption in Nyström is that the kernel function is of rank $m$. (Really we assume that it's approximately of rank $m$, but for simplicity let's just pretend it's exactly rank $m$ for now.) That means that any kernel matrix is going to have rank at most $m$, and in particular $$ K = \begin{bmatrix} k(x_1, x_1) & \dots & k(x_1, x_n) \\ \vdots & \ddots & \vdots \\ k(x_n, x_1) & \dots & k(x_n, x_n) \end{bmatrix} ,$$ is rank $m$. Therefore there are $m$ nonzero eigenvalues, and we can write the eigendecomposition of $K$ as $$K = U \Lambda U^T$$ with eigenvectors stored in $U$, of shape $n \times m$, and eigenvalues arranged in $\Lambda$, an $m \times m$ diagonal matrix. So, let's pick $m$ elements, usually uniformly at random but possibly according to other schemes – all that matters in this simplified version is that $K_{11}$ be of full rank. Once we do, just relabel the points so that we end up with the kernel matrix in blocks: $$ K = \begin{bmatrix} K_{11} & K_{21}^T \\ K_{21} & K_{22} \end{bmatrix} ,$$ where we evaluate each entry in $K_{11}$ (which is $m \times m$) and $K_{21}$ ($(n-m) \times m$), but don't want to evaluate any entries in $K_{22}$. Now, we can split up the eigendecomposition according to this block structure too: \begin{align} K &= U \Lambda U^T \\&= \begin{bmatrix}U_1 \\ U_2\end{bmatrix} \Lambda \begin{bmatrix}U_1 \\ U_2\end{bmatrix}^T \\&= \begin{bmatrix} U_1 \Lambda U_1^T & U_1 \Lambda U_2^T \\ U_2 \Lambda U_1^T & U_2 \Lambda U_2^T \end{bmatrix} ,\end{align} where $U_1$ is $m \times m$ and $U_2$ is $(n-m) \times m$. But note that now we have $K_{11} = U_1 \Lambda U_1^T$. So we can find $U_1$ and $\Lambda$ by eigendecomposing the known matrix $K_{11}$. We also know that $K_{21} = U_2 \Lambda U_1^T$. Here, we know everything in this equation except $U_2$, so we can solve for what eigenvalues that implies: right-multiply both sides by $(\Lambda U_1^T)^{-1} = U_1 \Lambda^{-1}$ to get $$ U_2 = K_{21} U_1 \Lambda^{-1} .$$ Now we have everything we need to evaluate $K_{22}$: \begin{align} K_{22} &= U_2 \Lambda U_2^T \\&= \left(K_{21} U_1 \Lambda^{-1}\right) \Lambda \left(K_{21} U_1 \Lambda^{-1}\right)^T \\&= K_{21} U_1 (\Lambda^{-1} \Lambda) \Lambda^{-1} U_1^T K_{21}^T \\&= K_{21} U_1 \Lambda^{-1} U_1^T K_{21}^T \\&= K_{21} K_{11}^{-1} K_{21}^T \tag{*} \\&= \left( K_{21} K_{11}^{-\frac12} \right) \left( K_{21} K_{11}^{-\frac12} \right)^T \tag{**} .\end{align} In (*), we've found a version of the Nyström embedding you might have seen simply as the definition. This tells us the effective kernel values that we're imputing for the block $K_{22}$. In (**), we see that the feature matrix $K_{21} K_{11}^{-\frac12}$, which is shape $(n-m) \times m$, corresponds to these imputed kernel values. If we use $K_{11}^{\frac12}$ for the $m$ points, we have a set of $m$-dimensional features $$ \Phi = \begin{bmatrix} K_{11}^{\frac12} \\ K_{21} K_{11}^{-\frac12} \end{bmatrix} .$$ We can just quickly verify that $\Phi$ corresponds to the correct kernel matrix: \begin{align} \Phi \Phi^T &= \begin{bmatrix} K_{11}^{\frac12} \\ K_{21} K_{11}^{-\frac12} \end{bmatrix} \begin{bmatrix} K_{11}^{\frac12} \\ K_{21} K_{11}^{-\frac12} \end{bmatrix}^T \\&=\begin{bmatrix} K_{11}^{\frac12} K_{11}^{\frac12} & K_{11}^{\frac12} K_{11}^{-\frac12} K_{21}^T \\ K_{21} K_{11}^{-\frac12} K_{11}^{\frac12} & K_{21} K_{11}^{-\frac12} K_{11}^{-\frac12} K_{21}^T \end{bmatrix} \\&=\begin{bmatrix} K_{11} & K_{21}^T \\ K_{21} & K_{21} K_{11}^{-1} K_{21}^T \end{bmatrix} \\&= K .\end{align} So, all we need to do is train our regular learning model with the $m$-dimensional features $\Phi$. This will be exactly the same (under the assumptions we've made) as the kernelized version of the learning problem with $K$. Now, for an individual data point $x$, the features in $\Phi$ correspond to $$ \phi(x) = \begin{bmatrix} k(x, x_1) & \dots & k(x, x_m) \end{bmatrix} K_{11}^{-\frac12} .$$ For a point $x$ in partition 2, the vector $\begin{bmatrix} k(x, x_1) & \dots & k(x, x_m) \end{bmatrix}$ is just the relevant row of $K_{21}$, so that stacking these up gives us $K_{21} K_{11}^{-\frac12}$ – so $\phi(x)$ agrees for points in partition 2. It also works in partition 1: there, the vector is a row of $K_{11}$, so stacking them up gets $K_{11} K_{11}^{-\frac12} = K_{11}^{\frac12}$, again agreeing with $\Phi$. So...it's still true for an unseen-at-training-time test point $x_\text{new}$. You just do the same thing: $$ \Phi_\text{test} = K_{\text{test},1} K_{11}^{-\frac12} .$$ Because we assumed the kernel is rank $m$, the matrix $\begin{bmatrix}K_{\text{train}} & K_{\text{train,test}} \\ K_{\text{test,train}} & K_{\text{test}} \end{bmatrix}$ is also of rank $m$, and the reconstruction of $K_\text{test}$ is still exact by exactly the same logic as for $K_{22}$. Above, we assumed that the kernel matrix $K$ was exactly rank $m$. This is not usually going to be the case; for a Gaussian kernel, for example, $K$ is always rank $n$, but the latter eigenvalues typically drop off pretty quickly, so it's going to be close to a matrix of rank $m$, and our reconstructions of $K_{21}$ or $K_{\text{test},1}$ are going to be close to the true values but not exactly the same. They'll be better reconstructions the closer the eigenspace of $K_{11}$ gets to that of $K$ overall, which is why choosing the right $m$ points is important in practice. Note also that if $K_{11}$ has any zero eigenvalues, you can replace inverses with pseudoinverses and everything still works; you just replace $K_{21}$ in the reconstruction with $K_{21} K_{11}^\dagger K_{11}$. You can use the SVD instead of the eigendecomposition if you'd like; since $K$ is psd, they're the same thing, but the SVD might be a little more robust to slight numerical error in the kernel matrix and such, so that's what scikit-learn does. scikit-learn's actual implementation does this, though it uses $\max(\lambda_i, 10^{-12})$ in the inverse instead of the pseudoinverse.
Nystroem Method for Kernel Approximation Let's derive the Nyström approximation in a way that should make the answers to your questions clearer. The key assumption in Nyström is that the kernel function is of rank $m$. (Really we assume that
12,667
What is the relationship between the Beta distribution and the logistic regression model?
Beta is a distribution of values in $(0,1)$ range that is very flexible in it's shape, so for almost any unimodal empirical distribution of values in $(0,1)$ you can easily find parameters of such beta distribution that "resembles" shape of the distribution. Notice that logistic regression provides you with conditional probabilities $\Pr(Y=1\mid X)$, while on your plot you are presenting us the marginal distribution of predicted probabilities. Those are two different things to talk about. There is no direct relation between logistic regression parameters and parameters of beta distribution when looking on the distribution of predictions from logistic regression model. Below you can see data simulated using normal, exponential and uniform distributions transformed using logistic function. Besides using exactly the same parameters of logistic regression (i.e. $\beta_0 = 0, \beta_1 = 1$), the distributions of predicted probabilities are very different. So distribution of predicted probabilities depends not only on parameters of logistic regression, but also on distributions of $X$'s and there is no simple relation between them. Since beta is a distribution of values in $(0,1)$, then it cannot be used to model binary data as logistic regression does. It can be used to model probabilities, in such way we use beta regression (see also here and here). So if you are interested as the probabilities (understood as random variable) behave, you can use beta regression for such purpose.
What is the relationship between the Beta distribution and the logistic regression model?
Beta is a distribution of values in $(0,1)$ range that is very flexible in it's shape, so for almost any unimodal empirical distribution of values in $(0,1)$ you can easily find parameters of such bet
What is the relationship between the Beta distribution and the logistic regression model? Beta is a distribution of values in $(0,1)$ range that is very flexible in it's shape, so for almost any unimodal empirical distribution of values in $(0,1)$ you can easily find parameters of such beta distribution that "resembles" shape of the distribution. Notice that logistic regression provides you with conditional probabilities $\Pr(Y=1\mid X)$, while on your plot you are presenting us the marginal distribution of predicted probabilities. Those are two different things to talk about. There is no direct relation between logistic regression parameters and parameters of beta distribution when looking on the distribution of predictions from logistic regression model. Below you can see data simulated using normal, exponential and uniform distributions transformed using logistic function. Besides using exactly the same parameters of logistic regression (i.e. $\beta_0 = 0, \beta_1 = 1$), the distributions of predicted probabilities are very different. So distribution of predicted probabilities depends not only on parameters of logistic regression, but also on distributions of $X$'s and there is no simple relation between them. Since beta is a distribution of values in $(0,1)$, then it cannot be used to model binary data as logistic regression does. It can be used to model probabilities, in such way we use beta regression (see also here and here). So if you are interested as the probabilities (understood as random variable) behave, you can use beta regression for such purpose.
What is the relationship between the Beta distribution and the logistic regression model? Beta is a distribution of values in $(0,1)$ range that is very flexible in it's shape, so for almost any unimodal empirical distribution of values in $(0,1)$ you can easily find parameters of such bet
12,668
What is the relationship between the Beta distribution and the logistic regression model?
Logistic regression is a special case of a Generalized Linear Model (GLM). In this particular case of binary data, the logistic function is the canonical link function that transforms the non-linear regression problem at hand into a linear problem. GLMs are somewhat special, in the sense that they apply only to distributions in the exponential family (such as the Binomial distribution). In Bayesian estimation, the Beta distribution is the conjugate prior to the binomial distribution, which means that a Bayesian update to a Beta prior, with binomial observations, will result in a Beta posterior. So if you have counts for observations of binary data, you can get an analytical Bayesian estimate of the parameters of the binomial distribution by using a Beta prior. So, along the lines of what has been said by other, I don't think there is a direct relation, but both the Beta distribution and logistic regression have close relationships with estimating the parameters of something that follows a binomial distribution.
What is the relationship between the Beta distribution and the logistic regression model?
Logistic regression is a special case of a Generalized Linear Model (GLM). In this particular case of binary data, the logistic function is the canonical link function that transforms the non-linear r
What is the relationship between the Beta distribution and the logistic regression model? Logistic regression is a special case of a Generalized Linear Model (GLM). In this particular case of binary data, the logistic function is the canonical link function that transforms the non-linear regression problem at hand into a linear problem. GLMs are somewhat special, in the sense that they apply only to distributions in the exponential family (such as the Binomial distribution). In Bayesian estimation, the Beta distribution is the conjugate prior to the binomial distribution, which means that a Bayesian update to a Beta prior, with binomial observations, will result in a Beta posterior. So if you have counts for observations of binary data, you can get an analytical Bayesian estimate of the parameters of the binomial distribution by using a Beta prior. So, along the lines of what has been said by other, I don't think there is a direct relation, but both the Beta distribution and logistic regression have close relationships with estimating the parameters of something that follows a binomial distribution.
What is the relationship between the Beta distribution and the logistic regression model? Logistic regression is a special case of a Generalized Linear Model (GLM). In this particular case of binary data, the logistic function is the canonical link function that transforms the non-linear r
12,669
What is the relationship between the Beta distribution and the logistic regression model?
Maybe there is no direct connection? The distribution of $P(A=1|X)$ largely depends on your simulation of $X$. If you simulated $X$ with $N(0,1)$, $\exp(-X\beta)$ will have log-normal distribution with $\mu=-1$ given $\beta_0=\beta_1=1$. The distribution of $P(A=1|X)$ can then be found explicitly: with c.d.f. $$F(x)=1-\Phi\left[\ln\left(\frac{1}{x}-1\right)+1\right],$$ inverse c.d.f. $$Q(x)=\frac{1}{1+\exp(\Phi^{-1}(1-x)-1)},$$ and p.d.f. $$f(x)=\frac{1}{x(1 - x)\sqrt{2\pi}}\exp\left(-\frac{(\ln(1/x-1)+1)^2}{2}\right),$$ which do not resemble those of Beta distribution. You can verify the results given above in R: n = 100000 X = cbind(rep(1, n), rnorm(n)) # simulate design matrix Y = 1 / (exp(-X %*% c(1,1)) + 1) # P(A=1|X) Z1 = 1 / (rlnorm(n, -1, 1) + 1) # simulate from lognormal directly Z2 = 1 / (1 + exp(qnorm(runif(n)) - 1)) # simulate with inverse CDF # Kolmogorov–Smirnov test ks.test(Y, Z1) ks.test(Y, Z2) # plot fitted density new.pdf = function(x) { 1 / (x * (1 - x) * sqrt(2 * pi)) * exp(-0.5 * (log(1 / x - 1) + 1)^2) } hist(Y, breaks = "FD", probability = T) curve(new.pdf, col = 4, add = T)
What is the relationship between the Beta distribution and the logistic regression model?
Maybe there is no direct connection? The distribution of $P(A=1|X)$ largely depends on your simulation of $X$. If you simulated $X$ with $N(0,1)$, $\exp(-X\beta)$ will have log-normal distribution wit
What is the relationship between the Beta distribution and the logistic regression model? Maybe there is no direct connection? The distribution of $P(A=1|X)$ largely depends on your simulation of $X$. If you simulated $X$ with $N(0,1)$, $\exp(-X\beta)$ will have log-normal distribution with $\mu=-1$ given $\beta_0=\beta_1=1$. The distribution of $P(A=1|X)$ can then be found explicitly: with c.d.f. $$F(x)=1-\Phi\left[\ln\left(\frac{1}{x}-1\right)+1\right],$$ inverse c.d.f. $$Q(x)=\frac{1}{1+\exp(\Phi^{-1}(1-x)-1)},$$ and p.d.f. $$f(x)=\frac{1}{x(1 - x)\sqrt{2\pi}}\exp\left(-\frac{(\ln(1/x-1)+1)^2}{2}\right),$$ which do not resemble those of Beta distribution. You can verify the results given above in R: n = 100000 X = cbind(rep(1, n), rnorm(n)) # simulate design matrix Y = 1 / (exp(-X %*% c(1,1)) + 1) # P(A=1|X) Z1 = 1 / (rlnorm(n, -1, 1) + 1) # simulate from lognormal directly Z2 = 1 / (1 + exp(qnorm(runif(n)) - 1)) # simulate with inverse CDF # Kolmogorov–Smirnov test ks.test(Y, Z1) ks.test(Y, Z2) # plot fitted density new.pdf = function(x) { 1 / (x * (1 - x) * sqrt(2 * pi)) * exp(-0.5 * (log(1 / x - 1) + 1)^2) } hist(Y, breaks = "FD", probability = T) curve(new.pdf, col = 4, add = T)
What is the relationship between the Beta distribution and the logistic regression model? Maybe there is no direct connection? The distribution of $P(A=1|X)$ largely depends on your simulation of $X$. If you simulated $X$ with $N(0,1)$, $\exp(-X\beta)$ will have log-normal distribution wit
12,670
Are log difference time series models better than growth rates?
One major advantage of log-differences is symmetry: if you have a log difference of $0.1$ today and one of $-0.1$ tomorrow, you are back from where you started. In contrast, 10% growth today and 10% decline tomorrow will not bring you back to the initial value.
Are log difference time series models better than growth rates?
One major advantage of log-differences is symmetry: if you have a log difference of $0.1$ today and one of $-0.1$ tomorrow, you are back from where you started. In contrast, 10% growth today and 10% d
Are log difference time series models better than growth rates? One major advantage of log-differences is symmetry: if you have a log difference of $0.1$ today and one of $-0.1$ tomorrow, you are back from where you started. In contrast, 10% growth today and 10% decline tomorrow will not bring you back to the initial value.
Are log difference time series models better than growth rates? One major advantage of log-differences is symmetry: if you have a log difference of $0.1$ today and one of $-0.1$ tomorrow, you are back from where you started. In contrast, 10% growth today and 10% d
12,671
Are log difference time series models better than growth rates?
Many macroeconomic indicators are tied to population growth, which is exponential, and thus have an exponential trend themselves. So the process before modelling with ARIMA, VAR or other linear methods is usually: Take logs to get a series with a linear trend Then difference to get a stationary series
Are log difference time series models better than growth rates?
Many macroeconomic indicators are tied to population growth, which is exponential, and thus have an exponential trend themselves. So the process before modelling with ARIMA, VAR or other linear method
Are log difference time series models better than growth rates? Many macroeconomic indicators are tied to population growth, which is exponential, and thus have an exponential trend themselves. So the process before modelling with ARIMA, VAR or other linear methods is usually: Take logs to get a series with a linear trend Then difference to get a stationary series
Are log difference time series models better than growth rates? Many macroeconomic indicators are tied to population growth, which is exponential, and thus have an exponential trend themselves. So the process before modelling with ARIMA, VAR or other linear method
12,672
Test a significant difference between two slope values
The following article might be helpfull to you, as it describes how to evaluate if the effect of a given explanatory factor is invariant over persons, time, or organizations: Paternoster, R., Brame, R., Mazerolle, P., & Piquero, A. R. (1998). Using the Correct Statistical Test for the Equality of Regression Coefficients. Criminology, 36(4), 859–866. What they basically say is, that to test the hypothesis that the difference between $b_1$ and $b_2$ (1 and 2 being two samples or times) is equal to zero you can apply the following formula: $\begin{equation} Z= \frac{b_1-b_2}{\sqrt{{SEb_1}^{2}+{SEb_2}^2}} \end{equation}$ SE being the standard error of the respective 'slopes' in your case.
Test a significant difference between two slope values
The following article might be helpfull to you, as it describes how to evaluate if the effect of a given explanatory factor is invariant over persons, time, or organizations: Paternoster, R., Brame, R
Test a significant difference between two slope values The following article might be helpfull to you, as it describes how to evaluate if the effect of a given explanatory factor is invariant over persons, time, or organizations: Paternoster, R., Brame, R., Mazerolle, P., & Piquero, A. R. (1998). Using the Correct Statistical Test for the Equality of Regression Coefficients. Criminology, 36(4), 859–866. What they basically say is, that to test the hypothesis that the difference between $b_1$ and $b_2$ (1 and 2 being two samples or times) is equal to zero you can apply the following formula: $\begin{equation} Z= \frac{b_1-b_2}{\sqrt{{SEb_1}^{2}+{SEb_2}^2}} \end{equation}$ SE being the standard error of the respective 'slopes' in your case.
Test a significant difference between two slope values The following article might be helpfull to you, as it describes how to evaluate if the effect of a given explanatory factor is invariant over persons, time, or organizations: Paternoster, R., Brame, R
12,673
Test a significant difference between two slope values
If the slopes come from ordinary least squares regression, it would be good to verify that the year-to-year data which generated these values are indeed independent. Most capture-recapture studies need to account for previous years' volumes using some method of handling the dependence of volume over time. Using standard errors, you can construct confidence intervals around your slope parameters. A naive test for whether they are different at the correct $\alpha$ level is to inspect whether any of the confidence intervals overlap. (Note the confidence interval from one parameter has to overlap the other actual parameter value, not its confidence interval, in order to fail to reject the null hypothesis that they're different).
Test a significant difference between two slope values
If the slopes come from ordinary least squares regression, it would be good to verify that the year-to-year data which generated these values are indeed independent. Most capture-recapture studies nee
Test a significant difference between two slope values If the slopes come from ordinary least squares regression, it would be good to verify that the year-to-year data which generated these values are indeed independent. Most capture-recapture studies need to account for previous years' volumes using some method of handling the dependence of volume over time. Using standard errors, you can construct confidence intervals around your slope parameters. A naive test for whether they are different at the correct $\alpha$ level is to inspect whether any of the confidence intervals overlap. (Note the confidence interval from one parameter has to overlap the other actual parameter value, not its confidence interval, in order to fail to reject the null hypothesis that they're different).
Test a significant difference between two slope values If the slopes come from ordinary least squares regression, it would be good to verify that the year-to-year data which generated these values are indeed independent. Most capture-recapture studies nee
12,674
Test a significant difference between two slope values
The classic (and more statistically powerful) way of testing this is to combine both datasets into a single regression model and then include the area as an interaction term. See, for example, here: http://www.theanalysisfactor.com/compare-regression-coefficients/
Test a significant difference between two slope values
The classic (and more statistically powerful) way of testing this is to combine both datasets into a single regression model and then include the area as an interaction term. See, for example, here:
Test a significant difference between two slope values The classic (and more statistically powerful) way of testing this is to combine both datasets into a single regression model and then include the area as an interaction term. See, for example, here: http://www.theanalysisfactor.com/compare-regression-coefficients/
Test a significant difference between two slope values The classic (and more statistically powerful) way of testing this is to combine both datasets into a single regression model and then include the area as an interaction term. See, for example, here:
12,675
What are some techniques for sampling two correlated random variables?
I think what you're looking for is a copula. You've got two marginal distributions (specified by either parametric or empirical cdfs) and now you want to specify the dependence between the two. For the bivariate case there are all kinds of choices, but the basic recipe is the same. I'll use a Gaussian copula for ease of interpretation. To draw from the Gaussian copula with correlation matrix $C$ Draw $(Z=(Z_1, Z_2)\sim N(0, C)$ Set $U_i = \Phi(Z_i)$ for $i=1, 2$ (with $\Phi$ the standard normal cdf). Now $U_1, U_2\sim U[0,1]$, but they're dependent. Set $Y_i = F_i^{-1}(U_i)$ where $F_i^{-1}$ is the (pseudo) inverse of the marginal cdf for variable $i$. This implies that $Y_i$ follow the desired distribution (this step is just inverse transform sampling). Voila! Try it for some simple cases, and look at marginal histograms and scatterpolots, it's fun. No guarantee that this is appropriate for your particular application though (in particular, you might need to replace the Gaussian copula with a t copula) but this should get you started. A good reference on copula modeling is Nelsen (1999), An Introduction to Copulas, but there are some pretty good introductions online too.
What are some techniques for sampling two correlated random variables?
I think what you're looking for is a copula. You've got two marginal distributions (specified by either parametric or empirical cdfs) and now you want to specify the dependence between the two. For th
What are some techniques for sampling two correlated random variables? I think what you're looking for is a copula. You've got two marginal distributions (specified by either parametric or empirical cdfs) and now you want to specify the dependence between the two. For the bivariate case there are all kinds of choices, but the basic recipe is the same. I'll use a Gaussian copula for ease of interpretation. To draw from the Gaussian copula with correlation matrix $C$ Draw $(Z=(Z_1, Z_2)\sim N(0, C)$ Set $U_i = \Phi(Z_i)$ for $i=1, 2$ (with $\Phi$ the standard normal cdf). Now $U_1, U_2\sim U[0,1]$, but they're dependent. Set $Y_i = F_i^{-1}(U_i)$ where $F_i^{-1}$ is the (pseudo) inverse of the marginal cdf for variable $i$. This implies that $Y_i$ follow the desired distribution (this step is just inverse transform sampling). Voila! Try it for some simple cases, and look at marginal histograms and scatterpolots, it's fun. No guarantee that this is appropriate for your particular application though (in particular, you might need to replace the Gaussian copula with a t copula) but this should get you started. A good reference on copula modeling is Nelsen (1999), An Introduction to Copulas, but there are some pretty good introductions online too.
What are some techniques for sampling two correlated random variables? I think what you're looking for is a copula. You've got two marginal distributions (specified by either parametric or empirical cdfs) and now you want to specify the dependence between the two. For th
12,676
What are some techniques for sampling two correlated random variables?
Another popular method is "trivariate reduction" which samples $X_1 \sim Y+Z$ and $X_2 \sim W+Z$ so that the correlation is induced by the random variate $Z$. Note that this is also generalizable to more than 2 dimensions-but is more complicated than the 2-d case. You might think you can only get positive correlations but in fact you can also get negative correlations by using $U$ and $(1-U)$ when generating random variates, this will induce a negative correlation on the distributions. A third popular method is (NORTA) NORmal To Anything; generate correlated normal variates, make them into uniform random variates via evaluating their respective cdfs, then use these "new" uniform random variates as a source of randomness in generating draws from the new distribution. Besides the copula (a whole class of methods) approach mentioned in another post, you can also sample from the maximal coupling distribution which is similar in spirit to the copula approach. You specify marginal distributions and the sample from the maximal coupling. This is accomplished by 2 accept-reject steps as described by Pierre Jacob here. Presumably this method can be extended to higher dimensions than 2 but might be more complicated to achieve. Note that the maximal coupling will induce a correlation that depends on the values of the parameters of the marginals see this post for a nice example of this in Xi'an's answer to my question. If you are willing to accept approximate (in most cases) samples then MCMC techniques are also an option to sample from multi-dimensional distributions. Also, you could use accept-reject methods but it is typically hard to find a dominating density to sample from and evaluate the ratio of that to the desired density. This is all the additional methods I can think of but there are probably a couple I missed.
What are some techniques for sampling two correlated random variables?
Another popular method is "trivariate reduction" which samples $X_1 \sim Y+Z$ and $X_2 \sim W+Z$ so that the correlation is induced by the random variate $Z$. Note that this is also generalizable to m
What are some techniques for sampling two correlated random variables? Another popular method is "trivariate reduction" which samples $X_1 \sim Y+Z$ and $X_2 \sim W+Z$ so that the correlation is induced by the random variate $Z$. Note that this is also generalizable to more than 2 dimensions-but is more complicated than the 2-d case. You might think you can only get positive correlations but in fact you can also get negative correlations by using $U$ and $(1-U)$ when generating random variates, this will induce a negative correlation on the distributions. A third popular method is (NORTA) NORmal To Anything; generate correlated normal variates, make them into uniform random variates via evaluating their respective cdfs, then use these "new" uniform random variates as a source of randomness in generating draws from the new distribution. Besides the copula (a whole class of methods) approach mentioned in another post, you can also sample from the maximal coupling distribution which is similar in spirit to the copula approach. You specify marginal distributions and the sample from the maximal coupling. This is accomplished by 2 accept-reject steps as described by Pierre Jacob here. Presumably this method can be extended to higher dimensions than 2 but might be more complicated to achieve. Note that the maximal coupling will induce a correlation that depends on the values of the parameters of the marginals see this post for a nice example of this in Xi'an's answer to my question. If you are willing to accept approximate (in most cases) samples then MCMC techniques are also an option to sample from multi-dimensional distributions. Also, you could use accept-reject methods but it is typically hard to find a dominating density to sample from and evaluate the ratio of that to the desired density. This is all the additional methods I can think of but there are probably a couple I missed.
What are some techniques for sampling two correlated random variables? Another popular method is "trivariate reduction" which samples $X_1 \sim Y+Z$ and $X_2 \sim W+Z$ so that the correlation is induced by the random variate $Z$. Note that this is also generalizable to m
12,677
How to measure/argue the goodness of fit of a trendline to a power law?
See Aaron Clauset's page: Power-law Distributions in Empirical Data which has links to code for fitting power laws (Matlab, R, Python, C++) as well as a paper by Clauset and Shalizi you should read first. You might want to read Clauset's and Shalizi's blogs posts on the paper first: Power laws and all that jazz So You Think You Have a Power Law — Well Isn't That Special? A summary of the last link could be: Lots of distributions give you straight-ish lines on a log-log plot. Abusing linear regression makes the baby Gauss cry. Fitting a line to your log-log plot by least squares is a bad idea. Use maximum likelihood to estimate the scaling exponent. Use goodness of fit to estimate where the scaling region begins. Use a goodness-of-fit test to check goodness of fit. Use Vuong's test to check alternatives, and be prepared for disappointment.
How to measure/argue the goodness of fit of a trendline to a power law?
See Aaron Clauset's page: Power-law Distributions in Empirical Data which has links to code for fitting power laws (Matlab, R, Python, C++) as well as a paper by Clauset and Shalizi you should read
How to measure/argue the goodness of fit of a trendline to a power law? See Aaron Clauset's page: Power-law Distributions in Empirical Data which has links to code for fitting power laws (Matlab, R, Python, C++) as well as a paper by Clauset and Shalizi you should read first. You might want to read Clauset's and Shalizi's blogs posts on the paper first: Power laws and all that jazz So You Think You Have a Power Law — Well Isn't That Special? A summary of the last link could be: Lots of distributions give you straight-ish lines on a log-log plot. Abusing linear regression makes the baby Gauss cry. Fitting a line to your log-log plot by least squares is a bad idea. Use maximum likelihood to estimate the scaling exponent. Use goodness of fit to estimate where the scaling region begins. Use a goodness-of-fit test to check goodness of fit. Use Vuong's test to check alternatives, and be prepared for disappointment.
How to measure/argue the goodness of fit of a trendline to a power law? See Aaron Clauset's page: Power-law Distributions in Empirical Data which has links to code for fitting power laws (Matlab, R, Python, C++) as well as a paper by Clauset and Shalizi you should read
12,678
How to measure/argue the goodness of fit of a trendline to a power law?
If you're interested in bivariate power-law functions (as opposed to univariate power-law distributions), then Warton et al. "Bivariate line-fitting methods for allometry." Biol. Rev. 81, 259-201 (2006) is an excellent reference. In this case, regression is the right thing to do, although there can be some corrections (OLS vs. RMA, etc.) depending on what you want the results of the regression to mean.
How to measure/argue the goodness of fit of a trendline to a power law?
If you're interested in bivariate power-law functions (as opposed to univariate power-law distributions), then Warton et al. "Bivariate line-fitting methods for allometry." Biol. Rev. 81, 259-201 (200
How to measure/argue the goodness of fit of a trendline to a power law? If you're interested in bivariate power-law functions (as opposed to univariate power-law distributions), then Warton et al. "Bivariate line-fitting methods for allometry." Biol. Rev. 81, 259-201 (2006) is an excellent reference. In this case, regression is the right thing to do, although there can be some corrections (OLS vs. RMA, etc.) depending on what you want the results of the regression to mean.
How to measure/argue the goodness of fit of a trendline to a power law? If you're interested in bivariate power-law functions (as opposed to univariate power-law distributions), then Warton et al. "Bivariate line-fitting methods for allometry." Biol. Rev. 81, 259-201 (200
12,679
A dynamical systems view of the Central Limit Theorem?
After doing some digging in the literature, encouraged by Kjetil's answer, I've found a few references that do take the geometric/dynamical systems approach to the CLT seriously, besides the book by Y. Sinai. I'm posting what I've found for others who may be interested, but I hope still to hear from an expert about the value of this point of view. The most significant influence seems to have come from the work of Charles Stein. But the most direct answer to my question seems to be from Hamedani and Walter, who put a metric on the space of distribution functions and show that convolution generates a contraction, which yields the normal distribution as the unique fixed point. M. Anshelevich, The linearization of the central limit operator in free probability theory, arXiv:math/9810047v2. L.H.Y. Chen, L. Goldstein, and Q. Shao, Normal Approximation by Stein's Method, Springer, 2011. J.A. Goldstein, Semigroup-theoretic proofs of the central limit theorem and other theorems of analysis, Semigroup Forum 12 (1976), no. 3, 189–206. G.G. Hamedani and G.G. Walter, A fixed point theorem and its application to the central limit theorem, Arch. Math. (Basel) 43 (1984), no. 3, 258–264. S. Swaminathan, Fixed-point-theoretic proofs of the central limit theorem, in Fixed Point Theory and Applications (Marseille, 1989), Pitman Res. Notes Math. Ser., vol. 252, Longman Sci. Tech., Harlow, 1991, pp. 391–396. Cited in Karl Stromberg, Probability for Analysts, page 114. ADDED October 19, 2018. Another source for this point of view is Oliver Knill's Probability and Stochastic Processes with Applications, p. 11 (emphasis added): Markov processes often are attracted by fixed points of the Markov operator. Such fixed points are called stationary states. They describe equilibria and often they are measures with maximal entropy. An example is the Markov operator $P$, which assigns to a probability density $f_y$ the probability density of $f_{\overline{Y+X}}$ where $\overline{Y+X}$ is the random variable $Y + X$ normalized so that it has mean $0$ and variance $1$. For the initial function $f= 1$, the function $P^n(f_X)$ is the distribution of $S^{*}_n$ the normalized sum of $n$ IID random variables $X_i$. This Markov operator has a unique equilibrium point, the standard normal distribution. It has maximal entropy among all distributions on the real line with variance $1$ and mean $0$. The central limit theorem tells that the Markov operator $P$ has the normal distribution as a unique attracting fixed point if one takes the weaker topology of convergence in distribution on $\mathcal{L}^1$. This works in other situations too. For circle-valued random variables for example, the uniform distribution maximizes entropy. It is not surprising therefore, that there is a central limit theorem for circle-valued random variables with the uniform distribution as the limiting distribution.
A dynamical systems view of the Central Limit Theorem?
After doing some digging in the literature, encouraged by Kjetil's answer, I've found a few references that do take the geometric/dynamical systems approach to the CLT seriously, besides the book by Y
A dynamical systems view of the Central Limit Theorem? After doing some digging in the literature, encouraged by Kjetil's answer, I've found a few references that do take the geometric/dynamical systems approach to the CLT seriously, besides the book by Y. Sinai. I'm posting what I've found for others who may be interested, but I hope still to hear from an expert about the value of this point of view. The most significant influence seems to have come from the work of Charles Stein. But the most direct answer to my question seems to be from Hamedani and Walter, who put a metric on the space of distribution functions and show that convolution generates a contraction, which yields the normal distribution as the unique fixed point. M. Anshelevich, The linearization of the central limit operator in free probability theory, arXiv:math/9810047v2. L.H.Y. Chen, L. Goldstein, and Q. Shao, Normal Approximation by Stein's Method, Springer, 2011. J.A. Goldstein, Semigroup-theoretic proofs of the central limit theorem and other theorems of analysis, Semigroup Forum 12 (1976), no. 3, 189–206. G.G. Hamedani and G.G. Walter, A fixed point theorem and its application to the central limit theorem, Arch. Math. (Basel) 43 (1984), no. 3, 258–264. S. Swaminathan, Fixed-point-theoretic proofs of the central limit theorem, in Fixed Point Theory and Applications (Marseille, 1989), Pitman Res. Notes Math. Ser., vol. 252, Longman Sci. Tech., Harlow, 1991, pp. 391–396. Cited in Karl Stromberg, Probability for Analysts, page 114. ADDED October 19, 2018. Another source for this point of view is Oliver Knill's Probability and Stochastic Processes with Applications, p. 11 (emphasis added): Markov processes often are attracted by fixed points of the Markov operator. Such fixed points are called stationary states. They describe equilibria and often they are measures with maximal entropy. An example is the Markov operator $P$, which assigns to a probability density $f_y$ the probability density of $f_{\overline{Y+X}}$ where $\overline{Y+X}$ is the random variable $Y + X$ normalized so that it has mean $0$ and variance $1$. For the initial function $f= 1$, the function $P^n(f_X)$ is the distribution of $S^{*}_n$ the normalized sum of $n$ IID random variables $X_i$. This Markov operator has a unique equilibrium point, the standard normal distribution. It has maximal entropy among all distributions on the real line with variance $1$ and mean $0$. The central limit theorem tells that the Markov operator $P$ has the normal distribution as a unique attracting fixed point if one takes the weaker topology of convergence in distribution on $\mathcal{L}^1$. This works in other situations too. For circle-valued random variables for example, the uniform distribution maximizes entropy. It is not surprising therefore, that there is a central limit theorem for circle-valued random variables with the uniform distribution as the limiting distribution.
A dynamical systems view of the Central Limit Theorem? After doing some digging in the literature, encouraged by Kjetil's answer, I've found a few references that do take the geometric/dynamical systems approach to the CLT seriously, besides the book by Y
12,680
A dynamical systems view of the Central Limit Theorem?
The text "Probability Theory An Introductory Course" by Y Sinai (Springer) discusses the CLT in this way. The idea is (from memory ...) that The normal distribution maximizes entropy (among distributions with fixed variance) The averaging operator $A(x_1,x_2) = \frac{x_1+x_2}{\sqrt{2}}$ maintains variance and increases entropy ... and the rest is technique. So, then you get the dynamical systems setting of iteration of an operator.
A dynamical systems view of the Central Limit Theorem?
The text "Probability Theory An Introductory Course" by Y Sinai (Springer) discusses the CLT in this way. The idea is (from memory ...) that The normal distribution maximizes entropy (among distribu
A dynamical systems view of the Central Limit Theorem? The text "Probability Theory An Introductory Course" by Y Sinai (Springer) discusses the CLT in this way. The idea is (from memory ...) that The normal distribution maximizes entropy (among distributions with fixed variance) The averaging operator $A(x_1,x_2) = \frac{x_1+x_2}{\sqrt{2}}$ maintains variance and increases entropy ... and the rest is technique. So, then you get the dynamical systems setting of iteration of an operator.
A dynamical systems view of the Central Limit Theorem? The text "Probability Theory An Introductory Course" by Y Sinai (Springer) discusses the CLT in this way. The idea is (from memory ...) that The normal distribution maximizes entropy (among distribu
12,681
A dynamical systems view of the Central Limit Theorem?
Great question; I've often wondered about that. A somewhat related idea is explained in our paper Dynamical attraction to stable processes, Ann. Inst. H. Poincaré Probab. Statist. Volume 48, Number 2, 2012, pp 551-578 (Albert Fisher and Marina Talet) see https://www.ime.usp.br/~afisher/ The idea is to turn Levy's probability notion of "domain of attraction" for stable processes (including Gaussian) into actual dynamics. We do this for the full stable process, rather than just for the stable distribution, because there the scaling property of these self-similar processes has a dynamical interpretation: it's a Bernoulli flow of infinite entropy. Then a random walk with increments in the domain of attraction converges to this in the sense that a walk path is a.s. a generic point for this flow. We don't use a contraction mapping per se but it is an interesting question to see if something like that might be useful. (Our theorem proves an a.s.i.p. in log density; the regularly varying case is especially tricky and there we have to apply an appropriate time change). See also the related papers on the above web page. The advantage of working with processes is that one has an actual flow. For the Gaussian distribution, this is not only a fixed point for the Fourier Transform, but for the convolution operator (suitably rescaled). The first is intriguing but there's no way that iteration helps, because it's an involution: applying it twice brings you back. The convolution really makes sense as that's just the distribution of a random walk. However, it's a semigroup action which is less sweet from the dynamical point of view than a flow.
A dynamical systems view of the Central Limit Theorem?
Great question; I've often wondered about that. A somewhat related idea is explained in our paper Dynamical attraction to stable processes, Ann. Inst. H. Poincaré Probab. Statist. Volume 48, Number 2,
A dynamical systems view of the Central Limit Theorem? Great question; I've often wondered about that. A somewhat related idea is explained in our paper Dynamical attraction to stable processes, Ann. Inst. H. Poincaré Probab. Statist. Volume 48, Number 2, 2012, pp 551-578 (Albert Fisher and Marina Talet) see https://www.ime.usp.br/~afisher/ The idea is to turn Levy's probability notion of "domain of attraction" for stable processes (including Gaussian) into actual dynamics. We do this for the full stable process, rather than just for the stable distribution, because there the scaling property of these self-similar processes has a dynamical interpretation: it's a Bernoulli flow of infinite entropy. Then a random walk with increments in the domain of attraction converges to this in the sense that a walk path is a.s. a generic point for this flow. We don't use a contraction mapping per se but it is an interesting question to see if something like that might be useful. (Our theorem proves an a.s.i.p. in log density; the regularly varying case is especially tricky and there we have to apply an appropriate time change). See also the related papers on the above web page. The advantage of working with processes is that one has an actual flow. For the Gaussian distribution, this is not only a fixed point for the Fourier Transform, but for the convolution operator (suitably rescaled). The first is intriguing but there's no way that iteration helps, because it's an involution: applying it twice brings you back. The convolution really makes sense as that's just the distribution of a random walk. However, it's a semigroup action which is less sweet from the dynamical point of view than a flow.
A dynamical systems view of the Central Limit Theorem? Great question; I've often wondered about that. A somewhat related idea is explained in our paper Dynamical attraction to stable processes, Ann. Inst. H. Poincaré Probab. Statist. Volume 48, Number 2,
12,682
What does "degree of freedom" mean in neural networks?
I suspect this is what Bishop means: If you think of a neural net as a function that maps inputs to an output, then when you first initialize a neural net with small random weights, the neural net looks a lot like a linear function. The sigmoid activation function is close to linear around zero (just do a Taylor expansion), and small incoming weights will guarantee that the effective domaine of each hidden unit is just a small interval around zero, so the entire neural net, regardless of how many layers you have, will look very much like a linear function. So you can heuristically describe the neural net as having a small number of degrees of freedom (equal to the dimension of the input). As you train the neural net, the weights can become arbitrarily large, and the neural net can better approximate arbitrary non-linear functions. So as training progresses, you can heuristically describe that change as an increase in the number of degrees of freedom, or, more specifically, in increase in the size of the class of functions that the neural net can closely approximate.
What does "degree of freedom" mean in neural networks?
I suspect this is what Bishop means: If you think of a neural net as a function that maps inputs to an output, then when you first initialize a neural net with small random weights, the neural net loo
What does "degree of freedom" mean in neural networks? I suspect this is what Bishop means: If you think of a neural net as a function that maps inputs to an output, then when you first initialize a neural net with small random weights, the neural net looks a lot like a linear function. The sigmoid activation function is close to linear around zero (just do a Taylor expansion), and small incoming weights will guarantee that the effective domaine of each hidden unit is just a small interval around zero, so the entire neural net, regardless of how many layers you have, will look very much like a linear function. So you can heuristically describe the neural net as having a small number of degrees of freedom (equal to the dimension of the input). As you train the neural net, the weights can become arbitrarily large, and the neural net can better approximate arbitrary non-linear functions. So as training progresses, you can heuristically describe that change as an increase in the number of degrees of freedom, or, more specifically, in increase in the size of the class of functions that the neural net can closely approximate.
What does "degree of freedom" mean in neural networks? I suspect this is what Bishop means: If you think of a neural net as a function that maps inputs to an output, then when you first initialize a neural net with small random weights, the neural net loo
12,683
What does "degree of freedom" mean in neural networks?
The phrase "sometimes explained qualitatively" suggests that he is merely making a analogy to simple linear regression. Each time we add a term to a linear regression model we add a degree of freedom to the model and subtract a degree of freedom from those associated with the error term. If we put enough independent terms into a model, we can perfectly "predict" history from a set of random numbers, but we will be totally unable to predict the future.
What does "degree of freedom" mean in neural networks?
The phrase "sometimes explained qualitatively" suggests that he is merely making a analogy to simple linear regression. Each time we add a term to a linear regression model we add a degree of freedom
What does "degree of freedom" mean in neural networks? The phrase "sometimes explained qualitatively" suggests that he is merely making a analogy to simple linear regression. Each time we add a term to a linear regression model we add a degree of freedom to the model and subtract a degree of freedom from those associated with the error term. If we put enough independent terms into a model, we can perfectly "predict" history from a set of random numbers, but we will be totally unable to predict the future.
What does "degree of freedom" mean in neural networks? The phrase "sometimes explained qualitatively" suggests that he is merely making a analogy to simple linear regression. Each time we add a term to a linear regression model we add a degree of freedom
12,684
What does "degree of freedom" mean in neural networks?
The issue of the degrees of freedom on complicated statistical learning models has been discussed in Ye 1998 JASA. Basically, the idea is to see by how much the output of a complicated model, such as the neural network, responds to a unit change in inputs. For linear models, the relation is unsurpisingly one-to-one, so the degrees of freedom for a model of complexity $p$ (number of regressors) is $p$. For more complicated models (Ye considered regression trees), an ability to add an extra node provides way more flexibility, as the CART model will look for a good variable to split, and a good split point. That's way more than what adding a regressor to a linear model can do, and Ye found the regression trees to consume about 3.5-4 d.f.s per node. Neural networks may be somewhere in between, but the degrees of freedom is surely way larger than the number of units, and may be larger than the number of weights. I think something similar was provided by HTF Sec. 7.6, although they surprisingly don't refer to Ye (1998). They do refer to Bishop as a special case, though.
What does "degree of freedom" mean in neural networks?
The issue of the degrees of freedom on complicated statistical learning models has been discussed in Ye 1998 JASA. Basically, the idea is to see by how much the output of a complicated model, such as
What does "degree of freedom" mean in neural networks? The issue of the degrees of freedom on complicated statistical learning models has been discussed in Ye 1998 JASA. Basically, the idea is to see by how much the output of a complicated model, such as the neural network, responds to a unit change in inputs. For linear models, the relation is unsurpisingly one-to-one, so the degrees of freedom for a model of complexity $p$ (number of regressors) is $p$. For more complicated models (Ye considered regression trees), an ability to add an extra node provides way more flexibility, as the CART model will look for a good variable to split, and a good split point. That's way more than what adding a regressor to a linear model can do, and Ye found the regression trees to consume about 3.5-4 d.f.s per node. Neural networks may be somewhere in between, but the degrees of freedom is surely way larger than the number of units, and may be larger than the number of weights. I think something similar was provided by HTF Sec. 7.6, although they surprisingly don't refer to Ye (1998). They do refer to Bishop as a special case, though.
What does "degree of freedom" mean in neural networks? The issue of the degrees of freedom on complicated statistical learning models has been discussed in Ye 1998 JASA. Basically, the idea is to see by how much the output of a complicated model, such as
12,685
What does "degree of freedom" mean in neural networks?
He says the "effective complexity of the network". He actually refers to the size of the weights of the network. This can be understood in terms of the minimum description length principle. But before I get into that, the intuition is that the bigger the weights, the more different sort of functions your network can fit, and thus the higher the degrees of freedom (and effective complexity). In that chapter he is talking about regularization, which is a technique of effectively reducing the risk of overfitting, by demanding the weights to be as small as possible. In general, $$p(D|\mathbf{w}) = \prod_{n} p(t_{n}|\mathbf{x_{n}},\mathbf{w}) = \prod_{n}\exp \left(\frac{\beta}{2} \left[t_{n}- y(\mathbf{x_{n}},\mathbf{w}) \right]^{2}\right)/Z_{D}(\beta)$$. where $\mathbf{w}$ is a vector containing all parameters which characterize your algorithm and $Z_{D}(\beta)$ is a normalization constant. If you maximize the log-likelihood if this expression you get the ML estimate. Now, you add a prior on the parameters which acts as a regularizer and helps you avoid overfitting by controlling the complexity of your classifier. Concretely, in the case it is natural to assume that your parameters are Gaussian distributed, $$p(\mathbf{w}) = \exp \left( -\frac{\alpha ||\mathbf{w}||^{2}}{2}\right)/Z_{W}(\alpha)$$ MAP is defined as $\arg\max_{w} p(\mathbf{w}|D)$. Using Bayes' theorem, $$p(\mathbf{w}|D) = p(D|\mathbf{w})p(\mathbf{w})$$ If you substitute the above expressions and take logarithms you end up with (the $Z$'s do not depend on $\mathbf{w}$), $$\arg\min_{w} \sum_{n}\frac{\beta}{2} \left[t_{n}- y(\mathbf{x_{n}},\mathbf{w}) \right]^{2} + \frac{\alpha}{2}\sum_{i}w_{i}^{2}$$ More generally, you have that the MAP estimate is equivalent to the following, $$\mathbf{w}_{MAP} = \operatorname{argmin}_{\mathbf{w}} -log_{2}P(D|\mathbf{w}) - log_{2}(\mathbf{w})$$ The right hand side of the expression can be interpreted as the number of bits necessary to describe your classifier. The first term represent the number of bits necessary to code the errors your network does on the training data. The second represents the number of bits necessary to code the weights. The MAP estimate is thus equivalent to choosing the most compact representation possible. In other words, you look for the set of weights which account for the training data as faithfully as possible which can be expressed with the least number of bits. Notice that this is another form of the bias/variance problem: the bigger the weights, the lower the first term, because the network can fit the training data better (overfitting). But at the same time the higher the complexity of weights. The smaller the weights, the smaller the complexity of the network, but the higher the error term (bias). The higher the number of bits necessary to code the errors of the network. Hope this gives you an good enough idea of what he is referring to. P.S. adding a longer argument to the ongoing discussion Maybe I misunderstand you. Let me please try to explain myself a last time. The prior on the weights means represent the assumption we make about the function you want to fit. The bigger the prior (i.e. the weights) the broader the Gaussian, i.e. the more possible configurations one considers to fit the network. Let us consider the case of regression (as in the paper I referred to). Low generalization error means that the network is able to map unseen samples very close to the actual values. If you are fitting a straight line, then a first order polynomial suffices (low complexity). Now, you could also fit the data with a higher order polynomial (let higher order coefficients be different from zero). The complexity of the network is higher because you allow for oscillations, for a more complex curve. Nevertheless, if the coefficients corresponding to higher order terms are low enough, the network can approximate the straight line very well, thus resulting in good generalization. So the whole point of MDL is to make your weights as small as possible, as long as the generalization error can me minimized along. Finally, quoting you: "I still find troublesome the argument that as the model starts to overfit, its capabilities to model other functions will increase. I think that's quite the opposite because a model that overfits, can't generalize to be applied to new information.". Yes, it can model OTHER, more complex functions, but it will fail to model the function at hand properly. In the figure 5.12 in the book, the error first declines, as the size of the weight increases (reduction in bias). Up to a given point when it starts to increase again (decrease in generalization, overfit).
What does "degree of freedom" mean in neural networks?
He says the "effective complexity of the network". He actually refers to the size of the weights of the network. This can be understood in terms of the minimum description length principle. But before
What does "degree of freedom" mean in neural networks? He says the "effective complexity of the network". He actually refers to the size of the weights of the network. This can be understood in terms of the minimum description length principle. But before I get into that, the intuition is that the bigger the weights, the more different sort of functions your network can fit, and thus the higher the degrees of freedom (and effective complexity). In that chapter he is talking about regularization, which is a technique of effectively reducing the risk of overfitting, by demanding the weights to be as small as possible. In general, $$p(D|\mathbf{w}) = \prod_{n} p(t_{n}|\mathbf{x_{n}},\mathbf{w}) = \prod_{n}\exp \left(\frac{\beta}{2} \left[t_{n}- y(\mathbf{x_{n}},\mathbf{w}) \right]^{2}\right)/Z_{D}(\beta)$$. where $\mathbf{w}$ is a vector containing all parameters which characterize your algorithm and $Z_{D}(\beta)$ is a normalization constant. If you maximize the log-likelihood if this expression you get the ML estimate. Now, you add a prior on the parameters which acts as a regularizer and helps you avoid overfitting by controlling the complexity of your classifier. Concretely, in the case it is natural to assume that your parameters are Gaussian distributed, $$p(\mathbf{w}) = \exp \left( -\frac{\alpha ||\mathbf{w}||^{2}}{2}\right)/Z_{W}(\alpha)$$ MAP is defined as $\arg\max_{w} p(\mathbf{w}|D)$. Using Bayes' theorem, $$p(\mathbf{w}|D) = p(D|\mathbf{w})p(\mathbf{w})$$ If you substitute the above expressions and take logarithms you end up with (the $Z$'s do not depend on $\mathbf{w}$), $$\arg\min_{w} \sum_{n}\frac{\beta}{2} \left[t_{n}- y(\mathbf{x_{n}},\mathbf{w}) \right]^{2} + \frac{\alpha}{2}\sum_{i}w_{i}^{2}$$ More generally, you have that the MAP estimate is equivalent to the following, $$\mathbf{w}_{MAP} = \operatorname{argmin}_{\mathbf{w}} -log_{2}P(D|\mathbf{w}) - log_{2}(\mathbf{w})$$ The right hand side of the expression can be interpreted as the number of bits necessary to describe your classifier. The first term represent the number of bits necessary to code the errors your network does on the training data. The second represents the number of bits necessary to code the weights. The MAP estimate is thus equivalent to choosing the most compact representation possible. In other words, you look for the set of weights which account for the training data as faithfully as possible which can be expressed with the least number of bits. Notice that this is another form of the bias/variance problem: the bigger the weights, the lower the first term, because the network can fit the training data better (overfitting). But at the same time the higher the complexity of weights. The smaller the weights, the smaller the complexity of the network, but the higher the error term (bias). The higher the number of bits necessary to code the errors of the network. Hope this gives you an good enough idea of what he is referring to. P.S. adding a longer argument to the ongoing discussion Maybe I misunderstand you. Let me please try to explain myself a last time. The prior on the weights means represent the assumption we make about the function you want to fit. The bigger the prior (i.e. the weights) the broader the Gaussian, i.e. the more possible configurations one considers to fit the network. Let us consider the case of regression (as in the paper I referred to). Low generalization error means that the network is able to map unseen samples very close to the actual values. If you are fitting a straight line, then a first order polynomial suffices (low complexity). Now, you could also fit the data with a higher order polynomial (let higher order coefficients be different from zero). The complexity of the network is higher because you allow for oscillations, for a more complex curve. Nevertheless, if the coefficients corresponding to higher order terms are low enough, the network can approximate the straight line very well, thus resulting in good generalization. So the whole point of MDL is to make your weights as small as possible, as long as the generalization error can me minimized along. Finally, quoting you: "I still find troublesome the argument that as the model starts to overfit, its capabilities to model other functions will increase. I think that's quite the opposite because a model that overfits, can't generalize to be applied to new information.". Yes, it can model OTHER, more complex functions, but it will fail to model the function at hand properly. In the figure 5.12 in the book, the error first declines, as the size of the weight increases (reduction in bias). Up to a given point when it starts to increase again (decrease in generalization, overfit).
What does "degree of freedom" mean in neural networks? He says the "effective complexity of the network". He actually refers to the size of the weights of the network. This can be understood in terms of the minimum description length principle. But before
12,686
Confirming the distribution of residuals in linear regression
It all depends on how you estimate the parameters. Usually, the estimators are linear, which implies the residuals are linear functions of the data. When the errors $u_i$ have a Normal distribution, then so do the data, whence so do the residuals $\hat{u}_i$ ($i$ indexes the data cases, of course). It's conceivable (and logically possible) that when the residuals appear to have approximately a Normal (univariate) distribution, that this arises from non-Normal distributions of errors. However, with least squares (or maximum likelihood) techniques of estimation, the linear transformation to compute the residuals is "mild" in the sense that the characteristic function of the (multivariate) distribution of the residuals cannot differ much from the cf of the errors. In practice, we never need that the errors be exactly Normally distributed, so this is an unimportant issue. Of much greater import for the errors is that (1) their expectations should all be close to zero; (2) their correlations should be low; and (3) there should be an acceptably small number of outlying values. To check these, we apply various goodness-of-fit tests, correlation tests, and tests of outliers (respectively) to the residuals. Careful regression modeling always includes running such tests (which include various graphical visualizations of the residuals, such as supplied automatically by R's plot method when applied to an lm class). Another way to get at this question is by simulating from the hypothesized model. Here is some (minimal, one-off) R code to do the job: # Simulate y = b0 + b1*x + u and draw a normal probability plot of the residuals. # (b0=1, b1=2, u ~ Normal(0,1) are hard-coded for this example.) f<-function(n) { # n is the amount of data to simulate x <- 1:n; y <- 1 + 2*x + rnorm(n); model<-lm(y ~ x); lines(qnorm(((1:n) - 1/2)/n), y=sort(model$residuals), col="gray") } # # Apply the simulation repeatedly to see what's happening in the long run. # n <- 6 # Specify the number of points to be in each simulated dataset plot(qnorm(((1:n) - 1/2)/n), seq(from=-3,to=3, length.out=n), type="n", xlab="x", ylab="Residual") # Create an empty plot out <- replicate(99, f(n)) # Overlay lots of probability plots abline(a=0, b=1, col="blue") # Draw the reference line y=x For the case n=32, this overlaid probability plot of 99 sets of residuals shows they tend to be close to the error distribution (which is standard normal), because they uniformly cleave to the reference line $y=x$: For the case n=6, the smaller median slope in the probability plots hints that the residuals have a slightly smaller variance than the errors, but overall they tend to be normally distributed, because most of them track the reference line sufficiently well (given the small value of $n$):
Confirming the distribution of residuals in linear regression
It all depends on how you estimate the parameters. Usually, the estimators are linear, which implies the residuals are linear functions of the data. When the errors $u_i$ have a Normal distribution,
Confirming the distribution of residuals in linear regression It all depends on how you estimate the parameters. Usually, the estimators are linear, which implies the residuals are linear functions of the data. When the errors $u_i$ have a Normal distribution, then so do the data, whence so do the residuals $\hat{u}_i$ ($i$ indexes the data cases, of course). It's conceivable (and logically possible) that when the residuals appear to have approximately a Normal (univariate) distribution, that this arises from non-Normal distributions of errors. However, with least squares (or maximum likelihood) techniques of estimation, the linear transformation to compute the residuals is "mild" in the sense that the characteristic function of the (multivariate) distribution of the residuals cannot differ much from the cf of the errors. In practice, we never need that the errors be exactly Normally distributed, so this is an unimportant issue. Of much greater import for the errors is that (1) their expectations should all be close to zero; (2) their correlations should be low; and (3) there should be an acceptably small number of outlying values. To check these, we apply various goodness-of-fit tests, correlation tests, and tests of outliers (respectively) to the residuals. Careful regression modeling always includes running such tests (which include various graphical visualizations of the residuals, such as supplied automatically by R's plot method when applied to an lm class). Another way to get at this question is by simulating from the hypothesized model. Here is some (minimal, one-off) R code to do the job: # Simulate y = b0 + b1*x + u and draw a normal probability plot of the residuals. # (b0=1, b1=2, u ~ Normal(0,1) are hard-coded for this example.) f<-function(n) { # n is the amount of data to simulate x <- 1:n; y <- 1 + 2*x + rnorm(n); model<-lm(y ~ x); lines(qnorm(((1:n) - 1/2)/n), y=sort(model$residuals), col="gray") } # # Apply the simulation repeatedly to see what's happening in the long run. # n <- 6 # Specify the number of points to be in each simulated dataset plot(qnorm(((1:n) - 1/2)/n), seq(from=-3,to=3, length.out=n), type="n", xlab="x", ylab="Residual") # Create an empty plot out <- replicate(99, f(n)) # Overlay lots of probability plots abline(a=0, b=1, col="blue") # Draw the reference line y=x For the case n=32, this overlaid probability plot of 99 sets of residuals shows they tend to be close to the error distribution (which is standard normal), because they uniformly cleave to the reference line $y=x$: For the case n=6, the smaller median slope in the probability plots hints that the residuals have a slightly smaller variance than the errors, but overall they tend to be normally distributed, because most of them track the reference line sufficiently well (given the small value of $n$):
Confirming the distribution of residuals in linear regression It all depends on how you estimate the parameters. Usually, the estimators are linear, which implies the residuals are linear functions of the data. When the errors $u_i$ have a Normal distribution,
12,687
Confirming the distribution of residuals in linear regression
Let us recall the geometry of the least squares: we have the basic equation $$ y_i = x_i'\beta + \epsilon_i $$ written in the matrix form as $$ \mathbf{y} = \mathbf{X}\beta + \mathbf{\epsilon} $$ from which we derive the residuals $$ \mathbf{e} = (I-H) \mathbf{y} $$ where $$ H = X(X'X)^{-1} X'$$ is the projection matrix, or hat-matrix. We see that each individual residual $e_i$ is a combination of potentially a large diagonal value $(1-h_{ii})$ times its own residual $\epsilon_i$, and a bunch of small magnitude off-diagonal values $h_{ij}$ times their residuals $\epsilon_j, j\neq i$. (The reason I am saying that the off-diagonal values are small is because $\sum_{j\neq i} h_{ij}^2 + h_{ii}^2 = h_{ii}$, and in fact either the diagonal or off-diagonal entries are roughly of order $O(1/n)$ although this is not a very strict statement that is easily thrown off by the high leverage points; $X'X$ is a sum of $n$ cross-products and is roughly of order $O(n)$; it's inverse is $O(1/n)$.) So what happens if you sum up a lot of i.i.d. pieces with small weights? Right, you get the normal distribution by the central limit theorem. So the contribution of the off-diagonal terms to the residual will produce an essentially normal component in large samples, smoothing out the non-normality that the original distribution of the errors $\epsilon_i$ may have featured. It is true of course that the major part of the residual $e_i$ still comes from the own error, $(1-h_{ii})\epsilon_i$, but the interplay of all these terms may produce distributions that are much closer to the normal than the original distribution of errors.
Confirming the distribution of residuals in linear regression
Let us recall the geometry of the least squares: we have the basic equation $$ y_i = x_i'\beta + \epsilon_i $$ written in the matrix form as $$ \mathbf{y} = \mathbf{X}\beta + \mathbf{\epsilon} $$ from
Confirming the distribution of residuals in linear regression Let us recall the geometry of the least squares: we have the basic equation $$ y_i = x_i'\beta + \epsilon_i $$ written in the matrix form as $$ \mathbf{y} = \mathbf{X}\beta + \mathbf{\epsilon} $$ from which we derive the residuals $$ \mathbf{e} = (I-H) \mathbf{y} $$ where $$ H = X(X'X)^{-1} X'$$ is the projection matrix, or hat-matrix. We see that each individual residual $e_i$ is a combination of potentially a large diagonal value $(1-h_{ii})$ times its own residual $\epsilon_i$, and a bunch of small magnitude off-diagonal values $h_{ij}$ times their residuals $\epsilon_j, j\neq i$. (The reason I am saying that the off-diagonal values are small is because $\sum_{j\neq i} h_{ij}^2 + h_{ii}^2 = h_{ii}$, and in fact either the diagonal or off-diagonal entries are roughly of order $O(1/n)$ although this is not a very strict statement that is easily thrown off by the high leverage points; $X'X$ is a sum of $n$ cross-products and is roughly of order $O(n)$; it's inverse is $O(1/n)$.) So what happens if you sum up a lot of i.i.d. pieces with small weights? Right, you get the normal distribution by the central limit theorem. So the contribution of the off-diagonal terms to the residual will produce an essentially normal component in large samples, smoothing out the non-normality that the original distribution of the errors $\epsilon_i$ may have featured. It is true of course that the major part of the residual $e_i$ still comes from the own error, $(1-h_{ii})\epsilon_i$, but the interplay of all these terms may produce distributions that are much closer to the normal than the original distribution of errors.
Confirming the distribution of residuals in linear regression Let us recall the geometry of the least squares: we have the basic equation $$ y_i = x_i'\beta + \epsilon_i $$ written in the matrix form as $$ \mathbf{y} = \mathbf{X}\beta + \mathbf{\epsilon} $$ from
12,688
Confirming the distribution of residuals in linear regression
If we get something which looks like a familiar distribution, can we assume that our error term has this distribution? I would argue that you can't, since the model you have just fit is invalid if the normality assumption about the errors does not hold. (in the sense that the shape of the distribution is distinctly non-normal such as Cauchy etc.) The usual approach instead of assuming f.e. Poisson distributed errors, is to perform some form of data transformation such as log y, or 1/y in order to normalize the residuals. (also the true model might not be linear which would make the plotted residuals appear weirdly distributed even though they are in fact normal) Say, if we found out that residuals resemble normal distribution, does it make sense to assume normality of error term in population? You assumed the normality of errors once you have fit an OLS regression. Whether you have to provide arguments for that claim, depends on the type and level of your work. (it is often useful to look at what is the accepted practice in the field) Now, if the residuals do in fact appear to be normally distributed, you can pet yourself on the back, since you can use it as an empirical proof of your previous assumptions. :)
Confirming the distribution of residuals in linear regression
If we get something which looks like a familiar distribution, can we assume that our error term has this distribution? I would argue that you can't, since the model you have just fit is invalid if
Confirming the distribution of residuals in linear regression If we get something which looks like a familiar distribution, can we assume that our error term has this distribution? I would argue that you can't, since the model you have just fit is invalid if the normality assumption about the errors does not hold. (in the sense that the shape of the distribution is distinctly non-normal such as Cauchy etc.) The usual approach instead of assuming f.e. Poisson distributed errors, is to perform some form of data transformation such as log y, or 1/y in order to normalize the residuals. (also the true model might not be linear which would make the plotted residuals appear weirdly distributed even though they are in fact normal) Say, if we found out that residuals resemble normal distribution, does it make sense to assume normality of error term in population? You assumed the normality of errors once you have fit an OLS regression. Whether you have to provide arguments for that claim, depends on the type and level of your work. (it is often useful to look at what is the accepted practice in the field) Now, if the residuals do in fact appear to be normally distributed, you can pet yourself on the back, since you can use it as an empirical proof of your previous assumptions. :)
Confirming the distribution of residuals in linear regression If we get something which looks like a familiar distribution, can we assume that our error term has this distribution? I would argue that you can't, since the model you have just fit is invalid if
12,689
Confirming the distribution of residuals in linear regression
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. Yes it is sensible. The residuals are the errors. You can also look at a normal Q-Q plot.
Confirming the distribution of residuals in linear regression
Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
Confirming the distribution of residuals in linear regression Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted. Yes it is sensible. The residuals are the errors. You can also look at a normal Q-Q plot.
Confirming the distribution of residuals in linear regression Want to improve this post? Provide detailed answers to this question, including citations and an explanation of why your answer is correct. Answers without enough detail may be edited or deleted.
12,690
What is the relation between estimator and estimate?
E. L. Lehmann, in his classic Theory of Point Estimation, answers this question on pp 1-2. The observations are now postulated to be the values taken on by random variables which are assumed to follow a joint probability distribution, $P$, belonging to some known class... ...let us now specialize to point estimation...suppose that $g$ is a real-valued function defined [on the stipulated class of distributions] and that we would like to know the value of $g$ [at whatever is the actual distribution in effect, $\theta$]. Unfortunately, $\theta$, and hence $g(\theta)$, is unknown. However, the data can be used to obtain an estimate of $g(\theta)$, a value that one hopes will be close to $g(\theta)$. In words: an estimator is a definite mathematical procedure that comes up with a number (the estimate) for any possible set of data that a particular problem could produce. That number is intended to represent some definite numerical property ($g(\theta)$) of the data-generation process; we might call this the "estimand." The estimator itself is not a random variable: it's just a mathematical function. However, the estimate it produces is based on data which themselves are modeled as random variables. This makes the estimate (thought of as depending on the data) into a random variable and a particular estimate for a particular set of data becomes a realization of that random variable. In one (conventional) ordinary least squares formulation, the data consist of ordered pairs $(x_i, y_i)$. The $x_i$ have been determined by the experimenter (they can be amounts of a drug administered, for example). Each $y_i$ (a response to the drug, for instance) is assumed to come from a probability distribution that is Normal but with unknown mean $\mu_i$ and common variance $\sigma^2$. Furthermore, it is assumed that the means are related to the $x_i$ via a formula $\mu_i = \beta_0 + \beta_1 x_i$. These three parameters--$\sigma$, $\beta_0$, and $\beta_1$--determine the underlying distribution of $y_i$ for any value of $x_i$. Therefore any property of that distribution can be thought of as a function of $(\sigma, \beta_0, \beta_1)$. Examples of such properties are the intercept $\beta_0$, the slope $\beta_1$, the value of $\cos(\sigma + \beta_0^2 - \beta_1)$, or even the mean at the value $x=2$, which (according to this formulation) must be $\beta_0 + 2 \beta_1$. In this OLS context, a non-example of an estimator would be a procedure to guess at the value of $y$ if $x$ were set equal to 2. This is not an estimator because this value of $y$ is random (in a way completely separate from the randomness of the data): it is not a (definite numerical) property of the distribution, even though it is related to that distribution. (As we just saw, though, the expectation of $y$ for $x=2$, equal to $\beta_0 + 2 \beta_1$, can be estimated.) In Lehmann's formulation, almost any formula can be an estimator of almost any property. There is no inherent mathematical link between an estimator and an estimand. However, we can assess--in advance--the chance that an estimator will be reasonably close to the quantity it is intended to estimate. Ways to do this, and how to exploit them, are the subject of estimation theory.
What is the relation between estimator and estimate?
E. L. Lehmann, in his classic Theory of Point Estimation, answers this question on pp 1-2. The observations are now postulated to be the values taken on by random variables which are assumed to follo
What is the relation between estimator and estimate? E. L. Lehmann, in his classic Theory of Point Estimation, answers this question on pp 1-2. The observations are now postulated to be the values taken on by random variables which are assumed to follow a joint probability distribution, $P$, belonging to some known class... ...let us now specialize to point estimation...suppose that $g$ is a real-valued function defined [on the stipulated class of distributions] and that we would like to know the value of $g$ [at whatever is the actual distribution in effect, $\theta$]. Unfortunately, $\theta$, and hence $g(\theta)$, is unknown. However, the data can be used to obtain an estimate of $g(\theta)$, a value that one hopes will be close to $g(\theta)$. In words: an estimator is a definite mathematical procedure that comes up with a number (the estimate) for any possible set of data that a particular problem could produce. That number is intended to represent some definite numerical property ($g(\theta)$) of the data-generation process; we might call this the "estimand." The estimator itself is not a random variable: it's just a mathematical function. However, the estimate it produces is based on data which themselves are modeled as random variables. This makes the estimate (thought of as depending on the data) into a random variable and a particular estimate for a particular set of data becomes a realization of that random variable. In one (conventional) ordinary least squares formulation, the data consist of ordered pairs $(x_i, y_i)$. The $x_i$ have been determined by the experimenter (they can be amounts of a drug administered, for example). Each $y_i$ (a response to the drug, for instance) is assumed to come from a probability distribution that is Normal but with unknown mean $\mu_i$ and common variance $\sigma^2$. Furthermore, it is assumed that the means are related to the $x_i$ via a formula $\mu_i = \beta_0 + \beta_1 x_i$. These three parameters--$\sigma$, $\beta_0$, and $\beta_1$--determine the underlying distribution of $y_i$ for any value of $x_i$. Therefore any property of that distribution can be thought of as a function of $(\sigma, \beta_0, \beta_1)$. Examples of such properties are the intercept $\beta_0$, the slope $\beta_1$, the value of $\cos(\sigma + \beta_0^2 - \beta_1)$, or even the mean at the value $x=2$, which (according to this formulation) must be $\beta_0 + 2 \beta_1$. In this OLS context, a non-example of an estimator would be a procedure to guess at the value of $y$ if $x$ were set equal to 2. This is not an estimator because this value of $y$ is random (in a way completely separate from the randomness of the data): it is not a (definite numerical) property of the distribution, even though it is related to that distribution. (As we just saw, though, the expectation of $y$ for $x=2$, equal to $\beta_0 + 2 \beta_1$, can be estimated.) In Lehmann's formulation, almost any formula can be an estimator of almost any property. There is no inherent mathematical link between an estimator and an estimand. However, we can assess--in advance--the chance that an estimator will be reasonably close to the quantity it is intended to estimate. Ways to do this, and how to exploit them, are the subject of estimation theory.
What is the relation between estimator and estimate? E. L. Lehmann, in his classic Theory of Point Estimation, answers this question on pp 1-2. The observations are now postulated to be the values taken on by random variables which are assumed to follo
12,691
What is the relation between estimator and estimate?
In short: an estimator is a function and an estimate is a value that summarizes an observed sample. An estimator is a function that maps a random sample to the parameter estimate: $$ \hat{\Theta}=t(X_1,X_2,...,X_n) $$ Note that an estimator of n random variables $X_1,X_2,...,X_n$ is a random variable $\hat{\Theta}$. For instance, an estimator is the sample mean: $$ \overline{X}=\frac{1}{n}\sum_{n=1}^nX_i $$ An estimate $\hat{\theta}$ is the result of applying the estimator function to a lowercase observed sample $x_1,x_2,...,x_n$: $$ \hat{\theta}=t(x_1,x_2,...,x_n) $$ For instance, an estimate of the observed sample $x_1,x_2,...,x_n$ is the sample mean: $$ \hat{\mu}=\overline{x}=\frac{1}{n}\sum_{n=1}^nx_i $$
What is the relation between estimator and estimate?
In short: an estimator is a function and an estimate is a value that summarizes an observed sample. An estimator is a function that maps a random sample to the parameter estimate: $$ \hat{\Theta}=t(X_
What is the relation between estimator and estimate? In short: an estimator is a function and an estimate is a value that summarizes an observed sample. An estimator is a function that maps a random sample to the parameter estimate: $$ \hat{\Theta}=t(X_1,X_2,...,X_n) $$ Note that an estimator of n random variables $X_1,X_2,...,X_n$ is a random variable $\hat{\Theta}$. For instance, an estimator is the sample mean: $$ \overline{X}=\frac{1}{n}\sum_{n=1}^nX_i $$ An estimate $\hat{\theta}$ is the result of applying the estimator function to a lowercase observed sample $x_1,x_2,...,x_n$: $$ \hat{\theta}=t(x_1,x_2,...,x_n) $$ For instance, an estimate of the observed sample $x_1,x_2,...,x_n$ is the sample mean: $$ \hat{\mu}=\overline{x}=\frac{1}{n}\sum_{n=1}^nx_i $$
What is the relation between estimator and estimate? In short: an estimator is a function and an estimate is a value that summarizes an observed sample. An estimator is a function that maps a random sample to the parameter estimate: $$ \hat{\Theta}=t(X_
12,692
What is the relation between estimator and estimate?
It might be helpful to illustrate whuber's answer in the context of a linear regression model. Let's say you have some bivariate data and you use Ordinary Least Squares to come up with the following model: Y = 6X + 1 At this point, you can take any value of X, plug it into the model and predict the outcome, Y. In this sense, you might think of the individual components of the generic form of the model (mX + B) as estimators. The sample data (which you presumably plugged into the generic model to calculate the specific values for m and B above) provided a basis on which you could come up with estimates for m and B respectively. Consistent with @whuber's points in our thread below, whatever values of Y a particular set of estimators generate you for are, in the context of linear regression, thought of as predicted values. (edited -- a few times -- to reflect the comments below)
What is the relation between estimator and estimate?
It might be helpful to illustrate whuber's answer in the context of a linear regression model. Let's say you have some bivariate data and you use Ordinary Least Squares to come up with the following m
What is the relation between estimator and estimate? It might be helpful to illustrate whuber's answer in the context of a linear regression model. Let's say you have some bivariate data and you use Ordinary Least Squares to come up with the following model: Y = 6X + 1 At this point, you can take any value of X, plug it into the model and predict the outcome, Y. In this sense, you might think of the individual components of the generic form of the model (mX + B) as estimators. The sample data (which you presumably plugged into the generic model to calculate the specific values for m and B above) provided a basis on which you could come up with estimates for m and B respectively. Consistent with @whuber's points in our thread below, whatever values of Y a particular set of estimators generate you for are, in the context of linear regression, thought of as predicted values. (edited -- a few times -- to reflect the comments below)
What is the relation between estimator and estimate? It might be helpful to illustrate whuber's answer in the context of a linear regression model. Let's say you have some bivariate data and you use Ordinary Least Squares to come up with the following m
12,693
What is the relation between estimator and estimate?
Suppose you received some data, and you had some observed variable called theta. Now your data can be from a distribution of data, for this distribution, there is a corresponding value of theta that you infer which is a random variable. You can use the MAP or mean for calculating the estimate of this random variable whenever the distribution of your data changes. So the random variable theta is known as an estimate, a single value of the unobserved variable for a particular type of data. While estimator is your data, which is also a random variable. For different types of distributions you have different types of data and thus you have a different estimate and thus this corresponding random variable is called the estimator.
What is the relation between estimator and estimate?
Suppose you received some data, and you had some observed variable called theta. Now your data can be from a distribution of data, for this distribution, there is a corresponding value of theta that y
What is the relation between estimator and estimate? Suppose you received some data, and you had some observed variable called theta. Now your data can be from a distribution of data, for this distribution, there is a corresponding value of theta that you infer which is a random variable. You can use the MAP or mean for calculating the estimate of this random variable whenever the distribution of your data changes. So the random variable theta is known as an estimate, a single value of the unobserved variable for a particular type of data. While estimator is your data, which is also a random variable. For different types of distributions you have different types of data and thus you have a different estimate and thus this corresponding random variable is called the estimator.
What is the relation between estimator and estimate? Suppose you received some data, and you had some observed variable called theta. Now your data can be from a distribution of data, for this distribution, there is a corresponding value of theta that y
12,694
Probability formula for a multivariate-bernoulli distribution
The random variable taking values in $\{0,1\}^n$ is a discrete random variable. Its distribution is fully described by probabilities $p_{\mathbf{i}}=P(X=\mathbf{i})$ with $\mathbf{i}\in\{0,1\}^n$. The probabilities $p_{i}$ and $p_{ij}$ you give are sums of $p_{\mathbf{i}}$ for certain indexes $\mathbf{i}$. Now it seems that you want to describe $p_{\mathbf{i}}$ by only using $p_i$ and $p_{ij}$. It is not possible without assuming certain properties on $p_{\mathbf{i}}$. To see that try to derive characteristic function of $X$. If we take $n=3$ we get \begin{align} Ee^{i(t_1X_1+t_2X_2+t_3X_3)}&=p_{000}+p_{100}e^{it_1}+p_{010}e^{it_2}+p_{001}e^{it_3}\\\\ &+p_{110}e^{i(t_1+t_2)}+p_{101}e^{i(t_1+t_3)}+p_{011}e^{i(t_2+t_3)}+p_{111}e^{i(t_1+t_2+t_3)} \end{align} It is not possible rearrange this expression so that $p_{\mathbf{i}}$ dissapear. For the gaussian random variable the characteristic function depends only on mean and covariance parameters. Characteristic functions uniquely define distributions, so this is why Gaussian can be described uniquely by using only mean and covariance. As we see for random variable $X$ this is not the case.
Probability formula for a multivariate-bernoulli distribution
The random variable taking values in $\{0,1\}^n$ is a discrete random variable. Its distribution is fully described by probabilities $p_{\mathbf{i}}=P(X=\mathbf{i})$ with $\mathbf{i}\in\{0,1\}^n$. T
Probability formula for a multivariate-bernoulli distribution The random variable taking values in $\{0,1\}^n$ is a discrete random variable. Its distribution is fully described by probabilities $p_{\mathbf{i}}=P(X=\mathbf{i})$ with $\mathbf{i}\in\{0,1\}^n$. The probabilities $p_{i}$ and $p_{ij}$ you give are sums of $p_{\mathbf{i}}$ for certain indexes $\mathbf{i}$. Now it seems that you want to describe $p_{\mathbf{i}}$ by only using $p_i$ and $p_{ij}$. It is not possible without assuming certain properties on $p_{\mathbf{i}}$. To see that try to derive characteristic function of $X$. If we take $n=3$ we get \begin{align} Ee^{i(t_1X_1+t_2X_2+t_3X_3)}&=p_{000}+p_{100}e^{it_1}+p_{010}e^{it_2}+p_{001}e^{it_3}\\\\ &+p_{110}e^{i(t_1+t_2)}+p_{101}e^{i(t_1+t_3)}+p_{011}e^{i(t_2+t_3)}+p_{111}e^{i(t_1+t_2+t_3)} \end{align} It is not possible rearrange this expression so that $p_{\mathbf{i}}$ dissapear. For the gaussian random variable the characteristic function depends only on mean and covariance parameters. Characteristic functions uniquely define distributions, so this is why Gaussian can be described uniquely by using only mean and covariance. As we see for random variable $X$ this is not the case.
Probability formula for a multivariate-bernoulli distribution The random variable taking values in $\{0,1\}^n$ is a discrete random variable. Its distribution is fully described by probabilities $p_{\mathbf{i}}=P(X=\mathbf{i})$ with $\mathbf{i}\in\{0,1\}^n$. T
12,695
Probability formula for a multivariate-bernoulli distribution
See the following paper: J. L. Teugels, Some representations of the multivariate Bernoulli and binomial distributions, Journal of Multivariate Analysis, vol. 32, no. 2, Feb. 1990, 256–268. Here is the abstract: Multivariate but vectorized versions for Bernoulli and binomial distributions are established using the concept of Kronecker product from matrix calculus. The multivariate Bernoulli distribution entails a parameterized model, that provides an alternative to the traditional log-linear model for binary variables.
Probability formula for a multivariate-bernoulli distribution
See the following paper: J. L. Teugels, Some representations of the multivariate Bernoulli and binomial distributions, Journal of Multivariate Analysis, vol. 32, no. 2, Feb. 1990, 256–268. Here is
Probability formula for a multivariate-bernoulli distribution See the following paper: J. L. Teugels, Some representations of the multivariate Bernoulli and binomial distributions, Journal of Multivariate Analysis, vol. 32, no. 2, Feb. 1990, 256–268. Here is the abstract: Multivariate but vectorized versions for Bernoulli and binomial distributions are established using the concept of Kronecker product from matrix calculus. The multivariate Bernoulli distribution entails a parameterized model, that provides an alternative to the traditional log-linear model for binary variables.
Probability formula for a multivariate-bernoulli distribution See the following paper: J. L. Teugels, Some representations of the multivariate Bernoulli and binomial distributions, Journal of Multivariate Analysis, vol. 32, no. 2, Feb. 1990, 256–268. Here is
12,696
Probability formula for a multivariate-bernoulli distribution
An $n$-dimensional Bernoulli distribution can be expressed in terms of an $n$ by $n$ matrix $\Sigma$, which is a matrix analogous to the covariance matrix of the Gaussian distribution, but not necessarily a symmetric matrix. For example, the diagonal elements of $\Sigma$ represent probabilities for a single element $p(X_i=1) = \Sigma_{ii} = \mu_i$. Probabilities for pairs of elements are given by the determinant of the submatrix of $\Sigma$: \begin{align*} p(X_i=1, X_j=1)=\det \begin{bmatrix} \Sigma_{ii} & \Sigma_{ij} \\ \Sigma_{ji} & \Sigma_{jj} \end{bmatrix}. \end{align*} In other words, the covariance between $X_i$ and $X_j$ is expressed as a product of off-diagonal elements as follows, \begin{align*} \mathrm{Cov}[X_i, X_j]=\mathrm{E}[(X_i-\mu_i)(X_j-\mu_j)] = -\Sigma_{ij} \Sigma_{ji}. \end{align*} Hence, covariance alone cannot uniquely determine the off-diagonal elements of $\Sigma$. However, model parameters of a distribution having a given mean and covariance can be obtained by the principle of entropy maximization. I think the above distribution is a canonical distribution for multivariate binary random variables in the sense that it shares similar properties to the multivariate Gaussian distribution. See the following paper for further details: T. Arai, "Multivariate binary probability distribution in the Grassmann formalism", Physical Review E 103, 062104, 2021.
Probability formula for a multivariate-bernoulli distribution
An $n$-dimensional Bernoulli distribution can be expressed in terms of an $n$ by $n$ matrix $\Sigma$, which is a matrix analogous to the covariance matrix of the Gaussian distribution, but not necessa
Probability formula for a multivariate-bernoulli distribution An $n$-dimensional Bernoulli distribution can be expressed in terms of an $n$ by $n$ matrix $\Sigma$, which is a matrix analogous to the covariance matrix of the Gaussian distribution, but not necessarily a symmetric matrix. For example, the diagonal elements of $\Sigma$ represent probabilities for a single element $p(X_i=1) = \Sigma_{ii} = \mu_i$. Probabilities for pairs of elements are given by the determinant of the submatrix of $\Sigma$: \begin{align*} p(X_i=1, X_j=1)=\det \begin{bmatrix} \Sigma_{ii} & \Sigma_{ij} \\ \Sigma_{ji} & \Sigma_{jj} \end{bmatrix}. \end{align*} In other words, the covariance between $X_i$ and $X_j$ is expressed as a product of off-diagonal elements as follows, \begin{align*} \mathrm{Cov}[X_i, X_j]=\mathrm{E}[(X_i-\mu_i)(X_j-\mu_j)] = -\Sigma_{ij} \Sigma_{ji}. \end{align*} Hence, covariance alone cannot uniquely determine the off-diagonal elements of $\Sigma$. However, model parameters of a distribution having a given mean and covariance can be obtained by the principle of entropy maximization. I think the above distribution is a canonical distribution for multivariate binary random variables in the sense that it shares similar properties to the multivariate Gaussian distribution. See the following paper for further details: T. Arai, "Multivariate binary probability distribution in the Grassmann formalism", Physical Review E 103, 062104, 2021.
Probability formula for a multivariate-bernoulli distribution An $n$-dimensional Bernoulli distribution can be expressed in terms of an $n$ by $n$ matrix $\Sigma$, which is a matrix analogous to the covariance matrix of the Gaussian distribution, but not necessa
12,697
Probability formula for a multivariate-bernoulli distribution
I don't know what the resulting distribution is called, or if it even has a name, but it strikes me the obvious way to set this up is to think of the model you'd use to model a 2×2×2×…×2 table using a log-linear (Poisson regression) model. As you know the 1st-order interactions only, it's then natural to assume that all higher-order interactions are zero. Using the questioner's notation, this gives the model: $$P(X_1=x_1, X_2=x_2,\ldots,X_n=x_n) = \prod_i \left[ p_i^{x_i}(1-p_i)^{1-x_i} \prod_{j<i} \left(\frac{p_{ij}}{p_i p_j}\right)^{x_i x_j} \right] $$
Probability formula for a multivariate-bernoulli distribution
I don't know what the resulting distribution is called, or if it even has a name, but it strikes me the obvious way to set this up is to think of the model you'd use to model a 2×2×2×…×2 table using a
Probability formula for a multivariate-bernoulli distribution I don't know what the resulting distribution is called, or if it even has a name, but it strikes me the obvious way to set this up is to think of the model you'd use to model a 2×2×2×…×2 table using a log-linear (Poisson regression) model. As you know the 1st-order interactions only, it's then natural to assume that all higher-order interactions are zero. Using the questioner's notation, this gives the model: $$P(X_1=x_1, X_2=x_2,\ldots,X_n=x_n) = \prod_i \left[ p_i^{x_i}(1-p_i)^{1-x_i} \prod_{j<i} \left(\frac{p_{ij}}{p_i p_j}\right)^{x_i x_j} \right] $$
Probability formula for a multivariate-bernoulli distribution I don't know what the resulting distribution is called, or if it even has a name, but it strikes me the obvious way to set this up is to think of the model you'd use to model a 2×2×2×…×2 table using a
12,698
Why the name "kernel" in stats and ML?
You can find some information on this matter by checking the website for earliest known uses for some of the words of mathematics maintained by mathematician Jeff Miller. You can also find information on the etymology of the word "kernel" in standard dictionary sources. Writing in French, Fredholm (1903) used the word "noyau" (core) and Hilbert (1904) adopted this term but wrote in German, yielding the German word "kern" (core). These terms were used in the context of writing about integral equations in functional analysis. Shortly after this, Bôcher (1909), writing in English, uses the term "kernel" to refer to the same objects. The term then spreads through the English-language literature on functional analysis, Fourier analysis, and later, probability and statistics. According to the above-linked dictionary, this word derives from Old-English and Proto-Germanic. It can refer either to a seed, or to the core, center or essence of an object. The linguistic similarity between the German "kern" and "kernel" appears to be due to similar historical derivations. The word "kernel" is alleged to have derived from a hypothesised (reconstructed) Proto-Germanic word "kurną" (corn). So, based on this history, it seems that etymologically, the word "kernel" refers to a seed, core or essence, and is based on the Anglicisation of an old German word for corn. UPDATE: This answer has been edited heavily to reflect new information that was brought to my attention by users cbeleites and R.M. I initially thought this may have been a recent Anglicisation of the word "kern", but the dictionary sources suggest that the word "kernel" in English is very old. I am not a linguist, so I am merely setting out information from the above sources.
Why the name "kernel" in stats and ML?
You can find some information on this matter by checking the website for earliest known uses for some of the words of mathematics maintained by mathematician Jeff Miller. You can also find informatio
Why the name "kernel" in stats and ML? You can find some information on this matter by checking the website for earliest known uses for some of the words of mathematics maintained by mathematician Jeff Miller. You can also find information on the etymology of the word "kernel" in standard dictionary sources. Writing in French, Fredholm (1903) used the word "noyau" (core) and Hilbert (1904) adopted this term but wrote in German, yielding the German word "kern" (core). These terms were used in the context of writing about integral equations in functional analysis. Shortly after this, Bôcher (1909), writing in English, uses the term "kernel" to refer to the same objects. The term then spreads through the English-language literature on functional analysis, Fourier analysis, and later, probability and statistics. According to the above-linked dictionary, this word derives from Old-English and Proto-Germanic. It can refer either to a seed, or to the core, center or essence of an object. The linguistic similarity between the German "kern" and "kernel" appears to be due to similar historical derivations. The word "kernel" is alleged to have derived from a hypothesised (reconstructed) Proto-Germanic word "kurną" (corn). So, based on this history, it seems that etymologically, the word "kernel" refers to a seed, core or essence, and is based on the Anglicisation of an old German word for corn. UPDATE: This answer has been edited heavily to reflect new information that was brought to my attention by users cbeleites and R.M. I initially thought this may have been a recent Anglicisation of the word "kern", but the dictionary sources suggest that the word "kernel" in English is very old. I am not a linguist, so I am merely setting out information from the above sources.
Why the name "kernel" in stats and ML? You can find some information on this matter by checking the website for earliest known uses for some of the words of mathematics maintained by mathematician Jeff Miller. You can also find informatio
12,699
Why the name "kernel" in stats and ML?
A kernel is used a multitude of times in Machine Learning and statistics. A few examples are: In Support Vector Machines a kernel is a function that maps the data to a higher-dimensional space where the problem becomes linearly solvable (watch this). Kernel Density Estimation Kernel Density Estimation is a non-parametric way to estimate the probability density function of a random variable. In this context a kernel is simply a weighting function used in kernel density estimation. The last link also has a few more uses of the word kernel in statistics. In Convolutional Neural Networks, a kernel is a small matrix that is used to perform the convolution between the image and itself. See here. In all these examples a kernel is a mathematical function that is used for some sort of transformation on your data. The kernel essentially is the constant part of that transformation. Depending on the choice of kernel we use for each transformation we might get a different effect from it.
Why the name "kernel" in stats and ML?
A kernel is used a multitude of times in Machine Learning and statistics. A few examples are: In Support Vector Machines a kernel is a function that maps the data to a higher-dimensional space where
Why the name "kernel" in stats and ML? A kernel is used a multitude of times in Machine Learning and statistics. A few examples are: In Support Vector Machines a kernel is a function that maps the data to a higher-dimensional space where the problem becomes linearly solvable (watch this). Kernel Density Estimation Kernel Density Estimation is a non-parametric way to estimate the probability density function of a random variable. In this context a kernel is simply a weighting function used in kernel density estimation. The last link also has a few more uses of the word kernel in statistics. In Convolutional Neural Networks, a kernel is a small matrix that is used to perform the convolution between the image and itself. See here. In all these examples a kernel is a mathematical function that is used for some sort of transformation on your data. The kernel essentially is the constant part of that transformation. Depending on the choice of kernel we use for each transformation we might get a different effect from it.
Why the name "kernel" in stats and ML? A kernel is used a multitude of times in Machine Learning and statistics. A few examples are: In Support Vector Machines a kernel is a function that maps the data to a higher-dimensional space where
12,700
Showing that 100 measurements for 5 subjects provide much less information than 5 measurements for 100 subjects
The short answer is that your conjecture is true when and only when there is a positive intra-class correlation in the data. Empirically speaking, most clustered datasets most of the time show a positive intra-class correlation, which means that in practice your conjecture is usually true. But if the intra-class correlation is 0, then the two cases you mentioned are equally informative. And if the intra-class correlation is negative, then it's actually less informative to take fewer measurements on more subjects; we would actually prefer (as far as reducing the variance of the parameter estimate is concerned) to take all our measurements on a single subject. Statistically there are two perspectives from which we can think about this: a random-effects (or mixed) model, which you mention in your question, or a marginal model, which ends up being a bit more informative here. Random-effects (mixed) model Say we have a set of $n$ subjects from whom we've taken $m$ measurements each. Then a simple random-effects model of the $j$th measurement from the $i$th subject might be $$ y_{ij} = \beta + u_i + e_{ij}, $$ where $\beta$ is the fixed intercept, $u_i$ is the random subject effect (with variance $\sigma^2_u$), $e_{ij}$ is the observation-level error term (with variance $\sigma^2_e$), and the latter two random terms are independent. In this model $\beta$ represents the population mean, and with a balanced dataset (i.e., an equal number of measurements from each subject), our best estimate is simply the sample mean. So if we take "more information" to mean a smaller variance for this estimate, then basically we want to know how the variance of the sample mean depends on $n$ and $m$. With a bit of algebra we can work out that $$ \begin{aligned} \text{var}(\frac{1}{nm}\sum_i\sum_jy_{ij}) &= \text{var}(\frac{1}{nm}\sum_i\sum_j\beta + u_i + e_{ij}) \\ &= \frac{1}{n^2m^2}\text{var}(\sum_i\sum_ju_i + \sum_i\sum_je_{ij}) \\ &= \frac{1}{n^2m^2}\Big(m^2\sum_i\text{var}(u_i) + \sum_i\sum_j\text{var}(e_{ij})\Big) \\ &= \frac{1}{n^2m^2}(nm^2\sigma^2_u + nm\sigma^2_e) \\ &= \frac{\sigma^2_u}{n} + \frac{\sigma^2_e}{nm}. \end{aligned} $$ Examining this expression, we can see that whenever there is any subject variance (i.e., $\sigma^2_u>0$), increasing the number of subjects ($n$) will make both of these terms smaller, while increasing the number of measurements per subject ($m$) will only make the second term smaller. (For a practical implication of this for designing multi-site replication projects, see this blog post I wrote a while ago.) Now you wanted to know what happens when we increase or decrease $m$ or $n$ while holding constant the total number of observations. So for that we consider $nm$ to be a constant, so that the whole variance expression just looks like $$ \frac{\sigma^2_u}{n} + \text{constant}, $$ which is as small as possible when $n$ is as large as possible (up to a maximum of $n=nm$, in which case $m=1$, meaning we take a single measurement from each subject). My short answer referred to the intra-class correlation, so where does that fit in? In this simple random-effects model the intra-class correlation is $$ \rho = \frac{\sigma^2_u}{\sigma^2_u + \sigma^2_e} $$ (sketch of a derivation here). So we can write the variance equation above as $$ \text{var}(\frac{1}{nm}\sum_i\sum_jy_{ij}) = \frac{\sigma^2_u}{n} + \frac{\sigma^2_e}{nm} = \Big(\frac{\rho}{n} + \frac{1-\rho}{nm}\Big)(\sigma^2_u+\sigma^2_e) $$ This doesn't really add any insight to what we already saw above, but it does make us wonder: since the intra-class correlation is a bona fide correlation coefficient, and correlation coefficients can be negative, what would happen (and what would it mean) if the intra-class correlation were negative? In the context of the random-effects model, a negative intra-class correlation doesn't really make sense, because it implies that the subject variance $\sigma^2_u$ is somehow negative (as we can see from the $\rho$ equation above, and as explained here and here)... but variances can't be negative! But this doesn't mean that the concept of a negative intra-class correlation doesn't make sense; it just means that the random-effects model doesn't have any way to express this concept, which is a failure of the model, not of the concept. To express this concept adequately we need to consider the marginal model. Marginal model For this same dataset we could consider a so-called marginal model of $y_{ij}$, $$ y_{ij} = \beta + e^*_{ij}, $$ where basically we've pushed the random subject effect $u_i$ from before into the error term $e_{ij}$ so that we have $e^*_{ij} = u_i + e_{ij}$. In the random-effects model we considered the two random terms $u_i$ and $e_{ij}$ to be i.i.d., but in the marginal model we instead consider $e^*_{ij}$ to follow a block-diagonal covariance matrix $\textbf{C}$ like $$\textbf{C}= \sigma^2\begin{bmatrix} \textbf{R} & 0& \cdots & 0\\ 0& \textbf{R} & \cdots & 0\\ \vdots & \vdots & \ddots & \vdots \\ 0& 0& \cdots &\textbf{R}\\ \end{bmatrix}, \textbf{R}= \begin{bmatrix} 1 & \rho & \cdots & \rho \\ \rho & 1 & \cdots & \rho \\ \vdots & \vdots & \ddots & \vdots \\ \rho & \rho & \cdots &1\\ \end{bmatrix} $$ In words, this means that under the marginal model we simply consider $\rho$ to be the expected correlation between two $e^*$s from the same subject (we assume the correlation across subjects is 0). When $\rho$ is positive, two observations drawn from the same subject tend to be more similar (closer together), on average, than two observations drawn randomly from the dataset while ignoring the clustering due to subjects. When $\rho$ is negative, two observations drawn from the same subject tend to be less similar (further apart), on average, than two observations drawn completely at random. (More information about this interpretation in the question/answers here.) So now when we look at the equation for the variance of the sample mean under the marginal model, we have $$ \begin{aligned} \text{var}(\frac{1}{nm}\sum_i\sum_jy_{ij}) &= \text{var}(\frac{1}{nm}\sum_i\sum_j\beta + e^*_{ij}) \\ &= \frac{1}{n^2m^2}\text{var}(\sum_i\sum_je^*_{ij}) \\ &= \frac{1}{n^2m^2}\Big(n\big(m\sigma^2 + (m^2-m)\rho\sigma^2\big)\Big) \\ &= \frac{\sigma^2\big(1+(m-1)\rho\big)}{nm} \\ &= \Big(\frac{\rho}{n}+\frac{1-\rho}{nm}\Big)\sigma^2, \end{aligned} $$ which is the same variance expression we derived above for the random-effects model, just with $\sigma^2_e+\sigma^2_u=\sigma^2$, which is consistent with our note above that $e^*_{ij} = u_i + e_{ij}$. The advantage of this (statistically equivalent) perspective is that here we can think about a negative intra-class correlation without needing to invoke any weird concepts like a negative subject variance. Negative intra-class correlations just fit naturally in this framework. (BTW, just a quick aside to point out that the second-to-last line of the derivation above implies that we must have $\rho \ge -1/(m-1)$, or else the whole equation is negative, but variances can't be negative! So there is a lower bound on the intra-class correlation that depends on how many measurements we have per cluster. For $m=2$ (i.e., we measure each subject twice), the intra-class correlation can go all the way down to $\rho=-1$; for $m=3$ it can only go down to $\rho=-1/2$; and so on. Fun fact!) So finally, once again considering the total number of observations $nm$ to be a constant, we see that the second-to-last line of the derivation above just looks like $$ \big(1+(m-1)\rho\big) \times \text{positive constant}. $$ So when $\rho>0$, having $m$ as small as possible (so that we take fewer measurements of more subjects--in the limit, 1 measurement of each subject) makes the variance of the estimate as small as possible. But when $\rho<0$, we actually want $m$ to be as large as possible (so that, in the limit, we take all $nm$ measurements from a single subject) in order to make the variance as small as possible. And when $\rho=0$, the variance of the estimate is just a constant, so our allocation of $m$ and $n$ doesn't matter.
Showing that 100 measurements for 5 subjects provide much less information than 5 measurements for 1
The short answer is that your conjecture is true when and only when there is a positive intra-class correlation in the data. Empirically speaking, most clustered datasets most of the time show a posit
Showing that 100 measurements for 5 subjects provide much less information than 5 measurements for 100 subjects The short answer is that your conjecture is true when and only when there is a positive intra-class correlation in the data. Empirically speaking, most clustered datasets most of the time show a positive intra-class correlation, which means that in practice your conjecture is usually true. But if the intra-class correlation is 0, then the two cases you mentioned are equally informative. And if the intra-class correlation is negative, then it's actually less informative to take fewer measurements on more subjects; we would actually prefer (as far as reducing the variance of the parameter estimate is concerned) to take all our measurements on a single subject. Statistically there are two perspectives from which we can think about this: a random-effects (or mixed) model, which you mention in your question, or a marginal model, which ends up being a bit more informative here. Random-effects (mixed) model Say we have a set of $n$ subjects from whom we've taken $m$ measurements each. Then a simple random-effects model of the $j$th measurement from the $i$th subject might be $$ y_{ij} = \beta + u_i + e_{ij}, $$ where $\beta$ is the fixed intercept, $u_i$ is the random subject effect (with variance $\sigma^2_u$), $e_{ij}$ is the observation-level error term (with variance $\sigma^2_e$), and the latter two random terms are independent. In this model $\beta$ represents the population mean, and with a balanced dataset (i.e., an equal number of measurements from each subject), our best estimate is simply the sample mean. So if we take "more information" to mean a smaller variance for this estimate, then basically we want to know how the variance of the sample mean depends on $n$ and $m$. With a bit of algebra we can work out that $$ \begin{aligned} \text{var}(\frac{1}{nm}\sum_i\sum_jy_{ij}) &= \text{var}(\frac{1}{nm}\sum_i\sum_j\beta + u_i + e_{ij}) \\ &= \frac{1}{n^2m^2}\text{var}(\sum_i\sum_ju_i + \sum_i\sum_je_{ij}) \\ &= \frac{1}{n^2m^2}\Big(m^2\sum_i\text{var}(u_i) + \sum_i\sum_j\text{var}(e_{ij})\Big) \\ &= \frac{1}{n^2m^2}(nm^2\sigma^2_u + nm\sigma^2_e) \\ &= \frac{\sigma^2_u}{n} + \frac{\sigma^2_e}{nm}. \end{aligned} $$ Examining this expression, we can see that whenever there is any subject variance (i.e., $\sigma^2_u>0$), increasing the number of subjects ($n$) will make both of these terms smaller, while increasing the number of measurements per subject ($m$) will only make the second term smaller. (For a practical implication of this for designing multi-site replication projects, see this blog post I wrote a while ago.) Now you wanted to know what happens when we increase or decrease $m$ or $n$ while holding constant the total number of observations. So for that we consider $nm$ to be a constant, so that the whole variance expression just looks like $$ \frac{\sigma^2_u}{n} + \text{constant}, $$ which is as small as possible when $n$ is as large as possible (up to a maximum of $n=nm$, in which case $m=1$, meaning we take a single measurement from each subject). My short answer referred to the intra-class correlation, so where does that fit in? In this simple random-effects model the intra-class correlation is $$ \rho = \frac{\sigma^2_u}{\sigma^2_u + \sigma^2_e} $$ (sketch of a derivation here). So we can write the variance equation above as $$ \text{var}(\frac{1}{nm}\sum_i\sum_jy_{ij}) = \frac{\sigma^2_u}{n} + \frac{\sigma^2_e}{nm} = \Big(\frac{\rho}{n} + \frac{1-\rho}{nm}\Big)(\sigma^2_u+\sigma^2_e) $$ This doesn't really add any insight to what we already saw above, but it does make us wonder: since the intra-class correlation is a bona fide correlation coefficient, and correlation coefficients can be negative, what would happen (and what would it mean) if the intra-class correlation were negative? In the context of the random-effects model, a negative intra-class correlation doesn't really make sense, because it implies that the subject variance $\sigma^2_u$ is somehow negative (as we can see from the $\rho$ equation above, and as explained here and here)... but variances can't be negative! But this doesn't mean that the concept of a negative intra-class correlation doesn't make sense; it just means that the random-effects model doesn't have any way to express this concept, which is a failure of the model, not of the concept. To express this concept adequately we need to consider the marginal model. Marginal model For this same dataset we could consider a so-called marginal model of $y_{ij}$, $$ y_{ij} = \beta + e^*_{ij}, $$ where basically we've pushed the random subject effect $u_i$ from before into the error term $e_{ij}$ so that we have $e^*_{ij} = u_i + e_{ij}$. In the random-effects model we considered the two random terms $u_i$ and $e_{ij}$ to be i.i.d., but in the marginal model we instead consider $e^*_{ij}$ to follow a block-diagonal covariance matrix $\textbf{C}$ like $$\textbf{C}= \sigma^2\begin{bmatrix} \textbf{R} & 0& \cdots & 0\\ 0& \textbf{R} & \cdots & 0\\ \vdots & \vdots & \ddots & \vdots \\ 0& 0& \cdots &\textbf{R}\\ \end{bmatrix}, \textbf{R}= \begin{bmatrix} 1 & \rho & \cdots & \rho \\ \rho & 1 & \cdots & \rho \\ \vdots & \vdots & \ddots & \vdots \\ \rho & \rho & \cdots &1\\ \end{bmatrix} $$ In words, this means that under the marginal model we simply consider $\rho$ to be the expected correlation between two $e^*$s from the same subject (we assume the correlation across subjects is 0). When $\rho$ is positive, two observations drawn from the same subject tend to be more similar (closer together), on average, than two observations drawn randomly from the dataset while ignoring the clustering due to subjects. When $\rho$ is negative, two observations drawn from the same subject tend to be less similar (further apart), on average, than two observations drawn completely at random. (More information about this interpretation in the question/answers here.) So now when we look at the equation for the variance of the sample mean under the marginal model, we have $$ \begin{aligned} \text{var}(\frac{1}{nm}\sum_i\sum_jy_{ij}) &= \text{var}(\frac{1}{nm}\sum_i\sum_j\beta + e^*_{ij}) \\ &= \frac{1}{n^2m^2}\text{var}(\sum_i\sum_je^*_{ij}) \\ &= \frac{1}{n^2m^2}\Big(n\big(m\sigma^2 + (m^2-m)\rho\sigma^2\big)\Big) \\ &= \frac{\sigma^2\big(1+(m-1)\rho\big)}{nm} \\ &= \Big(\frac{\rho}{n}+\frac{1-\rho}{nm}\Big)\sigma^2, \end{aligned} $$ which is the same variance expression we derived above for the random-effects model, just with $\sigma^2_e+\sigma^2_u=\sigma^2$, which is consistent with our note above that $e^*_{ij} = u_i + e_{ij}$. The advantage of this (statistically equivalent) perspective is that here we can think about a negative intra-class correlation without needing to invoke any weird concepts like a negative subject variance. Negative intra-class correlations just fit naturally in this framework. (BTW, just a quick aside to point out that the second-to-last line of the derivation above implies that we must have $\rho \ge -1/(m-1)$, or else the whole equation is negative, but variances can't be negative! So there is a lower bound on the intra-class correlation that depends on how many measurements we have per cluster. For $m=2$ (i.e., we measure each subject twice), the intra-class correlation can go all the way down to $\rho=-1$; for $m=3$ it can only go down to $\rho=-1/2$; and so on. Fun fact!) So finally, once again considering the total number of observations $nm$ to be a constant, we see that the second-to-last line of the derivation above just looks like $$ \big(1+(m-1)\rho\big) \times \text{positive constant}. $$ So when $\rho>0$, having $m$ as small as possible (so that we take fewer measurements of more subjects--in the limit, 1 measurement of each subject) makes the variance of the estimate as small as possible. But when $\rho<0$, we actually want $m$ to be as large as possible (so that, in the limit, we take all $nm$ measurements from a single subject) in order to make the variance as small as possible. And when $\rho=0$, the variance of the estimate is just a constant, so our allocation of $m$ and $n$ doesn't matter.
Showing that 100 measurements for 5 subjects provide much less information than 5 measurements for 1 The short answer is that your conjecture is true when and only when there is a positive intra-class correlation in the data. Empirically speaking, most clustered datasets most of the time show a posit