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
|
|---|---|---|---|---|---|---|
7,501
|
Should training samples randomly drawn for mini-batch training neural nets be drawn without replacement?
|
I loved your question because I found exactly the same issue. No one explicitly indicates if this is with or without replacement. Based on my own logic, it has to be with replacement since one epoch should contain all the training samples (by definition) and the following expression remains when training a NN (for example in Keras):
$$ i = \lceil s / b \rceil$$
where:
$i$ : Number of iterations per epoch
$s$ : Number of samples in the dataset
$b$ : (mini) Batch size
Otherwise, the definition of an epoch should be changed to a more generic one.
|
Should training samples randomly drawn for mini-batch training neural nets be drawn without replacem
|
I loved your question because I found exactly the same issue. No one explicitly indicates if this is with or without replacement. Based on my own logic, it has to be with replacement since one epoch s
|
Should training samples randomly drawn for mini-batch training neural nets be drawn without replacement?
I loved your question because I found exactly the same issue. No one explicitly indicates if this is with or without replacement. Based on my own logic, it has to be with replacement since one epoch should contain all the training samples (by definition) and the following expression remains when training a NN (for example in Keras):
$$ i = \lceil s / b \rceil$$
where:
$i$ : Number of iterations per epoch
$s$ : Number of samples in the dataset
$b$ : (mini) Batch size
Otherwise, the definition of an epoch should be changed to a more generic one.
|
Should training samples randomly drawn for mini-batch training neural nets be drawn without replacem
I loved your question because I found exactly the same issue. No one explicitly indicates if this is with or without replacement. Based on my own logic, it has to be with replacement since one epoch s
|
7,502
|
Is there any difference between $r^2$ and $R^2$?
|
Notation on this matter seems to vary a little.
$R$ is used in the context of multiple correlation and is called the "multiple correlation coefficient". It is the correlation between the observed responses $Y$ and the $\hat Y$ fitted by the model. The $\hat Y$ is generally predicted from several predictor variables $X_i$, e.g. $\hat Y = \hat \beta_0 + \hat \beta_1 X_1 + \hat \beta_2 X_2$ where the intercept and slope coefficients $\hat \beta_i$ have been estimated from the data. Note that $0 \leq R \leq 1$.
The symbol $r$ is the "sample correlation coefficient" used in the bivariate case - i.e. there are two variables, $X$ and $Y$ - and it usually means the correlation between $X$ and $Y$ in your sample. You can treat this as an estimate of the correlation $\rho$ between the two variables in the wider population. To correlate two variables it is not necessary to identify which one is the predictor and which one is the response. Indeed if you found the correlation between $Y$ and $X$ it would be the same as the correlation between $X$ and $Y$, because correlation is symmetric. Note that $-1 \leq r \leq 1$ when the symbol $r$ is used this way, with $r < 0$ (negative correlation) if the two variables have a linearly decreasing relationship (as one goes up, the other tends to go down).
Where the notation becomes inconsistent is when there are two variables, $X$ and $Y$, and a simple linear regression is performed. This means identifying one variable, $Y$, as the response variable, and the other, $X$, as the predictor variable, and fitting the model $\hat Y = \hat \beta_0 + \hat \beta_1 X$. Some people also use the symbol $r$ to indicate the correlation between $Y$ and $\hat Y$ while others (for consistency with multiple regression) write $R$. Note that the correlation between observed and fitted responses is necessarily greater than or equal to zero, provided the model included an intercept term.* This is one reason I don't like the use of the symbol $r$ in this case: the correlation between $X$ and $Y$ might be negative, while the correlation between $Y$ and $\hat Y$ is positive (in fact it will simply be the modulus of the correlation between $X$ and $Y$) yet both might be written with the symbol $r$. I've seen some textbooks, and Wikipedia articles, switch almost interchangeably between the two meanings of $r$ and found it unnecessarily confusing. I prefer to use the symbol $R$ for the correlation between $Y$ and $\hat Y$ in both single and multiple regression.
In both simple and multiple regresion, then so long as there is an intercept term fitted in the model, the $R$ between $Y$ and $\hat Y$ is simply the square root of the coefficient of determination $R^2$ (often called "proportion of variance explained" or similar). In the case of simple linear regression specifically, then $R^2 = r^2$ where I am writing $r$ for the correlation between $X$ and $Y$, and $R^2$ could represent either the coefficient of determination of the regression or the square of the correlation between $Y$ and $\hat Y$. Since $-1 \leq r \leq 1$ and $0 \leq R \leq 1$, this means that $R = |r|$. So for example, if you get a correlation between $X$ and $Y$ of $r=-0.7$ then the correlation between $Y$ and the fitted $\hat Y$ from the simple linear regression $Y = \hat \beta_0 + \hat \beta_1 X$ would be $R = 0.7$ and the coefficient of determination would be $R^2 = 0.49$ i.e. almost half of variation in the response would be explained by your model.
If no intercept term was included in the model, then the symbol $R^2$ is ambiguous. It is usually intended as the coefficient of determination, but this will generally be calculated in a different way to usual, so take care when reading the output from your statistical software. Then it is no longer the same as the square of the multiple correlation $R$, nor in the bivariate case will it equal $r^2$! Indeed the coefficient of determination can even become negative when an intercept term is excluded, in which case "R-squared" is clearly a misnomer.
$(*)$ It's possible for the correlation between $y$ and $\hat y$ to become negative if no intercept term is included, e.g. $\{(0,2), (1,0), (2,1)\}$ has OLS best-fit $\hat y = 0.4x$ without an intercept, and $\text{Corr}(y, \hat y) = \text{Corr}(x,y) = -0.5$.
|
Is there any difference between $r^2$ and $R^2$?
|
Notation on this matter seems to vary a little.
$R$ is used in the context of multiple correlation and is called the "multiple correlation coefficient". It is the correlation between the observed resp
|
Is there any difference between $r^2$ and $R^2$?
Notation on this matter seems to vary a little.
$R$ is used in the context of multiple correlation and is called the "multiple correlation coefficient". It is the correlation between the observed responses $Y$ and the $\hat Y$ fitted by the model. The $\hat Y$ is generally predicted from several predictor variables $X_i$, e.g. $\hat Y = \hat \beta_0 + \hat \beta_1 X_1 + \hat \beta_2 X_2$ where the intercept and slope coefficients $\hat \beta_i$ have been estimated from the data. Note that $0 \leq R \leq 1$.
The symbol $r$ is the "sample correlation coefficient" used in the bivariate case - i.e. there are two variables, $X$ and $Y$ - and it usually means the correlation between $X$ and $Y$ in your sample. You can treat this as an estimate of the correlation $\rho$ between the two variables in the wider population. To correlate two variables it is not necessary to identify which one is the predictor and which one is the response. Indeed if you found the correlation between $Y$ and $X$ it would be the same as the correlation between $X$ and $Y$, because correlation is symmetric. Note that $-1 \leq r \leq 1$ when the symbol $r$ is used this way, with $r < 0$ (negative correlation) if the two variables have a linearly decreasing relationship (as one goes up, the other tends to go down).
Where the notation becomes inconsistent is when there are two variables, $X$ and $Y$, and a simple linear regression is performed. This means identifying one variable, $Y$, as the response variable, and the other, $X$, as the predictor variable, and fitting the model $\hat Y = \hat \beta_0 + \hat \beta_1 X$. Some people also use the symbol $r$ to indicate the correlation between $Y$ and $\hat Y$ while others (for consistency with multiple regression) write $R$. Note that the correlation between observed and fitted responses is necessarily greater than or equal to zero, provided the model included an intercept term.* This is one reason I don't like the use of the symbol $r$ in this case: the correlation between $X$ and $Y$ might be negative, while the correlation between $Y$ and $\hat Y$ is positive (in fact it will simply be the modulus of the correlation between $X$ and $Y$) yet both might be written with the symbol $r$. I've seen some textbooks, and Wikipedia articles, switch almost interchangeably between the two meanings of $r$ and found it unnecessarily confusing. I prefer to use the symbol $R$ for the correlation between $Y$ and $\hat Y$ in both single and multiple regression.
In both simple and multiple regresion, then so long as there is an intercept term fitted in the model, the $R$ between $Y$ and $\hat Y$ is simply the square root of the coefficient of determination $R^2$ (often called "proportion of variance explained" or similar). In the case of simple linear regression specifically, then $R^2 = r^2$ where I am writing $r$ for the correlation between $X$ and $Y$, and $R^2$ could represent either the coefficient of determination of the regression or the square of the correlation between $Y$ and $\hat Y$. Since $-1 \leq r \leq 1$ and $0 \leq R \leq 1$, this means that $R = |r|$. So for example, if you get a correlation between $X$ and $Y$ of $r=-0.7$ then the correlation between $Y$ and the fitted $\hat Y$ from the simple linear regression $Y = \hat \beta_0 + \hat \beta_1 X$ would be $R = 0.7$ and the coefficient of determination would be $R^2 = 0.49$ i.e. almost half of variation in the response would be explained by your model.
If no intercept term was included in the model, then the symbol $R^2$ is ambiguous. It is usually intended as the coefficient of determination, but this will generally be calculated in a different way to usual, so take care when reading the output from your statistical software. Then it is no longer the same as the square of the multiple correlation $R$, nor in the bivariate case will it equal $r^2$! Indeed the coefficient of determination can even become negative when an intercept term is excluded, in which case "R-squared" is clearly a misnomer.
$(*)$ It's possible for the correlation between $y$ and $\hat y$ to become negative if no intercept term is included, e.g. $\{(0,2), (1,0), (2,1)\}$ has OLS best-fit $\hat y = 0.4x$ without an intercept, and $\text{Corr}(y, \hat y) = \text{Corr}(x,y) = -0.5$.
|
Is there any difference between $r^2$ and $R^2$?
Notation on this matter seems to vary a little.
$R$ is used in the context of multiple correlation and is called the "multiple correlation coefficient". It is the correlation between the observed resp
|
7,503
|
Why are bias nodes used in neural networks?
|
The bias node in a neural network is a node that is always 'on'. That is, its value is set to $1$ without regard for the data in a given pattern. It is analogous to the intercept in a regression model, and serves the same function. If a neural network does not have a bias node in a given layer, it will not be able to produce output in the next layer that differs from $0$ (on the linear scale, or the value that corresponds to the transformation of $0$ when passed through the activation function) when the feature values are $0$.
Consider a simple example: You have a feed forward perceptron with 2 input nodes $x_1$ and $x_2$, and 1 output node $y$. $x_1$ and $x_2$ are binary features and set at their reference level, $x_1=x_2=0$. Multiply those 2 $0$'s by whatever weights you like, $w_1$ and $w_2$, sum the products and pass it through whatever activation function you prefer. Without a bias node, only one output value is possible, which may yield a very poor fit. For instance, using a logistic activation function, $y$ must be $.5$, which would be awful for classifying rare events.
A bias node provides considerable flexibility to a neural network model. In the example given above, the only predicted proportion possible without a bias node was $50\%$, but with a bias node, any proportion in $(0, 1)$ can be fit for the patterns where $x_1=x_2=0$. For each layer, $j$, in which a bias node is added, the bias node will add $N_{j+1}$ additional parameters / weights to be estimated (where $N_{j+1}$ is the number of nodes in layer $j+1$). More parameters to be fitted means it will take proportionately longer for the neural network to be trained. It also increases the chance of overfitting, if you don't have considerably more data than weights to be learned.
With this understanding in mind, we can answer your explicit questions:
Bias nodes are added to increase the flexibility of the model to fit the data. Specifically, it allows the network to fit the data when all input features are equal to $0$, and very likely decreases the bias of the fitted values elsewhere in the data space.
Typically, a single bias node is added for the input layer and every hidden layer in a feedforward network. You would never add two or more to a given layer, but you might add zero. The total number is thus determined largely by the structure of your network, although other considerations could apply. (I am less clear on how bias nodes are added to neural network structures other than feedforward.)
Mostly this has been covered, but to be explicit: you would never add a bias node to the output layer; that wouldn't make any sense.
|
Why are bias nodes used in neural networks?
|
The bias node in a neural network is a node that is always 'on'. That is, its value is set to $1$ without regard for the data in a given pattern. It is analogous to the intercept in a regression mod
|
Why are bias nodes used in neural networks?
The bias node in a neural network is a node that is always 'on'. That is, its value is set to $1$ without regard for the data in a given pattern. It is analogous to the intercept in a regression model, and serves the same function. If a neural network does not have a bias node in a given layer, it will not be able to produce output in the next layer that differs from $0$ (on the linear scale, or the value that corresponds to the transformation of $0$ when passed through the activation function) when the feature values are $0$.
Consider a simple example: You have a feed forward perceptron with 2 input nodes $x_1$ and $x_2$, and 1 output node $y$. $x_1$ and $x_2$ are binary features and set at their reference level, $x_1=x_2=0$. Multiply those 2 $0$'s by whatever weights you like, $w_1$ and $w_2$, sum the products and pass it through whatever activation function you prefer. Without a bias node, only one output value is possible, which may yield a very poor fit. For instance, using a logistic activation function, $y$ must be $.5$, which would be awful for classifying rare events.
A bias node provides considerable flexibility to a neural network model. In the example given above, the only predicted proportion possible without a bias node was $50\%$, but with a bias node, any proportion in $(0, 1)$ can be fit for the patterns where $x_1=x_2=0$. For each layer, $j$, in which a bias node is added, the bias node will add $N_{j+1}$ additional parameters / weights to be estimated (where $N_{j+1}$ is the number of nodes in layer $j+1$). More parameters to be fitted means it will take proportionately longer for the neural network to be trained. It also increases the chance of overfitting, if you don't have considerably more data than weights to be learned.
With this understanding in mind, we can answer your explicit questions:
Bias nodes are added to increase the flexibility of the model to fit the data. Specifically, it allows the network to fit the data when all input features are equal to $0$, and very likely decreases the bias of the fitted values elsewhere in the data space.
Typically, a single bias node is added for the input layer and every hidden layer in a feedforward network. You would never add two or more to a given layer, but you might add zero. The total number is thus determined largely by the structure of your network, although other considerations could apply. (I am less clear on how bias nodes are added to neural network structures other than feedforward.)
Mostly this has been covered, but to be explicit: you would never add a bias node to the output layer; that wouldn't make any sense.
|
Why are bias nodes used in neural networks?
The bias node in a neural network is a node that is always 'on'. That is, its value is set to $1$ without regard for the data in a given pattern. It is analogous to the intercept in a regression mod
|
7,504
|
Why are bias nodes used in neural networks?
|
In the context of neural networks, Batch Normalization is currently the gold-standard for making smart "bias nodes." Instead of clamping a neuron's bias value, you instead adjust for the covariance of the neuron's input. So in a CNN, you would apply a batch normalization just between the convolutional layer and the next fully connected layer (of say, ReLus). In theory, all fully connected layers could benefit from Batch Normalization but this in practice becomes very expensive to implement since each batch normalization carries its own parameters.
Concerning why, most of the answers already have explained that, in particular, neurons are susceptible to saturated gradients when the input pushes the activation to an extreme. In the case of ReLu's this would be pushed to the left, giving a gradient of 0. In general, when you train a model, you first normalize the inputs to the neural network. Batch Normalization is a way of normalizing the inputs inside the neural network, between layers.
|
Why are bias nodes used in neural networks?
|
In the context of neural networks, Batch Normalization is currently the gold-standard for making smart "bias nodes." Instead of clamping a neuron's bias value, you instead adjust for the covariance of
|
Why are bias nodes used in neural networks?
In the context of neural networks, Batch Normalization is currently the gold-standard for making smart "bias nodes." Instead of clamping a neuron's bias value, you instead adjust for the covariance of the neuron's input. So in a CNN, you would apply a batch normalization just between the convolutional layer and the next fully connected layer (of say, ReLus). In theory, all fully connected layers could benefit from Batch Normalization but this in practice becomes very expensive to implement since each batch normalization carries its own parameters.
Concerning why, most of the answers already have explained that, in particular, neurons are susceptible to saturated gradients when the input pushes the activation to an extreme. In the case of ReLu's this would be pushed to the left, giving a gradient of 0. In general, when you train a model, you first normalize the inputs to the neural network. Batch Normalization is a way of normalizing the inputs inside the neural network, between layers.
|
Why are bias nodes used in neural networks?
In the context of neural networks, Batch Normalization is currently the gold-standard for making smart "bias nodes." Instead of clamping a neuron's bias value, you instead adjust for the covariance of
|
7,505
|
Why are bias nodes used in neural networks?
|
Simple, short answers:
To shift the input function / be more flexible about the learned function.
A single bias node per layer.
Add them to all hidden layers and the input layer - with some footnotes
In a couple of experiments in my masters thesis (e.g. page 59), I found that the bias might be important for the first layer(s), but especially at the fully connected layers at the end it seems not to play a big role. Hence one can have them at the first few layers and not at the last ones. Simply train a network, plot the distribution of weights of the bias nodes and prune them if the weights seem to be too close to zero.
This might be highly dependent on the network architecture / dataset.
|
Why are bias nodes used in neural networks?
|
Simple, short answers:
To shift the input function / be more flexible about the learned function.
A single bias node per layer.
Add them to all hidden layers and the input layer - with some footnotes
|
Why are bias nodes used in neural networks?
Simple, short answers:
To shift the input function / be more flexible about the learned function.
A single bias node per layer.
Add them to all hidden layers and the input layer - with some footnotes
In a couple of experiments in my masters thesis (e.g. page 59), I found that the bias might be important for the first layer(s), but especially at the fully connected layers at the end it seems not to play a big role. Hence one can have them at the first few layers and not at the last ones. Simply train a network, plot the distribution of weights of the bias nodes and prune them if the weights seem to be too close to zero.
This might be highly dependent on the network architecture / dataset.
|
Why are bias nodes used in neural networks?
Simple, short answers:
To shift the input function / be more flexible about the learned function.
A single bias node per layer.
Add them to all hidden layers and the input layer - with some footnotes
|
7,506
|
Gradient backpropagation through ResNet skip connections
|
Add sends the gradient back equally to both inputs. You can convince yourself of this by running the following in tensorflow:
import tensorflow as tf
graph = tf.Graph()
with graph.as_default():
x1_tf = tf.Variable(1.5, name='x1')
x2_tf = tf.Variable(3.5, name='x2')
out_tf = x1_tf + x2_tf
grads_tf = tf.gradients(ys=[out_tf], xs=[x1_tf, x2_tf])
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
fd = {
out_tf: 10.0
}
print(sess.run(grads_tf, feed_dict=fd))
Output:
[1.0, 1.0]
So, the gradient will be:
passed back to previous layers, unchanged, via the skip-layer connection, and also
passed to the block with weights, and used to update those weights
Edit: there is a question: "what is the operation at the point where the highway connection and the neural net block join back together again, at the bottom of Figure 2?"
There answer is: they are summed. You can see this from Figure 2's formula:
$$
\mathbf{\text{output}} \leftarrow \mathcal{F}(\mathbf{x}) + \mathbf{x}
$$
What this says is that:
the values in the bus ($\mathbf{x}$)
are added to the results of passing the bus values, $\mathbf{x}$, through the network, ie $\mathcal{F}(\mathbf{x})$
to give the output from the residual block, which I've labelled here as $\mathbf{\text{output}}$
Edit 2:
Rewriting in slightly different words:
in the forwards direction, the input data flows down the bus
at points along the bus, residual blocks can learn to add/remove values to the bus vector
in the backwards direction, the gradients flow back down the bus
along the way, the gradients update the residual blocks they move past
the residual blocks will themselves modify the gradients slightly too
The residual blocks do modify the gradients flowing backwards, but there are no 'squashing' or 'activation' functions that the gradients flow through. 'squashing'/'activation' functions are what causes the exploding/vanishing gradient problem, so by removing those from the bus itself, we mitigate this problem considerably.
Edit 3: Personally I imagine a resnet in my head as the following diagram. Its topologically identical to figure 2, but it shows more clearly perhaps how the bus just flows straight through the network, whilst the residual blocks just tap the values from it, and add/remove some small vector against the bus:
|
Gradient backpropagation through ResNet skip connections
|
Add sends the gradient back equally to both inputs. You can convince yourself of this by running the following in tensorflow:
import tensorflow as tf
graph = tf.Graph()
with graph.as_default():
x
|
Gradient backpropagation through ResNet skip connections
Add sends the gradient back equally to both inputs. You can convince yourself of this by running the following in tensorflow:
import tensorflow as tf
graph = tf.Graph()
with graph.as_default():
x1_tf = tf.Variable(1.5, name='x1')
x2_tf = tf.Variable(3.5, name='x2')
out_tf = x1_tf + x2_tf
grads_tf = tf.gradients(ys=[out_tf], xs=[x1_tf, x2_tf])
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
fd = {
out_tf: 10.0
}
print(sess.run(grads_tf, feed_dict=fd))
Output:
[1.0, 1.0]
So, the gradient will be:
passed back to previous layers, unchanged, via the skip-layer connection, and also
passed to the block with weights, and used to update those weights
Edit: there is a question: "what is the operation at the point where the highway connection and the neural net block join back together again, at the bottom of Figure 2?"
There answer is: they are summed. You can see this from Figure 2's formula:
$$
\mathbf{\text{output}} \leftarrow \mathcal{F}(\mathbf{x}) + \mathbf{x}
$$
What this says is that:
the values in the bus ($\mathbf{x}$)
are added to the results of passing the bus values, $\mathbf{x}$, through the network, ie $\mathcal{F}(\mathbf{x})$
to give the output from the residual block, which I've labelled here as $\mathbf{\text{output}}$
Edit 2:
Rewriting in slightly different words:
in the forwards direction, the input data flows down the bus
at points along the bus, residual blocks can learn to add/remove values to the bus vector
in the backwards direction, the gradients flow back down the bus
along the way, the gradients update the residual blocks they move past
the residual blocks will themselves modify the gradients slightly too
The residual blocks do modify the gradients flowing backwards, but there are no 'squashing' or 'activation' functions that the gradients flow through. 'squashing'/'activation' functions are what causes the exploding/vanishing gradient problem, so by removing those from the bus itself, we mitigate this problem considerably.
Edit 3: Personally I imagine a resnet in my head as the following diagram. Its topologically identical to figure 2, but it shows more clearly perhaps how the bus just flows straight through the network, whilst the residual blocks just tap the values from it, and add/remove some small vector against the bus:
|
Gradient backpropagation through ResNet skip connections
Add sends the gradient back equally to both inputs. You can convince yourself of this by running the following in tensorflow:
import tensorflow as tf
graph = tf.Graph()
with graph.as_default():
x
|
7,507
|
Gradient backpropagation through ResNet skip connections
|
I'd like to recommend this limpid article: CS231n Convolutional Neural Networks for Visual Recognition, and let me compare the (simplified) vanilla network with the (simplified) residual network as follows.
Here is a diagram I borrowed from that page:
where the green numbers above the lines indicate the forward pass, and the red numbers the backward pass(with the initial gradient 1).
And let's make a little change by adding a residual somewhere to get this one:
where the blue numbers above the lines indicate the forward pass, and the red numbers below the lines the backward pass(with the initial gradient 1).
Here is the code for the last example:
# use tensorflow 1.12
x = tf.Variable(3, name='x', dtype=tf.float32)
y = tf.Variable(-4, name='y', dtype=tf.float32)
z = tf.Variable(2, name='z', dtype=tf.float32)
w = tf.Variable(-1, name='w', dtype=tf.float32)
x_multiply_y = tf.math.multiply(x, y, name="x_multiply_y")
z_max_w = tf.math.maximum(z, w, name="z_max_w")
xy_plus_zw = tf.math.add(z_max_w, x_multiply_y, name="xy_plus_zw")
residual_op = tf.math.add(x_multiply_y, xy_plus_zw, name="residual_op")
multiply_2 = tf.math.multiply(residual_op, 2, name="multiply_2")
# to make sure that the last gradient is 1 we make the cost 1
cost = multiply_2 + 45
optimizer = tf.train.AdamOptimizer()
variables = tf.trainable_variables()
all_ops = variables + [x_multiply_y, z_max_w, xy_plus_zw, residual_op, multiply_2]
gradients = optimizer.compute_gradients(cost, all_ops)
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)
variables = [g[1] for g in gradients]
gradients = [g[0] for g in gradients]
gradients = sess.run(gradients)
for var, gdt in zip(variables, gradients):
print(var.name, "\t", gdt)
# the results are here:
# x:0 -16.0
# y:0 12.0
# z:0 2.0
# w:0 0.0
# x_multiply_y:0 4.0
# z_max_w:0 2.0
# xy_plus_zw:0 2.0
# residual_op:0 2.0
# multiply_2:0 1.0
We can see that the gradients are accumulated from different sources.
HTH.
|
Gradient backpropagation through ResNet skip connections
|
I'd like to recommend this limpid article: CS231n Convolutional Neural Networks for Visual Recognition, and let me compare the (simplified) vanilla network with the (simplified) residual network as fo
|
Gradient backpropagation through ResNet skip connections
I'd like to recommend this limpid article: CS231n Convolutional Neural Networks for Visual Recognition, and let me compare the (simplified) vanilla network with the (simplified) residual network as follows.
Here is a diagram I borrowed from that page:
where the green numbers above the lines indicate the forward pass, and the red numbers the backward pass(with the initial gradient 1).
And let's make a little change by adding a residual somewhere to get this one:
where the blue numbers above the lines indicate the forward pass, and the red numbers below the lines the backward pass(with the initial gradient 1).
Here is the code for the last example:
# use tensorflow 1.12
x = tf.Variable(3, name='x', dtype=tf.float32)
y = tf.Variable(-4, name='y', dtype=tf.float32)
z = tf.Variable(2, name='z', dtype=tf.float32)
w = tf.Variable(-1, name='w', dtype=tf.float32)
x_multiply_y = tf.math.multiply(x, y, name="x_multiply_y")
z_max_w = tf.math.maximum(z, w, name="z_max_w")
xy_plus_zw = tf.math.add(z_max_w, x_multiply_y, name="xy_plus_zw")
residual_op = tf.math.add(x_multiply_y, xy_plus_zw, name="residual_op")
multiply_2 = tf.math.multiply(residual_op, 2, name="multiply_2")
# to make sure that the last gradient is 1 we make the cost 1
cost = multiply_2 + 45
optimizer = tf.train.AdamOptimizer()
variables = tf.trainable_variables()
all_ops = variables + [x_multiply_y, z_max_w, xy_plus_zw, residual_op, multiply_2]
gradients = optimizer.compute_gradients(cost, all_ops)
init = tf.global_variables_initializer()
sess = tf.Session()
sess.run(init)
variables = [g[1] for g in gradients]
gradients = [g[0] for g in gradients]
gradients = sess.run(gradients)
for var, gdt in zip(variables, gradients):
print(var.name, "\t", gdt)
# the results are here:
# x:0 -16.0
# y:0 12.0
# z:0 2.0
# w:0 0.0
# x_multiply_y:0 4.0
# z_max_w:0 2.0
# xy_plus_zw:0 2.0
# residual_op:0 2.0
# multiply_2:0 1.0
We can see that the gradients are accumulated from different sources.
HTH.
|
Gradient backpropagation through ResNet skip connections
I'd like to recommend this limpid article: CS231n Convolutional Neural Networks for Visual Recognition, and let me compare the (simplified) vanilla network with the (simplified) residual network as fo
|
7,508
|
Cross-validation misuse (reporting performance for the best hyperparameter value)
|
Yes, there are issues with reporting only k-fold CV results. You could use e.g. the following three publications for your purpose (though there are more out there, of course) to point people towards the right direction:
Varma & Simon (2006). "Bias in error estimation when using cross-validation for model selection." BMC Bioinformatics, 7: 91
Cawley & Talbot (2010). "On Over-fitting in Model Selection and Subsequent Selection Bias in Performance Evaluation." Journal of Machine Learning Research, 11: 2079-2107
Bengio & Grandvalet (2004). "No Unbiased Estimator of the Variance of $K$-Fold Cross-Validation." Journal of Machine Learning Research, 5: 1089–1105
I personally like those because they try to state the issues more in plain English than in Math.
|
Cross-validation misuse (reporting performance for the best hyperparameter value)
|
Yes, there are issues with reporting only k-fold CV results. You could use e.g. the following three publications for your purpose (though there are more out there, of course) to point people towards t
|
Cross-validation misuse (reporting performance for the best hyperparameter value)
Yes, there are issues with reporting only k-fold CV results. You could use e.g. the following three publications for your purpose (though there are more out there, of course) to point people towards the right direction:
Varma & Simon (2006). "Bias in error estimation when using cross-validation for model selection." BMC Bioinformatics, 7: 91
Cawley & Talbot (2010). "On Over-fitting in Model Selection and Subsequent Selection Bias in Performance Evaluation." Journal of Machine Learning Research, 11: 2079-2107
Bengio & Grandvalet (2004). "No Unbiased Estimator of the Variance of $K$-Fold Cross-Validation." Journal of Machine Learning Research, 5: 1089–1105
I personally like those because they try to state the issues more in plain English than in Math.
|
Cross-validation misuse (reporting performance for the best hyperparameter value)
Yes, there are issues with reporting only k-fold CV results. You could use e.g. the following three publications for your purpose (though there are more out there, of course) to point people towards t
|
7,509
|
predict() Function for lmer Mixed Effects Models
|
It's easy to get confused by the presentation of coefficients when you call coef(fit2). Look at the summary of fit2:
> summary(fit2)
Linear mixed model fit by REML ['lmerMod']
Formula: Recall ~ (1 | Subject/Time) + Caffeine
Data: data
REML criterion at convergence: 444.5
Scaled residuals:
Min 1Q Median 3Q Max
-1.88657 -0.46382 -0.06054 0.31430 2.16244
Random effects:
Groups Name Variance Std.Dev.
Time:Subject (Intercept) 558.4 23.63
Subject (Intercept) 2458.0 49.58
Residual 675.0 25.98
Number of obs: 45, groups: Time:Subject, 15; Subject, 5
Fixed effects:
Estimate Std. Error t value
(Intercept) 61.91827 25.04930 2.472
Caffeine 0.21163 0.07439 2.845
Correlation of Fixed Effects:
(Intr)
Caffeine -0.365
There is an overall intercept of 61.92 for the model, with a caffeine coefficient of 0.212. So for caffeine = 95 you predict an average 82.06 recall.
Instead of using coef, use ranef to get the difference of each random-effect intercept from the mean intercept at the next higher level of nesting:
> ranef(fit2)
$`Time:Subject`
(Intercept)
0:Jason 13.112130
0:Jim 33.046151
0:Ron -3.197895
0:Tina 8.893985
0:Victor 24.392738
1:Jason -2.068105
1:Jim -9.260334
1:Ron -4.428399
1:Tina 6.515667
1:Victor 17.265589
2:Jason -18.203436
2:Jim -19.835771
2:Ron -3.473053
2:Tina -17.180791
2:Victor -25.578477
$Subject
(Intercept)
Jason -31.513915
Jim 17.387103
Ron -48.856516
Tina -7.796104
Victor 70.779432
The values for Jim at Time=0 will differ from that average value of 82.06 by the sum of both his Subject and his Time:Subject coefficients:
$$82.06+17.39+33.04=132.49$$
which I think is within rounding error of 132.46.
The intercept values returned by coef seem to represent the overall intercept plus the Subject or Time:Subject specific differences, so it's harder to work with those; if you tried to do the above calculation with the coef values you would be double-counting the overall intercept.
|
predict() Function for lmer Mixed Effects Models
|
It's easy to get confused by the presentation of coefficients when you call coef(fit2). Look at the summary of fit2:
> summary(fit2)
Linear mixed model fit by REML ['lmerMod']
Formula: Recall ~ (1 |
|
predict() Function for lmer Mixed Effects Models
It's easy to get confused by the presentation of coefficients when you call coef(fit2). Look at the summary of fit2:
> summary(fit2)
Linear mixed model fit by REML ['lmerMod']
Formula: Recall ~ (1 | Subject/Time) + Caffeine
Data: data
REML criterion at convergence: 444.5
Scaled residuals:
Min 1Q Median 3Q Max
-1.88657 -0.46382 -0.06054 0.31430 2.16244
Random effects:
Groups Name Variance Std.Dev.
Time:Subject (Intercept) 558.4 23.63
Subject (Intercept) 2458.0 49.58
Residual 675.0 25.98
Number of obs: 45, groups: Time:Subject, 15; Subject, 5
Fixed effects:
Estimate Std. Error t value
(Intercept) 61.91827 25.04930 2.472
Caffeine 0.21163 0.07439 2.845
Correlation of Fixed Effects:
(Intr)
Caffeine -0.365
There is an overall intercept of 61.92 for the model, with a caffeine coefficient of 0.212. So for caffeine = 95 you predict an average 82.06 recall.
Instead of using coef, use ranef to get the difference of each random-effect intercept from the mean intercept at the next higher level of nesting:
> ranef(fit2)
$`Time:Subject`
(Intercept)
0:Jason 13.112130
0:Jim 33.046151
0:Ron -3.197895
0:Tina 8.893985
0:Victor 24.392738
1:Jason -2.068105
1:Jim -9.260334
1:Ron -4.428399
1:Tina 6.515667
1:Victor 17.265589
2:Jason -18.203436
2:Jim -19.835771
2:Ron -3.473053
2:Tina -17.180791
2:Victor -25.578477
$Subject
(Intercept)
Jason -31.513915
Jim 17.387103
Ron -48.856516
Tina -7.796104
Victor 70.779432
The values for Jim at Time=0 will differ from that average value of 82.06 by the sum of both his Subject and his Time:Subject coefficients:
$$82.06+17.39+33.04=132.49$$
which I think is within rounding error of 132.46.
The intercept values returned by coef seem to represent the overall intercept plus the Subject or Time:Subject specific differences, so it's harder to work with those; if you tried to do the above calculation with the coef values you would be double-counting the overall intercept.
|
predict() Function for lmer Mixed Effects Models
It's easy to get confused by the presentation of coefficients when you call coef(fit2). Look at the summary of fit2:
> summary(fit2)
Linear mixed model fit by REML ['lmerMod']
Formula: Recall ~ (1 |
|
7,510
|
Multiple comparisons on a mixed effects model
|
If time and Genotype are both categorical predictors as they appear to be, and you are interested in comparing all time/Genotype pairs to each other, then you can just create one interaction variable, and use Tukey contrasts on it:
weights$TimeGeno <- interaction(weigths$Time, weights$Geno)
model <- lme(weight ~ TimeGeno, random = ~1|Animal/time, data=weights)
comp.timegeno <- glht(model, linfct=mcp(TimeGeno="Tukey"))
If you are interested in other contrasts, then you can use the fact that the linfct argument can take a matrix of coefficients for the contrasts - this way you can set up exactly the comparisons you want.
EDIT
There appears some concern in the comments that the model fitted with the TimeGeno predictor is different from the original model fitted with the Time * Genotype predictor. This is not the case, the models are equivalent. The only difference is in the parametrization of the fixed effects, which is set up to make it easier to use the glht function.
I have used one of the built-in datasets (it has Diet instead of Genotype) to demonstrate that the two approaches have the same likelihood, predicted values, etc:
> # extract a subset of a built-in dataset for the example
> data(BodyWeight)
> ex <- as.data.frame(subset(BodyWeight, Time %in% c(1, 22, 44)))
> ex$Time <- factor(ex$Time)
>
> #create interaction variable
> ex$TimeDiet <- interaction(ex$Time, ex$Diet)
>
> model1 <- lme(weight ~ Time * Diet, random = ~1|Rat/Time, data=ex)
> model2 <- lme(weight ~ TimeDiet, random = ~1|Rat/Time, data=ex)
>
> # the degrees of freedom, AIC, BIC, log-likelihood are all the same
> anova(model1, model2)
Model df AIC BIC logLik
model1 1 12 367.4266 387.3893 -171.7133
model2 2 12 367.4266 387.3893 -171.7133
Warning message:
In anova.lme(model1, model2) :
fitted objects with different fixed effects. REML comparisons are not meaningful.
>
> # the second model collapses the main and interaction effects of the first model
> anova(model1)
numDF denDF F-value p-value
(Intercept) 1 26 1719.5059 <.0001
Time 2 26 28.9986 <.0001
Diet 2 13 85.3659 <.0001
Time:Diet 4 26 1.7610 0.1671
> anova(model2)
numDF denDF F-value p-value
(Intercept) 1 24 1719.5059 <.0001
TimeDiet 8 24 29.4716 <.0001
>
> # they give the same predicted values
> newdata <- expand.grid(Time=levels(ex$Time), Diet=levels(ex$Diet))
> newdata$TimeDiet <- interaction(newdata$Time, newdata$Diet)
> newdata$pred1 <- predict(model1, newdata=newdata, level=0)
> newdata$pred2 <- predict(model2, newdata=newdata, level=0)
> newdata
Time Diet TimeDiet pred1 pred2
1 1 1 1.1 250.625 250.625
2 22 1 22.1 261.875 261.875
3 44 1 44.1 267.250 267.250
4 1 2 1.2 453.750 453.750
5 22 2 22.2 475.000 475.000
6 44 2 44.2 488.750 488.750
7 1 3 1.3 508.750 508.750
8 22 3 22.3 518.250 518.250
9 44 3 44.3 530.000 530.000
The only difference is that what hypotheses are easy to test. For example, in the first model it is easy to test whether the two predictors interact, in the second model there is no explicit test for this. On the other hand, the joint effect of the two predictors is easy to test in the second model, but not the first one. The other hypotheses are testable, it is just more work to set those up.
|
Multiple comparisons on a mixed effects model
|
If time and Genotype are both categorical predictors as they appear to be, and you are interested in comparing all time/Genotype pairs to each other, then you can just create one interaction variable,
|
Multiple comparisons on a mixed effects model
If time and Genotype are both categorical predictors as they appear to be, and you are interested in comparing all time/Genotype pairs to each other, then you can just create one interaction variable, and use Tukey contrasts on it:
weights$TimeGeno <- interaction(weigths$Time, weights$Geno)
model <- lme(weight ~ TimeGeno, random = ~1|Animal/time, data=weights)
comp.timegeno <- glht(model, linfct=mcp(TimeGeno="Tukey"))
If you are interested in other contrasts, then you can use the fact that the linfct argument can take a matrix of coefficients for the contrasts - this way you can set up exactly the comparisons you want.
EDIT
There appears some concern in the comments that the model fitted with the TimeGeno predictor is different from the original model fitted with the Time * Genotype predictor. This is not the case, the models are equivalent. The only difference is in the parametrization of the fixed effects, which is set up to make it easier to use the glht function.
I have used one of the built-in datasets (it has Diet instead of Genotype) to demonstrate that the two approaches have the same likelihood, predicted values, etc:
> # extract a subset of a built-in dataset for the example
> data(BodyWeight)
> ex <- as.data.frame(subset(BodyWeight, Time %in% c(1, 22, 44)))
> ex$Time <- factor(ex$Time)
>
> #create interaction variable
> ex$TimeDiet <- interaction(ex$Time, ex$Diet)
>
> model1 <- lme(weight ~ Time * Diet, random = ~1|Rat/Time, data=ex)
> model2 <- lme(weight ~ TimeDiet, random = ~1|Rat/Time, data=ex)
>
> # the degrees of freedom, AIC, BIC, log-likelihood are all the same
> anova(model1, model2)
Model df AIC BIC logLik
model1 1 12 367.4266 387.3893 -171.7133
model2 2 12 367.4266 387.3893 -171.7133
Warning message:
In anova.lme(model1, model2) :
fitted objects with different fixed effects. REML comparisons are not meaningful.
>
> # the second model collapses the main and interaction effects of the first model
> anova(model1)
numDF denDF F-value p-value
(Intercept) 1 26 1719.5059 <.0001
Time 2 26 28.9986 <.0001
Diet 2 13 85.3659 <.0001
Time:Diet 4 26 1.7610 0.1671
> anova(model2)
numDF denDF F-value p-value
(Intercept) 1 24 1719.5059 <.0001
TimeDiet 8 24 29.4716 <.0001
>
> # they give the same predicted values
> newdata <- expand.grid(Time=levels(ex$Time), Diet=levels(ex$Diet))
> newdata$TimeDiet <- interaction(newdata$Time, newdata$Diet)
> newdata$pred1 <- predict(model1, newdata=newdata, level=0)
> newdata$pred2 <- predict(model2, newdata=newdata, level=0)
> newdata
Time Diet TimeDiet pred1 pred2
1 1 1 1.1 250.625 250.625
2 22 1 22.1 261.875 261.875
3 44 1 44.1 267.250 267.250
4 1 2 1.2 453.750 453.750
5 22 2 22.2 475.000 475.000
6 44 2 44.2 488.750 488.750
7 1 3 1.3 508.750 508.750
8 22 3 22.3 518.250 518.250
9 44 3 44.3 530.000 530.000
The only difference is that what hypotheses are easy to test. For example, in the first model it is easy to test whether the two predictors interact, in the second model there is no explicit test for this. On the other hand, the joint effect of the two predictors is easy to test in the second model, but not the first one. The other hypotheses are testable, it is just more work to set those up.
|
Multiple comparisons on a mixed effects model
If time and Genotype are both categorical predictors as they appear to be, and you are interested in comparing all time/Genotype pairs to each other, then you can just create one interaction variable,
|
7,511
|
Mathematical differences between GBM, XGBoost, LightGBM, CatBoost?
|
My guess is that catboost doesn't use the dummified variables, so the weight given to each (categorical) variable is more balanced compared to the other implementations, so the high-cardinality variables don't have more weight than the others.
https://arxiv.org/abs/1706.09516
You want to look at this English language paper from the Yandex team about CATBoost mathematical uniqueness.
I read it briefly, and among few things I could understand quickly was the fact that they do not use the residuals obtained on TRAIN to do TRAIN, since these residuals create optimistic bias of the learning quality. (Update: this novelty brings about a way to battle the overfitting, which is one of the reasons the algorithm worked better compared to its analogues, apart from a variety of ways to preprocess categorical variables).
I am sorry for not giving you a specific and full answer.
Mathematical differences between GBM, XGBoost
First I suggest you read a paper by Friedman about Gradient Boosting Machine applied to linear regressor models, classifiers, and decision trees in particular. https://statweb.stanford.edu/~jhf/ftp/trebst.pdf
I would not go in the details here. It is just a good read covering various types of loss (L) and besides variable importance concept. Of course this is a milestone paper of implementation of the method of a descent in the space of functions (low-level models) rather than parameters in pursuit of loss minimization.
If you look here: https://arxiv.org/pdf/1603.02754.pdf
You find a mathematical vignette for XGBoost model by Tianqi Chen et al. Now it becomes interesting. A couple of mathematical deviations of this model form the classic Friedman's GBM are:
Regularized (penalized) parameters (and we remember that parameters
in the boossting are the function, trees, or linear models): L1 and
L2 are available.
Using second derivatives to speed up the process (if it was used
before please correct me).
To this point: look here to find an implementation of quantile loss in CATBoost, which comes in handy and provides both first and second derivatives: https://github.com/catboost/catboost/blob/master/catboost/libs/algo/error_functions.h
class TQuantileError : public IDerCalcer<TQuantileError, /*StoreExpApproxParam*/ false> { public:
const double QUANTILE_DER2 = 0.0;
double Alpha;
SAVELOAD(Alpha);
explicit TQuantileError(bool storeExpApprox)
: Alpha(0.5)
{
CB_ENSURE(storeExpApprox == StoreExpApprox, "Approx format does not match");
}
TQuantileError(double alpha, bool storeExpApprox)
: Alpha(alpha)
{
Y_ASSERT(Alpha > -1e-6 && Alpha < 1.0 + 1e-6);
CB_ENSURE(storeExpApprox == StoreExpApprox, "Approx format does not match");
}
double CalcDer(double approx, float target) const {
return (target - approx > 0) ? Alpha : -(1 - Alpha);
}
double CalcDer2(double = 0, float = 0) const {
return QUANTILE_DER2;
} };
While you cannot find this useful L1 loss function in XGBoost, you can try to compare Yandex's implementation with some of the custom loss functions written for XGB.
Besides, CATBoost works excelently with categorical features, while
XGBoost only accepts numeric inputs.
Consider this link: https://tech.yandex.com/catboost/doc/dg/concepts/algorithm-main-stages_cat-to-numberic-docpage/#algorithm-main-stages_cat-to-numberic
They offer a variety of ways to feed categorical features to the model training on top of using old and well-known one-hot approach. Decreasing dimensions of an input space without loosing much information is one of possible reasons the fitted model are less overfitted.
I am done. I don't use LightGBM, so cannot shed any light on it.
|
Mathematical differences between GBM, XGBoost, LightGBM, CatBoost?
|
My guess is that catboost doesn't use the dummified variables, so the weight given to each (categorical) variable is more balanced compared to the other implementations, so the high-cardinality variab
|
Mathematical differences between GBM, XGBoost, LightGBM, CatBoost?
My guess is that catboost doesn't use the dummified variables, so the weight given to each (categorical) variable is more balanced compared to the other implementations, so the high-cardinality variables don't have more weight than the others.
https://arxiv.org/abs/1706.09516
You want to look at this English language paper from the Yandex team about CATBoost mathematical uniqueness.
I read it briefly, and among few things I could understand quickly was the fact that they do not use the residuals obtained on TRAIN to do TRAIN, since these residuals create optimistic bias of the learning quality. (Update: this novelty brings about a way to battle the overfitting, which is one of the reasons the algorithm worked better compared to its analogues, apart from a variety of ways to preprocess categorical variables).
I am sorry for not giving you a specific and full answer.
Mathematical differences between GBM, XGBoost
First I suggest you read a paper by Friedman about Gradient Boosting Machine applied to linear regressor models, classifiers, and decision trees in particular. https://statweb.stanford.edu/~jhf/ftp/trebst.pdf
I would not go in the details here. It is just a good read covering various types of loss (L) and besides variable importance concept. Of course this is a milestone paper of implementation of the method of a descent in the space of functions (low-level models) rather than parameters in pursuit of loss minimization.
If you look here: https://arxiv.org/pdf/1603.02754.pdf
You find a mathematical vignette for XGBoost model by Tianqi Chen et al. Now it becomes interesting. A couple of mathematical deviations of this model form the classic Friedman's GBM are:
Regularized (penalized) parameters (and we remember that parameters
in the boossting are the function, trees, or linear models): L1 and
L2 are available.
Using second derivatives to speed up the process (if it was used
before please correct me).
To this point: look here to find an implementation of quantile loss in CATBoost, which comes in handy and provides both first and second derivatives: https://github.com/catboost/catboost/blob/master/catboost/libs/algo/error_functions.h
class TQuantileError : public IDerCalcer<TQuantileError, /*StoreExpApproxParam*/ false> { public:
const double QUANTILE_DER2 = 0.0;
double Alpha;
SAVELOAD(Alpha);
explicit TQuantileError(bool storeExpApprox)
: Alpha(0.5)
{
CB_ENSURE(storeExpApprox == StoreExpApprox, "Approx format does not match");
}
TQuantileError(double alpha, bool storeExpApprox)
: Alpha(alpha)
{
Y_ASSERT(Alpha > -1e-6 && Alpha < 1.0 + 1e-6);
CB_ENSURE(storeExpApprox == StoreExpApprox, "Approx format does not match");
}
double CalcDer(double approx, float target) const {
return (target - approx > 0) ? Alpha : -(1 - Alpha);
}
double CalcDer2(double = 0, float = 0) const {
return QUANTILE_DER2;
} };
While you cannot find this useful L1 loss function in XGBoost, you can try to compare Yandex's implementation with some of the custom loss functions written for XGB.
Besides, CATBoost works excelently with categorical features, while
XGBoost only accepts numeric inputs.
Consider this link: https://tech.yandex.com/catboost/doc/dg/concepts/algorithm-main-stages_cat-to-numberic-docpage/#algorithm-main-stages_cat-to-numberic
They offer a variety of ways to feed categorical features to the model training on top of using old and well-known one-hot approach. Decreasing dimensions of an input space without loosing much information is one of possible reasons the fitted model are less overfitted.
I am done. I don't use LightGBM, so cannot shed any light on it.
|
Mathematical differences between GBM, XGBoost, LightGBM, CatBoost?
My guess is that catboost doesn't use the dummified variables, so the weight given to each (categorical) variable is more balanced compared to the other implementations, so the high-cardinality variab
|
7,512
|
Intuition behind standard deviation
|
My intuition is that the standard deviation is: a measure of spread of the data.
You have a good point that whether it is wide, or tight depends on what our underlying assumption is for the distribution of the data.
Caveat: A measure of spread is most helpful when the distribution of your data is symmetric around the mean and has a variance relatively close to that of the Normal distribution.
(This means that it is approximately Normal.)
In the case where data is approximately Normal, the standard deviation has a canonical interpretation:
Region: Sample mean +/- 1 standard deviation, contains roughly 68% of the data
Region: Sample mean +/- 2 standard deviation, contains roughly 95% of the data
Region: Sample mean +/- 3 standard deviation, contains roughly 99% of the data
(see first graphic in Wiki)
This means that if we know the population mean is 5 and the standard deviation is 2.83 and we assume the distribution is approximately Normal, I would tell you that I am reasonably certain that if we make (a great) many observations, only 5% will be smaller than 0.4 = 5 - 2*2.3 or bigger than 9.6 = 5 + 2*2.3.
Notice what is the impact of standard deviation on our confidence interval? (the more spread, the more uncertainty)
Furthermore, in the general case where the data is not even approximately normal, but still symmetrical, you know that there exist some $\alpha$ for which:
Region: Sample mean +/- $\alpha$ standard deviation, contains roughly 95% of the data
You can either learn the $\alpha$ from a sub-sample, or assume $\alpha=2$ and this gives you often a good rule of thumb for calculating in your head what future observations to expect, or which of the new observations can be considered as outliers. (keep the caveat in mind though!)
I don't see how you are supposed to interpret it. Does 2.83 mean the values are spread very wide or are they all tightly clustered around the mean...
I guess every question asking "wide or tight", should also contain: "in relation to what?". One suggestion might be to use a well-known distribution as reference. Depending on the context it might be useful to think about: "Is it much wider, or tighter than a Normal/Poisson?".
EDIT:
Based on a useful hint in the comments, one more aspect about standard deviation as a distance measure.
Yet another intuition of the usefulness of the standard deviation $s_N$ is that it is a distance measure between the sample data $x_1,… , x_N$ and its mean $\bar{x}$:
$s_N = \sqrt{\frac{1}{N} \sum_{i=1}^N (x_i - \overline{x})^2}$
As a comparison, the mean squared error (MSE), one of the most popular error measures in statistics, is defined as:
$\operatorname{MSE}=\frac{1}{n}\sum_{i=1}^n(\hat{Y_i} - Y_i)^2$
The questions can be raised why the above distance function? Why squared distances, and not absolute distances for example? And why are we taking the square root?
Having quadratic distance, or error, functions has the advantage that we can both differentiate and easily minimise them. As far as the square root is concerned, it adds towards interpretability as it converts the error back to the scale of our observed data.
|
Intuition behind standard deviation
|
My intuition is that the standard deviation is: a measure of spread of the data.
You have a good point that whether it is wide, or tight depends on what our underlying assumption is for the distributi
|
Intuition behind standard deviation
My intuition is that the standard deviation is: a measure of spread of the data.
You have a good point that whether it is wide, or tight depends on what our underlying assumption is for the distribution of the data.
Caveat: A measure of spread is most helpful when the distribution of your data is symmetric around the mean and has a variance relatively close to that of the Normal distribution.
(This means that it is approximately Normal.)
In the case where data is approximately Normal, the standard deviation has a canonical interpretation:
Region: Sample mean +/- 1 standard deviation, contains roughly 68% of the data
Region: Sample mean +/- 2 standard deviation, contains roughly 95% of the data
Region: Sample mean +/- 3 standard deviation, contains roughly 99% of the data
(see first graphic in Wiki)
This means that if we know the population mean is 5 and the standard deviation is 2.83 and we assume the distribution is approximately Normal, I would tell you that I am reasonably certain that if we make (a great) many observations, only 5% will be smaller than 0.4 = 5 - 2*2.3 or bigger than 9.6 = 5 + 2*2.3.
Notice what is the impact of standard deviation on our confidence interval? (the more spread, the more uncertainty)
Furthermore, in the general case where the data is not even approximately normal, but still symmetrical, you know that there exist some $\alpha$ for which:
Region: Sample mean +/- $\alpha$ standard deviation, contains roughly 95% of the data
You can either learn the $\alpha$ from a sub-sample, or assume $\alpha=2$ and this gives you often a good rule of thumb for calculating in your head what future observations to expect, or which of the new observations can be considered as outliers. (keep the caveat in mind though!)
I don't see how you are supposed to interpret it. Does 2.83 mean the values are spread very wide or are they all tightly clustered around the mean...
I guess every question asking "wide or tight", should also contain: "in relation to what?". One suggestion might be to use a well-known distribution as reference. Depending on the context it might be useful to think about: "Is it much wider, or tighter than a Normal/Poisson?".
EDIT:
Based on a useful hint in the comments, one more aspect about standard deviation as a distance measure.
Yet another intuition of the usefulness of the standard deviation $s_N$ is that it is a distance measure between the sample data $x_1,… , x_N$ and its mean $\bar{x}$:
$s_N = \sqrt{\frac{1}{N} \sum_{i=1}^N (x_i - \overline{x})^2}$
As a comparison, the mean squared error (MSE), one of the most popular error measures in statistics, is defined as:
$\operatorname{MSE}=\frac{1}{n}\sum_{i=1}^n(\hat{Y_i} - Y_i)^2$
The questions can be raised why the above distance function? Why squared distances, and not absolute distances for example? And why are we taking the square root?
Having quadratic distance, or error, functions has the advantage that we can both differentiate and easily minimise them. As far as the square root is concerned, it adds towards interpretability as it converts the error back to the scale of our observed data.
|
Intuition behind standard deviation
My intuition is that the standard deviation is: a measure of spread of the data.
You have a good point that whether it is wide, or tight depends on what our underlying assumption is for the distributi
|
7,513
|
Intuition behind standard deviation
|
It may help to realize that the mean is analogous to the center of mass. The variance is the moment of inertia. The standard deviation is the radius of gyration.
For a historical perspective, take a look at:
George Airy (1875) On the algebraical and numerical theory of errors of observations and the combination of observations
Karl Pearson (1894) Contributions To the Mathematical theory of Evolution.
This plot from Airy 1875 shows the various measures of deviation which are easily interconverted (page 17). The standard deviation is called "error of mean square". It is also discussed pages 20-21 and he justifies its use on page 48, showing that it is easiest to calculate by hand because there is no need for separate calculation of negative and positive errors. The term standard deviation was introduced by Pearson in the paper cited above on page 75.
As an aside: Note that the utility of the standard deviation is dependent on the applicability of the "law of errors", also known as the "normal curve", which arises from "a great many independent causes of error" (Airy 1875 pg 7). There is no reason to expect that deviations from a group mean of each individual should follow this law. In many cases for biological systems a log normal distribution is better assumption than normal. See:
Limpert et al (2001) Log-normal Distributions across the Sciences: Keys and Clues
It is further questionable whether it is appropriate to treat individual variation as noise, since the data generating process acts at the level of the individual and not group.
|
Intuition behind standard deviation
|
It may help to realize that the mean is analogous to the center of mass. The variance is the moment of inertia. The standard deviation is the radius of gyration.
For a historical perspective, take a l
|
Intuition behind standard deviation
It may help to realize that the mean is analogous to the center of mass. The variance is the moment of inertia. The standard deviation is the radius of gyration.
For a historical perspective, take a look at:
George Airy (1875) On the algebraical and numerical theory of errors of observations and the combination of observations
Karl Pearson (1894) Contributions To the Mathematical theory of Evolution.
This plot from Airy 1875 shows the various measures of deviation which are easily interconverted (page 17). The standard deviation is called "error of mean square". It is also discussed pages 20-21 and he justifies its use on page 48, showing that it is easiest to calculate by hand because there is no need for separate calculation of negative and positive errors. The term standard deviation was introduced by Pearson in the paper cited above on page 75.
As an aside: Note that the utility of the standard deviation is dependent on the applicability of the "law of errors", also known as the "normal curve", which arises from "a great many independent causes of error" (Airy 1875 pg 7). There is no reason to expect that deviations from a group mean of each individual should follow this law. In many cases for biological systems a log normal distribution is better assumption than normal. See:
Limpert et al (2001) Log-normal Distributions across the Sciences: Keys and Clues
It is further questionable whether it is appropriate to treat individual variation as noise, since the data generating process acts at the level of the individual and not group.
|
Intuition behind standard deviation
It may help to realize that the mean is analogous to the center of mass. The variance is the moment of inertia. The standard deviation is the radius of gyration.
For a historical perspective, take a l
|
7,514
|
Intuition behind standard deviation
|
The standard deviation does, indeed, give more weight to those farther from the mean, because it is the square root of the average of the squared distances. The reasons for using this (rather than the mean absolute deviation that you propose, or the median absolute deviation, which is used in robust statistics) are partly due to the fact that calculus has an easier time with polynomials than with absolute values. However, often, we do want to emphasize the extreme values.
As to your question about the intuitive meaning - it develops over time. You are correct that more than one set of numbers can have the same mean and sd; this is because the mean and sd are just two pieces of information, and the data set may be 5 pieces (as 1,3,5,7,9) or much more.
Whether a mean 5 and sd of 2.83 is "wide" or "narrow" depends on the field you are working in.
When you have only 5 numbers, it is easy to look at the full list; when you have many numbers, more intuitive ways of thinking about spread include such things as the five number summary or, even better, graphs such as a density plot.
|
Intuition behind standard deviation
|
The standard deviation does, indeed, give more weight to those farther from the mean, because it is the square root of the average of the squared distances. The reasons for using this (rather than the
|
Intuition behind standard deviation
The standard deviation does, indeed, give more weight to those farther from the mean, because it is the square root of the average of the squared distances. The reasons for using this (rather than the mean absolute deviation that you propose, or the median absolute deviation, which is used in robust statistics) are partly due to the fact that calculus has an easier time with polynomials than with absolute values. However, often, we do want to emphasize the extreme values.
As to your question about the intuitive meaning - it develops over time. You are correct that more than one set of numbers can have the same mean and sd; this is because the mean and sd are just two pieces of information, and the data set may be 5 pieces (as 1,3,5,7,9) or much more.
Whether a mean 5 and sd of 2.83 is "wide" or "narrow" depends on the field you are working in.
When you have only 5 numbers, it is easy to look at the full list; when you have many numbers, more intuitive ways of thinking about spread include such things as the five number summary or, even better, graphs such as a density plot.
|
Intuition behind standard deviation
The standard deviation does, indeed, give more weight to those farther from the mean, because it is the square root of the average of the squared distances. The reasons for using this (rather than the
|
7,515
|
Intuition behind standard deviation
|
Standard deviation measures the distance of your population from the mean as random variables.
Let us suppose that your 5 numbers are equally likely to have occurred, so that each has probability .20. This is represented by the random variable $X: [0,1] \rightarrow \mathbb{R}$ given by
$$X(t) = \begin{cases} 1 & 0 \leq t < \frac{1}{5} \\
3 & \frac{1}{5} \leq t < \frac{2}{5}\\
5 & \frac{2}{5} \leq t < \frac{3}{5}\\
7 & \frac{3}{5} \leq t < \frac{4}{5}\\
9 & \frac{4}{5} \leq t \leq 1
\end{cases}$$
The reason we move to functions and measure theory is because we need to have a systematic way of discussing how two probability spaces are the same up to events which have zero chance of occurring. Now that we have moved to functions we need a sense of distance.
There are many senses of distance for functions, most notably the norms
$$||Y||_p = \left(\int_{0}^1|Y(t)|^pdt\right)^{1/p}$$
for $Y: [0,1] \rightarrow \mathbb{R}$ and $1 \leq p < \infty$ induce the distance functions $d_p(Y,Z) = ||X - Z||_p$.
If we take the $p=1$ norm we get the naïve absolute value deviation that you mentioned:
$$d_1(X,5) = ||X - \underline{5} ||_1 = 2.4. $$
If we take the $p=2$ norm we get the usual standard deviation
$$d_2(X,5) = ||X-\underline{5}||_2 = 2.83.$$
Here $\underline{5}$ denotes the constant function $t \mapsto 5$.
Understanding the meaning of standard deviation is really understanding the meaning of the distance function $d_2$ and understanding why it is, in many senses, the best measure of distance between functions.
|
Intuition behind standard deviation
|
Standard deviation measures the distance of your population from the mean as random variables.
Let us suppose that your 5 numbers are equally likely to have occurred, so that each has probability .20.
|
Intuition behind standard deviation
Standard deviation measures the distance of your population from the mean as random variables.
Let us suppose that your 5 numbers are equally likely to have occurred, so that each has probability .20. This is represented by the random variable $X: [0,1] \rightarrow \mathbb{R}$ given by
$$X(t) = \begin{cases} 1 & 0 \leq t < \frac{1}{5} \\
3 & \frac{1}{5} \leq t < \frac{2}{5}\\
5 & \frac{2}{5} \leq t < \frac{3}{5}\\
7 & \frac{3}{5} \leq t < \frac{4}{5}\\
9 & \frac{4}{5} \leq t \leq 1
\end{cases}$$
The reason we move to functions and measure theory is because we need to have a systematic way of discussing how two probability spaces are the same up to events which have zero chance of occurring. Now that we have moved to functions we need a sense of distance.
There are many senses of distance for functions, most notably the norms
$$||Y||_p = \left(\int_{0}^1|Y(t)|^pdt\right)^{1/p}$$
for $Y: [0,1] \rightarrow \mathbb{R}$ and $1 \leq p < \infty$ induce the distance functions $d_p(Y,Z) = ||X - Z||_p$.
If we take the $p=1$ norm we get the naïve absolute value deviation that you mentioned:
$$d_1(X,5) = ||X - \underline{5} ||_1 = 2.4. $$
If we take the $p=2$ norm we get the usual standard deviation
$$d_2(X,5) = ||X-\underline{5}||_2 = 2.83.$$
Here $\underline{5}$ denotes the constant function $t \mapsto 5$.
Understanding the meaning of standard deviation is really understanding the meaning of the distance function $d_2$ and understanding why it is, in many senses, the best measure of distance between functions.
|
Intuition behind standard deviation
Standard deviation measures the distance of your population from the mean as random variables.
Let us suppose that your 5 numbers are equally likely to have occurred, so that each has probability .20.
|
7,516
|
What concepts/objects are "wrongly" formed in probability and statistics?
|
The chi-squared distribution is wrong!
The two main statistical uses of the chi-square distribution are to give the asymptotic (and in some cases exact) distribution of variance estimators, and to give the asymptotic distribution of test statistics relating to squared deviations. In both cases the chi-squared distribution is on the wrong "scale" and this means that results pertaining to the chi-squared distribution generally require the inclusion of a scaling constant to put the quantity of interest on the same scale as the distribution.
For example, consider some of the standard statistical results where we use the chi-squared distribution. When looking at the distribution of the sample variance $S^2$ or the true-mean-adjusted sample variance $S_\mu^2$, we have the standard asymptotic results (exact for normal data):
$$\begin{align}
n \cdot \frac{S_\mu^2}{\sigma^2} &\sim \text{ChiSq}(n), \\[12pt]
(n-1) \cdot \frac{S^2}{\sigma^2} &\sim \text{ChiSq}(n-1). \\[6pt]
\end{align}$$
Similarly, when constructing the F distribution, for testing ratios of variances, we define the F-statistic as:
$$F = \frac{\chi_{n_1}^2/n_1}{\chi_{n_2}^2/n_2} \sim \text{F}(n_1,n_2).$$
We get a similar scaling issue when we use the Pearson test statistic. In this test the framing in terms of the chi-squared distribution works on the scale of expected cell counts rather than the more natural scale of probabilities. This is easily seen when examining the Pearson test for multinomial data. With $n$ values over $k$ categories we get the test statistic and null distribution:
$$n \sum_{i=1}^k \frac{(\hat{p}_i - p_i)^2}{p_i} \overset{H_0}{\sim} \text{ChiSq}(n-1).$$
Observe that in all these statistical results there is an annoying scaling constant, which is there solely to make up for the fact that the chi-squared distribution is on an unnatural scale to begin with (i.e., the chi-squared distribution is wrong!). A simpler framing of these results can be obtained by re-scaling the distribution so that it is on a more natural scale to begin with, which means that we no longer need scaling constants in the equations.
(An obvious corollary of my position is that the chi distribution is also wrong --- I recommend that this distribution also be reframed mutatis mutandis with the chi-squared distribution.)
Re-framing the distribution: To reframe these distributions, let's consider a set of IID standard normal random variables $Z_1,...,Z_k \sim \text{N}(0,1)$ and then denote the mean-of-squares of these values as:
$$\eta_k^2 = \frac{\chi_k^2}{k} = \frac{1}{k} \sum_{i=1}^k Z_i^2.$$
This leads us to define the eta-squared distribution, which is a scaled version of the chi-squared distribution, scaled to give unit mean. The distribution $\eta_k^2 \sim \text{EtaSq}(k)$ can be characterised by its density functions:
$$\begin{align}
\text{EtaSq}(x|k)
= \text{Ga}(x|\tfrac{k}{2},\tfrac{k}{2})
= \frac{(k/2)^{k/2}}{\Gamma(k/2)} \cdot x^{k/2-1} \exp \bigg( -\frac{k x}{2} \bigg) \cdot \mathbb{I}(x \geqslant 0),
\end{align}$$
The eta-squared distribution has mean $\mathbb{E}(\eta_k^2) = 1$ and variance $\mathbb{V}(\eta_k^2) = \tfrac{2}{k}$, so it is trivial to see that $\eta_k^2 \rightarrow 1$ as $k \rightarrow \infty$. This distribution allows us to re-frame various standard results in probability and statistics into simpler forms.
Advantage 1: We now have simpler sample variance results. If we have $n$ data points then the sample variance distributions can be written as:
$$\frac{S^2}{\sigma^2} \sim \text{EtaSq}(n-1)
\quad \quad \quad
\frac{S_\mu^2}{\sigma^2} \sim \text{EtaSq}(n).$$
These are simpler equations than those framed in terms of the chi-squared distribution. As previously noted, it is trivial from the moments to see that this ratio converges to one as $n \rightarrow \infty$, which means that the sample variance converges to the true variance.
Advantage 2: We now have a more natural transition into the F distribution, which is just the distribution of the ratio of independent eta-squared random variables. Taking independent values $\eta_{k_1}^2 \sim \text{EtaSq}(k_1)$ and $\eta_{k_2}^2 \sim \text{EtaSq}(k_2)$ we have:
$$F = \frac{\eta_{k_1}^2}{\eta_{k_2}^2} \sim \text{F}(k_1,k_2)$$
Advantage 3: We now have the simpler version of the Pearson test for multinomial data. With $n$ values over $k$ categories we get the test statistic and null distribution:
$$\frac{n}{n-1} \sum_{i=1}^k \frac{(\hat{p}_i - p_i)^2}{p_i} \overset{H_0}{\sim} \text{EtaSq}(n-1).$$
Whilst there is still a scaling constant in this equation, for large $n$ this scaling constant barely affects the result, and we can get a reasonable result even if we remove it. In any case, the result is more natural than the corresponding result for the chi-squared distribution, insofar as we are now working on the scale of probabilities rather than expected counts.
|
What concepts/objects are "wrongly" formed in probability and statistics?
|
The chi-squared distribution is wrong!
The two main statistical uses of the chi-square distribution are to give the asymptotic (and in some cases exact) distribution of variance estimators, and to gi
|
What concepts/objects are "wrongly" formed in probability and statistics?
The chi-squared distribution is wrong!
The two main statistical uses of the chi-square distribution are to give the asymptotic (and in some cases exact) distribution of variance estimators, and to give the asymptotic distribution of test statistics relating to squared deviations. In both cases the chi-squared distribution is on the wrong "scale" and this means that results pertaining to the chi-squared distribution generally require the inclusion of a scaling constant to put the quantity of interest on the same scale as the distribution.
For example, consider some of the standard statistical results where we use the chi-squared distribution. When looking at the distribution of the sample variance $S^2$ or the true-mean-adjusted sample variance $S_\mu^2$, we have the standard asymptotic results (exact for normal data):
$$\begin{align}
n \cdot \frac{S_\mu^2}{\sigma^2} &\sim \text{ChiSq}(n), \\[12pt]
(n-1) \cdot \frac{S^2}{\sigma^2} &\sim \text{ChiSq}(n-1). \\[6pt]
\end{align}$$
Similarly, when constructing the F distribution, for testing ratios of variances, we define the F-statistic as:
$$F = \frac{\chi_{n_1}^2/n_1}{\chi_{n_2}^2/n_2} \sim \text{F}(n_1,n_2).$$
We get a similar scaling issue when we use the Pearson test statistic. In this test the framing in terms of the chi-squared distribution works on the scale of expected cell counts rather than the more natural scale of probabilities. This is easily seen when examining the Pearson test for multinomial data. With $n$ values over $k$ categories we get the test statistic and null distribution:
$$n \sum_{i=1}^k \frac{(\hat{p}_i - p_i)^2}{p_i} \overset{H_0}{\sim} \text{ChiSq}(n-1).$$
Observe that in all these statistical results there is an annoying scaling constant, which is there solely to make up for the fact that the chi-squared distribution is on an unnatural scale to begin with (i.e., the chi-squared distribution is wrong!). A simpler framing of these results can be obtained by re-scaling the distribution so that it is on a more natural scale to begin with, which means that we no longer need scaling constants in the equations.
(An obvious corollary of my position is that the chi distribution is also wrong --- I recommend that this distribution also be reframed mutatis mutandis with the chi-squared distribution.)
Re-framing the distribution: To reframe these distributions, let's consider a set of IID standard normal random variables $Z_1,...,Z_k \sim \text{N}(0,1)$ and then denote the mean-of-squares of these values as:
$$\eta_k^2 = \frac{\chi_k^2}{k} = \frac{1}{k} \sum_{i=1}^k Z_i^2.$$
This leads us to define the eta-squared distribution, which is a scaled version of the chi-squared distribution, scaled to give unit mean. The distribution $\eta_k^2 \sim \text{EtaSq}(k)$ can be characterised by its density functions:
$$\begin{align}
\text{EtaSq}(x|k)
= \text{Ga}(x|\tfrac{k}{2},\tfrac{k}{2})
= \frac{(k/2)^{k/2}}{\Gamma(k/2)} \cdot x^{k/2-1} \exp \bigg( -\frac{k x}{2} \bigg) \cdot \mathbb{I}(x \geqslant 0),
\end{align}$$
The eta-squared distribution has mean $\mathbb{E}(\eta_k^2) = 1$ and variance $\mathbb{V}(\eta_k^2) = \tfrac{2}{k}$, so it is trivial to see that $\eta_k^2 \rightarrow 1$ as $k \rightarrow \infty$. This distribution allows us to re-frame various standard results in probability and statistics into simpler forms.
Advantage 1: We now have simpler sample variance results. If we have $n$ data points then the sample variance distributions can be written as:
$$\frac{S^2}{\sigma^2} \sim \text{EtaSq}(n-1)
\quad \quad \quad
\frac{S_\mu^2}{\sigma^2} \sim \text{EtaSq}(n).$$
These are simpler equations than those framed in terms of the chi-squared distribution. As previously noted, it is trivial from the moments to see that this ratio converges to one as $n \rightarrow \infty$, which means that the sample variance converges to the true variance.
Advantage 2: We now have a more natural transition into the F distribution, which is just the distribution of the ratio of independent eta-squared random variables. Taking independent values $\eta_{k_1}^2 \sim \text{EtaSq}(k_1)$ and $\eta_{k_2}^2 \sim \text{EtaSq}(k_2)$ we have:
$$F = \frac{\eta_{k_1}^2}{\eta_{k_2}^2} \sim \text{F}(k_1,k_2)$$
Advantage 3: We now have the simpler version of the Pearson test for multinomial data. With $n$ values over $k$ categories we get the test statistic and null distribution:
$$\frac{n}{n-1} \sum_{i=1}^k \frac{(\hat{p}_i - p_i)^2}{p_i} \overset{H_0}{\sim} \text{EtaSq}(n-1).$$
Whilst there is still a scaling constant in this equation, for large $n$ this scaling constant barely affects the result, and we can get a reasonable result even if we remove it. In any case, the result is more natural than the corresponding result for the chi-squared distribution, insofar as we are now working on the scale of probabilities rather than expected counts.
|
What concepts/objects are "wrongly" formed in probability and statistics?
The chi-squared distribution is wrong!
The two main statistical uses of the chi-square distribution are to give the asymptotic (and in some cases exact) distribution of variance estimators, and to gi
|
7,517
|
How to statistically compare the performance of machine learning classifiers?
|
A review and critique of some t-test approaches is given in Choosing between two learning algorithms based on calibrated tests, Approximate Statistical Tests for Comparing Supervised Classification Learning Algorithms, and On Comparing Classifiers: Pitfalls to Avoid and a Recommended Approach
|
How to statistically compare the performance of machine learning classifiers?
|
A review and critique of some t-test approaches is given in Choosing between two learning algorithms based on calibrated tests, Approximate Statistical Tests for Comparing Supervised Classification Le
|
How to statistically compare the performance of machine learning classifiers?
A review and critique of some t-test approaches is given in Choosing between two learning algorithms based on calibrated tests, Approximate Statistical Tests for Comparing Supervised Classification Learning Algorithms, and On Comparing Classifiers: Pitfalls to Avoid and a Recommended Approach
|
How to statistically compare the performance of machine learning classifiers?
A review and critique of some t-test approaches is given in Choosing between two learning algorithms based on calibrated tests, Approximate Statistical Tests for Comparing Supervised Classification Le
|
7,518
|
How to statistically compare the performance of machine learning classifiers?
|
I don't have the Fleiss book at hand, so all this is IIRC.
Answering @JohnMoeller's question in the comments for the moment: the original question is IMHO unanswerable as it is.
So suppose that I have 30 samples, and I test c1 and c2 on each sample, and record the accuracy for each on each sample.
doing this, you end up with a 2 x 2 contingency table giving classifier 1 correct/wrong against classifier 2 correct/wrong. Which is the starting point for McNemar's test.
So this is for a paired comparison, which is more powerful than comparing "independent" proportions (which are not completely independent if they come from drawing randomly from the same finite sample).
I cannot look up McNemar's "small print" right now, but 30 samples is not much. So you may even have to switch from McNemar's to Fisher's exact test [or something else] which calculates the binomial probabilities.
Means of proportions:
It doesn't matter whether you test one and the same classifier 10x with 10 test cases or once with all those 100 cases (the 2 x 2 table just counts all test cases).
If the 10 estimates of accuracy for each classifier in the original question are obtained by random hold out or 10-fold cross validation or 10x out-of-bootstrap, the assumption is usually that the 10 surrogate models calculated for each classifier are equivalent (= have the same accuracy), so test results can be pooled*. For 10-fold cross validation you then assume that the test sample size equals the total number of test samples. For the other methods I'm not so sure: you may test the same case more than once. Depending on the data/problem/application, this doesn't amount to as much information as testing a new case.
*If the surrogate models are unstable, this assumption breaks down. But you can measure this: Do iterated $k$-fold cross validation. Each complete run gives one prediction for each case. So if you compare the predictions for the same test case over a number of different surrogate models, you can measure the variance caused by exchanging some of the training data. This variance is in addition to the variance due to the finite total sample size.
Put your iterated CV results into a "correct classification matrix" with each row corresponding to one case and each column to one of the surrogate models. Now the variance along the rows (removing all empty elements) is solely due to instability in the surrogate models. The variance in the columns is due to the finite number of cases you used for testing of this surrogate model. Say, you have $k$ correct predicitions out of $n$ tested cases in a column. The point estimate for the accuracy is $\hat p = \frac{k}{n}$, it is subject to variance $\sigma^2 (\hat p) = \sigma^2 (\frac{k}{n}) = \frac{p (1 - p)}{n}$.
Check whether the variance due to instability is large or small compared to the variance due to finite test sample size.
|
How to statistically compare the performance of machine learning classifiers?
|
I don't have the Fleiss book at hand, so all this is IIRC.
Answering @JohnMoeller's question in the comments for the moment: the original question is IMHO unanswerable as it is.
So suppose that I hav
|
How to statistically compare the performance of machine learning classifiers?
I don't have the Fleiss book at hand, so all this is IIRC.
Answering @JohnMoeller's question in the comments for the moment: the original question is IMHO unanswerable as it is.
So suppose that I have 30 samples, and I test c1 and c2 on each sample, and record the accuracy for each on each sample.
doing this, you end up with a 2 x 2 contingency table giving classifier 1 correct/wrong against classifier 2 correct/wrong. Which is the starting point for McNemar's test.
So this is for a paired comparison, which is more powerful than comparing "independent" proportions (which are not completely independent if they come from drawing randomly from the same finite sample).
I cannot look up McNemar's "small print" right now, but 30 samples is not much. So you may even have to switch from McNemar's to Fisher's exact test [or something else] which calculates the binomial probabilities.
Means of proportions:
It doesn't matter whether you test one and the same classifier 10x with 10 test cases or once with all those 100 cases (the 2 x 2 table just counts all test cases).
If the 10 estimates of accuracy for each classifier in the original question are obtained by random hold out or 10-fold cross validation or 10x out-of-bootstrap, the assumption is usually that the 10 surrogate models calculated for each classifier are equivalent (= have the same accuracy), so test results can be pooled*. For 10-fold cross validation you then assume that the test sample size equals the total number of test samples. For the other methods I'm not so sure: you may test the same case more than once. Depending on the data/problem/application, this doesn't amount to as much information as testing a new case.
*If the surrogate models are unstable, this assumption breaks down. But you can measure this: Do iterated $k$-fold cross validation. Each complete run gives one prediction for each case. So if you compare the predictions for the same test case over a number of different surrogate models, you can measure the variance caused by exchanging some of the training data. This variance is in addition to the variance due to the finite total sample size.
Put your iterated CV results into a "correct classification matrix" with each row corresponding to one case and each column to one of the surrogate models. Now the variance along the rows (removing all empty elements) is solely due to instability in the surrogate models. The variance in the columns is due to the finite number of cases you used for testing of this surrogate model. Say, you have $k$ correct predicitions out of $n$ tested cases in a column. The point estimate for the accuracy is $\hat p = \frac{k}{n}$, it is subject to variance $\sigma^2 (\hat p) = \sigma^2 (\frac{k}{n}) = \frac{p (1 - p)}{n}$.
Check whether the variance due to instability is large or small compared to the variance due to finite test sample size.
|
How to statistically compare the performance of machine learning classifiers?
I don't have the Fleiss book at hand, so all this is IIRC.
Answering @JohnMoeller's question in the comments for the moment: the original question is IMHO unanswerable as it is.
So suppose that I hav
|
7,519
|
How does batch size affect convergence of SGD and why?
|
Sure one update with a big minibatch is "better" (in terms of accuracy) than one update with a small minibatch. This can be seen in the table you copied in your question (call $N$ the sample size):
batch size 1: number of updates $27N$
batch size 20,000: number of updates $8343\times\frac{N}{20000}\approx 0.47N$
You can see that with bigger batches you need much fewer updates for the same accuracy.
But it can't be compared because it's not processing the same amount of data. I'm quoting the first article:
"We compare the effect of executing $k$ SGD iterations with small minibatches
$B_j$ versus a single iteration with a large minibatch $\displaystyle\bigcup_{1\leq j\leq k} B_j$"
Here it's about processing the same amount of data and while there is small overhead for multiple mini-batches, this takes comparable processing resources.
There are several ways to understand why several updates is better (for the same amount of data being read). It's the key idea of stochastic gradient descent vs. gradient descent. Instead of reading everything and then correct yourself at the end, you correct yourself on the way, making the next reads more useful since you correct yourself from a better guess. Geometrically, several updates is better because you are drawing several segments, each in the direction of the (approximated) gradient at the start of each segment. while a single big update is a single segment from the very start in the direction of the (exact) gradient. It's better to change direction several times even if the direction is less precise.
The size of mini-batches is essentially the frequency of updates: the smaller minibatches the more updates. At one extreme (minibatch=dataset) you have gradient descent. At the other extreme (minibatch=one line) you have full per line SGD. Per line SGD is better anyway, but bigger minibatches are suited for more efficient parallelization.
At the end of the convergence process, SGD becomes less precise than (batch) GD. But at this point, things become (usually) a sort of uselessly precise fitting. While you get a slightly smaller loss function on the training set, you don't get real predictive power. You are only looking for the very precise optimum but it does not help. If the loss function is correctly regularized (which prevents over-fitting) you don't exactly "over"-fit, you just uselessly "hyper"-fit. This shows as a non significant change in accuracy on the test set.
|
How does batch size affect convergence of SGD and why?
|
Sure one update with a big minibatch is "better" (in terms of accuracy) than one update with a small minibatch. This can be seen in the table you copied in your question (call $N$ the sample size):
|
How does batch size affect convergence of SGD and why?
Sure one update with a big minibatch is "better" (in terms of accuracy) than one update with a small minibatch. This can be seen in the table you copied in your question (call $N$ the sample size):
batch size 1: number of updates $27N$
batch size 20,000: number of updates $8343\times\frac{N}{20000}\approx 0.47N$
You can see that with bigger batches you need much fewer updates for the same accuracy.
But it can't be compared because it's not processing the same amount of data. I'm quoting the first article:
"We compare the effect of executing $k$ SGD iterations with small minibatches
$B_j$ versus a single iteration with a large minibatch $\displaystyle\bigcup_{1\leq j\leq k} B_j$"
Here it's about processing the same amount of data and while there is small overhead for multiple mini-batches, this takes comparable processing resources.
There are several ways to understand why several updates is better (for the same amount of data being read). It's the key idea of stochastic gradient descent vs. gradient descent. Instead of reading everything and then correct yourself at the end, you correct yourself on the way, making the next reads more useful since you correct yourself from a better guess. Geometrically, several updates is better because you are drawing several segments, each in the direction of the (approximated) gradient at the start of each segment. while a single big update is a single segment from the very start in the direction of the (exact) gradient. It's better to change direction several times even if the direction is less precise.
The size of mini-batches is essentially the frequency of updates: the smaller minibatches the more updates. At one extreme (minibatch=dataset) you have gradient descent. At the other extreme (minibatch=one line) you have full per line SGD. Per line SGD is better anyway, but bigger minibatches are suited for more efficient parallelization.
At the end of the convergence process, SGD becomes less precise than (batch) GD. But at this point, things become (usually) a sort of uselessly precise fitting. While you get a slightly smaller loss function on the training set, you don't get real predictive power. You are only looking for the very precise optimum but it does not help. If the loss function is correctly regularized (which prevents over-fitting) you don't exactly "over"-fit, you just uselessly "hyper"-fit. This shows as a non significant change in accuracy on the test set.
|
How does batch size affect convergence of SGD and why?
Sure one update with a big minibatch is "better" (in terms of accuracy) than one update with a small minibatch. This can be seen in the table you copied in your question (call $N$ the sample size):
|
7,520
|
How does batch size affect convergence of SGD and why?
|
To add to Curtis White's answer (and adding some more references):
Yes SGD works as a type of regularization. This is important because otherwise, it's hard to explain why DNNs do not always overfit, because they can.
The reason, as I understand, is that SGD causes 'hopping around' in parameter space, so during training the parameters cannot stay in a narrow minimum, only in (or close to) wider ones. And these wider ones apparently [1] generalize better (aka, less overfitting).
More references:
Here's [2] another paper that formalizes this (or tries to, I didn't follow everything through, check for yourself!)
This paper [3] claims that there is a phase of "stochastic relaxation, or random diffusion" where the stochasticity inherent in SGD leads to "maximiz[ation of] the conditional entropy of the layer".
Both sort of say that SGD corresponds to an entropy regularization term.
There could definitely be other ways in which batch size influences convergence; this is the one I know of.
Editing in another reference, to show where people in practice observe that a smaller batch size improves generalization: [5]
[1] Example: "A Bayesian Perspective on Generalization and Stochastic Gradient Descent", Smith, Le, 2018. From the abstract: "We propose that the noise introduced by small mini-batches drives the parameters towards minima whose evidence is large."
[2] "Stochastic gradient descent performs variational inference, converges to limit cycles for deep networks", Chaudhari, Soatto 2017
[3] "Opening the black box of Deep Neural Networks via Information" Schwartz-Ziv, Tishby, 2017
[4] "Understanding deep learning requires rethinking generalization", C. Zhang etc. 2016
[5] "On Large-Batch Training for Deep Learning: Generalization Gap and Sharp Minima", N. S. Keskar et al 2016
|
How does batch size affect convergence of SGD and why?
|
To add to Curtis White's answer (and adding some more references):
Yes SGD works as a type of regularization. This is important because otherwise, it's hard to explain why DNNs do not always overfit,
|
How does batch size affect convergence of SGD and why?
To add to Curtis White's answer (and adding some more references):
Yes SGD works as a type of regularization. This is important because otherwise, it's hard to explain why DNNs do not always overfit, because they can.
The reason, as I understand, is that SGD causes 'hopping around' in parameter space, so during training the parameters cannot stay in a narrow minimum, only in (or close to) wider ones. And these wider ones apparently [1] generalize better (aka, less overfitting).
More references:
Here's [2] another paper that formalizes this (or tries to, I didn't follow everything through, check for yourself!)
This paper [3] claims that there is a phase of "stochastic relaxation, or random diffusion" where the stochasticity inherent in SGD leads to "maximiz[ation of] the conditional entropy of the layer".
Both sort of say that SGD corresponds to an entropy regularization term.
There could definitely be other ways in which batch size influences convergence; this is the one I know of.
Editing in another reference, to show where people in practice observe that a smaller batch size improves generalization: [5]
[1] Example: "A Bayesian Perspective on Generalization and Stochastic Gradient Descent", Smith, Le, 2018. From the abstract: "We propose that the noise introduced by small mini-batches drives the parameters towards minima whose evidence is large."
[2] "Stochastic gradient descent performs variational inference, converges to limit cycles for deep networks", Chaudhari, Soatto 2017
[3] "Opening the black box of Deep Neural Networks via Information" Schwartz-Ziv, Tishby, 2017
[4] "Understanding deep learning requires rethinking generalization", C. Zhang etc. 2016
[5] "On Large-Batch Training for Deep Learning: Generalization Gap and Sharp Minima", N. S. Keskar et al 2016
|
How does batch size affect convergence of SGD and why?
To add to Curtis White's answer (and adding some more references):
Yes SGD works as a type of regularization. This is important because otherwise, it's hard to explain why DNNs do not always overfit,
|
7,521
|
How does batch size affect convergence of SGD and why?
|
A too large batch size can prevent convergence at least when using SGD and training MLP using Keras. As for why, I am not 100% sure whether it has to do with averaging of the gradients or that smaller updates provides greater probability of escaping the local minima.
See here.
|
How does batch size affect convergence of SGD and why?
|
A too large batch size can prevent convergence at least when using SGD and training MLP using Keras. As for why, I am not 100% sure whether it has to do with averaging of the gradients or that smaller
|
How does batch size affect convergence of SGD and why?
A too large batch size can prevent convergence at least when using SGD and training MLP using Keras. As for why, I am not 100% sure whether it has to do with averaging of the gradients or that smaller updates provides greater probability of escaping the local minima.
See here.
|
How does batch size affect convergence of SGD and why?
A too large batch size can prevent convergence at least when using SGD and training MLP using Keras. As for why, I am not 100% sure whether it has to do with averaging of the gradients or that smaller
|
7,522
|
How does batch size affect convergence of SGD and why?
|
From my experience with tensorflow and keras (which is confirmed by this article):
Higher batchsize results lower accuracy
Accuracy can be kept up if learning rate is increased when batchsize is high
|
How does batch size affect convergence of SGD and why?
|
From my experience with tensorflow and keras (which is confirmed by this article):
Higher batchsize results lower accuracy
Accuracy can be kept up if learning rate is increased when batchsize is high
|
How does batch size affect convergence of SGD and why?
From my experience with tensorflow and keras (which is confirmed by this article):
Higher batchsize results lower accuracy
Accuracy can be kept up if learning rate is increased when batchsize is high
|
How does batch size affect convergence of SGD and why?
From my experience with tensorflow and keras (which is confirmed by this article):
Higher batchsize results lower accuracy
Accuracy can be kept up if learning rate is increased when batchsize is high
|
7,523
|
Comparison between SHAP (Shapley Additive Explanation) and LIME (Local Interpretable Model-Agnostic Explanations)
|
LIME creates a surrogate model locally around the unit whose prediction you wish to understand. Thus it is inherently local.
Shapley values 'decompose' the final prediction into the contribution of each attribute - this is what some mean by 'consistent' (the values add up to the actual prediction of the true model, and this is not something you get with LIME).
But to actually get the shapley values, some decision must be made about what to do/how to handle the values of the attributes 'left out', which is how the values are arrived at. In this decision, there is some choice which could change the interpretation. If I 'leave out' an attribute, do I average all the possibilities? Do choose some 'baseline'?
in a nutshell:
Shapley values actually tell you, in an additive way, how you got your score, but there is some choice about the 'starting point' (i.e. the decision about omitted attributes).
LIME simply tells you, in a local sense, what is the most important attribute around the data point of interest.
|
Comparison between SHAP (Shapley Additive Explanation) and LIME (Local Interpretable Model-Agnostic
|
LIME creates a surrogate model locally around the unit whose prediction you wish to understand. Thus it is inherently local.
Shapley values 'decompose' the final prediction into the contribution of e
|
Comparison between SHAP (Shapley Additive Explanation) and LIME (Local Interpretable Model-Agnostic Explanations)
LIME creates a surrogate model locally around the unit whose prediction you wish to understand. Thus it is inherently local.
Shapley values 'decompose' the final prediction into the contribution of each attribute - this is what some mean by 'consistent' (the values add up to the actual prediction of the true model, and this is not something you get with LIME).
But to actually get the shapley values, some decision must be made about what to do/how to handle the values of the attributes 'left out', which is how the values are arrived at. In this decision, there is some choice which could change the interpretation. If I 'leave out' an attribute, do I average all the possibilities? Do choose some 'baseline'?
in a nutshell:
Shapley values actually tell you, in an additive way, how you got your score, but there is some choice about the 'starting point' (i.e. the decision about omitted attributes).
LIME simply tells you, in a local sense, what is the most important attribute around the data point of interest.
|
Comparison between SHAP (Shapley Additive Explanation) and LIME (Local Interpretable Model-Agnostic
LIME creates a surrogate model locally around the unit whose prediction you wish to understand. Thus it is inherently local.
Shapley values 'decompose' the final prediction into the contribution of e
|
7,524
|
What are the relative merits of Winsorizing vs. Trimming data?
|
In a different, but related question on trimming that I just stumbled across, one answer had the following helpful insight into why one might use either winsorizing or trimming:
If you take the trimmed distribution, you explicitly state: I am not
interested in outliers/ the tails of the distribution. If you believe
that the "outliers" are really outliers (i.e., they do not belong to
the distribution, but are of "another kind") then do trimming. If you
think they belong to the distribution, but you want to have a less
skewed distribution, you could think about winsorising.
I'm curious if there is a more definitive approach, but the above logic sounds reasonable.
|
What are the relative merits of Winsorizing vs. Trimming data?
|
In a different, but related question on trimming that I just stumbled across, one answer had the following helpful insight into why one might use either winsorizing or trimming:
If you take the trimm
|
What are the relative merits of Winsorizing vs. Trimming data?
In a different, but related question on trimming that I just stumbled across, one answer had the following helpful insight into why one might use either winsorizing or trimming:
If you take the trimmed distribution, you explicitly state: I am not
interested in outliers/ the tails of the distribution. If you believe
that the "outliers" are really outliers (i.e., they do not belong to
the distribution, but are of "another kind") then do trimming. If you
think they belong to the distribution, but you want to have a less
skewed distribution, you could think about winsorising.
I'm curious if there is a more definitive approach, but the above logic sounds reasonable.
|
What are the relative merits of Winsorizing vs. Trimming data?
In a different, but related question on trimming that I just stumbled across, one answer had the following helpful insight into why one might use either winsorizing or trimming:
If you take the trimm
|
7,525
|
What are the relative merits of Winsorizing vs. Trimming data?
|
Clearly, the respective merits depend on the data under analysis, and although they depend in non-trivial ways on what actually causes data to be distributed as it is, we can at least consider two extreme cases.
Data is virtually error-free, it just has legitimate outliers, but you don't want your results to be severely affected by them. For instance: in a distribution of wealth, there are horribly rich and horribly indebted people that would bear an excessive weight in your estimates. Now, you don't necessarily want to ignore these people, you just want to ignore they are so rich, or indebted. By winsorizing, you treat them as "reasonably rich" or "reasonably indebted". (Notice that in this specific example if you were only looking at positive wealth, taking a logarithm might be preferable)
The underlying distribution is nice, possibly normal, but there are (few but relevant) errors in the data and you know it is only such errors that cause the outliers. For instance: in a distribution of reported salaries, a few survey participants might have mistyped, or reported in the wrong currency, their own salary, resulting in unreasonable amounts. By trimming, you exclude outliers because they really don't provide useful information, they are just noise (notice you will have some noise left in the distribution, but at least you remove the noise that would disproportionately distort your analysis).
Then, outliers in real data are often a mixture of data error and legitimate extreme values, which it is not obvious to interpret.
The recommendation to always parallel your winsorized/trimmed results with the full results is always valid, but for two slightly different reasons. In the first case, to warn the reader that you do not claim you are talking about the actual distribution: rather, you study a modified distribution which de-emphasizes extreme values. In the second case, because you claim you are talking about the actual distribution, but you must warn the reader you more or less arbitrarily decided what in the data was actually noise, not information.
On a more subjective note, trimmed results (and the difference with full results) are often easier to describe correctly, and to grasp intuitively, than winsorized results.
|
What are the relative merits of Winsorizing vs. Trimming data?
|
Clearly, the respective merits depend on the data under analysis, and although they depend in non-trivial ways on what actually causes data to be distributed as it is, we can at least consider two ext
|
What are the relative merits of Winsorizing vs. Trimming data?
Clearly, the respective merits depend on the data under analysis, and although they depend in non-trivial ways on what actually causes data to be distributed as it is, we can at least consider two extreme cases.
Data is virtually error-free, it just has legitimate outliers, but you don't want your results to be severely affected by them. For instance: in a distribution of wealth, there are horribly rich and horribly indebted people that would bear an excessive weight in your estimates. Now, you don't necessarily want to ignore these people, you just want to ignore they are so rich, or indebted. By winsorizing, you treat them as "reasonably rich" or "reasonably indebted". (Notice that in this specific example if you were only looking at positive wealth, taking a logarithm might be preferable)
The underlying distribution is nice, possibly normal, but there are (few but relevant) errors in the data and you know it is only such errors that cause the outliers. For instance: in a distribution of reported salaries, a few survey participants might have mistyped, or reported in the wrong currency, their own salary, resulting in unreasonable amounts. By trimming, you exclude outliers because they really don't provide useful information, they are just noise (notice you will have some noise left in the distribution, but at least you remove the noise that would disproportionately distort your analysis).
Then, outliers in real data are often a mixture of data error and legitimate extreme values, which it is not obvious to interpret.
The recommendation to always parallel your winsorized/trimmed results with the full results is always valid, but for two slightly different reasons. In the first case, to warn the reader that you do not claim you are talking about the actual distribution: rather, you study a modified distribution which de-emphasizes extreme values. In the second case, because you claim you are talking about the actual distribution, but you must warn the reader you more or less arbitrarily decided what in the data was actually noise, not information.
On a more subjective note, trimmed results (and the difference with full results) are often easier to describe correctly, and to grasp intuitively, than winsorized results.
|
What are the relative merits of Winsorizing vs. Trimming data?
Clearly, the respective merits depend on the data under analysis, and although they depend in non-trivial ways on what actually causes data to be distributed as it is, we can at least consider two ext
|
7,526
|
What are the relative merits of Winsorizing vs. Trimming data?
|
A good question that is faced very often in all fields!
In either case you are technically removing them from the data set.
I know it is common practice when trying to find a trend graphically to use a form of truncation: use the whole data set for plotting purposes, but then exclude the extreme values for the interpretation.
The problem with 'winsorizing' is that the parts you add are self-fullfilling, that is they originate from the data set itself and so just support it. There are simlar problems if you look at cross-validation/classification work in machine-learning, when deciding how to use training and test data sets.
I haven't come across a standardised approach in any case - it is always data specific. You can try finding out which percentile your data (the outliers) are causing a given percentage of the volatility/st. deviation, and find a balance between reducing that volatility but retaining as much of the data as possible.
|
What are the relative merits of Winsorizing vs. Trimming data?
|
A good question that is faced very often in all fields!
In either case you are technically removing them from the data set.
I know it is common practice when trying to find a trend graphically to use
|
What are the relative merits of Winsorizing vs. Trimming data?
A good question that is faced very often in all fields!
In either case you are technically removing them from the data set.
I know it is common practice when trying to find a trend graphically to use a form of truncation: use the whole data set for plotting purposes, but then exclude the extreme values for the interpretation.
The problem with 'winsorizing' is that the parts you add are self-fullfilling, that is they originate from the data set itself and so just support it. There are simlar problems if you look at cross-validation/classification work in machine-learning, when deciding how to use training and test data sets.
I haven't come across a standardised approach in any case - it is always data specific. You can try finding out which percentile your data (the outliers) are causing a given percentage of the volatility/st. deviation, and find a balance between reducing that volatility but retaining as much of the data as possible.
|
What are the relative merits of Winsorizing vs. Trimming data?
A good question that is faced very often in all fields!
In either case you are technically removing them from the data set.
I know it is common practice when trying to find a trend graphically to use
|
7,527
|
What are the relative merits of Winsorizing vs. Trimming data?
|
This is a good question, and one I have been faced with. In cases where you have a large dataset or a more accurately a largely varying dataset, where the minority of data values vary across a wide scale (but nevertheless are required to be shown), and the majority of the dataset is within a narrow band, such that if the data is plotted as is, the details where the majority of the data lie are lost, and normalizing or standardizing does not show adequate differentiation(at least visually), or, raw data is required instead, then truncating or winsorizing the extreme data values helps for better data visualization.
|
What are the relative merits of Winsorizing vs. Trimming data?
|
This is a good question, and one I have been faced with. In cases where you have a large dataset or a more accurately a largely varying dataset, where the minority of data values vary across a wide sc
|
What are the relative merits of Winsorizing vs. Trimming data?
This is a good question, and one I have been faced with. In cases where you have a large dataset or a more accurately a largely varying dataset, where the minority of data values vary across a wide scale (but nevertheless are required to be shown), and the majority of the dataset is within a narrow band, such that if the data is plotted as is, the details where the majority of the data lie are lost, and normalizing or standardizing does not show adequate differentiation(at least visually), or, raw data is required instead, then truncating or winsorizing the extreme data values helps for better data visualization.
|
What are the relative merits of Winsorizing vs. Trimming data?
This is a good question, and one I have been faced with. In cases where you have a large dataset or a more accurately a largely varying dataset, where the minority of data values vary across a wide sc
|
7,528
|
What are the relative merits of Winsorizing vs. Trimming data?
|
One advantage of Winsorizing is that the calculation may be more efficient. In order to calculate a true truncated mean, you need to sort all of the data elements, and that is typically $O(n \log n)$. However there are efficient ways of figuring out just the 25% and 75% percentiles using a the quick select algorithm, which is typically $O(n)$. If you know these end points, you can quickly loop over the data again, and replace values less than 25% with the 25% value and more than 75% with 75% and average. This is identical to the Winsor mean. But looping over the data and only averaging data between the 25% value and 75% value is NOT identical to the truncated mean, because the 25% or 75% values may not be a unique value. Consider the data sequence $(1,2,3,4,4)$. The Winsor mean is $(2+2+3+4+4)/5$. The correct truncated mean should be $(2+3+4)/3$. The "quick-select" optimized truncated mean will be $(2+3+4+4)/4$.
|
What are the relative merits of Winsorizing vs. Trimming data?
|
One advantage of Winsorizing is that the calculation may be more efficient. In order to calculate a true truncated mean, you need to sort all of the data elements, and that is typically $O(n \log n)$
|
What are the relative merits of Winsorizing vs. Trimming data?
One advantage of Winsorizing is that the calculation may be more efficient. In order to calculate a true truncated mean, you need to sort all of the data elements, and that is typically $O(n \log n)$. However there are efficient ways of figuring out just the 25% and 75% percentiles using a the quick select algorithm, which is typically $O(n)$. If you know these end points, you can quickly loop over the data again, and replace values less than 25% with the 25% value and more than 75% with 75% and average. This is identical to the Winsor mean. But looping over the data and only averaging data between the 25% value and 75% value is NOT identical to the truncated mean, because the 25% or 75% values may not be a unique value. Consider the data sequence $(1,2,3,4,4)$. The Winsor mean is $(2+2+3+4+4)/5$. The correct truncated mean should be $(2+3+4)/3$. The "quick-select" optimized truncated mean will be $(2+3+4+4)/4$.
|
What are the relative merits of Winsorizing vs. Trimming data?
One advantage of Winsorizing is that the calculation may be more efficient. In order to calculate a true truncated mean, you need to sort all of the data elements, and that is typically $O(n \log n)$
|
7,529
|
Training a neural network for regression always predicts the mean
|
I am going to contradict @Pieter's answer and say that your problem is that you have too much bias and too little variance. In other words, your network is not complex enough for this task.
To see this, let $Y$ be the true and correct output that your network should return (the target), and let $\hat{Y}$ be the output that your network actually returns. Your loss-function is the mean squared-error, averaged over all examples in your training dataset $\mathcal{D}$ :
$$
\mathbb{E}_{\mathcal{D}}\left[(Y - \hat{Y})^2\right]
$$
In this loss-function, using your network, we are trying to adjust the probability distribution of $\hat{Y}$ such that it matches the probability distribution of $Y$. In other words, we are trying to make $Y=\hat{Y}$, such that the mean squared-error is $0$. This is the lowest possible value of the mean squared-error:
$$
\mathbb{E}_{\mathcal{D}}\left[(Y - \hat{Y})^2\right] \geq 0
$$
However, from the question How can I prove mathematically that the mean of a distribution is the measure that minimizes the variance?, we know that the mean squared-error actually has a tighter lower-bound, which is when $\hat{Y} = \mathbb{E}_{\mathcal{D}}[Y]$, such that the mean squared-error loss-function becomes
$$
\mathbb{E}_{\mathcal{D}}\left[(Y - \mathbb{E}_{\mathcal{D}}[Y])^2\right] = \text{Var}(Y)
$$
Since we know that the variance of $Y$ is non-negative, then the mean squared-error loss-function has the following lower-bounds
$$
\mathbb{E}_{\mathcal{D}}\left[(Y - \hat{Y})^2\right] \geq \text{Var}(Y) \geq 0
$$
In your case, you have reached the lower-bound $\text{Var}(Y)$, since you observe that $\hat{Y} = \mathbb{E}_{\mathcal{D}}[Y]$. This means that the bias (strictly speaking, this is not the correct definition of bias, but it gets the point across.) of $\hat{Y}$ is
$$
(Y - \hat{Y})^2 = (Y - \mathbb{E}_{\mathcal{D}}[Y])^2
$$
The variance of $\hat{Y}$ is
$$
\mathbb{E}_{\mathcal{D}}\left[\left(\hat{Y} - \mathbb{E}_{\mathcal{D}}\left[\hat{Y}\right]\right)^2\right] = \mathbb{E}_{\mathcal{D}}\left[\left(\mathbb{E}_{\mathcal{D}}[Y] - \mathbb{E}_{\mathcal{D}}[\mathbb{E}_{\mathcal{D}}[Y]]\right)^2\right] = 0
$$
Clearly, you have too much bias and too little variance.
So, how do we reach the lower-lower-bound of $0$? We need to increase the variance of $\hat{Y}$ by either adding more parameters to the network or adjusting the network architecture. As discussed in What should I do when my neural network doesn't learn? (highly recommended read), consider over-fitting and then testing your network on a single example by adding many more parameters or by adjusting the network architecture.
If the network no longer predicts the mean on a single example, then you can scale up slowly and start over-fitting and testing the network on two examples, then three examples, and so on. Otherwise, you need to keep adding more parameters/adjusting the network architecture until your network no longer predicts the mean.
Eventually, once you reach a dataset size of around 100 examples, you can start to split your data into training and testing to evaluate the generalization performance of your network. At this point, if it starts to predict the mean again, then make sure that the examples that you are adding to the dataset are similar to the examples that you already worked through in the smaller datasets. In other words, they are normalized and "look" similar. Also, keep in mind that as you add more data to the dataset, you will more likely need to add more parameters for better generalization performance.
Another helpful modification, but not as helpful as what I stated above, that helps in practice, is to slightly adjust the mean squared-error loss function itself. If your mean squared-error loss function is
$$
\mathcal{L}(y,\hat{y}) = \frac{1}{N} \sum_{i=1}^N (y_i-\hat{y}_i)^2
$$
where $N$ is the dataset size, then consider using the following loss function instead:
$$
\mathcal{L}(y,\hat{y}) = \left[\frac{1}{N} \sum_{i=1}^N (y_i-\hat{y}_i)^2\right] + \alpha \cdot \left[\frac{1}{N} \sum_{i=1}^N (\log(y_i)-\log(\hat{y}_i))^2\right]
$$
Where $\alpha$ is a hyperparameter that can be tuned via trial and error. A starting value for $\alpha$ could be $\alpha=5$. The advantage of this loss function over the plain mean squared-error loss function is that the $\log(\cdot)$ function stretches small values in the interval $[0,1]$ away from each other, which means that small differences between $y$ and $\hat{y}$ are amplified, leading to larger gradients. I have personally found this modified loss function to be very helpful in practice.
For this to work well, it is recommended (but not necessary) that $y$ and $\hat{y}$ are each scaled to have values in the interval $[0,1]$. Also, since $\log(0)=-\infty$, and since it is likely that $y$ and $\hat{y}$ will have values very close to $0$, then it is recommended to add a small value $\epsilon$, such as $\epsilon=10^{-9}$, to $y$ and $\hat{y}$ in the loss function as follows:
$$
\mathcal{L}(y,\hat{y}) = \left[\frac{1}{N} \sum_{i=1}^N (y_i-\hat{y}_i)^2\right] + \alpha \cdot \left[\frac{1}{N} \sum_{i=1}^N (\log(y_i + \epsilon)-\log(\hat{y}_i + \epsilon))^2\right]
$$
This loss function may be thought of as the Mean Squared Log-scaled Error Loss.
|
Training a neural network for regression always predicts the mean
|
I am going to contradict @Pieter's answer and say that your problem is that you have too much bias and too little variance. In other words, your network is not complex enough for this task.
To see thi
|
Training a neural network for regression always predicts the mean
I am going to contradict @Pieter's answer and say that your problem is that you have too much bias and too little variance. In other words, your network is not complex enough for this task.
To see this, let $Y$ be the true and correct output that your network should return (the target), and let $\hat{Y}$ be the output that your network actually returns. Your loss-function is the mean squared-error, averaged over all examples in your training dataset $\mathcal{D}$ :
$$
\mathbb{E}_{\mathcal{D}}\left[(Y - \hat{Y})^2\right]
$$
In this loss-function, using your network, we are trying to adjust the probability distribution of $\hat{Y}$ such that it matches the probability distribution of $Y$. In other words, we are trying to make $Y=\hat{Y}$, such that the mean squared-error is $0$. This is the lowest possible value of the mean squared-error:
$$
\mathbb{E}_{\mathcal{D}}\left[(Y - \hat{Y})^2\right] \geq 0
$$
However, from the question How can I prove mathematically that the mean of a distribution is the measure that minimizes the variance?, we know that the mean squared-error actually has a tighter lower-bound, which is when $\hat{Y} = \mathbb{E}_{\mathcal{D}}[Y]$, such that the mean squared-error loss-function becomes
$$
\mathbb{E}_{\mathcal{D}}\left[(Y - \mathbb{E}_{\mathcal{D}}[Y])^2\right] = \text{Var}(Y)
$$
Since we know that the variance of $Y$ is non-negative, then the mean squared-error loss-function has the following lower-bounds
$$
\mathbb{E}_{\mathcal{D}}\left[(Y - \hat{Y})^2\right] \geq \text{Var}(Y) \geq 0
$$
In your case, you have reached the lower-bound $\text{Var}(Y)$, since you observe that $\hat{Y} = \mathbb{E}_{\mathcal{D}}[Y]$. This means that the bias (strictly speaking, this is not the correct definition of bias, but it gets the point across.) of $\hat{Y}$ is
$$
(Y - \hat{Y})^2 = (Y - \mathbb{E}_{\mathcal{D}}[Y])^2
$$
The variance of $\hat{Y}$ is
$$
\mathbb{E}_{\mathcal{D}}\left[\left(\hat{Y} - \mathbb{E}_{\mathcal{D}}\left[\hat{Y}\right]\right)^2\right] = \mathbb{E}_{\mathcal{D}}\left[\left(\mathbb{E}_{\mathcal{D}}[Y] - \mathbb{E}_{\mathcal{D}}[\mathbb{E}_{\mathcal{D}}[Y]]\right)^2\right] = 0
$$
Clearly, you have too much bias and too little variance.
So, how do we reach the lower-lower-bound of $0$? We need to increase the variance of $\hat{Y}$ by either adding more parameters to the network or adjusting the network architecture. As discussed in What should I do when my neural network doesn't learn? (highly recommended read), consider over-fitting and then testing your network on a single example by adding many more parameters or by adjusting the network architecture.
If the network no longer predicts the mean on a single example, then you can scale up slowly and start over-fitting and testing the network on two examples, then three examples, and so on. Otherwise, you need to keep adding more parameters/adjusting the network architecture until your network no longer predicts the mean.
Eventually, once you reach a dataset size of around 100 examples, you can start to split your data into training and testing to evaluate the generalization performance of your network. At this point, if it starts to predict the mean again, then make sure that the examples that you are adding to the dataset are similar to the examples that you already worked through in the smaller datasets. In other words, they are normalized and "look" similar. Also, keep in mind that as you add more data to the dataset, you will more likely need to add more parameters for better generalization performance.
Another helpful modification, but not as helpful as what I stated above, that helps in practice, is to slightly adjust the mean squared-error loss function itself. If your mean squared-error loss function is
$$
\mathcal{L}(y,\hat{y}) = \frac{1}{N} \sum_{i=1}^N (y_i-\hat{y}_i)^2
$$
where $N$ is the dataset size, then consider using the following loss function instead:
$$
\mathcal{L}(y,\hat{y}) = \left[\frac{1}{N} \sum_{i=1}^N (y_i-\hat{y}_i)^2\right] + \alpha \cdot \left[\frac{1}{N} \sum_{i=1}^N (\log(y_i)-\log(\hat{y}_i))^2\right]
$$
Where $\alpha$ is a hyperparameter that can be tuned via trial and error. A starting value for $\alpha$ could be $\alpha=5$. The advantage of this loss function over the plain mean squared-error loss function is that the $\log(\cdot)$ function stretches small values in the interval $[0,1]$ away from each other, which means that small differences between $y$ and $\hat{y}$ are amplified, leading to larger gradients. I have personally found this modified loss function to be very helpful in practice.
For this to work well, it is recommended (but not necessary) that $y$ and $\hat{y}$ are each scaled to have values in the interval $[0,1]$. Also, since $\log(0)=-\infty$, and since it is likely that $y$ and $\hat{y}$ will have values very close to $0$, then it is recommended to add a small value $\epsilon$, such as $\epsilon=10^{-9}$, to $y$ and $\hat{y}$ in the loss function as follows:
$$
\mathcal{L}(y,\hat{y}) = \left[\frac{1}{N} \sum_{i=1}^N (y_i-\hat{y}_i)^2\right] + \alpha \cdot \left[\frac{1}{N} \sum_{i=1}^N (\log(y_i + \epsilon)-\log(\hat{y}_i + \epsilon))^2\right]
$$
This loss function may be thought of as the Mean Squared Log-scaled Error Loss.
|
Training a neural network for regression always predicts the mean
I am going to contradict @Pieter's answer and say that your problem is that you have too much bias and too little variance. In other words, your network is not complex enough for this task.
To see thi
|
7,530
|
Training a neural network for regression always predicts the mean
|
It means that your model decides to "do nothing" rather than prediction. And you should know that "doing nothing" will get a lower error than a random guess for the regression.
For example, if the true values are in the range [-10 10], then keep predicting 0 will return you about 2.5 mean absolute error; In contrast, if you try to guess values in the same range, you will get about 3.3 mean absolute error.
Therefore, if the model finds itself doesn't have the ability to make predictions better than random guesses, or maybe only a little bit better than random guesses (say MAE=2.8), then it will give up and choose to output zeros.
The problem may come from the model design (for example, capacity), or maybe just the data labels are too weak (for example, random labels).
Actually, this problem always appears in regression problems, as long as your data labels and/or models are not perfect, regardless of the data balance.
|
Training a neural network for regression always predicts the mean
|
It means that your model decides to "do nothing" rather than prediction. And you should know that "doing nothing" will get a lower error than a random guess for the regression.
For example, if the tru
|
Training a neural network for regression always predicts the mean
It means that your model decides to "do nothing" rather than prediction. And you should know that "doing nothing" will get a lower error than a random guess for the regression.
For example, if the true values are in the range [-10 10], then keep predicting 0 will return you about 2.5 mean absolute error; In contrast, if you try to guess values in the same range, you will get about 3.3 mean absolute error.
Therefore, if the model finds itself doesn't have the ability to make predictions better than random guesses, or maybe only a little bit better than random guesses (say MAE=2.8), then it will give up and choose to output zeros.
The problem may come from the model design (for example, capacity), or maybe just the data labels are too weak (for example, random labels).
Actually, this problem always appears in regression problems, as long as your data labels and/or models are not perfect, regardless of the data balance.
|
Training a neural network for regression always predicts the mean
It means that your model decides to "do nothing" rather than prediction. And you should know that "doing nothing" will get a lower error than a random guess for the regression.
For example, if the tru
|
7,531
|
Training a neural network for regression always predicts the mean
|
I was actually working on a very similar problem. Basically, I had a bunch of dots on a white background and I was training a NN to recognize the dot that was placed on the background first. The way I found to work was to just use one fully-connected layer of neurons (so a 1-layer NN). For example, for a 100x100 image, I would have 10,000 input neurons (the pixels) directly connected to 2 output neurons (the coordinates). In PyTorch, when I converted the pixel values to a tensor, it was normalizing my data automatically, by subtracting the mean and dividing by the standard deviation. In normal machine learning problems, this is fine, but not for an image where there might be a disparity in the number of colored pixels in an image (i.e. yours where there are only a few white pixels). So, I manually normalized by dividing all pixel intensity values by 255 (so they're now in the range of 0-1 without the typical normalization technique that tries to fit all the intensity values to a normal distribution). Then, I still had issues because it was predicting the average coordinate of the pixels in the training set. So, my solution was to set the learning rate very high, which goes against almost all ML instructors and tutorials. Instead of using 1e-3, 1e-4, 1e-5, like most people say, I was using a learning rate of 1 or 0.1 with stochastic gradient descent. This fixed my issues and my network finally learned to memorize my training set. It doesn't generalize to a testing set too well, but at least it somewhat works, which is a better solution than most everybody else suggested on your question.
|
Training a neural network for regression always predicts the mean
|
I was actually working on a very similar problem. Basically, I had a bunch of dots on a white background and I was training a NN to recognize the dot that was placed on the background first. The way I
|
Training a neural network for regression always predicts the mean
I was actually working on a very similar problem. Basically, I had a bunch of dots on a white background and I was training a NN to recognize the dot that was placed on the background first. The way I found to work was to just use one fully-connected layer of neurons (so a 1-layer NN). For example, for a 100x100 image, I would have 10,000 input neurons (the pixels) directly connected to 2 output neurons (the coordinates). In PyTorch, when I converted the pixel values to a tensor, it was normalizing my data automatically, by subtracting the mean and dividing by the standard deviation. In normal machine learning problems, this is fine, but not for an image where there might be a disparity in the number of colored pixels in an image (i.e. yours where there are only a few white pixels). So, I manually normalized by dividing all pixel intensity values by 255 (so they're now in the range of 0-1 without the typical normalization technique that tries to fit all the intensity values to a normal distribution). Then, I still had issues because it was predicting the average coordinate of the pixels in the training set. So, my solution was to set the learning rate very high, which goes against almost all ML instructors and tutorials. Instead of using 1e-3, 1e-4, 1e-5, like most people say, I was using a learning rate of 1 or 0.1 with stochastic gradient descent. This fixed my issues and my network finally learned to memorize my training set. It doesn't generalize to a testing set too well, but at least it somewhat works, which is a better solution than most everybody else suggested on your question.
|
Training a neural network for regression always predicts the mean
I was actually working on a very similar problem. Basically, I had a bunch of dots on a white background and I was training a NN to recognize the dot that was placed on the background first. The way I
|
7,532
|
Training a neural network for regression always predicts the mean
|
I am facing the same problem with my data set. It turns out that in my case the predictors are highly concentrated with a very small variance. You should check out the variance of your prediction variables and see how it is distributed.
However, some transformations on the output variable can be performed to modify or change its scale. This might result in a more uniform type distribution. For example, in image recognition tasks histogram equalization or contrast enhancement sometimes works in the favor of correct decision making.
|
Training a neural network for regression always predicts the mean
|
I am facing the same problem with my data set. It turns out that in my case the predictors are highly concentrated with a very small variance. You should check out the variance of your prediction vari
|
Training a neural network for regression always predicts the mean
I am facing the same problem with my data set. It turns out that in my case the predictors are highly concentrated with a very small variance. You should check out the variance of your prediction variables and see how it is distributed.
However, some transformations on the output variable can be performed to modify or change its scale. This might result in a more uniform type distribution. For example, in image recognition tasks histogram equalization or contrast enhancement sometimes works in the favor of correct decision making.
|
Training a neural network for regression always predicts the mean
I am facing the same problem with my data set. It turns out that in my case the predictors are highly concentrated with a very small variance. You should check out the variance of your prediction vari
|
7,533
|
Training a neural network for regression always predicts the mean
|
Here is a more information-theoretic reason for why this is happening. Let $Y$ be the true and correct output that your network should return (the target), and let $\hat{Y}$ be the output that your network actually returns. The problem that you observe is that $\hat{Y}=K$, where $K$ is some constant, which means that $Y$ is independent of $\hat{Y}$.
If we compute the mutual information between $Y$ and $\hat{Y}$, we observe that:
$$
I(Y;\hat{Y}) = h(Y) - h(Y|\hat{Y}) = h(Y) - h(Y) = 0
$$
Where $h(\cdot)$ is the differential entropy and $h(Y|\hat{Y})=h(Y)$ since $Y$ and $\hat{Y}$ are independent. In other words, if we assume that $Y \rightarrow \hat{Y}$ is a communications channel, then there is no information flowing between the input of the channel $Y$ and the output of the channel $\hat{Y}$!
A more accurate channel would be the Markov chain $Y \rightarrow X \rightarrow \hat{Y}$, where $X$ is the input to the network. However, by the data processing inequality:
$$
I(Y;\hat{Y}) \leq I(Y;X) \\
I(Y;\hat{Y}) \leq I(X;\hat{Y})
$$
Which are just upper-bounds on the mutual information $I(Y;\hat{Y})$. Our objective is to increase the mutual information $I(Y;\hat{Y})$, which can be done by increasing a lower-bound on $I(Y;\hat{Y})$. So, we are not interested in $I(Y;X)$ and $I(X;\hat{Y})$ at this time.
Now let the mean-squared error between $Y$ and $\hat{Y}$ be:
$$
\mathbb{E}\left[(Y-\hat{Y})^2\right] = \delta
$$
Now, to find a lower-bound on $I(Y;\hat{Y})$, note that:
$$
\begin{align}
I(Y;\hat{Y})
&= h(Y) - h(Y|\hat{Y}) \\
&= h(Y) - h(Y-\hat{Y}|\hat{Y}) \tag{1} \\
&\geq h(Y) - h(Y-\hat{Y}) \tag{2} \\
&\geq h(Y) - \frac{1}{2} \log{(2\pi e \delta)} \tag{3}
\end{align}
$$
Where:
$(1)$ is because differential entropy is translation invariant.
$(2)$ is because conditioning reduces entropy.
$(3)$ is because random variable $Z=Y-\hat{Y}$ has variance $\mathbb{E}[(Z-\mathbb{E}[Z])^2]=\mathbb{E}\left[(Y-\hat{Y})^2\right] = \delta$, and so this is the Gaussian bound on differential entropy.
So:
$$
I(Y;\hat{Y}) \geq h(Y) - \frac{1}{2} \log{(2\pi e \delta)}
$$
If we further assume that the target $Y$ has mean $\mathbb{E}[Y]=0$ and variance $\text{Var}(Y)=\sigma^2$, then we get the tighter lower-bound:
$$
I(Y;\hat{Y}) \geq \frac{1}{2} \log{(2\pi e \sigma^2)} - \frac{1}{2} \log{(2\pi e \delta)} \geq h(Y) - \frac{1}{2} \log{(2\pi e \delta)}
$$
And so we can increase the mutual information by either increasing the variance $\sigma^2$ of $Y$ or decreasing the mean squared-error $\delta$. Unfortunately, we do not usually have the ability to adjust the variance of $Y$, so we would need to resort to decreasing $\delta$.
Interestingly, we have just shown that minimizing the mean squared-error $\delta$ corresponds to maximizing the mutual information between $Y$ and $\hat{Y}$, and vice-versa. At first glance, it seems like there is a contradiction here: you clearly can achieve small mean squared-error values, which means that the mutual information between $Y$ and $\hat{Y}$ is maximized. However, what you practically observe is that the mutual information between $Y$ and $\hat{Y}$ is $0$.
To resolve this contradiction, it is helpful to take a closer look at the mean squared-error between $Y$ and $\hat{Y}$. We know that:
$$
\mathbb{E}\left[(Y-\hat{Y})^2\right] = \text{Var}(\hat{Y}) + \text{Bias}(\hat{Y},Y)^2
$$
Since both of these terms are non-negative, then the variance and bias of $\hat{Y}$ each individually form lower-bounds for the mean squared-error:
$$
\mathbb{E}\left[(Y-\hat{Y})^2\right] \geq \text{Var}(\hat{Y}) \\
\mathbb{E}\left[(Y-\hat{Y})^2\right] \geq \text{Bias}(\hat{Y},Y)^2
$$
And therefore the true lower-bounds on the mutual information are:
$$
I(Y;\hat{Y}) \geq h(Y) - \frac{1}{2} \log{(2\pi e \cdot \text{Var}(\hat{Y}))} \geq h(Y) - \frac{1}{2} \log{(2\pi e \delta)} \\
I(Y;\hat{Y}) \geq h(Y) - \frac{1}{2} \log{(2\pi e \cdot \text{Bias}(\hat{Y},Y)^2)} \geq h(Y) - \frac{1}{2} \log{(2\pi e \delta)}
$$
These new lower-bounds indicate that although your mean squared-error values were small, they were not small enough, as they are upper-bounded by the variance and bias of $\hat{Y}$. Therefore, what we really want to do to maximize the mutual information between $Y$ and $\hat{Y}$ is to decrease the variance and bias of $\hat{Y}$. Unfortunately, we know that there is a trade-off between the variance and bias of $\hat{Y}$.
|
Training a neural network for regression always predicts the mean
|
Here is a more information-theoretic reason for why this is happening. Let $Y$ be the true and correct output that your network should return (the target), and let $\hat{Y}$ be the output that your ne
|
Training a neural network for regression always predicts the mean
Here is a more information-theoretic reason for why this is happening. Let $Y$ be the true and correct output that your network should return (the target), and let $\hat{Y}$ be the output that your network actually returns. The problem that you observe is that $\hat{Y}=K$, where $K$ is some constant, which means that $Y$ is independent of $\hat{Y}$.
If we compute the mutual information between $Y$ and $\hat{Y}$, we observe that:
$$
I(Y;\hat{Y}) = h(Y) - h(Y|\hat{Y}) = h(Y) - h(Y) = 0
$$
Where $h(\cdot)$ is the differential entropy and $h(Y|\hat{Y})=h(Y)$ since $Y$ and $\hat{Y}$ are independent. In other words, if we assume that $Y \rightarrow \hat{Y}$ is a communications channel, then there is no information flowing between the input of the channel $Y$ and the output of the channel $\hat{Y}$!
A more accurate channel would be the Markov chain $Y \rightarrow X \rightarrow \hat{Y}$, where $X$ is the input to the network. However, by the data processing inequality:
$$
I(Y;\hat{Y}) \leq I(Y;X) \\
I(Y;\hat{Y}) \leq I(X;\hat{Y})
$$
Which are just upper-bounds on the mutual information $I(Y;\hat{Y})$. Our objective is to increase the mutual information $I(Y;\hat{Y})$, which can be done by increasing a lower-bound on $I(Y;\hat{Y})$. So, we are not interested in $I(Y;X)$ and $I(X;\hat{Y})$ at this time.
Now let the mean-squared error between $Y$ and $\hat{Y}$ be:
$$
\mathbb{E}\left[(Y-\hat{Y})^2\right] = \delta
$$
Now, to find a lower-bound on $I(Y;\hat{Y})$, note that:
$$
\begin{align}
I(Y;\hat{Y})
&= h(Y) - h(Y|\hat{Y}) \\
&= h(Y) - h(Y-\hat{Y}|\hat{Y}) \tag{1} \\
&\geq h(Y) - h(Y-\hat{Y}) \tag{2} \\
&\geq h(Y) - \frac{1}{2} \log{(2\pi e \delta)} \tag{3}
\end{align}
$$
Where:
$(1)$ is because differential entropy is translation invariant.
$(2)$ is because conditioning reduces entropy.
$(3)$ is because random variable $Z=Y-\hat{Y}$ has variance $\mathbb{E}[(Z-\mathbb{E}[Z])^2]=\mathbb{E}\left[(Y-\hat{Y})^2\right] = \delta$, and so this is the Gaussian bound on differential entropy.
So:
$$
I(Y;\hat{Y}) \geq h(Y) - \frac{1}{2} \log{(2\pi e \delta)}
$$
If we further assume that the target $Y$ has mean $\mathbb{E}[Y]=0$ and variance $\text{Var}(Y)=\sigma^2$, then we get the tighter lower-bound:
$$
I(Y;\hat{Y}) \geq \frac{1}{2} \log{(2\pi e \sigma^2)} - \frac{1}{2} \log{(2\pi e \delta)} \geq h(Y) - \frac{1}{2} \log{(2\pi e \delta)}
$$
And so we can increase the mutual information by either increasing the variance $\sigma^2$ of $Y$ or decreasing the mean squared-error $\delta$. Unfortunately, we do not usually have the ability to adjust the variance of $Y$, so we would need to resort to decreasing $\delta$.
Interestingly, we have just shown that minimizing the mean squared-error $\delta$ corresponds to maximizing the mutual information between $Y$ and $\hat{Y}$, and vice-versa. At first glance, it seems like there is a contradiction here: you clearly can achieve small mean squared-error values, which means that the mutual information between $Y$ and $\hat{Y}$ is maximized. However, what you practically observe is that the mutual information between $Y$ and $\hat{Y}$ is $0$.
To resolve this contradiction, it is helpful to take a closer look at the mean squared-error between $Y$ and $\hat{Y}$. We know that:
$$
\mathbb{E}\left[(Y-\hat{Y})^2\right] = \text{Var}(\hat{Y}) + \text{Bias}(\hat{Y},Y)^2
$$
Since both of these terms are non-negative, then the variance and bias of $\hat{Y}$ each individually form lower-bounds for the mean squared-error:
$$
\mathbb{E}\left[(Y-\hat{Y})^2\right] \geq \text{Var}(\hat{Y}) \\
\mathbb{E}\left[(Y-\hat{Y})^2\right] \geq \text{Bias}(\hat{Y},Y)^2
$$
And therefore the true lower-bounds on the mutual information are:
$$
I(Y;\hat{Y}) \geq h(Y) - \frac{1}{2} \log{(2\pi e \cdot \text{Var}(\hat{Y}))} \geq h(Y) - \frac{1}{2} \log{(2\pi e \delta)} \\
I(Y;\hat{Y}) \geq h(Y) - \frac{1}{2} \log{(2\pi e \cdot \text{Bias}(\hat{Y},Y)^2)} \geq h(Y) - \frac{1}{2} \log{(2\pi e \delta)}
$$
These new lower-bounds indicate that although your mean squared-error values were small, they were not small enough, as they are upper-bounded by the variance and bias of $\hat{Y}$. Therefore, what we really want to do to maximize the mutual information between $Y$ and $\hat{Y}$ is to decrease the variance and bias of $\hat{Y}$. Unfortunately, we know that there is a trade-off between the variance and bias of $\hat{Y}$.
|
Training a neural network for regression always predicts the mean
Here is a more information-theoretic reason for why this is happening. Let $Y$ be the true and correct output that your network should return (the target), and let $\hat{Y}$ be the output that your ne
|
7,534
|
Training a neural network for regression always predicts the mean
|
It looks like a typical overfitting problem. Your data does not provide enough information to get the better result. You choose the complex NN with you train to remember all nuances of the train data. Loss can never be a zero, as it is on your graph. BTW It seems your validation has a bug or validation set is not a good for validation because the validation loss is also getting zero.
|
Training a neural network for regression always predicts the mean
|
It looks like a typical overfitting problem. Your data does not provide enough information to get the better result. You choose the complex NN with you train to remember all nuances of the train data.
|
Training a neural network for regression always predicts the mean
It looks like a typical overfitting problem. Your data does not provide enough information to get the better result. You choose the complex NN with you train to remember all nuances of the train data. Loss can never be a zero, as it is on your graph. BTW It seems your validation has a bug or validation set is not a good for validation because the validation loss is also getting zero.
|
Training a neural network for regression always predicts the mean
It looks like a typical overfitting problem. Your data does not provide enough information to get the better result. You choose the complex NN with you train to remember all nuances of the train data.
|
7,535
|
What statistical blogs would you recommend?
|
http://www.r-bloggers.com/ is an aggregated blog from lots of blogs that talk about statistics using R, and the #rstats hashtag on twitter is also helpful. I write quite a bit about statistics and R in genetics research.
|
What statistical blogs would you recommend?
|
http://www.r-bloggers.com/ is an aggregated blog from lots of blogs that talk about statistics using R, and the #rstats hashtag on twitter is also helpful. I write quite a bit about statistics and R i
|
What statistical blogs would you recommend?
http://www.r-bloggers.com/ is an aggregated blog from lots of blogs that talk about statistics using R, and the #rstats hashtag on twitter is also helpful. I write quite a bit about statistics and R in genetics research.
|
What statistical blogs would you recommend?
http://www.r-bloggers.com/ is an aggregated blog from lots of blogs that talk about statistics using R, and the #rstats hashtag on twitter is also helpful. I write quite a bit about statistics and R i
|
7,536
|
What statistical blogs would you recommend?
|
Statistical Modeling, Causal Inference, and Social Science from Andrew Gelman is a good blog.
|
What statistical blogs would you recommend?
|
Statistical Modeling, Causal Inference, and Social Science from Andrew Gelman is a good blog.
|
What statistical blogs would you recommend?
Statistical Modeling, Causal Inference, and Social Science from Andrew Gelman is a good blog.
|
What statistical blogs would you recommend?
Statistical Modeling, Causal Inference, and Social Science from Andrew Gelman is a good blog.
|
7,537
|
What statistical blogs would you recommend?
|
The Endeavour sometimes features statistics posts. Otherwise it is mostly around the interplay of computer science and math.
|
What statistical blogs would you recommend?
|
The Endeavour sometimes features statistics posts. Otherwise it is mostly around the interplay of computer science and math.
|
What statistical blogs would you recommend?
The Endeavour sometimes features statistics posts. Otherwise it is mostly around the interplay of computer science and math.
|
What statistical blogs would you recommend?
The Endeavour sometimes features statistics posts. Otherwise it is mostly around the interplay of computer science and math.
|
7,538
|
What statistical blogs would you recommend?
|
In addition to those already mentioned, I like Rob Hyndman's blog:
http://robjhyndman.com/researchtips/
I guess he's too modest to mention it himself! ;-)
|
What statistical blogs would you recommend?
|
In addition to those already mentioned, I like Rob Hyndman's blog:
http://robjhyndman.com/researchtips/
I guess he's too modest to mention it himself! ;-)
|
What statistical blogs would you recommend?
In addition to those already mentioned, I like Rob Hyndman's blog:
http://robjhyndman.com/researchtips/
I guess he's too modest to mention it himself! ;-)
|
What statistical blogs would you recommend?
In addition to those already mentioned, I like Rob Hyndman's blog:
http://robjhyndman.com/researchtips/
I guess he's too modest to mention it himself! ;-)
|
7,539
|
What statistical blogs would you recommend?
|
Cosma Shalizi's blog, often talks about statistics, and is always interesting.
|
What statistical blogs would you recommend?
|
Cosma Shalizi's blog, often talks about statistics, and is always interesting.
|
What statistical blogs would you recommend?
Cosma Shalizi's blog, often talks about statistics, and is always interesting.
|
What statistical blogs would you recommend?
Cosma Shalizi's blog, often talks about statistics, and is always interesting.
|
7,540
|
What statistical blogs would you recommend?
|
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.
XI'AN'S OG
|
What statistical blogs would you recommend?
|
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 statistical blogs would you recommend?
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.
XI'AN'S OG
|
What statistical blogs would you recommend?
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.
|
7,541
|
What statistical blogs would you recommend?
|
Darren Wilkinson's research blog
|
What statistical blogs would you recommend?
|
Darren Wilkinson's research blog
|
What statistical blogs would you recommend?
Darren Wilkinson's research blog
|
What statistical blogs would you recommend?
Darren Wilkinson's research blog
|
7,542
|
What statistical blogs would you recommend?
|
I like Dave Giles' blog Econometrics Beat It has a time series focus, but lots of other interesting things as well. Here's a nice post on the Pythagorean means.
|
What statistical blogs would you recommend?
|
I like Dave Giles' blog Econometrics Beat It has a time series focus, but lots of other interesting things as well. Here's a nice post on the Pythagorean means.
|
What statistical blogs would you recommend?
I like Dave Giles' blog Econometrics Beat It has a time series focus, but lots of other interesting things as well. Here's a nice post on the Pythagorean means.
|
What statistical blogs would you recommend?
I like Dave Giles' blog Econometrics Beat It has a time series focus, but lots of other interesting things as well. Here's a nice post on the Pythagorean means.
|
7,543
|
What statistical blogs would you recommend?
|
simplystatistics.org is rather good. It is run by three biostatistics professors (Jeff Leek, Roger Peng, and Rafa Irizarry).
http://simplystatistics.org/
|
What statistical blogs would you recommend?
|
simplystatistics.org is rather good. It is run by three biostatistics professors (Jeff Leek, Roger Peng, and Rafa Irizarry).
http://simplystatistics.org/
|
What statistical blogs would you recommend?
simplystatistics.org is rather good. It is run by three biostatistics professors (Jeff Leek, Roger Peng, and Rafa Irizarry).
http://simplystatistics.org/
|
What statistical blogs would you recommend?
simplystatistics.org is rather good. It is run by three biostatistics professors (Jeff Leek, Roger Peng, and Rafa Irizarry).
http://simplystatistics.org/
|
7,544
|
What statistical blogs would you recommend?
|
Luckily now you don't have to spend too much effort finding good blogs. Stats Blogs is a relatively new aggregator which compiles a collection of blogs focused on statistics. A lot of the blogs mentioned are aggregated there.
|
What statistical blogs would you recommend?
|
Luckily now you don't have to spend too much effort finding good blogs. Stats Blogs is a relatively new aggregator which compiles a collection of blogs focused on statistics. A lot of the blogs ment
|
What statistical blogs would you recommend?
Luckily now you don't have to spend too much effort finding good blogs. Stats Blogs is a relatively new aggregator which compiles a collection of blogs focused on statistics. A lot of the blogs mentioned are aggregated there.
|
What statistical blogs would you recommend?
Luckily now you don't have to spend too much effort finding good blogs. Stats Blogs is a relatively new aggregator which compiles a collection of blogs focused on statistics. A lot of the blogs ment
|
7,545
|
What statistical blogs would you recommend?
|
http://blog.thegrandlocus.com/
This blog mixes basic concepts of statistics, everyday life and research. A must-read.
|
What statistical blogs would you recommend?
|
http://blog.thegrandlocus.com/
This blog mixes basic concepts of statistics, everyday life and research. A must-read.
|
What statistical blogs would you recommend?
http://blog.thegrandlocus.com/
This blog mixes basic concepts of statistics, everyday life and research. A must-read.
|
What statistical blogs would you recommend?
http://blog.thegrandlocus.com/
This blog mixes basic concepts of statistics, everyday life and research. A must-read.
|
7,546
|
What statistical blogs would you recommend?
|
FlowingData is a good read, with an emphasis on data visualization
|
What statistical blogs would you recommend?
|
FlowingData is a good read, with an emphasis on data visualization
|
What statistical blogs would you recommend?
FlowingData is a good read, with an emphasis on data visualization
|
What statistical blogs would you recommend?
FlowingData is a good read, with an emphasis on data visualization
|
7,547
|
What statistical blogs would you recommend?
|
Statistical Ideas at statisticalideas@blogspot.com for a mix of applied finance and theory.
|
What statistical blogs would you recommend?
|
Statistical Ideas at statisticalideas@blogspot.com for a mix of applied finance and theory.
|
What statistical blogs would you recommend?
Statistical Ideas at statisticalideas@blogspot.com for a mix of applied finance and theory.
|
What statistical blogs would you recommend?
Statistical Ideas at statisticalideas@blogspot.com for a mix of applied finance and theory.
|
7,548
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
|
For any one relationship, the odds of sharing the same month and day are approximately 1 in 365 (not exactly because of leap year and because births are not exactly evenly spaced within a year. If you add in year, it's probably something like 1 in 3000 or 4000 (most people have relationships with people relatively close in age).
But that' a priori.
That is, if you had asked, before meeting your current boyfriend "What are the odds that the next man I have a relationship with will be born on same day and year?" the odds would have been 1 in 3000 or so.
However, post hoc (that is, while in the relationship) it's trickier because you would have noticed a lot of other coincidences too: My boyfriend was born the day before me! My boyfriend's mother has the same name as my mother!" etc etc.
The odds of "some weird connection with my boyfriend" are impossible to calculate.
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
|
For any one relationship, the odds of sharing the same month and day are approximately 1 in 365 (not exactly because of leap year and because births are not exactly evenly spaced within a year. If you
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
For any one relationship, the odds of sharing the same month and day are approximately 1 in 365 (not exactly because of leap year and because births are not exactly evenly spaced within a year. If you add in year, it's probably something like 1 in 3000 or 4000 (most people have relationships with people relatively close in age).
But that' a priori.
That is, if you had asked, before meeting your current boyfriend "What are the odds that the next man I have a relationship with will be born on same day and year?" the odds would have been 1 in 3000 or so.
However, post hoc (that is, while in the relationship) it's trickier because you would have noticed a lot of other coincidences too: My boyfriend was born the day before me! My boyfriend's mother has the same name as my mother!" etc etc.
The odds of "some weird connection with my boyfriend" are impossible to calculate.
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
For any one relationship, the odds of sharing the same month and day are approximately 1 in 365 (not exactly because of leap year and because births are not exactly evenly spaced within a year. If you
|
7,549
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
|
As Peter pointed out, it is impossible to calculate coincidences after the fact.
Your question got me thinking, and I realized my girlfriend and I also have a strange birthday coincidence. She was born exactly 432 days before me! And we are also in a successful relationship!
I don't know what this probability is, but it is the exact same as yours!
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
|
As Peter pointed out, it is impossible to calculate coincidences after the fact.
Your question got me thinking, and I realized my girlfriend and I also have a strange birthday coincidence. She was bo
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
As Peter pointed out, it is impossible to calculate coincidences after the fact.
Your question got me thinking, and I realized my girlfriend and I also have a strange birthday coincidence. She was born exactly 432 days before me! And we are also in a successful relationship!
I don't know what this probability is, but it is the exact same as yours!
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
As Peter pointed out, it is impossible to calculate coincidences after the fact.
Your question got me thinking, and I realized my girlfriend and I also have a strange birthday coincidence. She was bo
|
7,550
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
|
So, first of all, the odds of sharing some weird connection with any random person are probably quite high. From experience I'd guess around 20% or so, no way to seriously calculate that, but no matter what it exactly is, just want to be clear having a special weird connection means nothing (though it is fun).
Then, something the other didn't take into account, looking at birth rates per month
we get a nice overview (it's caused by things like people being off thus having a lot of free time on hand 9 months before the months in question), next dividing that percentage by the number of days in that month.
Next one should figure out what the chance is of being born in the same year. Just to give an impression of this chance I'd start with the rule of thumb as presented by xkcd which gives a dating age range of $\pm \ age-\frac{age}{2}+7$, where age $=$ age you started dating. Which in turn gives $P(same\ year)=\frac{1}{pool\ size}$. However, the chances of dating someone from the exact same year are far greater due to a flaw in the educational system where pooling is done by the date of conception. A consequence of this is that the pool of people you know from the exact same ages is by guesstimation a factor of 5 bigger than the expected value, if $age<24$ or so.
What that exactly boils down to depends on age and month born, but for me it boiled down to more than 0.2% (1 in 500). Definitely not normal, but then again, coming full circle, you will find something like that for everyone after the fact.
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
|
So, first of all, the odds of sharing some weird connection with any random person are probably quite high. From experience I'd guess around 20% or so, no way to seriously calculate that, but no matte
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
So, first of all, the odds of sharing some weird connection with any random person are probably quite high. From experience I'd guess around 20% or so, no way to seriously calculate that, but no matter what it exactly is, just want to be clear having a special weird connection means nothing (though it is fun).
Then, something the other didn't take into account, looking at birth rates per month
we get a nice overview (it's caused by things like people being off thus having a lot of free time on hand 9 months before the months in question), next dividing that percentage by the number of days in that month.
Next one should figure out what the chance is of being born in the same year. Just to give an impression of this chance I'd start with the rule of thumb as presented by xkcd which gives a dating age range of $\pm \ age-\frac{age}{2}+7$, where age $=$ age you started dating. Which in turn gives $P(same\ year)=\frac{1}{pool\ size}$. However, the chances of dating someone from the exact same year are far greater due to a flaw in the educational system where pooling is done by the date of conception. A consequence of this is that the pool of people you know from the exact same ages is by guesstimation a factor of 5 bigger than the expected value, if $age<24$ or so.
What that exactly boils down to depends on age and month born, but for me it boiled down to more than 0.2% (1 in 500). Definitely not normal, but then again, coming full circle, you will find something like that for everyone after the fact.
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
So, first of all, the odds of sharing some weird connection with any random person are probably quite high. From experience I'd guess around 20% or so, no way to seriously calculate that, but no matte
|
7,551
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
|
If it's an event specified before the fact, you can simply break it down:
The chance that your boyfriend was born the same year as you is actually very high (especially given many situations tend to bring people of very similar age together); it's a very difficult probability to calculate, though, without data.
If you had that probability, P(Same day and same year) = P(Same year) $\times$ P(Same day|same year).
But P(same day) should be roughly independent of whether you were born in the same year. So it will be $\approx$ P(Same year) $\times$ P(Same day).
So if you had some good estimate of P(Same year), you can calculate the overall probability reasonably well.
I'd guess that P(same year) is roughly of the order of 0.1 to 0.2, but that's just a guess. [Edit: Jeromy gives a figure based on actual data, which turns out to be about 17%.]
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
|
If it's an event specified before the fact, you can simply break it down:
The chance that your boyfriend was born the same year as you is actually very high (especially given many situations tend to b
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
If it's an event specified before the fact, you can simply break it down:
The chance that your boyfriend was born the same year as you is actually very high (especially given many situations tend to bring people of very similar age together); it's a very difficult probability to calculate, though, without data.
If you had that probability, P(Same day and same year) = P(Same year) $\times$ P(Same day|same year).
But P(same day) should be roughly independent of whether you were born in the same year. So it will be $\approx$ P(Same year) $\times$ P(Same day).
So if you had some good estimate of P(Same year), you can calculate the overall probability reasonably well.
I'd guess that P(same year) is roughly of the order of 0.1 to 0.2, but that's just a guess. [Edit: Jeromy gives a figure based on actual data, which turns out to be about 17%.]
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
If it's an event specified before the fact, you can simply break it down:
The chance that your boyfriend was born the same year as you is actually very high (especially given many situations tend to b
|
7,552
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
|
Taking the question literally
According to wikipedia, 33.2% of married couples in the United States differ in age by less than one year.
Thus, a baseline estimate for sharing the same date of birth would be the above statistic divided by two (because it captures 2 years) for sharing the same year multiplied by the probability of sharing the same birthday:
$$P(DOB_i=DOB_j)\approx \frac{0.332}{2} \times \frac{1}{365} = 0.00045$$
Or roughly 1 in 2200.
As has been noted, both the shared year and shared birthday probabilities could be further refined based on additional information.
Probability of shared year: The distribution of age differences in relationships varies based on many factors including culture and time. Also, the above statistic is for a year difference. Dividing by two might lead to an underestimation because the probability of being within six months of age is probably more than half the probability of being within a year.
Shared date of birth: There could be tweaks to this. In particular, the uneven distribution of births throughout the year could have a small effect. If you're born in a leap year, then you have 366 as the base divisor. Then there is the elusive effect that being born on the same day might have on you both. In particular, if you are a person who reads into such things and searches for coincidences, such a coincidence might subtly increase your chances of staying together.
Thinking about other coincidences
When it comes to two people, there are many potential sources of coincidences. Humans are very good at identifying patterns. Within the domain of date of births, you could imagine many possible similarities: same month; same day of month; same star sign; same birthday, different year; some similarity in the numbers such as 2nd of May and 5th of February; dates are some round number apart (e.g., 8th of May 18th of May); dates are only only some small number apart (e.g., 8th and 9th of May). We could in some sense describe our sense to which any of these feel surprising or like a major coincidence.
But of course, when we speak about coincidences there is a much wide domain of search. For example, we could look at similarities in names, employment history, appearance, etc. The larger you cast the search, the more possible bases there are for finding coincidences.
In general, the more you look for them, the more you will see them. This is analogous to the analyst who performs many post-hoc statistical tests without correcting alpha. With enough analyses, the probability of finding a significant pattern gets close to one even when alpha is small.
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
|
Taking the question literally
According to wikipedia, 33.2% of married couples in the United States differ in age by less than one year.
Thus, a baseline estimate for sharing the same date of birth wo
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
Taking the question literally
According to wikipedia, 33.2% of married couples in the United States differ in age by less than one year.
Thus, a baseline estimate for sharing the same date of birth would be the above statistic divided by two (because it captures 2 years) for sharing the same year multiplied by the probability of sharing the same birthday:
$$P(DOB_i=DOB_j)\approx \frac{0.332}{2} \times \frac{1}{365} = 0.00045$$
Or roughly 1 in 2200.
As has been noted, both the shared year and shared birthday probabilities could be further refined based on additional information.
Probability of shared year: The distribution of age differences in relationships varies based on many factors including culture and time. Also, the above statistic is for a year difference. Dividing by two might lead to an underestimation because the probability of being within six months of age is probably more than half the probability of being within a year.
Shared date of birth: There could be tweaks to this. In particular, the uneven distribution of births throughout the year could have a small effect. If you're born in a leap year, then you have 366 as the base divisor. Then there is the elusive effect that being born on the same day might have on you both. In particular, if you are a person who reads into such things and searches for coincidences, such a coincidence might subtly increase your chances of staying together.
Thinking about other coincidences
When it comes to two people, there are many potential sources of coincidences. Humans are very good at identifying patterns. Within the domain of date of births, you could imagine many possible similarities: same month; same day of month; same star sign; same birthday, different year; some similarity in the numbers such as 2nd of May and 5th of February; dates are some round number apart (e.g., 8th of May 18th of May); dates are only only some small number apart (e.g., 8th and 9th of May). We could in some sense describe our sense to which any of these feel surprising or like a major coincidence.
But of course, when we speak about coincidences there is a much wide domain of search. For example, we could look at similarities in names, employment history, appearance, etc. The larger you cast the search, the more possible bases there are for finding coincidences.
In general, the more you look for them, the more you will see them. This is analogous to the analyst who performs many post-hoc statistical tests without correcting alpha. With enough analyses, the probability of finding a significant pattern gets close to one even when alpha is small.
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
Taking the question literally
According to wikipedia, 33.2% of married couples in the United States differ in age by less than one year.
Thus, a baseline estimate for sharing the same date of birth wo
|
7,553
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
|
The chances for this to happen.... two people having their birthday on the same day as explained by the other posters is 1/365 * 1/30 to be conservative here with the age ranges. To be in a relationship, a successful one multiply by maybe 1/2 or 1/3?!
However, for you to be in a relationship, you first have to be here. For you to be here, your mom and dad needed to get together - how likely was that then? Then their parents, grandparents, great grandparents, predecessors, apes, fish, amoebas, rays of sun hitting the first predecessors to plants, back to the big bang going as it did and whatever was before it. If you consider all, then every atom in the universe had to be exactly the way it was for you to be there.
You could almost say it's a miracle you guys got together.
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
|
The chances for this to happen.... two people having their birthday on the same day as explained by the other posters is 1/365 * 1/30 to be conservative here with the age ranges. To be in a relationsh
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
The chances for this to happen.... two people having their birthday on the same day as explained by the other posters is 1/365 * 1/30 to be conservative here with the age ranges. To be in a relationship, a successful one multiply by maybe 1/2 or 1/3?!
However, for you to be in a relationship, you first have to be here. For you to be here, your mom and dad needed to get together - how likely was that then? Then their parents, grandparents, great grandparents, predecessors, apes, fish, amoebas, rays of sun hitting the first predecessors to plants, back to the big bang going as it did and whatever was before it. If you consider all, then every atom in the universe had to be exactly the way it was for you to be there.
You could almost say it's a miracle you guys got together.
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
The chances for this to happen.... two people having their birthday on the same day as explained by the other posters is 1/365 * 1/30 to be conservative here with the age ranges. To be in a relationsh
|
7,554
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
|
Although the question is about birthdays, the "birthday paradox" isn't really relevant here. It's about how many random samples you need to take before you expect at least two samples among them to be equal (a collision). Your question is mostly about the probability of two samples being equal. If there were 30 people in your relationship then you'd expect two of them to share a birthday but there aren't 30 people, there are only 2.
The odds of having a relationship only have quite a small effect. Most people have a relationship at one time or another. I'd guess more than half of adults have one right at this moment. Some people have several at once, mentioning no Présidents de la République in particular ;-) So it's not going to massively reduce the odds, maybe halve them.
The main consideration is, given this significant person, what is the probability of them sharing your birthday? On pure chance it'd be roughly 1/365 given that the person in question exists at all. Since you choose a partner based on everything you know about them, which includes their birthday, you can't discount the possibility that the actual incidence is significantly higher or lower.
Look at it another way: what's the chance of there being someone who delivers your post and shares your birthday? The chance of a randomly-selected person being the one who delivers your post is tiny, but so what if it is? It doesn't affect the answer. Assuming universal delivery (which I can in my country), someone delivers my post. If there's only one then the answer is roughly 1/365. We can completely exclude from consideration all the people who don't deliver my post, they don't affect the odds no matter how many of them there are.
What's the chance that you have a partner who shares your birthday? It's about 1/365, times the chance you have a partner. Then adjusted by any factors that mean sharing your birthday is correlated or anti-correlated with dating you.
What's the chance that your boyfriend shares your birthday? Well the question pretty much assumes that you have a boyfriend, so strike that part from consideration!
To incorporate the year you need to look at the way the age differences in relationships are distributed. As a rough guess, I'd look at what proportion of relationships have an age difference of less than a year, and multiply my previous number by that. Of course, if you have access to that kind of data you might just be able to look at what proportion of relationships match your criteria, and get the exact frequency without estimating anything :-)
In a society where there's a strong tradition that the man should be somewhat older than the woman in a relationship, you might find that the proportion of age differences below a year is very small, and the proportion couples who share date and year of birth is tiny. This could be the case even if the average age difference is just a couple of years. So maybe you are special, by bucking society's rules. Myself, I'd guess that the proportion of relationships with an age difference less than a year is probably over 10%. But I wouldn't be surprised to be wrong and besides, a lot of my friends met their partners at university, which clearly affects the age difference among the available candidates and that biases what I see to make my guess. Everyone's equal in modern society (right?), but "the man a couple of years older than the woman" is probably a stereotype for a reason.
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
|
Although the question is about birthdays, the "birthday paradox" isn't really relevant here. It's about how many random samples you need to take before you expect at least two samples among them to be
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
Although the question is about birthdays, the "birthday paradox" isn't really relevant here. It's about how many random samples you need to take before you expect at least two samples among them to be equal (a collision). Your question is mostly about the probability of two samples being equal. If there were 30 people in your relationship then you'd expect two of them to share a birthday but there aren't 30 people, there are only 2.
The odds of having a relationship only have quite a small effect. Most people have a relationship at one time or another. I'd guess more than half of adults have one right at this moment. Some people have several at once, mentioning no Présidents de la République in particular ;-) So it's not going to massively reduce the odds, maybe halve them.
The main consideration is, given this significant person, what is the probability of them sharing your birthday? On pure chance it'd be roughly 1/365 given that the person in question exists at all. Since you choose a partner based on everything you know about them, which includes their birthday, you can't discount the possibility that the actual incidence is significantly higher or lower.
Look at it another way: what's the chance of there being someone who delivers your post and shares your birthday? The chance of a randomly-selected person being the one who delivers your post is tiny, but so what if it is? It doesn't affect the answer. Assuming universal delivery (which I can in my country), someone delivers my post. If there's only one then the answer is roughly 1/365. We can completely exclude from consideration all the people who don't deliver my post, they don't affect the odds no matter how many of them there are.
What's the chance that you have a partner who shares your birthday? It's about 1/365, times the chance you have a partner. Then adjusted by any factors that mean sharing your birthday is correlated or anti-correlated with dating you.
What's the chance that your boyfriend shares your birthday? Well the question pretty much assumes that you have a boyfriend, so strike that part from consideration!
To incorporate the year you need to look at the way the age differences in relationships are distributed. As a rough guess, I'd look at what proportion of relationships have an age difference of less than a year, and multiply my previous number by that. Of course, if you have access to that kind of data you might just be able to look at what proportion of relationships match your criteria, and get the exact frequency without estimating anything :-)
In a society where there's a strong tradition that the man should be somewhat older than the woman in a relationship, you might find that the proportion of age differences below a year is very small, and the proportion couples who share date and year of birth is tiny. This could be the case even if the average age difference is just a couple of years. So maybe you are special, by bucking society's rules. Myself, I'd guess that the proportion of relationships with an age difference less than a year is probably over 10%. But I wouldn't be surprised to be wrong and besides, a lot of my friends met their partners at university, which clearly affects the age difference among the available candidates and that biases what I see to make my guess. Everyone's equal in modern society (right?), but "the man a couple of years older than the woman" is probably a stereotype for a reason.
|
Birthday paradox with a (huge) twist: Probability of sharing exact same date of birth with partner?
Although the question is about birthdays, the "birthday paradox" isn't really relevant here. It's about how many random samples you need to take before you expect at least two samples among them to be
|
7,555
|
Why do some people use -999 or -9999 to replace missing values?
|
This is a holdout from earlier times, when computer software stored numerical vectors as numerical vectors. No real number has the semantics "I'm missing". So when early statistical software had to differentiate between "true" numbers and missing values, they put in something that was "obviously" not a valid number, like -999 or -9999.
Of course, that -999 or -9999 stood for a missing value is not "obvious" at all. Quite often, it can certainly be a valid value. Unless you explicitly check for such values, you can have all kinds of "interesting" errors in your analyses.
Nowadays, numerical vectors that can contain missing values are internally represented as "enriched" numerical vectors, i.e., numerical vectors with additional information as to which values are missing. This of course is much better, because then missing values will be treated as such and not mistakenly treated as valid.
Unfortunately, some software still uses such a convention, perhaps for compatibility. And some users have soaked up this convention through informal osmosis and enter -999 instead of NA even if their software supports cleanly entering missing values.
Moral: don't encode missing values as -999.
|
Why do some people use -999 or -9999 to replace missing values?
|
This is a holdout from earlier times, when computer software stored numerical vectors as numerical vectors. No real number has the semantics "I'm missing". So when early statistical software had to di
|
Why do some people use -999 or -9999 to replace missing values?
This is a holdout from earlier times, when computer software stored numerical vectors as numerical vectors. No real number has the semantics "I'm missing". So when early statistical software had to differentiate between "true" numbers and missing values, they put in something that was "obviously" not a valid number, like -999 or -9999.
Of course, that -999 or -9999 stood for a missing value is not "obvious" at all. Quite often, it can certainly be a valid value. Unless you explicitly check for such values, you can have all kinds of "interesting" errors in your analyses.
Nowadays, numerical vectors that can contain missing values are internally represented as "enriched" numerical vectors, i.e., numerical vectors with additional information as to which values are missing. This of course is much better, because then missing values will be treated as such and not mistakenly treated as valid.
Unfortunately, some software still uses such a convention, perhaps for compatibility. And some users have soaked up this convention through informal osmosis and enter -999 instead of NA even if their software supports cleanly entering missing values.
Moral: don't encode missing values as -999.
|
Why do some people use -999 or -9999 to replace missing values?
This is a holdout from earlier times, when computer software stored numerical vectors as numerical vectors. No real number has the semantics "I'm missing". So when early statistical software had to di
|
7,556
|
Why do some people use -999 or -9999 to replace missing values?
|
Such values are for databases. Most databases long ago, and many today, allocated a fixed number of digits for integer-valued data. A number like -999 is the smallest that can be stored in four characters, -9999 in five characters, and so on.
(It should go without saying that--by definition--a numeric field cannot store alphanumeric characters such as "NA". Some numeric code has to be used to represent missing or invalid data.)
Why use the most negative number that can be stored to signify a missing value? Because if you mistakenly treat it as a valid number, you want the results to be dramatically incorrect. The further your codes for missing values get from being realistic, the safer you are, because hugely wrong input usually screws up the output. (Robust statistical methods are notable exceptions!)
How could such a mistake happen? This occurs all the time when data are exchanged between systems. A system that assumes -9999 represents a missing value will blithely output that value when you write the data out in most formats, such as CSV. The system that reads that CSV file might not "know" (or not be "told") to treat such values as missing.
Another reason is that good statistical data and computing platforms recognize many different kinds of missing values: NaNs, truly missing values, overflows, underflows, non-responses, etc, etc. By devoting the most negative possible values (such as -9999, -9998, -9997, etc) to these, you make it easy to query out all missing values from any table or array.
Yet another is that such values usually show up in graphical displays as extreme outliers. Of all the values you could choose to stand out in a graphic, the most negative possible one stands the greatest chance of being far from your data.
There are useful implications and generalizations:
A good value to use for missing data in floating-point fields is the most negative valid number, equal approximately to $-10^{303}$ for double-precision floats. (Imagine the effect that would have on any average!) On the same principle, many old programs, which used single-precision floats, used somewhat arbitrary large numbers such as 1E+30 for missing values.
Adopt a standard rule of this type to make it easy to invent NoData codes in new circumstances (when you are designing your own database software).
Design your software and systems to fail dramatically if they fail at all. The worst bugs are those that are intermittent, random, or tiny, because they can go undetected and be difficult to hunt down.
|
Why do some people use -999 or -9999 to replace missing values?
|
Such values are for databases. Most databases long ago, and many today, allocated a fixed number of digits for integer-valued data. A number like -999 is the smallest that can be stored in four char
|
Why do some people use -999 or -9999 to replace missing values?
Such values are for databases. Most databases long ago, and many today, allocated a fixed number of digits for integer-valued data. A number like -999 is the smallest that can be stored in four characters, -9999 in five characters, and so on.
(It should go without saying that--by definition--a numeric field cannot store alphanumeric characters such as "NA". Some numeric code has to be used to represent missing or invalid data.)
Why use the most negative number that can be stored to signify a missing value? Because if you mistakenly treat it as a valid number, you want the results to be dramatically incorrect. The further your codes for missing values get from being realistic, the safer you are, because hugely wrong input usually screws up the output. (Robust statistical methods are notable exceptions!)
How could such a mistake happen? This occurs all the time when data are exchanged between systems. A system that assumes -9999 represents a missing value will blithely output that value when you write the data out in most formats, such as CSV. The system that reads that CSV file might not "know" (or not be "told") to treat such values as missing.
Another reason is that good statistical data and computing platforms recognize many different kinds of missing values: NaNs, truly missing values, overflows, underflows, non-responses, etc, etc. By devoting the most negative possible values (such as -9999, -9998, -9997, etc) to these, you make it easy to query out all missing values from any table or array.
Yet another is that such values usually show up in graphical displays as extreme outliers. Of all the values you could choose to stand out in a graphic, the most negative possible one stands the greatest chance of being far from your data.
There are useful implications and generalizations:
A good value to use for missing data in floating-point fields is the most negative valid number, equal approximately to $-10^{303}$ for double-precision floats. (Imagine the effect that would have on any average!) On the same principle, many old programs, which used single-precision floats, used somewhat arbitrary large numbers such as 1E+30 for missing values.
Adopt a standard rule of this type to make it easy to invent NoData codes in new circumstances (when you are designing your own database software).
Design your software and systems to fail dramatically if they fail at all. The worst bugs are those that are intermittent, random, or tiny, because they can go undetected and be difficult to hunt down.
|
Why do some people use -999 or -9999 to replace missing values?
Such values are for databases. Most databases long ago, and many today, allocated a fixed number of digits for integer-valued data. A number like -999 is the smallest that can be stored in four char
|
7,557
|
Why do some people use -999 or -9999 to replace missing values?
|
You can use anything to encode missing values. Some software, like R, use special values to encode missing data, but there are also software packages, e.g. SPSS, that do not have any special codes for missing data. In the second case you need to make arbitrary choice for such values. You can choose anything, but generally it is a good idea to choose some value that visibly differs from your data (e.g. your data are percentages in 0-100 range, so you choose 999 for encoding missing data, or your data is human age and you use negative values for missing observations). The idea behind it is that by doing so you should be able to notice if something went wrong and the numbers do not add up.
The problem with such encoding is however that you actually can not notice the special encoding and end up with rubbish results.
|
Why do some people use -999 or -9999 to replace missing values?
|
You can use anything to encode missing values. Some software, like R, use special values to encode missing data, but there are also software packages, e.g. SPSS, that do not have any special codes for
|
Why do some people use -999 or -9999 to replace missing values?
You can use anything to encode missing values. Some software, like R, use special values to encode missing data, but there are also software packages, e.g. SPSS, that do not have any special codes for missing data. In the second case you need to make arbitrary choice for such values. You can choose anything, but generally it is a good idea to choose some value that visibly differs from your data (e.g. your data are percentages in 0-100 range, so you choose 999 for encoding missing data, or your data is human age and you use negative values for missing observations). The idea behind it is that by doing so you should be able to notice if something went wrong and the numbers do not add up.
The problem with such encoding is however that you actually can not notice the special encoding and end up with rubbish results.
|
Why do some people use -999 or -9999 to replace missing values?
You can use anything to encode missing values. Some software, like R, use special values to encode missing data, but there are also software packages, e.g. SPSS, that do not have any special codes for
|
7,558
|
Why do some people use -999 or -9999 to replace missing values?
|
Are there computed variables in the dataset? Or is this an analytic dataset that comes form merged / sorted data? Some software uses very large negative values to denote missing data. But other software creates missing values with NA or .. When they are discrepant, usually some post processing has led to disagreement.
|
Why do some people use -999 or -9999 to replace missing values?
|
Are there computed variables in the dataset? Or is this an analytic dataset that comes form merged / sorted data? Some software uses very large negative values to denote missing data. But other softwa
|
Why do some people use -999 or -9999 to replace missing values?
Are there computed variables in the dataset? Or is this an analytic dataset that comes form merged / sorted data? Some software uses very large negative values to denote missing data. But other software creates missing values with NA or .. When they are discrepant, usually some post processing has led to disagreement.
|
Why do some people use -999 or -9999 to replace missing values?
Are there computed variables in the dataset? Or is this an analytic dataset that comes form merged / sorted data? Some software uses very large negative values to denote missing data. But other softwa
|
7,559
|
Why do some people use -999 or -9999 to replace missing values?
|
Of course, in SPSS, the missing value(s) 999 or whatever IS tagged as a special missing code and handled separately from other values. It may be tabulated separately or excluded entirely. A distinction is made from the result of things like zero division or log(0).
|
Why do some people use -999 or -9999 to replace missing values?
|
Of course, in SPSS, the missing value(s) 999 or whatever IS tagged as a special missing code and handled separately from other values. It may be tabulated separately or excluded entirely. A distinct
|
Why do some people use -999 or -9999 to replace missing values?
Of course, in SPSS, the missing value(s) 999 or whatever IS tagged as a special missing code and handled separately from other values. It may be tabulated separately or excluded entirely. A distinction is made from the result of things like zero division or log(0).
|
Why do some people use -999 or -9999 to replace missing values?
Of course, in SPSS, the missing value(s) 999 or whatever IS tagged as a special missing code and handled separately from other values. It may be tabulated separately or excluded entirely. A distinct
|
7,560
|
Why is generating 8 random bits uniform on (0, 255)?
|
TL;DR:
The sharp contrast between the bits and coins is that in the case of the coins, you're ignoring the order of the outcomes. HHHHTTTT is treated as the same as TTTTHHHH (both have 4 heads and 4 tails). But in bits, you care about the order (because you have to give "weights" to the bit positions in order to get 256 outcomes), so 11110000 is different from 00001111.
Longer explanation:
These concepts can be more precisely unified if we are a bit more formal in framing the problem. Consider an experiment to be a sequence of eight trials with dichotomous outcomes and probability of a "success" 0.5, and a "failure" 0.5, and the trials are independent. In general, I'll call this $k$ successes, $n$ total trials and $n-k$ failures and the probability of success is $p$.
In the coin example, the outcome "$k$ heads, $n-k$ tails" ignores the ordering of the trials (4 heads is 4 heads no matter the order of occurrence), and this gives rise to your observation that 4 heads are more likely than 0 or 8 heads. Four heads are more common because there are many ways to make four heads (TTHHTTHH, or HHTTHHTT, etc.) than there are some other number (8 heads only has one sequence). The binomial theorem gives the number of ways to make these different configurations.
By contrast, the order is important to bits because each place has an associated "weight" or "place value." One property of the binomial coefficient is that $2^n=\sum_{k=0}^n\binom{n}{k}$, that is if we count up all the different ordered sequences, we get $2^8=256$. This directly connects the idea of how many different ways there are to make $k$ heads in $n$ binomial trials to the number of different byte sequences.
Additionally, we can show that the 256 outcomes are equally likely by the property of independence. Previous trials have no influence on the next trial, so the probability of a particular ordering is, in general, $p^k(1-p)^{n-k}$ (because joint probability of independent events is the product of their probabilities). Because the trials are fair, $P(\text{success})=P(\text{fail})=p=0.5$, this expression reduces to $P(\text{any ordering})=0.5^8=\frac{1}{256}$. Because all orderings have the same probability, we have a uniform distribution over these outcomes (which by binary encoding can be represented as integers in $[0,255]$).
Finally, we can take this full circle back to the coin toss and binomial distribution. We know the occurrence of 0 heads doesn't have the same probability as 4 heads, and that this is because there are different ways to order the occurrences of 4 heads, and that the number of such orderings are given by the binomial theorem. So $P(\text{4 heads})$ must be weighted somehow, specifically it must be weighted by the binomial coefficient. So this gives us the PMF of the binomial distribution, $P(k \text{ successes})=\binom{n}{k}p^k(1-p)^{n-k}$. It might be surprising that this expression is a PMF, specifically because it's not immediately obvious that it sums to 1. To verify, we have to check that $\sum_{k=0}^n \binom{n}{k}p^k(1-p)^{n-k}=1$, however this is just a problem of binomial coefficients: $1=1^n=(p+1-p)^n=\sum_{k=0}^n \binom{n}{k}p^k(1-p)^{n-k}$.
|
Why is generating 8 random bits uniform on (0, 255)?
|
TL;DR:
The sharp contrast between the bits and coins is that in the case of the coins, you're ignoring the order of the outcomes. HHHHTTTT is treated as the same as TTTTHHHH (both have 4 heads and 4 t
|
Why is generating 8 random bits uniform on (0, 255)?
TL;DR:
The sharp contrast between the bits and coins is that in the case of the coins, you're ignoring the order of the outcomes. HHHHTTTT is treated as the same as TTTTHHHH (both have 4 heads and 4 tails). But in bits, you care about the order (because you have to give "weights" to the bit positions in order to get 256 outcomes), so 11110000 is different from 00001111.
Longer explanation:
These concepts can be more precisely unified if we are a bit more formal in framing the problem. Consider an experiment to be a sequence of eight trials with dichotomous outcomes and probability of a "success" 0.5, and a "failure" 0.5, and the trials are independent. In general, I'll call this $k$ successes, $n$ total trials and $n-k$ failures and the probability of success is $p$.
In the coin example, the outcome "$k$ heads, $n-k$ tails" ignores the ordering of the trials (4 heads is 4 heads no matter the order of occurrence), and this gives rise to your observation that 4 heads are more likely than 0 or 8 heads. Four heads are more common because there are many ways to make four heads (TTHHTTHH, or HHTTHHTT, etc.) than there are some other number (8 heads only has one sequence). The binomial theorem gives the number of ways to make these different configurations.
By contrast, the order is important to bits because each place has an associated "weight" or "place value." One property of the binomial coefficient is that $2^n=\sum_{k=0}^n\binom{n}{k}$, that is if we count up all the different ordered sequences, we get $2^8=256$. This directly connects the idea of how many different ways there are to make $k$ heads in $n$ binomial trials to the number of different byte sequences.
Additionally, we can show that the 256 outcomes are equally likely by the property of independence. Previous trials have no influence on the next trial, so the probability of a particular ordering is, in general, $p^k(1-p)^{n-k}$ (because joint probability of independent events is the product of their probabilities). Because the trials are fair, $P(\text{success})=P(\text{fail})=p=0.5$, this expression reduces to $P(\text{any ordering})=0.5^8=\frac{1}{256}$. Because all orderings have the same probability, we have a uniform distribution over these outcomes (which by binary encoding can be represented as integers in $[0,255]$).
Finally, we can take this full circle back to the coin toss and binomial distribution. We know the occurrence of 0 heads doesn't have the same probability as 4 heads, and that this is because there are different ways to order the occurrences of 4 heads, and that the number of such orderings are given by the binomial theorem. So $P(\text{4 heads})$ must be weighted somehow, specifically it must be weighted by the binomial coefficient. So this gives us the PMF of the binomial distribution, $P(k \text{ successes})=\binom{n}{k}p^k(1-p)^{n-k}$. It might be surprising that this expression is a PMF, specifically because it's not immediately obvious that it sums to 1. To verify, we have to check that $\sum_{k=0}^n \binom{n}{k}p^k(1-p)^{n-k}=1$, however this is just a problem of binomial coefficients: $1=1^n=(p+1-p)^n=\sum_{k=0}^n \binom{n}{k}p^k(1-p)^{n-k}$.
|
Why is generating 8 random bits uniform on (0, 255)?
TL;DR:
The sharp contrast between the bits and coins is that in the case of the coins, you're ignoring the order of the outcomes. HHHHTTTT is treated as the same as TTTTHHHH (both have 4 heads and 4 t
|
7,561
|
Why is generating 8 random bits uniform on (0, 255)?
|
why does a sequence of 8 zeroes or 8 ones seem to be equally as likely as a sequence of 4 and 4, or 5 and 3, etc
The aparent paradox can be summarized in two propositions, that might seem contradictory:
The sequence $s_1: 00000000$ (eight zeroes) is equally probable as sequence $s_2: 01010101$ (four zeroes, four ones). (In general: all $2^8$ sequences have the same probability, regardless of how many zeroes/ones they have.)
The event "$e_1$: the sequence had four zeroes" is more probable (indeed, $70$ times more probable) than the event "$e_2$: the sequence had eight zeroes".
These propositions are both true. Because the event $e_1$ includes many sequences.
|
Why is generating 8 random bits uniform on (0, 255)?
|
why does a sequence of 8 zeroes or 8 ones seem to be equally as likely as a sequence of 4 and 4, or 5 and 3, etc
The aparent paradox can be summarized in two propositions, that might seem contradicto
|
Why is generating 8 random bits uniform on (0, 255)?
why does a sequence of 8 zeroes or 8 ones seem to be equally as likely as a sequence of 4 and 4, or 5 and 3, etc
The aparent paradox can be summarized in two propositions, that might seem contradictory:
The sequence $s_1: 00000000$ (eight zeroes) is equally probable as sequence $s_2: 01010101$ (four zeroes, four ones). (In general: all $2^8$ sequences have the same probability, regardless of how many zeroes/ones they have.)
The event "$e_1$: the sequence had four zeroes" is more probable (indeed, $70$ times more probable) than the event "$e_2$: the sequence had eight zeroes".
These propositions are both true. Because the event $e_1$ includes many sequences.
|
Why is generating 8 random bits uniform on (0, 255)?
why does a sequence of 8 zeroes or 8 ones seem to be equally as likely as a sequence of 4 and 4, or 5 and 3, etc
The aparent paradox can be summarized in two propositions, that might seem contradicto
|
7,562
|
Why is generating 8 random bits uniform on (0, 255)?
|
All of the $2^8$ sequences have the same probability 1/$2^8$=1/256. It is a wrong to think that the sequences that have closer to an equal number of 0s and 1s is more likely as the question is interpreted.. It should be clear that we arrive at 1/256 because we assume independence from trial to trial. That is why we multiply the probabilities and the outcome of one trial has no influence on the next.
|
Why is generating 8 random bits uniform on (0, 255)?
|
All of the $2^8$ sequences have the same probability 1/$2^8$=1/256. It is a wrong to think that the sequences that have closer to an equal number of 0s and 1s is more likely as the question is interpr
|
Why is generating 8 random bits uniform on (0, 255)?
All of the $2^8$ sequences have the same probability 1/$2^8$=1/256. It is a wrong to think that the sequences that have closer to an equal number of 0s and 1s is more likely as the question is interpreted.. It should be clear that we arrive at 1/256 because we assume independence from trial to trial. That is why we multiply the probabilities and the outcome of one trial has no influence on the next.
|
Why is generating 8 random bits uniform on (0, 255)?
All of the $2^8$ sequences have the same probability 1/$2^8$=1/256. It is a wrong to think that the sequences that have closer to an equal number of 0s and 1s is more likely as the question is interpr
|
7,563
|
Why is generating 8 random bits uniform on (0, 255)?
|
EXAMPLE with 3 bits (often an example is more illustrative)
I will write the natural numbers 0 through 7 as:
A number in base 10
A number in base 2 (i.e. a sequence of bits)
A series of coin flips implied by the base 2 representation (1 denotes a flip of heads and 0 denotes a flip of tails).
$$\begin{array}
&\text{Base 10} & \text{Base 2 (with 3 bits)} & \text{Implied Coin Flip Series} &\text{Heads} & \text{Tails}\\
0 & 000 & TTT & 0 & 3 \\
1 & 001 & TTH & 1 & 2\\
2 & 010 & THT & 1 & 2\\
3 & 011 & THH & 2 & 1\\
4 & 100 & HTT & 1 & 2\\
5 & 101 & HTH & 2 & 1\\
6 & 110 & HHT & 2 & 1\\
7 & 111 & HHH & 3 & 0
\end{array} $$
Choosing a natural number from 0 through 7 with equal probability is equivalent to choosing one of the coin flip series on the right with equal probability.
Hence if you choose a number from the uniform distribution over integers 0-7, you have a $\frac{1}{8}$ chance of choosing 3 heads, $\frac{3}{8}$ chance of choosing 2 heads, $\frac{3}{8}$ chance of choosing 1 head, and $\frac{1}{8}$ chance of choosing 0 heads.
|
Why is generating 8 random bits uniform on (0, 255)?
|
EXAMPLE with 3 bits (often an example is more illustrative)
I will write the natural numbers 0 through 7 as:
A number in base 10
A number in base 2 (i.e. a sequence of bits)
A series of coin flips im
|
Why is generating 8 random bits uniform on (0, 255)?
EXAMPLE with 3 bits (often an example is more illustrative)
I will write the natural numbers 0 through 7 as:
A number in base 10
A number in base 2 (i.e. a sequence of bits)
A series of coin flips implied by the base 2 representation (1 denotes a flip of heads and 0 denotes a flip of tails).
$$\begin{array}
&\text{Base 10} & \text{Base 2 (with 3 bits)} & \text{Implied Coin Flip Series} &\text{Heads} & \text{Tails}\\
0 & 000 & TTT & 0 & 3 \\
1 & 001 & TTH & 1 & 2\\
2 & 010 & THT & 1 & 2\\
3 & 011 & THH & 2 & 1\\
4 & 100 & HTT & 1 & 2\\
5 & 101 & HTH & 2 & 1\\
6 & 110 & HHT & 2 & 1\\
7 & 111 & HHH & 3 & 0
\end{array} $$
Choosing a natural number from 0 through 7 with equal probability is equivalent to choosing one of the coin flip series on the right with equal probability.
Hence if you choose a number from the uniform distribution over integers 0-7, you have a $\frac{1}{8}$ chance of choosing 3 heads, $\frac{3}{8}$ chance of choosing 2 heads, $\frac{3}{8}$ chance of choosing 1 head, and $\frac{1}{8}$ chance of choosing 0 heads.
|
Why is generating 8 random bits uniform on (0, 255)?
EXAMPLE with 3 bits (often an example is more illustrative)
I will write the natural numbers 0 through 7 as:
A number in base 10
A number in base 2 (i.e. a sequence of bits)
A series of coin flips im
|
7,564
|
Why is generating 8 random bits uniform on (0, 255)?
|
Sycorax's answer is correct, but it seems like you're not entirely clear on why.
When you flip 8 coins or generate 8 random bits taking order into account, your result will be one of 256 equally likely possibilities. In your case, each of these 256 possible outcomes uniquely map to an integer, so you get a uniform distribution as your result.
If you don't take order into account, such as considering just how many heads or tails you got, there are only 9 possible outcomes (0 Heads/8 Tails - 8 Heads/0 Tails), and they're no longer equally likely. The reason for this is because out of the 256 possible results, there are 1 combination of flips that gives you 8 Heads/0 Tails (HHHHHHHH) and 8 combinations that give 7 Heads/1 Tails (a Tails in each of the 8 positions in the order), but 8C4 = 70 ways to have 4 Heads and 4 Tails. In the coin flipping case each of those 70 combinations maps to 4 Heads/4 Tails, but in the binary number problem each of those 70 outcomes maps to a unique integer.
|
Why is generating 8 random bits uniform on (0, 255)?
|
Sycorax's answer is correct, but it seems like you're not entirely clear on why.
When you flip 8 coins or generate 8 random bits taking order into account, your result will be one of 256 equally likel
|
Why is generating 8 random bits uniform on (0, 255)?
Sycorax's answer is correct, but it seems like you're not entirely clear on why.
When you flip 8 coins or generate 8 random bits taking order into account, your result will be one of 256 equally likely possibilities. In your case, each of these 256 possible outcomes uniquely map to an integer, so you get a uniform distribution as your result.
If you don't take order into account, such as considering just how many heads or tails you got, there are only 9 possible outcomes (0 Heads/8 Tails - 8 Heads/0 Tails), and they're no longer equally likely. The reason for this is because out of the 256 possible results, there are 1 combination of flips that gives you 8 Heads/0 Tails (HHHHHHHH) and 8 combinations that give 7 Heads/1 Tails (a Tails in each of the 8 positions in the order), but 8C4 = 70 ways to have 4 Heads and 4 Tails. In the coin flipping case each of those 70 combinations maps to 4 Heads/4 Tails, but in the binary number problem each of those 70 outcomes maps to a unique integer.
|
Why is generating 8 random bits uniform on (0, 255)?
Sycorax's answer is correct, but it seems like you're not entirely clear on why.
When you flip 8 coins or generate 8 random bits taking order into account, your result will be one of 256 equally likel
|
7,565
|
Why is generating 8 random bits uniform on (0, 255)?
|
The problem, restated, is: Why is the number of combinations of 8 random binary digits taken as 0 to 8 selected digits (e.g., the 1's) at a time different from the number of permutations of 8 random binary digits. In the context herein, random choice of 0's and 1's means that each digit is independent of any other, so that digits are uncorrelated and $p(0)=p(1)=\frac{1}{2}$; .
The answer is: There are two different encodings; 1) lossless encoding of permutations and 2) lossy encoding of combinations.
Ad 1) To lossless encode the numbers so that each sequence is unique we can view that number as being a binary integer $\sum_{i=1}^82^{i-1}{X_i}$, where ${X_i}$ are the left to right $i^{th}$ digits in the binary sequence of random 0's and 1's. What that does is make each permutation unique, as each random digit is then positional encoded. And the total number of permutations is then $2^8=256$. Then, coincidentally one can translate those binary digits into the base 10 numbers 0 to 255 without loss of uniqueness, or for that matter one can rewrite that number using any other lossless encoding (e.g. lossless compressed data, Hex, Octal). The question itself, however, is a binary one. Each permutation is then equally probable because there is then only one way each unique encoding sequence can be created, and we have assumed that the appearance of a 1 or a 0 is equally likely anywhere within that string, such that each permutation is equally probable.
Ad 2) When the lossless encoding is abandoned by only considering combinations, we then have a lossy encoding in which outcomes are combined and information is lost. We are then viewing the number series, w.l.o.g. as the number of 1's; $\sum_{i=1}^82^{0}{X_i}$, which in turn reduces to $C(8,\sum_{i=1}^8{X_i})$, the number of combinations of 8 objects taken $\sum_{i=1}^8{X_i}$ at at time, and for that different problem, the probability of exactly 4 1's is 70 ($C(8,4)$) times greater than obtaining 8 1's, because there are 70, equally likely permutations that can produce 4 1's.
Note: At the current time, the above answer is the only one containing an explicit computational comparison of the two encodings, and the only answer that even mentions the concept of encoding. It took a while to get it right, which is why this answer has been downvoted, historically. If there are any outstanding complaints, leave a comment.
Update: Since the last update, I am gratified to see that the concept of encoding has begun to catch on in the other answers. To show this explicitly for the current problem I have attached the number of permutations that are lossy encoded in each combination.
Note that the number of bytes of information lost during each combinatorial encoding is equivalent to the number of permutations for that combination minus one [$C(8,n)-1$, where $n$ is the number of 1's], i.e., for this problem, from $0$ to $69$ per combination, or $256-9=247$ overall.
|
Why is generating 8 random bits uniform on (0, 255)?
|
The problem, restated, is: Why is the number of combinations of 8 random binary digits taken as 0 to 8 selected digits (e.g., the 1's) at a time different from the number of permutations of 8 random b
|
Why is generating 8 random bits uniform on (0, 255)?
The problem, restated, is: Why is the number of combinations of 8 random binary digits taken as 0 to 8 selected digits (e.g., the 1's) at a time different from the number of permutations of 8 random binary digits. In the context herein, random choice of 0's and 1's means that each digit is independent of any other, so that digits are uncorrelated and $p(0)=p(1)=\frac{1}{2}$; .
The answer is: There are two different encodings; 1) lossless encoding of permutations and 2) lossy encoding of combinations.
Ad 1) To lossless encode the numbers so that each sequence is unique we can view that number as being a binary integer $\sum_{i=1}^82^{i-1}{X_i}$, where ${X_i}$ are the left to right $i^{th}$ digits in the binary sequence of random 0's and 1's. What that does is make each permutation unique, as each random digit is then positional encoded. And the total number of permutations is then $2^8=256$. Then, coincidentally one can translate those binary digits into the base 10 numbers 0 to 255 without loss of uniqueness, or for that matter one can rewrite that number using any other lossless encoding (e.g. lossless compressed data, Hex, Octal). The question itself, however, is a binary one. Each permutation is then equally probable because there is then only one way each unique encoding sequence can be created, and we have assumed that the appearance of a 1 or a 0 is equally likely anywhere within that string, such that each permutation is equally probable.
Ad 2) When the lossless encoding is abandoned by only considering combinations, we then have a lossy encoding in which outcomes are combined and information is lost. We are then viewing the number series, w.l.o.g. as the number of 1's; $\sum_{i=1}^82^{0}{X_i}$, which in turn reduces to $C(8,\sum_{i=1}^8{X_i})$, the number of combinations of 8 objects taken $\sum_{i=1}^8{X_i}$ at at time, and for that different problem, the probability of exactly 4 1's is 70 ($C(8,4)$) times greater than obtaining 8 1's, because there are 70, equally likely permutations that can produce 4 1's.
Note: At the current time, the above answer is the only one containing an explicit computational comparison of the two encodings, and the only answer that even mentions the concept of encoding. It took a while to get it right, which is why this answer has been downvoted, historically. If there are any outstanding complaints, leave a comment.
Update: Since the last update, I am gratified to see that the concept of encoding has begun to catch on in the other answers. To show this explicitly for the current problem I have attached the number of permutations that are lossy encoded in each combination.
Note that the number of bytes of information lost during each combinatorial encoding is equivalent to the number of permutations for that combination minus one [$C(8,n)-1$, where $n$ is the number of 1's], i.e., for this problem, from $0$ to $69$ per combination, or $256-9=247$ overall.
|
Why is generating 8 random bits uniform on (0, 255)?
The problem, restated, is: Why is the number of combinations of 8 random binary digits taken as 0 to 8 selected digits (e.g., the 1's) at a time different from the number of permutations of 8 random b
|
7,566
|
Why is generating 8 random bits uniform on (0, 255)?
|
Each bit you choose is independent from each other bit. If you consider for the first bit there is a
50% probability it will be 1
and
50% probability it will be 0.
This also applies to the second bit, third bit and so on so that you end up with so for each possible combination of bits to make your byte you have $(\frac{1}{2})^8$ = $\frac{1}{256}$ chance of that unique 8 bit integer occurring.
|
Why is generating 8 random bits uniform on (0, 255)?
|
Each bit you choose is independent from each other bit. If you consider for the first bit there is a
50% probability it will be 1
and
50% probability it will be 0.
This also applies to the seco
|
Why is generating 8 random bits uniform on (0, 255)?
Each bit you choose is independent from each other bit. If you consider for the first bit there is a
50% probability it will be 1
and
50% probability it will be 0.
This also applies to the second bit, third bit and so on so that you end up with so for each possible combination of bits to make your byte you have $(\frac{1}{2})^8$ = $\frac{1}{256}$ chance of that unique 8 bit integer occurring.
|
Why is generating 8 random bits uniform on (0, 255)?
Each bit you choose is independent from each other bit. If you consider for the first bit there is a
50% probability it will be 1
and
50% probability it will be 0.
This also applies to the seco
|
7,567
|
Why is generating 8 random bits uniform on (0, 255)?
|
If you do a binary search comparing each bit, then you need the same number of steps for each 8 bit number, from 0000 0000 to 1111 1111, they both have the length 8 bit. At each step in the binary search both sides have a 50/50 chance of occuring, so in the end, because every number has the same depth and the same probabilities, without any real choice, each number must have the same weight. Thus the distribution must be uniform, even when each individual bit is determined by coin flips.
However, the digitsum of the numbers isn't uniform and would be equal in distribution to tossing 8 coins.
|
Why is generating 8 random bits uniform on (0, 255)?
|
If you do a binary search comparing each bit, then you need the same number of steps for each 8 bit number, from 0000 0000 to 1111 1111, they both have the length 8 bit. At each step in the binary sea
|
Why is generating 8 random bits uniform on (0, 255)?
If you do a binary search comparing each bit, then you need the same number of steps for each 8 bit number, from 0000 0000 to 1111 1111, they both have the length 8 bit. At each step in the binary search both sides have a 50/50 chance of occuring, so in the end, because every number has the same depth and the same probabilities, without any real choice, each number must have the same weight. Thus the distribution must be uniform, even when each individual bit is determined by coin flips.
However, the digitsum of the numbers isn't uniform and would be equal in distribution to tossing 8 coins.
|
Why is generating 8 random bits uniform on (0, 255)?
If you do a binary search comparing each bit, then you need the same number of steps for each 8 bit number, from 0000 0000 to 1111 1111, they both have the length 8 bit. At each step in the binary sea
|
7,568
|
Why is generating 8 random bits uniform on (0, 255)?
|
There is only one sequence with eight zeros. There are seventy sequences with four zeros and four ones.
Therefore, while 0 has a probability of 0.39%, and 15 [00001111] also has a probability of 0.39%, and 23 [00010111] has a probability of 0.39%, etc., if you add up all seventy of the 0.39% probabilities you get 27.3%, which is the probability of having four ones. The probability of each individual four-and-four result does not have to be any higher than 0.39% for this to work.
|
Why is generating 8 random bits uniform on (0, 255)?
|
There is only one sequence with eight zeros. There are seventy sequences with four zeros and four ones.
Therefore, while 0 has a probability of 0.39%, and 15 [00001111] also has a probability of 0.39%
|
Why is generating 8 random bits uniform on (0, 255)?
There is only one sequence with eight zeros. There are seventy sequences with four zeros and four ones.
Therefore, while 0 has a probability of 0.39%, and 15 [00001111] also has a probability of 0.39%, and 23 [00010111] has a probability of 0.39%, etc., if you add up all seventy of the 0.39% probabilities you get 27.3%, which is the probability of having four ones. The probability of each individual four-and-four result does not have to be any higher than 0.39% for this to work.
|
Why is generating 8 random bits uniform on (0, 255)?
There is only one sequence with eight zeros. There are seventy sequences with four zeros and four ones.
Therefore, while 0 has a probability of 0.39%, and 15 [00001111] also has a probability of 0.39%
|
7,569
|
Why is generating 8 random bits uniform on (0, 255)?
|
Consider dice
Think about rolling a couple of dice, a common example of non-uniform distribution. For the sake of the math, imagine the dice are numbered from 0 to 5 instead of the traditional 1 to 6. The reason the distribution is not uniform is that you are looking at the sum of the dice rolls, where multiple combinations can yield the same total like {5, 0}, {0, 5}, {4, 1}, etc. all generating 5.
However, if you were to interpret the dice roll as a 2 digit random number in base 6, each possible combination of dice is unique. {5, 0} would be 50 (base 6) which would be 5*($6^1$) + 0*($6^0$) = 30 (base 10). {0, 5} would be 5 (base 6) which would be 5*($6^0$) = 5 (base 10). So you can see, there is a 1 to 1 mapping of possible dice rolls interpreted as numbers in base 6 versus a many to 1 mapping for the sum of the two dice each roll.
As both @Sycorax and @Blacksteel point out, this difference really boils down to the question of order.
|
Why is generating 8 random bits uniform on (0, 255)?
|
Consider dice
Think about rolling a couple of dice, a common example of non-uniform distribution. For the sake of the math, imagine the dice are numbered from 0 to 5 instead of the traditional 1 to 6.
|
Why is generating 8 random bits uniform on (0, 255)?
Consider dice
Think about rolling a couple of dice, a common example of non-uniform distribution. For the sake of the math, imagine the dice are numbered from 0 to 5 instead of the traditional 1 to 6. The reason the distribution is not uniform is that you are looking at the sum of the dice rolls, where multiple combinations can yield the same total like {5, 0}, {0, 5}, {4, 1}, etc. all generating 5.
However, if you were to interpret the dice roll as a 2 digit random number in base 6, each possible combination of dice is unique. {5, 0} would be 50 (base 6) which would be 5*($6^1$) + 0*($6^0$) = 30 (base 10). {0, 5} would be 5 (base 6) which would be 5*($6^0$) = 5 (base 10). So you can see, there is a 1 to 1 mapping of possible dice rolls interpreted as numbers in base 6 versus a many to 1 mapping for the sum of the two dice each roll.
As both @Sycorax and @Blacksteel point out, this difference really boils down to the question of order.
|
Why is generating 8 random bits uniform on (0, 255)?
Consider dice
Think about rolling a couple of dice, a common example of non-uniform distribution. For the sake of the math, imagine the dice are numbered from 0 to 5 instead of the traditional 1 to 6.
|
7,570
|
Why is generating 8 random bits uniform on (0, 255)?
|
I'd like to expand a little bit on the idea of order dependence vs. independence.
In the problem of calculating the expected number of heads from flipping 8 coins, we're summing the values from 8 identical distributions, each of which is the Bernoulli distribution $ B(1, 0.5) $ (in other words, a 50% chance of 0, a 50% chance of 1). The distribution of the sum is the binomial distribution $ B(8, 0.5) $, which has the familiar hump shape with most of the probability centered around 4.
In the problem of calculating the expected value of a byte made of 8 random bits, each bit has a different value that it contributes to the byte, so we're summing the values from 8 different distributions. The first is $ B(1, 0.5) $, the second is $ 2 B(1, 0.5) $, the third is $ 4 B(1, 0.5) $ , so on up to the eighth which is $ 128 B(1, 0.5) $. The distribution of this sum is understandably quite different from the first one.
If you wanted to prove that this latter distribution is uniform, I think you could do it inductively — the distribution of the lowest bit is uniform with a range of 1 by assumption, so you would want to show that if the distribution of the lowest $ n $ bits is uniform with a range of $ 2^{n - 1} $ then the addition of the $ n+1 $st bit makes the distribution of the lowest $ n + 1 $ bits uniform with a range of $ 2^{n+1} - 1 $, achieving a proof for all positive $ n $. But the intuitive way is probably the exact opposite. If you start at the high bit, and choose values one at a time down to the low bit, each bit divides the space of possible outcomes exactly in half, and each half is chosen with equal probability, so by the time you get to the bottom, each individual value must have had the same probability to be chosen.
|
Why is generating 8 random bits uniform on (0, 255)?
|
I'd like to expand a little bit on the idea of order dependence vs. independence.
In the problem of calculating the expected number of heads from flipping 8 coins, we're summing the values from 8 iden
|
Why is generating 8 random bits uniform on (0, 255)?
I'd like to expand a little bit on the idea of order dependence vs. independence.
In the problem of calculating the expected number of heads from flipping 8 coins, we're summing the values from 8 identical distributions, each of which is the Bernoulli distribution $ B(1, 0.5) $ (in other words, a 50% chance of 0, a 50% chance of 1). The distribution of the sum is the binomial distribution $ B(8, 0.5) $, which has the familiar hump shape with most of the probability centered around 4.
In the problem of calculating the expected value of a byte made of 8 random bits, each bit has a different value that it contributes to the byte, so we're summing the values from 8 different distributions. The first is $ B(1, 0.5) $, the second is $ 2 B(1, 0.5) $, the third is $ 4 B(1, 0.5) $ , so on up to the eighth which is $ 128 B(1, 0.5) $. The distribution of this sum is understandably quite different from the first one.
If you wanted to prove that this latter distribution is uniform, I think you could do it inductively — the distribution of the lowest bit is uniform with a range of 1 by assumption, so you would want to show that if the distribution of the lowest $ n $ bits is uniform with a range of $ 2^{n - 1} $ then the addition of the $ n+1 $st bit makes the distribution of the lowest $ n + 1 $ bits uniform with a range of $ 2^{n+1} - 1 $, achieving a proof for all positive $ n $. But the intuitive way is probably the exact opposite. If you start at the high bit, and choose values one at a time down to the low bit, each bit divides the space of possible outcomes exactly in half, and each half is chosen with equal probability, so by the time you get to the bottom, each individual value must have had the same probability to be chosen.
|
Why is generating 8 random bits uniform on (0, 255)?
I'd like to expand a little bit on the idea of order dependence vs. independence.
In the problem of calculating the expected number of heads from flipping 8 coins, we're summing the values from 8 iden
|
7,571
|
Is an overfitted model necessarily useless?
|
I think the argument is correct. If 70% is acceptable in the particular application, then the model is useful even though it is overfitted (more generally, regardless of whether it is overfitted or not).
While balancing overfitting against underfitting concerns optimality (looking for an optimal solution), having satisfactory performance is about sufficiency (is the model performing well enough for the task?). A model can be sufficiently good without being optimal.
Edit: after the comments by Firebug and Matthew Drury under the OP, I will add that to judge whether the model is overfitted without knowing the validation performance can be problematic. Firebug suggests comparing the validation vs. the test performance to measure the amount of overfitting. Nevertheless, when the model delivers 100% accuracy on the training set without delivering 100% accuracy on the test set, it is an indicator of possible overfitting (especially so in the case of regression but not necessarily in classification).
|
Is an overfitted model necessarily useless?
|
I think the argument is correct. If 70% is acceptable in the particular application, then the model is useful even though it is overfitted (more generally, regardless of whether it is overfitted or no
|
Is an overfitted model necessarily useless?
I think the argument is correct. If 70% is acceptable in the particular application, then the model is useful even though it is overfitted (more generally, regardless of whether it is overfitted or not).
While balancing overfitting against underfitting concerns optimality (looking for an optimal solution), having satisfactory performance is about sufficiency (is the model performing well enough for the task?). A model can be sufficiently good without being optimal.
Edit: after the comments by Firebug and Matthew Drury under the OP, I will add that to judge whether the model is overfitted without knowing the validation performance can be problematic. Firebug suggests comparing the validation vs. the test performance to measure the amount of overfitting. Nevertheless, when the model delivers 100% accuracy on the training set without delivering 100% accuracy on the test set, it is an indicator of possible overfitting (especially so in the case of regression but not necessarily in classification).
|
Is an overfitted model necessarily useless?
I think the argument is correct. If 70% is acceptable in the particular application, then the model is useful even though it is overfitted (more generally, regardless of whether it is overfitted or no
|
7,572
|
Is an overfitted model necessarily useless?
|
In my past project with Credit Card Fraud detection, we intentionally want to over fit the data / hard coded to remember fraud cases. (Note, overfitting one class is not exactly the general overfitting problem OP talked about.) Such system has relatively low false positives and satisfy our needs.
So, I would say, overfitted model can be useful for some cases.
|
Is an overfitted model necessarily useless?
|
In my past project with Credit Card Fraud detection, we intentionally want to over fit the data / hard coded to remember fraud cases. (Note, overfitting one class is not exactly the general overfittin
|
Is an overfitted model necessarily useless?
In my past project with Credit Card Fraud detection, we intentionally want to over fit the data / hard coded to remember fraud cases. (Note, overfitting one class is not exactly the general overfitting problem OP talked about.) Such system has relatively low false positives and satisfy our needs.
So, I would say, overfitted model can be useful for some cases.
|
Is an overfitted model necessarily useless?
In my past project with Credit Card Fraud detection, we intentionally want to over fit the data / hard coded to remember fraud cases. (Note, overfitting one class is not exactly the general overfittin
|
7,573
|
Is an overfitted model necessarily useless?
|
Maybe: beware. When you say that 70% accuracy (however you measure it) is good enough for you, it feels like you're assuming that errors are randomly or evenly distributed.
But one of the ways of looking at overfitting is that it happens when a model technique allows (and its training process encourages) paying too much attention to quirks in the training set. Subjects in the general population that share these quirks may have highly-unbalanced results.
So perhaps you end up with a model that says all red dogs have cancer -- because of that particular quirk in your training data. Or that married people between the ages of 24 and 26 are nearly guaranteed to file fraudulent insurance claims. Your 70% accuracy leaves a lot of room for pockets of subjects to be 100% wrong because your model is overfit.
(Not being overfit isn't a guarantee that you won't have pockets of wrong predictions. In fact an under-fit model will have swaths of bad predictions, but with overfitting you know you are magnifying the effect of quirks in your training data.)
|
Is an overfitted model necessarily useless?
|
Maybe: beware. When you say that 70% accuracy (however you measure it) is good enough for you, it feels like you're assuming that errors are randomly or evenly distributed.
But one of the ways of look
|
Is an overfitted model necessarily useless?
Maybe: beware. When you say that 70% accuracy (however you measure it) is good enough for you, it feels like you're assuming that errors are randomly or evenly distributed.
But one of the ways of looking at overfitting is that it happens when a model technique allows (and its training process encourages) paying too much attention to quirks in the training set. Subjects in the general population that share these quirks may have highly-unbalanced results.
So perhaps you end up with a model that says all red dogs have cancer -- because of that particular quirk in your training data. Or that married people between the ages of 24 and 26 are nearly guaranteed to file fraudulent insurance claims. Your 70% accuracy leaves a lot of room for pockets of subjects to be 100% wrong because your model is overfit.
(Not being overfit isn't a guarantee that you won't have pockets of wrong predictions. In fact an under-fit model will have swaths of bad predictions, but with overfitting you know you are magnifying the effect of quirks in your training data.)
|
Is an overfitted model necessarily useless?
Maybe: beware. When you say that 70% accuracy (however you measure it) is good enough for you, it feels like you're assuming that errors are randomly or evenly distributed.
But one of the ways of look
|
7,574
|
Is an overfitted model necessarily useless?
|
No they can be useful, but it depends on your purpose. Several things spring to mind:
Cost-Sensitive Classification: If your evaluation function overweights TPR and underweights FPR, we use $F_\beta$ score with $\beta \gg 1$. (such as @hxd1011's answer on antifraud)
Such a classifier can be really useful in an ensemble. We could have one classifier with normal weights, one that overweights TPR, one that overweights FNR. Then even simple rule-of-three voting, or averaging, will give better AUC than any single best classifier. If each model uses different hyperparameters (or subsampled training-sets, or model architectures), that buys the ensemble some immunity from overfitting.
Similarly, for real-time anti-spam, anti-fraud or credit-scoring, it's ok and desirable to use a hierarchy of classifiers. The level-1 classifiers should evaluate really fast (ms) and it's ok to have a high FPR; any mistakes they make will be caught by more accurate, fully-featured, slower higher-level classifiers or ultimately human reviewers. Obvious example: prevent fake-news headlines from Twitter account takeovers like the 2013 "White House bomb attack kills three" from affecting $billions of trading within ms of posting. It's ok for the level-1 classifier to flag that as positive for spam; let's allow it takes a little while to (automatically) determine the truth/falsehood of sensational-but-unverified news reports.
|
Is an overfitted model necessarily useless?
|
No they can be useful, but it depends on your purpose. Several things spring to mind:
Cost-Sensitive Classification: If your evaluation function overweights TPR and underweights FPR, we use $F_\beta$
|
Is an overfitted model necessarily useless?
No they can be useful, but it depends on your purpose. Several things spring to mind:
Cost-Sensitive Classification: If your evaluation function overweights TPR and underweights FPR, we use $F_\beta$ score with $\beta \gg 1$. (such as @hxd1011's answer on antifraud)
Such a classifier can be really useful in an ensemble. We could have one classifier with normal weights, one that overweights TPR, one that overweights FNR. Then even simple rule-of-three voting, or averaging, will give better AUC than any single best classifier. If each model uses different hyperparameters (or subsampled training-sets, or model architectures), that buys the ensemble some immunity from overfitting.
Similarly, for real-time anti-spam, anti-fraud or credit-scoring, it's ok and desirable to use a hierarchy of classifiers. The level-1 classifiers should evaluate really fast (ms) and it's ok to have a high FPR; any mistakes they make will be caught by more accurate, fully-featured, slower higher-level classifiers or ultimately human reviewers. Obvious example: prevent fake-news headlines from Twitter account takeovers like the 2013 "White House bomb attack kills three" from affecting $billions of trading within ms of posting. It's ok for the level-1 classifier to flag that as positive for spam; let's allow it takes a little while to (automatically) determine the truth/falsehood of sensational-but-unverified news reports.
|
Is an overfitted model necessarily useless?
No they can be useful, but it depends on your purpose. Several things spring to mind:
Cost-Sensitive Classification: If your evaluation function overweights TPR and underweights FPR, we use $F_\beta$
|
7,575
|
Is an overfitted model necessarily useless?
|
I'm not denying that an overfitted model could still be useful. But just keep in mind that this 70% could be a misleading information. What you need in order to judge if a model is useful or not is the out-of-sample error, not the testing error (the out-of-sample error is not known, so we have to estimate it using a blinded testing set), and that 70% is barely the good approximation.
In order to make sure that we're on the same page on the terminology after the comment of @RichardHardy, let's define the testing error as the error obtained when applying the model on the blind testing set. And the out-of-sample error is the error when applying the model to the whole population.
The approximation of the out-of-sample error depends on two things: the model itself and the data.
An "optimal" model yields to an (testing) accuracy that scarcely depends on the data, in this case, it would be a good approximation. "Regardless" of the data, the prediction error would be stable.
But, an overfitted model's accuracy is highly dependent of the data (as you mentioned 100% on the training set, and 70% on the other set). So it might happens that when applying to another data set, the accuracy could be somewhere lower than 70% (or higher), and we could have bad surprises. In other words, that 70% is telling you what you believe it to be, but it is not.
|
Is an overfitted model necessarily useless?
|
I'm not denying that an overfitted model could still be useful. But just keep in mind that this 70% could be a misleading information. What you need in order to judge if a model is useful or not is th
|
Is an overfitted model necessarily useless?
I'm not denying that an overfitted model could still be useful. But just keep in mind that this 70% could be a misleading information. What you need in order to judge if a model is useful or not is the out-of-sample error, not the testing error (the out-of-sample error is not known, so we have to estimate it using a blinded testing set), and that 70% is barely the good approximation.
In order to make sure that we're on the same page on the terminology after the comment of @RichardHardy, let's define the testing error as the error obtained when applying the model on the blind testing set. And the out-of-sample error is the error when applying the model to the whole population.
The approximation of the out-of-sample error depends on two things: the model itself and the data.
An "optimal" model yields to an (testing) accuracy that scarcely depends on the data, in this case, it would be a good approximation. "Regardless" of the data, the prediction error would be stable.
But, an overfitted model's accuracy is highly dependent of the data (as you mentioned 100% on the training set, and 70% on the other set). So it might happens that when applying to another data set, the accuracy could be somewhere lower than 70% (or higher), and we could have bad surprises. In other words, that 70% is telling you what you believe it to be, but it is not.
|
Is an overfitted model necessarily useless?
I'm not denying that an overfitted model could still be useful. But just keep in mind that this 70% could be a misleading information. What you need in order to judge if a model is useful or not is th
|
7,576
|
Extrapolation v. Interpolation
|
To add a visual explanation to this: let's consider a few points that you plan to model.
They look like they could be described well with a straight line, so you fit a linear regression to them:
This regression line lets you both interpolate (generate expected values in between your data points) and extrapolate (generate expected values outside the range of your data points). I've highlighted the extrapolation in red and the biggest region of interpolation in blue. To be clear, even the tiny regions between the points are interpolated, but I'm only highlighting the big one here.
Why is extrapolation generally more of a concern? Because you're usually much less certain about the shape of the relationship outside the range of your data. Consider what might happen when you collect a few more data points (hollow circles):
It turns out that the relationship was not captured well with your hypothesized relationship after all. The predictions in the extrapolated region are way off. Even if you had guessed the precise function that describes this nonlinear relationship correctly, your data did not extend over enough of a range for you to capture the nonlinearity well, so you may still have been pretty far off. Note that this is a problem not just for linear regression, but for any relationship at all - this is why extrapolation is considered dangerous.
Predictions in the interpolated region are also incorrect because of the lack of nonlinearity in the fit, but their prediction error is much lower. There's no guarantee that you won't have an unexpected relationship in between your points (i.e. the region of interpolation), but it's generally less likely.
I will add that extrapolation is not always a terrible idea - if you extrapolate a tiny bit outside the range of your data, you're probably not going to be very wrong (though it is possible!). Ancients who had no good scientific model of the world would not have been far wrong if they forecast that the sun would rise again the next day and the day after that (though one day far into the future, even this will fail).
And sometimes, extrapolation can even be informative - for example, simple short-term extrapolations of the exponential increase in atmospheric CO$_2$ have been reasonably accurate over the past few decades. If you were a student who didn't have scientific expertise but wanted a rough, short-term forecast, this would have given you fairly reasonable results. But the farther away from your data you extrapolate, the more likely your prediction is likely to fail, and fail disastrously, as described very nicely in this great thread: What is wrong with extrapolation? (thanks to @J.M.isnotastatistician for reminding me of that).
Edit based on comments: whether interpolating or extrapolating, it's always best to have some theory to ground expectations. If theory-free modelling must be done, the risk from interpolation is usually less than that from extrapolation. That said, as the gap between data points increases in magnitude, interpolation also becomes more and more fraught with risk.
|
Extrapolation v. Interpolation
|
To add a visual explanation to this: let's consider a few points that you plan to model.
They look like they could be described well with a straight line, so you fit a linear regression to them:
T
|
Extrapolation v. Interpolation
To add a visual explanation to this: let's consider a few points that you plan to model.
They look like they could be described well with a straight line, so you fit a linear regression to them:
This regression line lets you both interpolate (generate expected values in between your data points) and extrapolate (generate expected values outside the range of your data points). I've highlighted the extrapolation in red and the biggest region of interpolation in blue. To be clear, even the tiny regions between the points are interpolated, but I'm only highlighting the big one here.
Why is extrapolation generally more of a concern? Because you're usually much less certain about the shape of the relationship outside the range of your data. Consider what might happen when you collect a few more data points (hollow circles):
It turns out that the relationship was not captured well with your hypothesized relationship after all. The predictions in the extrapolated region are way off. Even if you had guessed the precise function that describes this nonlinear relationship correctly, your data did not extend over enough of a range for you to capture the nonlinearity well, so you may still have been pretty far off. Note that this is a problem not just for linear regression, but for any relationship at all - this is why extrapolation is considered dangerous.
Predictions in the interpolated region are also incorrect because of the lack of nonlinearity in the fit, but their prediction error is much lower. There's no guarantee that you won't have an unexpected relationship in between your points (i.e. the region of interpolation), but it's generally less likely.
I will add that extrapolation is not always a terrible idea - if you extrapolate a tiny bit outside the range of your data, you're probably not going to be very wrong (though it is possible!). Ancients who had no good scientific model of the world would not have been far wrong if they forecast that the sun would rise again the next day and the day after that (though one day far into the future, even this will fail).
And sometimes, extrapolation can even be informative - for example, simple short-term extrapolations of the exponential increase in atmospheric CO$_2$ have been reasonably accurate over the past few decades. If you were a student who didn't have scientific expertise but wanted a rough, short-term forecast, this would have given you fairly reasonable results. But the farther away from your data you extrapolate, the more likely your prediction is likely to fail, and fail disastrously, as described very nicely in this great thread: What is wrong with extrapolation? (thanks to @J.M.isnotastatistician for reminding me of that).
Edit based on comments: whether interpolating or extrapolating, it's always best to have some theory to ground expectations. If theory-free modelling must be done, the risk from interpolation is usually less than that from extrapolation. That said, as the gap between data points increases in magnitude, interpolation also becomes more and more fraught with risk.
|
Extrapolation v. Interpolation
To add a visual explanation to this: let's consider a few points that you plan to model.
They look like they could be described well with a straight line, so you fit a linear regression to them:
T
|
7,577
|
Extrapolation v. Interpolation
|
In essence interpolation is an operation within the data support, or between existing known data points; extrapolation is beyond the data support. Otherwise put, the criterion is: where are the missing values?
One reason for the distinction is that extrapolation is usually more difficult to do well, and even dangerous, statistically if not practically. That is not always true: for example, river floods may overwhelm the means of measuring discharge or even stage (vertical level), tearing a hole in the measured record. In those circumstances, interpolation of discharge or stage is difficult too and being within the data support does not help much.
In the long run, qualitative change usually supersedes quantitative change. Around 1900 there was much concern that growth in horse-drawn traffic would swamp cities with mostly unwanted excrement. The exponential in excrement was superseded by the internal combustion engine and its different exponentials.
A trend is a trend is a trend,
But the question is, will it bend?
Will it alter its course
Through some unforeseen force
And come to a premature end?
-- Alexander Cairncross
Cairncross, A. 1969. Economic forecasting. The Economic Journal, 79: 797-812. doi:10.2307/2229792 (quotation on p.797)
|
Extrapolation v. Interpolation
|
In essence interpolation is an operation within the data support, or between existing known data points; extrapolation is beyond the data support. Otherwise put, the criterion is: where are the missin
|
Extrapolation v. Interpolation
In essence interpolation is an operation within the data support, or between existing known data points; extrapolation is beyond the data support. Otherwise put, the criterion is: where are the missing values?
One reason for the distinction is that extrapolation is usually more difficult to do well, and even dangerous, statistically if not practically. That is not always true: for example, river floods may overwhelm the means of measuring discharge or even stage (vertical level), tearing a hole in the measured record. In those circumstances, interpolation of discharge or stage is difficult too and being within the data support does not help much.
In the long run, qualitative change usually supersedes quantitative change. Around 1900 there was much concern that growth in horse-drawn traffic would swamp cities with mostly unwanted excrement. The exponential in excrement was superseded by the internal combustion engine and its different exponentials.
A trend is a trend is a trend,
But the question is, will it bend?
Will it alter its course
Through some unforeseen force
And come to a premature end?
-- Alexander Cairncross
Cairncross, A. 1969. Economic forecasting. The Economic Journal, 79: 797-812. doi:10.2307/2229792 (quotation on p.797)
|
Extrapolation v. Interpolation
In essence interpolation is an operation within the data support, or between existing known data points; extrapolation is beyond the data support. Otherwise put, the criterion is: where are the missin
|
7,578
|
Extrapolation v. Interpolation
|
TL;DR version:
Interpolation takes place between existing data points.
Extrapolation takes place beyond them.
Mnemonic: interpolation => inside.
FWIW: The prefix inter- means between, and extra- means beyond. Think also of interstate highways which go between states, or extraterrestrials from beyond our planet.
|
Extrapolation v. Interpolation
|
TL;DR version:
Interpolation takes place between existing data points.
Extrapolation takes place beyond them.
Mnemonic: interpolation => inside.
FWIW: The prefix inter- means between, and extra-
|
Extrapolation v. Interpolation
TL;DR version:
Interpolation takes place between existing data points.
Extrapolation takes place beyond them.
Mnemonic: interpolation => inside.
FWIW: The prefix inter- means between, and extra- means beyond. Think also of interstate highways which go between states, or extraterrestrials from beyond our planet.
|
Extrapolation v. Interpolation
TL;DR version:
Interpolation takes place between existing data points.
Extrapolation takes place beyond them.
Mnemonic: interpolation => inside.
FWIW: The prefix inter- means between, and extra-
|
7,579
|
Extrapolation v. Interpolation
|
Example:
Study: Want to fit a simple linear regression on the height on the age for girls of age 6-15 years old. Sample size is 100, age is calculated by (date of measuring - date of birth)/365.25.
After data collection, model is fit and get the estimate of intercept b0 and slope b1. it means we have E(height|age) = b0 + b1*age.
When you want the mean height for age 13, you find that there is no 13 year old girl in your sample of 100 girls, one of them is 12.83 years old and one is 13.24.
Now you plug in age = 13 into formula E(height|age) = b0 + b1*age. It is called interpolation because 13 year old is covered by the range of your data used to fit model.
If you want to get mean height for age 30 and use that formula, that is called extrapolation, because age 30 is out of the range of the age covered by your data.
If the model has several covariates, you need to be careful because it is hard to draw the border that data covered.
In statistics, we do not advocate extrapolation.
|
Extrapolation v. Interpolation
|
Example:
Study: Want to fit a simple linear regression on the height on the age for girls of age 6-15 years old. Sample size is 100, age is calculated by (date of measuring - date of birth)/365.25.
|
Extrapolation v. Interpolation
Example:
Study: Want to fit a simple linear regression on the height on the age for girls of age 6-15 years old. Sample size is 100, age is calculated by (date of measuring - date of birth)/365.25.
After data collection, model is fit and get the estimate of intercept b0 and slope b1. it means we have E(height|age) = b0 + b1*age.
When you want the mean height for age 13, you find that there is no 13 year old girl in your sample of 100 girls, one of them is 12.83 years old and one is 13.24.
Now you plug in age = 13 into formula E(height|age) = b0 + b1*age. It is called interpolation because 13 year old is covered by the range of your data used to fit model.
If you want to get mean height for age 30 and use that formula, that is called extrapolation, because age 30 is out of the range of the age covered by your data.
If the model has several covariates, you need to be careful because it is hard to draw the border that data covered.
In statistics, we do not advocate extrapolation.
|
Extrapolation v. Interpolation
Example:
Study: Want to fit a simple linear regression on the height on the age for girls of age 6-15 years old. Sample size is 100, age is calculated by (date of measuring - date of birth)/365.25.
|
7,580
|
Extrapolation v. Interpolation
|
The extrapolation v.s. interpolation also applys in neural networks as mentioned in Rethinking Eliminative Connectionism and Deep Learning: A Critical Appraisal:
generalization can be thought of as coming in two flavors,
interpolation between known examples, and extrapolation, which
requires going beyond a space of known training examples
The author wrote that extrapolation is a wall stopping us reaching artificial general intelligence.
Let's suppose that we train a translation model to translate English to German very well with tons of data, we can be sure that it can fail a test with randomly permutated English words because it has never seen such data in the training process and it is certain to fail a new phrase coined after it is trained. That is it behaves badly for open-ended inferences because it can be only accurat for data similar to the training ones but the real world is open-ended.
References:
Extrapolation in NLP
Real Artificial Intelligence: Understanding Extrapolation vs Generalization
|
Extrapolation v. Interpolation
|
The extrapolation v.s. interpolation also applys in neural networks as mentioned in Rethinking Eliminative Connectionism and Deep Learning: A Critical Appraisal:
generalization can be thought of as c
|
Extrapolation v. Interpolation
The extrapolation v.s. interpolation also applys in neural networks as mentioned in Rethinking Eliminative Connectionism and Deep Learning: A Critical Appraisal:
generalization can be thought of as coming in two flavors,
interpolation between known examples, and extrapolation, which
requires going beyond a space of known training examples
The author wrote that extrapolation is a wall stopping us reaching artificial general intelligence.
Let's suppose that we train a translation model to translate English to German very well with tons of data, we can be sure that it can fail a test with randomly permutated English words because it has never seen such data in the training process and it is certain to fail a new phrase coined after it is trained. That is it behaves badly for open-ended inferences because it can be only accurat for data similar to the training ones but the real world is open-ended.
References:
Extrapolation in NLP
Real Artificial Intelligence: Understanding Extrapolation vs Generalization
|
Extrapolation v. Interpolation
The extrapolation v.s. interpolation also applys in neural networks as mentioned in Rethinking Eliminative Connectionism and Deep Learning: A Critical Appraisal:
generalization can be thought of as c
|
7,581
|
Statistical methods to more efficiently plot data when millions of points are present?
|
This is a hard task with no ready solutions (this is of course because density plot is so a tempting fallback than no one really cares). So, what can you do?
If they really overlap (i.e. have exactly the same X & Y coordinates) and you are not using alpha, the best idea would be just to reduce the overlap using unique (with alpha, it may be summed over such groups).
If not, you may manually round the coordinates to the nearest pixels and use the previous method (yet this is a dirty solution).
Finally, you can make a density plot only to use it to subsample the points in the most dense areas. This on the other hand will not make the exactly same plot and may introduce artifacts if not precisely tuned.
|
Statistical methods to more efficiently plot data when millions of points are present?
|
This is a hard task with no ready solutions (this is of course because density plot is so a tempting fallback than no one really cares). So, what can you do?
If they really overlap (i.e. have exactly
|
Statistical methods to more efficiently plot data when millions of points are present?
This is a hard task with no ready solutions (this is of course because density plot is so a tempting fallback than no one really cares). So, what can you do?
If they really overlap (i.e. have exactly the same X & Y coordinates) and you are not using alpha, the best idea would be just to reduce the overlap using unique (with alpha, it may be summed over such groups).
If not, you may manually round the coordinates to the nearest pixels and use the previous method (yet this is a dirty solution).
Finally, you can make a density plot only to use it to subsample the points in the most dense areas. This on the other hand will not make the exactly same plot and may introduce artifacts if not precisely tuned.
|
Statistical methods to more efficiently plot data when millions of points are present?
This is a hard task with no ready solutions (this is of course because density plot is so a tempting fallback than no one really cares). So, what can you do?
If they really overlap (i.e. have exactly
|
7,582
|
Statistical methods to more efficiently plot data when millions of points are present?
|
Look at the hexbin package which implements paper/method by Dan Carr. The pdf vignette has more details which I quote below:
1 Overview
Hexagon binning is a form of bivariate
histogram useful for visualizing the
struc- ture in datasets with large n.
The underlying concept of hexagon
binning is extremely simple;
the xy plane over the set (range(x), range(y)) is tessellated by
a regular grid of hexagons.
the number of points falling in each hexagon are counted and stored in
a data structure
the hexagons with count > 0 are plotted using a color ramp or varying
the radius of the hexagon in
proportion to the counts. The
underlying algorithm is extremely fast
and eective for displaying the
structure of datasets with $n \ge 10^6$
If the size of the grid and the cuts
in the color ramp are chosen in a
clever fashion than the structure
inherent in the data should emerge in
the binned plots. The same caveats
apply to hexagon binning as apply to
histograms and care should be
exercised in choosing the binning
parameters
|
Statistical methods to more efficiently plot data when millions of points are present?
|
Look at the hexbin package which implements paper/method by Dan Carr. The pdf vignette has more details which I quote below:
1 Overview
Hexagon binning is a form of bivariate
histogram useful for v
|
Statistical methods to more efficiently plot data when millions of points are present?
Look at the hexbin package which implements paper/method by Dan Carr. The pdf vignette has more details which I quote below:
1 Overview
Hexagon binning is a form of bivariate
histogram useful for visualizing the
struc- ture in datasets with large n.
The underlying concept of hexagon
binning is extremely simple;
the xy plane over the set (range(x), range(y)) is tessellated by
a regular grid of hexagons.
the number of points falling in each hexagon are counted and stored in
a data structure
the hexagons with count > 0 are plotted using a color ramp or varying
the radius of the hexagon in
proportion to the counts. The
underlying algorithm is extremely fast
and eective for displaying the
structure of datasets with $n \ge 10^6$
If the size of the grid and the cuts
in the color ramp are chosen in a
clever fashion than the structure
inherent in the data should emerge in
the binned plots. The same caveats
apply to hexagon binning as apply to
histograms and care should be
exercised in choosing the binning
parameters
|
Statistical methods to more efficiently plot data when millions of points are present?
Look at the hexbin package which implements paper/method by Dan Carr. The pdf vignette has more details which I quote below:
1 Overview
Hexagon binning is a form of bivariate
histogram useful for v
|
7,583
|
Statistical methods to more efficiently plot data when millions of points are present?
|
I must admit that I do not fully understand your last paragraph:
"I am not looking for a density plot
(although those are often useful), I
would want the same output as a simple
plot call but much faster than
millions of overplots if possible."
It is also unclear what type of plot (function) you are looking for.
Given that you have metric variables, you might find hexagon binned plots or sunnflower plots usefull. For further references, see
Graphics of Large Datasets by Unwin/Theus/Hofmann
Quick-R on "High Density Scatterplots"
ggplot2's stat_hexbin
|
Statistical methods to more efficiently plot data when millions of points are present?
|
I must admit that I do not fully understand your last paragraph:
"I am not looking for a density plot
(although those are often useful), I
would want the same output as a simple
plot call but m
|
Statistical methods to more efficiently plot data when millions of points are present?
I must admit that I do not fully understand your last paragraph:
"I am not looking for a density plot
(although those are often useful), I
would want the same output as a simple
plot call but much faster than
millions of overplots if possible."
It is also unclear what type of plot (function) you are looking for.
Given that you have metric variables, you might find hexagon binned plots or sunnflower plots usefull. For further references, see
Graphics of Large Datasets by Unwin/Theus/Hofmann
Quick-R on "High Density Scatterplots"
ggplot2's stat_hexbin
|
Statistical methods to more efficiently plot data when millions of points are present?
I must admit that I do not fully understand your last paragraph:
"I am not looking for a density plot
(although those are often useful), I
would want the same output as a simple
plot call but m
|
7,584
|
Statistical methods to more efficiently plot data when millions of points are present?
|
Another direct answer to the question is the rgl package, which can plot millions of points using OpenGL. Also, specify a point size (e.g. 3) and zoom out to see these centers of masses as monolithic blocks, or zoom in and see the structure of what used to be monolithic - the point sizes are constant but the distances among them on the screen depend on the zooming. Alpha levels can also be used.
|
Statistical methods to more efficiently plot data when millions of points are present?
|
Another direct answer to the question is the rgl package, which can plot millions of points using OpenGL. Also, specify a point size (e.g. 3) and zoom out to see these centers of masses as monolithic
|
Statistical methods to more efficiently plot data when millions of points are present?
Another direct answer to the question is the rgl package, which can plot millions of points using OpenGL. Also, specify a point size (e.g. 3) and zoom out to see these centers of masses as monolithic blocks, or zoom in and see the structure of what used to be monolithic - the point sizes are constant but the distances among them on the screen depend on the zooming. Alpha levels can also be used.
|
Statistical methods to more efficiently plot data when millions of points are present?
Another direct answer to the question is the rgl package, which can plot millions of points using OpenGL. Also, specify a point size (e.g. 3) and zoom out to see these centers of masses as monolithic
|
7,585
|
Statistical methods to more efficiently plot data when millions of points are present?
|
Here's a file I call bigplotfix.R. If you source it, it will define a wrapper for plot.xy which "compresses" the plot data when it is very large. The wrapper does nothing if the input is small, but if the input is large then it breaks it into chunks and just plots the maximum and minimum x and y value for each chunk. Sourcing bigplotfix.R also rebinds graphics::plot.xy to point to the wrapper (sourcing multiple times is OK).
Note that plot.xy is the "workhorse" function for the standard plotting methods like plot(), lines(), and points(). Thus you can continue to use these functions in your code with no modification, and your large plots will be automatically compressed.
This is some example output. It's essentially plot(runif(1e5)), with points and lines, and with and without the "compression" implemented here. The "compressed points" plot misses the middle region due to the nature of the compression, but the "compressed lines" plot looks much closer to the uncompressed original. The times are for the png() device; for some reason points are much faster in the png device than in the X11 device, but the speed-ups in X11 are comparable (X11(type="cairo") was slower than X11(type="Xlib") in my experiments).
The reason I wrote this is because I was tired of running plot() by accident on a large dataset (e.g. a WAV file). In such cases I would have to choose between waiting several minutes for the plot to finish, and terminating my R session with a signal (thereby losing my recent command history and variables). Now if I can remember to load this file before each session, I can actually get a useful plot in these cases. A little warning message indicates when the plot data has been "compressed".
# bigplotfix.R
# 28 Nov 2016
# This file defines a wrapper for plot.xy which checks if the input
# data is longer than a certain maximum limit. If it is, it is
# downsampled before plotting. For 3 million input points, I got
# speed-ups of 10-100x. Note that if you want the output to look the
# same as the "uncompressed" version, you should be drawing lines,
# because the compression involves taking maximum and minimum values
# of blocks of points (try running test_bigplotfix() for a visual
# explanation). Also, no sorting is done on the input points, so
# things could get weird if they are out of order.
test_bigplotfix = function() {
oldpar=par();
par(mfrow=c(2,2))
n=1e5;
r=runif(n)
bigplotfix_verbose<<-T
mytitle=function(t,m) { title(main=sprintf("%s; elapsed=%0.4f s",m,t["elapsed"])) }
mytime=function(m,e) { t=system.time(e); mytitle(t,m); }
oldbigplotfix_maxlen = bigplotfix_maxlen
bigplotfix_maxlen <<- 1e3;
mytime("Compressed, points",plot(r));
mytime("Compressed, lines",plot(r,type="l"));
bigplotfix_maxlen <<- n
mytime("Uncompressed, points",plot(r));
mytime("Uncompressed, lines",plot(r,type="l"));
par(oldpar);
bigplotfix_maxlen <<- oldbigplotfix_maxlen
bigplotfix_verbose <<- F
}
bigplotfix_verbose=F
downsample_xy = function(xy, n, xlog=F) {
msg=if(bigplotfix_verbose) { message } else { function(...) { NULL } }
msg("Finding range");
r=range(xy$x);
msg("Finding breaks");
if(xlog) {
breaks=exp(seq(from=log(r[1]),to=log(r[2]),length.out=n))
} else {
breaks=seq(from=r[1],to=r[2],length.out=n)
}
msg("Calling findInterval");
## cuts=cut(xy$x,breaks);
# findInterval is much faster than cuts!
cuts = findInterval(xy$x,breaks);
if(0) {
msg("In aggregate 1");
dmax = aggregate(list(x=xy$x, y=xy$y), by=list(cuts=cuts), max)
dmax$cuts = NULL;
msg("In aggregate 2");
dmin = aggregate(list(x=xy$x, y=xy$y), by=list(cuts=cuts), min)
dmin$cuts = NULL;
} else { # use data.table for MUCH faster aggregates
# (see http://stackoverflow.com/questions/7722493/how-does-one-aggregate-and-summarize-data-quickly)
suppressMessages(library(data.table))
msg("In data.table");
dt = data.table(x=xy$x,y=xy$y,cuts=cuts)
msg("In data.table aggregate 1");
dmax = dt[,list(x=max(x),y=max(y)),keyby="cuts"]
dmax$cuts=NULL;
msg("In data.table aggregate 2");
dmin = dt[,list(x=min(x),y=min(y)),keyby="cuts"]
dmin$cuts=NULL;
# ans = data_t[,list(A = sum(count), B = mean(count)), by = 'PID,Time,Site']
}
msg("In rep, rbind");
# interleave rows (copied from a SO answer)
s <- rep(1:n, each = 2) + (0:1) * n
xy = rbind(dmin,dmax)[s,];
xy
}
library(graphics);
# make sure we don't create infinite recursion if someone sources
# this file twice
if(!exists("old_plot.xy")) {
old_plot.xy = graphics::plot.xy
}
bigplotfix_maxlen = 1e4
# formals copied from graphics::plot.xy
my_plot.xy = function(xy, type, pch = par("pch"), lty = par("lty"),
col = par("col"), bg = NA, cex = 1, lwd = par("lwd"),
...) {
if(bigplotfix_verbose) {
message("In bigplotfix's plot.xy\n");
}
mycall=match.call();
len=length(xy$x)
if(len>bigplotfix_maxlen) {
warning("bigplotfix.R (plot.xy): too many points (",len,"), compressing to ",bigplotfix_maxlen,"\n");
xy = downsample_xy(xy, bigplotfix_maxlen, xlog=par("xlog"));
mycall$xy=xy
}
mycall[[1]]=as.symbol("old_plot.xy");
eval(mycall,envir=parent.frame());
}
# new binding solution adapted from Henrik Bengtsson
# https://stat.ethz.ch/pipermail/r-help/2008-August/171217.html
rebindPackageVar = function(pkg, name, new) {
# assignInNamespace() no longer works here, thanks nannies
ns=asNamespace(pkg)
unlockBinding(name,ns)
assign(name,new,envir=asNamespace(pkg),inherits=F)
assign(name,new,envir=globalenv())
lockBinding(name,ns)
}
rebindPackageVar("graphics", "plot.xy", my_plot.xy);
|
Statistical methods to more efficiently plot data when millions of points are present?
|
Here's a file I call bigplotfix.R. If you source it, it will define a wrapper for plot.xy which "compresses" the plot data when it is very large. The wrapper does nothing if the input is small, but if
|
Statistical methods to more efficiently plot data when millions of points are present?
Here's a file I call bigplotfix.R. If you source it, it will define a wrapper for plot.xy which "compresses" the plot data when it is very large. The wrapper does nothing if the input is small, but if the input is large then it breaks it into chunks and just plots the maximum and minimum x and y value for each chunk. Sourcing bigplotfix.R also rebinds graphics::plot.xy to point to the wrapper (sourcing multiple times is OK).
Note that plot.xy is the "workhorse" function for the standard plotting methods like plot(), lines(), and points(). Thus you can continue to use these functions in your code with no modification, and your large plots will be automatically compressed.
This is some example output. It's essentially plot(runif(1e5)), with points and lines, and with and without the "compression" implemented here. The "compressed points" plot misses the middle region due to the nature of the compression, but the "compressed lines" plot looks much closer to the uncompressed original. The times are for the png() device; for some reason points are much faster in the png device than in the X11 device, but the speed-ups in X11 are comparable (X11(type="cairo") was slower than X11(type="Xlib") in my experiments).
The reason I wrote this is because I was tired of running plot() by accident on a large dataset (e.g. a WAV file). In such cases I would have to choose between waiting several minutes for the plot to finish, and terminating my R session with a signal (thereby losing my recent command history and variables). Now if I can remember to load this file before each session, I can actually get a useful plot in these cases. A little warning message indicates when the plot data has been "compressed".
# bigplotfix.R
# 28 Nov 2016
# This file defines a wrapper for plot.xy which checks if the input
# data is longer than a certain maximum limit. If it is, it is
# downsampled before plotting. For 3 million input points, I got
# speed-ups of 10-100x. Note that if you want the output to look the
# same as the "uncompressed" version, you should be drawing lines,
# because the compression involves taking maximum and minimum values
# of blocks of points (try running test_bigplotfix() for a visual
# explanation). Also, no sorting is done on the input points, so
# things could get weird if they are out of order.
test_bigplotfix = function() {
oldpar=par();
par(mfrow=c(2,2))
n=1e5;
r=runif(n)
bigplotfix_verbose<<-T
mytitle=function(t,m) { title(main=sprintf("%s; elapsed=%0.4f s",m,t["elapsed"])) }
mytime=function(m,e) { t=system.time(e); mytitle(t,m); }
oldbigplotfix_maxlen = bigplotfix_maxlen
bigplotfix_maxlen <<- 1e3;
mytime("Compressed, points",plot(r));
mytime("Compressed, lines",plot(r,type="l"));
bigplotfix_maxlen <<- n
mytime("Uncompressed, points",plot(r));
mytime("Uncompressed, lines",plot(r,type="l"));
par(oldpar);
bigplotfix_maxlen <<- oldbigplotfix_maxlen
bigplotfix_verbose <<- F
}
bigplotfix_verbose=F
downsample_xy = function(xy, n, xlog=F) {
msg=if(bigplotfix_verbose) { message } else { function(...) { NULL } }
msg("Finding range");
r=range(xy$x);
msg("Finding breaks");
if(xlog) {
breaks=exp(seq(from=log(r[1]),to=log(r[2]),length.out=n))
} else {
breaks=seq(from=r[1],to=r[2],length.out=n)
}
msg("Calling findInterval");
## cuts=cut(xy$x,breaks);
# findInterval is much faster than cuts!
cuts = findInterval(xy$x,breaks);
if(0) {
msg("In aggregate 1");
dmax = aggregate(list(x=xy$x, y=xy$y), by=list(cuts=cuts), max)
dmax$cuts = NULL;
msg("In aggregate 2");
dmin = aggregate(list(x=xy$x, y=xy$y), by=list(cuts=cuts), min)
dmin$cuts = NULL;
} else { # use data.table for MUCH faster aggregates
# (see http://stackoverflow.com/questions/7722493/how-does-one-aggregate-and-summarize-data-quickly)
suppressMessages(library(data.table))
msg("In data.table");
dt = data.table(x=xy$x,y=xy$y,cuts=cuts)
msg("In data.table aggregate 1");
dmax = dt[,list(x=max(x),y=max(y)),keyby="cuts"]
dmax$cuts=NULL;
msg("In data.table aggregate 2");
dmin = dt[,list(x=min(x),y=min(y)),keyby="cuts"]
dmin$cuts=NULL;
# ans = data_t[,list(A = sum(count), B = mean(count)), by = 'PID,Time,Site']
}
msg("In rep, rbind");
# interleave rows (copied from a SO answer)
s <- rep(1:n, each = 2) + (0:1) * n
xy = rbind(dmin,dmax)[s,];
xy
}
library(graphics);
# make sure we don't create infinite recursion if someone sources
# this file twice
if(!exists("old_plot.xy")) {
old_plot.xy = graphics::plot.xy
}
bigplotfix_maxlen = 1e4
# formals copied from graphics::plot.xy
my_plot.xy = function(xy, type, pch = par("pch"), lty = par("lty"),
col = par("col"), bg = NA, cex = 1, lwd = par("lwd"),
...) {
if(bigplotfix_verbose) {
message("In bigplotfix's plot.xy\n");
}
mycall=match.call();
len=length(xy$x)
if(len>bigplotfix_maxlen) {
warning("bigplotfix.R (plot.xy): too many points (",len,"), compressing to ",bigplotfix_maxlen,"\n");
xy = downsample_xy(xy, bigplotfix_maxlen, xlog=par("xlog"));
mycall$xy=xy
}
mycall[[1]]=as.symbol("old_plot.xy");
eval(mycall,envir=parent.frame());
}
# new binding solution adapted from Henrik Bengtsson
# https://stat.ethz.ch/pipermail/r-help/2008-August/171217.html
rebindPackageVar = function(pkg, name, new) {
# assignInNamespace() no longer works here, thanks nannies
ns=asNamespace(pkg)
unlockBinding(name,ns)
assign(name,new,envir=asNamespace(pkg),inherits=F)
assign(name,new,envir=globalenv())
lockBinding(name,ns)
}
rebindPackageVar("graphics", "plot.xy", my_plot.xy);
|
Statistical methods to more efficiently plot data when millions of points are present?
Here's a file I call bigplotfix.R. If you source it, it will define a wrapper for plot.xy which "compresses" the plot data when it is very large. The wrapper does nothing if the input is small, but if
|
7,586
|
Statistical methods to more efficiently plot data when millions of points are present?
|
For large time series, I have grown to love smoothScatter (part of base R no less). I often have to include some additional data, and preserving the basic plot API is really helpful, for instance:
set.seed(1)
ra <- rnorm(n = 100000, sd = 1, mean = 0)
smoothScatter(ra)
abline(v=25000, col=2)
text(25000, 0, "Event 1", col=2)
Which gives you (if you pardon the design):
It's always available and works well with enormous datasets, so it's nice to at least take a look at what you have.
|
Statistical methods to more efficiently plot data when millions of points are present?
|
For large time series, I have grown to love smoothScatter (part of base R no less). I often have to include some additional data, and preserving the basic plot API is really helpful, for instance:
set
|
Statistical methods to more efficiently plot data when millions of points are present?
For large time series, I have grown to love smoothScatter (part of base R no less). I often have to include some additional data, and preserving the basic plot API is really helpful, for instance:
set.seed(1)
ra <- rnorm(n = 100000, sd = 1, mean = 0)
smoothScatter(ra)
abline(v=25000, col=2)
text(25000, 0, "Event 1", col=2)
Which gives you (if you pardon the design):
It's always available and works well with enormous datasets, so it's nice to at least take a look at what you have.
|
Statistical methods to more efficiently plot data when millions of points are present?
For large time series, I have grown to love smoothScatter (part of base R no less). I often have to include some additional data, and preserving the basic plot API is really helpful, for instance:
set
|
7,587
|
Statistical methods to more efficiently plot data when millions of points are present?
|
Maybe I'll get shunned for my method, bad memories of one of my research profs screaming at people for throwing away good data by translating them into categories (of course, I do agree now a days lol), don't know. Anyway, if you're talking about a scatterplot, then I've had the same issues. Now, when I have numerical data, doesn't make much sense for me to categorize it for analysis. But visualizing is a different story. What I have found that works best for me is to first (1) break your independent variable into groups using the cut function. You can play around with the number of groups, and then (2) just simply plotting the DV against the cut version of the IV. R will generate box plots instead of that disgusting scatter plot. I do recommend removing the outliers form the plot (use the outline=FALSE option in the plot command). Again, I would NEVER waste perfectly good numerical data by categorizing and then analyzing. Too many issues doing that. Although I know that's a touchy subject of debate. But doing that specifically for the goal of at least making some visual sense out of the data, not much harm I've seen from it. I've plotted data as large as 10M and still managed to make sense out of it from this method. Hope that helps! Best Regards!
|
Statistical methods to more efficiently plot data when millions of points are present?
|
Maybe I'll get shunned for my method, bad memories of one of my research profs screaming at people for throwing away good data by translating them into categories (of course, I do agree now a days lol
|
Statistical methods to more efficiently plot data when millions of points are present?
Maybe I'll get shunned for my method, bad memories of one of my research profs screaming at people for throwing away good data by translating them into categories (of course, I do agree now a days lol), don't know. Anyway, if you're talking about a scatterplot, then I've had the same issues. Now, when I have numerical data, doesn't make much sense for me to categorize it for analysis. But visualizing is a different story. What I have found that works best for me is to first (1) break your independent variable into groups using the cut function. You can play around with the number of groups, and then (2) just simply plotting the DV against the cut version of the IV. R will generate box plots instead of that disgusting scatter plot. I do recommend removing the outliers form the plot (use the outline=FALSE option in the plot command). Again, I would NEVER waste perfectly good numerical data by categorizing and then analyzing. Too many issues doing that. Although I know that's a touchy subject of debate. But doing that specifically for the goal of at least making some visual sense out of the data, not much harm I've seen from it. I've plotted data as large as 10M and still managed to make sense out of it from this method. Hope that helps! Best Regards!
|
Statistical methods to more efficiently plot data when millions of points are present?
Maybe I'll get shunned for my method, bad memories of one of my research profs screaming at people for throwing away good data by translating them into categories (of course, I do agree now a days lol
|
7,588
|
Likelihood - Why multiply?
|
This is a very basic question, and instead of using formal language and mathematical notation, I will try to answer it at a level at which everybody who can understand the question can also understand the answer.
Imagine that we have a race of cats. They have a 75% probability of being born white, and 25% probability of being born grey, no other colors. Also, they have a 50% probability of having green eyes and 50% probability of having blue eyes, and coat color and eye color are independent.
Now let us look at a litter of eight kittens:
You will see that 1 out of 4, or 25%, are grey. Also, 1 out of 2, or 50% have blue eyes. Now the question is,
how many kittens have grey fur and blue eyes?
You can count them, the answer is one. That is, $\frac{1}{4} \times \frac{1}{2} = \frac{1}{8}$, or 12.5% of 8 kittens.
Why does it happen? Because any cat has a 1 in 4 probability to be grey. So, pick four cats, and you can expect one of them to be grey. But if you only pick four cats out of many (and get the expected value of 1 grey cat), the one which is grey has a 1 in 2 probability to have blue eyes. This means, of the total of cats you pick, you first multiply the total by 25% to get the grey cats, and then you multiply the selected 25% of all cats by 50% to get those of them which have blue eyes. This gives you the probability of getting blue-eyed grey cats.
Summing them up would give you $\frac{1}{4} + \frac{1}{2}$, which makes $\frac{3}{4}$ or 6 out of 8. In our picture, it corresponds to summing up the cats which have blue eyes with the cats which have grey fur - and counting the one grey blue-eyed kitten twice! Such a calculation can have its place, but it is rather unusual in probability calculations, and it is certainly not the one you are asking about.
|
Likelihood - Why multiply?
|
This is a very basic question, and instead of using formal language and mathematical notation, I will try to answer it at a level at which everybody who can understand the question can also understand
|
Likelihood - Why multiply?
This is a very basic question, and instead of using formal language and mathematical notation, I will try to answer it at a level at which everybody who can understand the question can also understand the answer.
Imagine that we have a race of cats. They have a 75% probability of being born white, and 25% probability of being born grey, no other colors. Also, they have a 50% probability of having green eyes and 50% probability of having blue eyes, and coat color and eye color are independent.
Now let us look at a litter of eight kittens:
You will see that 1 out of 4, or 25%, are grey. Also, 1 out of 2, or 50% have blue eyes. Now the question is,
how many kittens have grey fur and blue eyes?
You can count them, the answer is one. That is, $\frac{1}{4} \times \frac{1}{2} = \frac{1}{8}$, or 12.5% of 8 kittens.
Why does it happen? Because any cat has a 1 in 4 probability to be grey. So, pick four cats, and you can expect one of them to be grey. But if you only pick four cats out of many (and get the expected value of 1 grey cat), the one which is grey has a 1 in 2 probability to have blue eyes. This means, of the total of cats you pick, you first multiply the total by 25% to get the grey cats, and then you multiply the selected 25% of all cats by 50% to get those of them which have blue eyes. This gives you the probability of getting blue-eyed grey cats.
Summing them up would give you $\frac{1}{4} + \frac{1}{2}$, which makes $\frac{3}{4}$ or 6 out of 8. In our picture, it corresponds to summing up the cats which have blue eyes with the cats which have grey fur - and counting the one grey blue-eyed kitten twice! Such a calculation can have its place, but it is rather unusual in probability calculations, and it is certainly not the one you are asking about.
|
Likelihood - Why multiply?
This is a very basic question, and instead of using formal language and mathematical notation, I will try to answer it at a level at which everybody who can understand the question can also understand
|
7,589
|
Likelihood - Why multiply?
|
Independence between two events means that the occurrence of one event does not affect the likelihood of the occurrence of the another event . So for any two events $A$ and $B$ in a sample space $S$ we say that $A$ and $B$ are independent iff $P(A$ and $B)=P(A\cap B) = P(A)P(B)$ .Now for more than two events we say that the events $A_1,A_2,...A_n $ are independent iff $P(\underset{i\in I}{\cap A_i})= \prod_{i\in I} P(A_i)$ for all subsets $I \subset [1,2,...,n]$ .
In the likelihood we suppose that there is a sample $x_1, x_2, …, x_n $of $n$ independent and identically distributed observations (iid), coming from a distribution with an unknown probability density function , that means this joint density function is
$f(x_1,x_2,...,x_n|\theta) = \prod_{i=1}^{i=n}f(x_i|\theta)$.
|
Likelihood - Why multiply?
|
Independence between two events means that the occurrence of one event does not affect the likelihood of the occurrence of the another event . So for any two events $A$ and $B$ in a sample space $S$
|
Likelihood - Why multiply?
Independence between two events means that the occurrence of one event does not affect the likelihood of the occurrence of the another event . So for any two events $A$ and $B$ in a sample space $S$ we say that $A$ and $B$ are independent iff $P(A$ and $B)=P(A\cap B) = P(A)P(B)$ .Now for more than two events we say that the events $A_1,A_2,...A_n $ are independent iff $P(\underset{i\in I}{\cap A_i})= \prod_{i\in I} P(A_i)$ for all subsets $I \subset [1,2,...,n]$ .
In the likelihood we suppose that there is a sample $x_1, x_2, …, x_n $of $n$ independent and identically distributed observations (iid), coming from a distribution with an unknown probability density function , that means this joint density function is
$f(x_1,x_2,...,x_n|\theta) = \prod_{i=1}^{i=n}f(x_i|\theta)$.
|
Likelihood - Why multiply?
Independence between two events means that the occurrence of one event does not affect the likelihood of the occurrence of the another event . So for any two events $A$ and $B$ in a sample space $S$
|
7,590
|
Likelihood - Why multiply?
|
Under the common assumption of independence, $P(A \cap B)$ = $P(A) P(B)$.
Thus, if you assume that all your observations are independent, then the probability of observing all the values you saw is equal to the product of the individual probabilities.
|
Likelihood - Why multiply?
|
Under the common assumption of independence, $P(A \cap B)$ = $P(A) P(B)$.
Thus, if you assume that all your observations are independent, then the probability of observing all the values you saw is e
|
Likelihood - Why multiply?
Under the common assumption of independence, $P(A \cap B)$ = $P(A) P(B)$.
Thus, if you assume that all your observations are independent, then the probability of observing all the values you saw is equal to the product of the individual probabilities.
|
Likelihood - Why multiply?
Under the common assumption of independence, $P(A \cap B)$ = $P(A) P(B)$.
Thus, if you assume that all your observations are independent, then the probability of observing all the values you saw is e
|
7,591
|
Likelihood - Why multiply?
|
Why not add?
Because that clearly makes no sense. Suppose you have a quarter and a nickel, and you want to flip them both. There's a 50% chance the quarter will come up heads, and a 50% chance the nickel comes up heads. If the chance of both coming up heads were the sum, that would make 100% chance, which is obviously wrong, as it leaves no chance for HT, TH, and TT.
Why multiply?
Because it does make sense. When you multiply the 50% chance of the quarter coming up heads by the 50% chance of the nickel coming up heads, you get 0.5 x 0.5 = 0.25 =25% chance of both coins being heads. Given that there are four possible combinations (HH, HT, TH, HT) and each is equally likely, this fit perfectly. When evaluating the likelihood of two independent events both occurring, we multiply their individual probabilities.
|
Likelihood - Why multiply?
|
Why not add?
Because that clearly makes no sense. Suppose you have a quarter and a nickel, and you want to flip them both. There's a 50% chance the quarter will come up heads, and a 50% chance the ni
|
Likelihood - Why multiply?
Why not add?
Because that clearly makes no sense. Suppose you have a quarter and a nickel, and you want to flip them both. There's a 50% chance the quarter will come up heads, and a 50% chance the nickel comes up heads. If the chance of both coming up heads were the sum, that would make 100% chance, which is obviously wrong, as it leaves no chance for HT, TH, and TT.
Why multiply?
Because it does make sense. When you multiply the 50% chance of the quarter coming up heads by the 50% chance of the nickel coming up heads, you get 0.5 x 0.5 = 0.25 =25% chance of both coins being heads. Given that there are four possible combinations (HH, HT, TH, HT) and each is equally likely, this fit perfectly. When evaluating the likelihood of two independent events both occurring, we multiply their individual probabilities.
|
Likelihood - Why multiply?
Why not add?
Because that clearly makes no sense. Suppose you have a quarter and a nickel, and you want to flip them both. There's a 50% chance the quarter will come up heads, and a 50% chance the ni
|
7,592
|
Likelihood - Why multiply?
|
I am reading these posts because, like the Original Poster, my need is to understand why the 'Likelihood' fn is the 'Product' of the density of each sample value -'x'.
A readable and logical reason is given under the heading Principle of maximum likelihood Ref:
http://www-structmed.cimr.cam.ac.uk/Course/Likelihood/likelihood.html
A further quotation Mathematically, the likelihood is defined as the probability of making the set of measurements (same ref.)
In short, the probabilty that you arrived at the sample that you have at hand.
|
Likelihood - Why multiply?
|
I am reading these posts because, like the Original Poster, my need is to understand why the 'Likelihood' fn is the 'Product' of the density of each sample value -'x'.
A readable and logical reason is
|
Likelihood - Why multiply?
I am reading these posts because, like the Original Poster, my need is to understand why the 'Likelihood' fn is the 'Product' of the density of each sample value -'x'.
A readable and logical reason is given under the heading Principle of maximum likelihood Ref:
http://www-structmed.cimr.cam.ac.uk/Course/Likelihood/likelihood.html
A further quotation Mathematically, the likelihood is defined as the probability of making the set of measurements (same ref.)
In short, the probabilty that you arrived at the sample that you have at hand.
|
Likelihood - Why multiply?
I am reading these posts because, like the Original Poster, my need is to understand why the 'Likelihood' fn is the 'Product' of the density of each sample value -'x'.
A readable and logical reason is
|
7,593
|
Likelihood - Why multiply?
|
The goal of the maximum likelihood method is find estimator that maximize the probability of observe certains values of the variable ( endogenous variable). That is the reason why we must multiply the probabilties of ocurrence.
For example: imagine that the numbers of phone calls that a secretary can answer in an hour follows a poisson distribution. Then, you extract 2 values of the sample ( 5 phone calls and 8 phone calls per hour)
Now you must answer this question. What is the value of the parameter that maximize the probability of observe 5 and 8 phone calls, simultaneously?. After, try to answer with the probaility of observe all the values of the sam
Due to the independant random variables,
f(y1 = 5 phone calls)*f(y2 = 8 phone calls) = ∏i f(y,θ) = L(θ,y1,y2)
Finally, try to answer, the probability of observe all the values of the sample.
|
Likelihood - Why multiply?
|
The goal of the maximum likelihood method is find estimator that maximize the probability of observe certains values of the variable ( endogenous variable). That is the reason why we must multiply the
|
Likelihood - Why multiply?
The goal of the maximum likelihood method is find estimator that maximize the probability of observe certains values of the variable ( endogenous variable). That is the reason why we must multiply the probabilties of ocurrence.
For example: imagine that the numbers of phone calls that a secretary can answer in an hour follows a poisson distribution. Then, you extract 2 values of the sample ( 5 phone calls and 8 phone calls per hour)
Now you must answer this question. What is the value of the parameter that maximize the probability of observe 5 and 8 phone calls, simultaneously?. After, try to answer with the probaility of observe all the values of the sam
Due to the independant random variables,
f(y1 = 5 phone calls)*f(y2 = 8 phone calls) = ∏i f(y,θ) = L(θ,y1,y2)
Finally, try to answer, the probability of observe all the values of the sample.
|
Likelihood - Why multiply?
The goal of the maximum likelihood method is find estimator that maximize the probability of observe certains values of the variable ( endogenous variable). That is the reason why we must multiply the
|
7,594
|
Likelihood - Why multiply?
|
In practice, when we want to find MLE we would usually take the log of the likelihood function. Then the product of density function or probability (depend on the data type) shall become sum.
As to the question why likelihood is a product of probability. Considering "The goal of maximum likelihood estimation is to find the values of the model parameters that maximize the likelihood function over the parameter space", we want to maximize the likelihood and a best estimate is the probability. Suppose there is a normal distribution with parameters $\mu$ and $\sigma^2$, response Y, $x_i$ are independent, then $L(\mu, \sigma^2 | Y) = P(y | \mu, \sigma^2)$. Because probability of independent events $P(A\cup{B}) = P(A)P(B)$. The likelihood becomes the product of the probability.
|
Likelihood - Why multiply?
|
In practice, when we want to find MLE we would usually take the log of the likelihood function. Then the product of density function or probability (depend on the data type) shall become sum.
As to th
|
Likelihood - Why multiply?
In practice, when we want to find MLE we would usually take the log of the likelihood function. Then the product of density function or probability (depend on the data type) shall become sum.
As to the question why likelihood is a product of probability. Considering "The goal of maximum likelihood estimation is to find the values of the model parameters that maximize the likelihood function over the parameter space", we want to maximize the likelihood and a best estimate is the probability. Suppose there is a normal distribution with parameters $\mu$ and $\sigma^2$, response Y, $x_i$ are independent, then $L(\mu, \sigma^2 | Y) = P(y | \mu, \sigma^2)$. Because probability of independent events $P(A\cup{B}) = P(A)P(B)$. The likelihood becomes the product of the probability.
|
Likelihood - Why multiply?
In practice, when we want to find MLE we would usually take the log of the likelihood function. Then the product of density function or probability (depend on the data type) shall become sum.
As to th
|
7,595
|
What is the difference between logistic regression and neural networks?
|
I assume you're thinking of what used to be, and perhaps still are referred to as 'multilayer perceptrons' in your question about neural networks. If so then I'd explain the whole thing in terms of flexibility about the form of the decision boundary as a function of explanatory variables. In particular, for this audience, I wouldn't mention link functions / log odds etc. Just keep with the idea that the probability of an event is being predicted on the basis of some observations.
Here's a possible sequence:
Make sure they know what a predicted probability is, conceptually speaking. Show it as a function of one variable in the context of some familiar data. Explain the decision context that will be shared by logistic regression and neural networks.
Start with logistic regression. State that it is the linear case but show the linearity of the resulting decision boundary using a heat or contour plot of the output probabilities with two explanatory variables.
Note that two classes may not be well-separated by the boundary they see and motivate a more flexible model to make a more curvy boundary. If necessary show some data that would be well distinguished this way. (This is why you start with 2 variables)
Note that you could start complicating the original linear model with extra terms, e.g. squares or other transformations, and maybe show the boundaries that these generate.
But then discard these, observing that you don't know in advance what the function form ought to be and you'd prefer to learn it from the data. Just as they get enthusiastic about this, note the impossibility of this in complete generality, and suggest that you are happy to assume that it should at least be 'smooth' rather than 'choppy', but otherwise determined by the data. (Assert that they were probably already thinking of only smooth boundaries, in the same way as they'd been speaking prose all their lives).
Show the output of a generalized additive model where the output probability is a joint function of the pair of the original variables rather than a true additive combination - this is just for demonstration purposes. Importantly, call it a smoother because that's nice and general and describes things intuitively. Demonstrate the non-linear decision boundary in the picture as before.
Note that this (currently anonymous) smoother has a smoothness parameter that controls how smooth it actually is, refer to this in passing as being like a prior belief about smoothness of the function turning the explanatory variables into the predicted probability. Maybe show the consequences of different smoothness settings on the decision boundary.
Now introduce the neural net as a diagram. Point out that the second layer is just a logistic regression model, but also point out the non-linear transformation that happens in the hidden units. Remind the audience that this is just another function from input to output that will be non-linear in its decision boundary.
Note that it has a lot of parameters and that some of them need to be constrained to make a smooth decision boundary - reintroduce the idea of a number that controls smoothness as the same (conceptually speaking) number that keeps the parameters tied together and away from extreme values. Also note that the more hidden units it has, the more different types of functional forms it can realise. To maintain intuition, talk about hidden units in terms of flexibility and parameter constraint in terms of smoothness (despite the mathematical sloppiness of this characterization)
Then surprise them by claiming since you still don't know the functional form so you want to be infinitely flexible by adding an infinite number of hidden units. Let the practical impossibility of this sink in a bit. Then observe that this limit can be taken in the mathematics, and ask (rhetorically) what such a thing would look like.
Answer that it would be a smoother again (a Gaussian process, as it happens; Neal, 1996, but this detail is not important), like the one they saw before. Observe that there is again a quantity that controls smoothness but no other particular parameters (integrated out, for those that care about this sort of thing).
Conclude that neural networks are particular, implicitly limited, implementations of ordinary smoothers, which are the non-linear, not necessarily additive extensions of the logistic regression model. Then do it the other way, concluding that logistic regression is equivalent to a neural network model or a smoother with the smoothing parameter set to 'extra extra smooth' i.e. linear.
The advantages of this approach is that you don't have to really get into any mathematical detail to give the correct idea. In fact they don't have to understand either logistic regression or neural networks already to understand the similarities and differences.
The disadvantage of the approach is that you have to make a lot of pictures, and strongly resist the temptation to drop down into the algebra to explain things.
|
What is the difference between logistic regression and neural networks?
|
I assume you're thinking of what used to be, and perhaps still are referred to as 'multilayer perceptrons' in your question about neural networks. If so then I'd explain the whole thing in terms of f
|
What is the difference between logistic regression and neural networks?
I assume you're thinking of what used to be, and perhaps still are referred to as 'multilayer perceptrons' in your question about neural networks. If so then I'd explain the whole thing in terms of flexibility about the form of the decision boundary as a function of explanatory variables. In particular, for this audience, I wouldn't mention link functions / log odds etc. Just keep with the idea that the probability of an event is being predicted on the basis of some observations.
Here's a possible sequence:
Make sure they know what a predicted probability is, conceptually speaking. Show it as a function of one variable in the context of some familiar data. Explain the decision context that will be shared by logistic regression and neural networks.
Start with logistic regression. State that it is the linear case but show the linearity of the resulting decision boundary using a heat or contour plot of the output probabilities with two explanatory variables.
Note that two classes may not be well-separated by the boundary they see and motivate a more flexible model to make a more curvy boundary. If necessary show some data that would be well distinguished this way. (This is why you start with 2 variables)
Note that you could start complicating the original linear model with extra terms, e.g. squares or other transformations, and maybe show the boundaries that these generate.
But then discard these, observing that you don't know in advance what the function form ought to be and you'd prefer to learn it from the data. Just as they get enthusiastic about this, note the impossibility of this in complete generality, and suggest that you are happy to assume that it should at least be 'smooth' rather than 'choppy', but otherwise determined by the data. (Assert that they were probably already thinking of only smooth boundaries, in the same way as they'd been speaking prose all their lives).
Show the output of a generalized additive model where the output probability is a joint function of the pair of the original variables rather than a true additive combination - this is just for demonstration purposes. Importantly, call it a smoother because that's nice and general and describes things intuitively. Demonstrate the non-linear decision boundary in the picture as before.
Note that this (currently anonymous) smoother has a smoothness parameter that controls how smooth it actually is, refer to this in passing as being like a prior belief about smoothness of the function turning the explanatory variables into the predicted probability. Maybe show the consequences of different smoothness settings on the decision boundary.
Now introduce the neural net as a diagram. Point out that the second layer is just a logistic regression model, but also point out the non-linear transformation that happens in the hidden units. Remind the audience that this is just another function from input to output that will be non-linear in its decision boundary.
Note that it has a lot of parameters and that some of them need to be constrained to make a smooth decision boundary - reintroduce the idea of a number that controls smoothness as the same (conceptually speaking) number that keeps the parameters tied together and away from extreme values. Also note that the more hidden units it has, the more different types of functional forms it can realise. To maintain intuition, talk about hidden units in terms of flexibility and parameter constraint in terms of smoothness (despite the mathematical sloppiness of this characterization)
Then surprise them by claiming since you still don't know the functional form so you want to be infinitely flexible by adding an infinite number of hidden units. Let the practical impossibility of this sink in a bit. Then observe that this limit can be taken in the mathematics, and ask (rhetorically) what such a thing would look like.
Answer that it would be a smoother again (a Gaussian process, as it happens; Neal, 1996, but this detail is not important), like the one they saw before. Observe that there is again a quantity that controls smoothness but no other particular parameters (integrated out, for those that care about this sort of thing).
Conclude that neural networks are particular, implicitly limited, implementations of ordinary smoothers, which are the non-linear, not necessarily additive extensions of the logistic regression model. Then do it the other way, concluding that logistic regression is equivalent to a neural network model or a smoother with the smoothing parameter set to 'extra extra smooth' i.e. linear.
The advantages of this approach is that you don't have to really get into any mathematical detail to give the correct idea. In fact they don't have to understand either logistic regression or neural networks already to understand the similarities and differences.
The disadvantage of the approach is that you have to make a lot of pictures, and strongly resist the temptation to drop down into the algebra to explain things.
|
What is the difference between logistic regression and neural networks?
I assume you're thinking of what used to be, and perhaps still are referred to as 'multilayer perceptrons' in your question about neural networks. If so then I'd explain the whole thing in terms of f
|
7,596
|
What is the difference between logistic regression and neural networks?
|
For a simpler summary:
Logistic regression: The simplest form of Neural Network, that results in decision boundaries that are a straight line
Neural Networks: A superset that includes Logistic regression and also other classifiers that can generate more complex decision boundaries.
(note: I'm referring to "plain" logistic regression, without the assistance of integral kernels)
(reference: deeplearning.ai courses by Andrew Ng, "Logistic regression as a neural network" and "Planar data classification with one hidden layer")
|
What is the difference between logistic regression and neural networks?
|
For a simpler summary:
Logistic regression: The simplest form of Neural Network, that results in decision boundaries that are a straight line
Neural Networks: A superset that includes Logistic regres
|
What is the difference between logistic regression and neural networks?
For a simpler summary:
Logistic regression: The simplest form of Neural Network, that results in decision boundaries that are a straight line
Neural Networks: A superset that includes Logistic regression and also other classifiers that can generate more complex decision boundaries.
(note: I'm referring to "plain" logistic regression, without the assistance of integral kernels)
(reference: deeplearning.ai courses by Andrew Ng, "Logistic regression as a neural network" and "Planar data classification with one hidden layer")
|
What is the difference between logistic regression and neural networks?
For a simpler summary:
Logistic regression: The simplest form of Neural Network, that results in decision boundaries that are a straight line
Neural Networks: A superset that includes Logistic regres
|
7,597
|
What is the difference between logistic regression and neural networks?
|
I am going to take the question literally: Someone with no background in statistics. And I'm not going to try to give that person a background in statistics. For instance, suppose you have to explain the difference to the CEO of a company or something like that.
So: Logistic regression is a tool for modeling a categorical variable in terms of other variables. It gives you ways to find out how changes in each of the "other" variables affects the odds of different outcomes in the first variable. The output is fairly easy to interpret.
Neural networks are a set of methods to let a computer try to learn from examples in ways that vaguely resemble how humans learn about things. It may result in models that are good predictors, but they are usually much more opaque than those from logistic regression.
|
What is the difference between logistic regression and neural networks?
|
I am going to take the question literally: Someone with no background in statistics. And I'm not going to try to give that person a background in statistics. For instance, suppose you have to explain
|
What is the difference between logistic regression and neural networks?
I am going to take the question literally: Someone with no background in statistics. And I'm not going to try to give that person a background in statistics. For instance, suppose you have to explain the difference to the CEO of a company or something like that.
So: Logistic regression is a tool for modeling a categorical variable in terms of other variables. It gives you ways to find out how changes in each of the "other" variables affects the odds of different outcomes in the first variable. The output is fairly easy to interpret.
Neural networks are a set of methods to let a computer try to learn from examples in ways that vaguely resemble how humans learn about things. It may result in models that are good predictors, but they are usually much more opaque than those from logistic regression.
|
What is the difference between logistic regression and neural networks?
I am going to take the question literally: Someone with no background in statistics. And I'm not going to try to give that person a background in statistics. For instance, suppose you have to explain
|
7,598
|
What is the difference between logistic regression and neural networks?
|
I was taught that you can think of neural networks (with logistic activation functions) as as a weighted average of logit functions, with the weights themselves estimated. By choosing a large number of logits, you can fit any functional form. There's some graphical intuition in the Econometric Sense blog post.
|
What is the difference between logistic regression and neural networks?
|
I was taught that you can think of neural networks (with logistic activation functions) as as a weighted average of logit functions, with the weights themselves estimated. By choosing a large number o
|
What is the difference between logistic regression and neural networks?
I was taught that you can think of neural networks (with logistic activation functions) as as a weighted average of logit functions, with the weights themselves estimated. By choosing a large number of logits, you can fit any functional form. There's some graphical intuition in the Econometric Sense blog post.
|
What is the difference between logistic regression and neural networks?
I was taught that you can think of neural networks (with logistic activation functions) as as a weighted average of logit functions, with the weights themselves estimated. By choosing a large number o
|
7,599
|
What is the difference between logistic regression and neural networks?
|
The other answers are great. I would simply add some pictures showing that you can think of logistic regression and multi-class logistic regression (a.k.a. maxent, multinomial logistic regression, softmax regression, maximum entropy classifier) as a special architecture of neural networks.
From Sebastian Raschka, Michigan State University, on KDnuggets:
A few more illustration for multi-class logistic regression:
A similar illustration taken from http://www.deeplearningbook.org/ chapter 1:
And one more from TensorFlow tutorials:
E.g. in Caffe, you would implement logistic regression as follows:
|
What is the difference between logistic regression and neural networks?
|
The other answers are great. I would simply add some pictures showing that you can think of logistic regression and multi-class logistic regression (a.k.a. maxent, multinomial logistic regression, sof
|
What is the difference between logistic regression and neural networks?
The other answers are great. I would simply add some pictures showing that you can think of logistic regression and multi-class logistic regression (a.k.a. maxent, multinomial logistic regression, softmax regression, maximum entropy classifier) as a special architecture of neural networks.
From Sebastian Raschka, Michigan State University, on KDnuggets:
A few more illustration for multi-class logistic regression:
A similar illustration taken from http://www.deeplearningbook.org/ chapter 1:
And one more from TensorFlow tutorials:
E.g. in Caffe, you would implement logistic regression as follows:
|
What is the difference between logistic regression and neural networks?
The other answers are great. I would simply add some pictures showing that you can think of logistic regression and multi-class logistic regression (a.k.a. maxent, multinomial logistic regression, sof
|
7,600
|
What is the difference between logistic regression and neural networks?
|
I would use an example of a complicated but concrete problem the audience understands. Use hidden nodes whose interpretations are not trained, but have particular meanings.
If you use chess positions (predicting whether white will win), you could let the inputs be a representation of the board (ignore whether you can castle or capture en passant, or even whose move it is), say $64 \times 12$ binary inputs indicating whether there is a piece of each type on each square.
Linear regression determines how good it is to have a white knight on h4. It might not be obvious that it is good at all, but if it is on h4 it hasn't been captured, which probably outweighs other considerations. Linear regression probably recovers the rough values of the pieces, and that it is better to have your pieces toward the center of the board, and on your opponent's side of the board. Linear regression is unable to value combinations, such as that your queen on b2 is suddenly more valuable if the opposing king is on a1.
A neural network could have hidden nodes for concepts, such as "material advantage," "black king safety," "control of the center," "both rooks on the d-file," "isolated queen rook pawn," or "bishop mobility." Some of these can be estimated just from the board inputs, while others might have to be in a second or later hidden layer. The neural network can use these as inputs to the final evaluation of the position. These concepts help an expert to assess a position, so a neural network should be capable of more accurate assessments than a linear regression. However, it takes more work to create the neural network since you have to choose its structure and it has many more parameters to train.
|
What is the difference between logistic regression and neural networks?
|
I would use an example of a complicated but concrete problem the audience understands. Use hidden nodes whose interpretations are not trained, but have particular meanings.
If you use chess positions
|
What is the difference between logistic regression and neural networks?
I would use an example of a complicated but concrete problem the audience understands. Use hidden nodes whose interpretations are not trained, but have particular meanings.
If you use chess positions (predicting whether white will win), you could let the inputs be a representation of the board (ignore whether you can castle or capture en passant, or even whose move it is), say $64 \times 12$ binary inputs indicating whether there is a piece of each type on each square.
Linear regression determines how good it is to have a white knight on h4. It might not be obvious that it is good at all, but if it is on h4 it hasn't been captured, which probably outweighs other considerations. Linear regression probably recovers the rough values of the pieces, and that it is better to have your pieces toward the center of the board, and on your opponent's side of the board. Linear regression is unable to value combinations, such as that your queen on b2 is suddenly more valuable if the opposing king is on a1.
A neural network could have hidden nodes for concepts, such as "material advantage," "black king safety," "control of the center," "both rooks on the d-file," "isolated queen rook pawn," or "bishop mobility." Some of these can be estimated just from the board inputs, while others might have to be in a second or later hidden layer. The neural network can use these as inputs to the final evaluation of the position. These concepts help an expert to assess a position, so a neural network should be capable of more accurate assessments than a linear regression. However, it takes more work to create the neural network since you have to choose its structure and it has many more parameters to train.
|
What is the difference between logistic regression and neural networks?
I would use an example of a complicated but concrete problem the audience understands. Use hidden nodes whose interpretations are not trained, but have particular meanings.
If you use chess positions
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.