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,801
What's the point of time series analysis?
Time series analysis can also contribute to effective anomaly or outlier detection in temporal data. As an example, it is possible to fit an ARIMA model and calculate a forecast interval. Depending on the use case, the interval can be used to set a threshold, within which the process can be said to be in control; if new data falls outside the threshold it is flagged for further attention. This blog post has a brief and broad overview of time series analysis for outlier detection. For a more in-depth treatment, researchers at ebay explain how they carried out anomaly detection at scale based on the statistical analysis of time series data.
What's the point of time series analysis?
Time series analysis can also contribute to effective anomaly or outlier detection in temporal data. As an example, it is possible to fit an ARIMA model and calculate a forecast interval. Depending o
What's the point of time series analysis? Time series analysis can also contribute to effective anomaly or outlier detection in temporal data. As an example, it is possible to fit an ARIMA model and calculate a forecast interval. Depending on the use case, the interval can be used to set a threshold, within which the process can be said to be in control; if new data falls outside the threshold it is flagged for further attention. This blog post has a brief and broad overview of time series analysis for outlier detection. For a more in-depth treatment, researchers at ebay explain how they carried out anomaly detection at scale based on the statistical analysis of time series data.
What's the point of time series analysis? Time series analysis can also contribute to effective anomaly or outlier detection in temporal data. As an example, it is possible to fit an ARIMA model and calculate a forecast interval. Depending o
7,802
What's the point of time series analysis?
To add some color to the anomaly detection answer by redhqs, at work I build anomaly detection models for operational metrics like sales and traffic flows. We do the time series analysis to understand what sales ought to be if everything is working as expected, and then compare these to the observed values to see whether the web site is broken. It's important because for every minute the site is down we are losing a lot of money. There are different methods you can use, and different methods try to accomplish different things in many cases. For example the main statistical method I have used for sales anomaly detection is called "STL" (seasonal-trend decomposition using loess). This separates the regular seasonality, trend and random noise. We actually use this to identify both daily and weekly seasonalities. Then we throw out the noise, and combine the trend/seasonalities to estimate expected sales. So in our case we use the approach to understand how sales vary with time of day and time of week, and to exclude random noise from the estimates.
What's the point of time series analysis?
To add some color to the anomaly detection answer by redhqs, at work I build anomaly detection models for operational metrics like sales and traffic flows. We do the time series analysis to understand
What's the point of time series analysis? To add some color to the anomaly detection answer by redhqs, at work I build anomaly detection models for operational metrics like sales and traffic flows. We do the time series analysis to understand what sales ought to be if everything is working as expected, and then compare these to the observed values to see whether the web site is broken. It's important because for every minute the site is down we are losing a lot of money. There are different methods you can use, and different methods try to accomplish different things in many cases. For example the main statistical method I have used for sales anomaly detection is called "STL" (seasonal-trend decomposition using loess). This separates the regular seasonality, trend and random noise. We actually use this to identify both daily and weekly seasonalities. Then we throw out the noise, and combine the trend/seasonalities to estimate expected sales. So in our case we use the approach to understand how sales vary with time of day and time of week, and to exclude random noise from the estimates.
What's the point of time series analysis? To add some color to the anomaly detection answer by redhqs, at work I build anomaly detection models for operational metrics like sales and traffic flows. We do the time series analysis to understand
7,803
What's the point of time series analysis?
There are plenty of other statistical methods, such as regression and machine learning, that have obvious use cases: regression can provide information on the relationship between two variables, while machine learning is great for prediction. You answer your own question, below: autocorrelation. Time series usually have it, violating an assumption of basic OLS regression. Time series techniques have the appropriate assumptions for time series. Machine learning methods which deal with sequential data are specialized, like recurrent neural networks (RNNs) or 1-D convolutional neural networks (CNNs), so you still have specialized techniques for time series. But meanwhile, I don't see what time series analysis is good for. Sure, I can fit an ARIMA model and use it for prediction, but what good is that when the confidence intervals for that prediction are going to be huge? There's a reason nobody can predict the stock market despite it being the most data-driven industry in world history. Confidence intervals (CIs) resulting from a time series technique will probably be larger than those from a non-time-series regression. This feature is known as being accurate. In general, when you use a non-time-series regression your CI will be smaller but it is incorrect because you've violated its assumptions. If all you want to do is present a graph with small CI's make them up or skip the CI's entirely, but if you want appropriate CIs use appropriate techniques. The stock market is hard to predict because of it's nature. Other time series are much more predictable. Try using your machine learning technique of choice in the stock market and I doubt you'll have more success. Likewise, how do I use it to understand my process further? Sure, I can plot the ACF and go "aha! there's some dependence!", but then what? What's the point? Of course there's dependence, that's why you are doing time series analysis to begin with. You already knew there was dependence. But what are you going to use it for? To predict. To see seasonality. To have an idea about the variability of the data over different seasons. Not to mention that there are more powerful time series techniques than old-school ARIMA, like State Space methods. ARIMA is not the best technique for modeling time series. (In fact, the ARIMA procedure in your statistical software of choice is probably using a State Space representation under the hood.)
What's the point of time series analysis?
There are plenty of other statistical methods, such as regression and machine learning, that have obvious use cases: regression can provide information on the relationship between two variables, w
What's the point of time series analysis? There are plenty of other statistical methods, such as regression and machine learning, that have obvious use cases: regression can provide information on the relationship between two variables, while machine learning is great for prediction. You answer your own question, below: autocorrelation. Time series usually have it, violating an assumption of basic OLS regression. Time series techniques have the appropriate assumptions for time series. Machine learning methods which deal with sequential data are specialized, like recurrent neural networks (RNNs) or 1-D convolutional neural networks (CNNs), so you still have specialized techniques for time series. But meanwhile, I don't see what time series analysis is good for. Sure, I can fit an ARIMA model and use it for prediction, but what good is that when the confidence intervals for that prediction are going to be huge? There's a reason nobody can predict the stock market despite it being the most data-driven industry in world history. Confidence intervals (CIs) resulting from a time series technique will probably be larger than those from a non-time-series regression. This feature is known as being accurate. In general, when you use a non-time-series regression your CI will be smaller but it is incorrect because you've violated its assumptions. If all you want to do is present a graph with small CI's make them up or skip the CI's entirely, but if you want appropriate CIs use appropriate techniques. The stock market is hard to predict because of it's nature. Other time series are much more predictable. Try using your machine learning technique of choice in the stock market and I doubt you'll have more success. Likewise, how do I use it to understand my process further? Sure, I can plot the ACF and go "aha! there's some dependence!", but then what? What's the point? Of course there's dependence, that's why you are doing time series analysis to begin with. You already knew there was dependence. But what are you going to use it for? To predict. To see seasonality. To have an idea about the variability of the data over different seasons. Not to mention that there are more powerful time series techniques than old-school ARIMA, like State Space methods. ARIMA is not the best technique for modeling time series. (In fact, the ARIMA procedure in your statistical software of choice is probably using a State Space representation under the hood.)
What's the point of time series analysis? There are plenty of other statistical methods, such as regression and machine learning, that have obvious use cases: regression can provide information on the relationship between two variables, w
7,804
What's the point of time series analysis?
In addition to the excellent answers provided by others, I would like to comment on how time series analyses are used in electrical engineering. A large part of electrical engineering consists of modulating voltages and currents to transmit information, or using sensors to convert a physical signal (such as a sound wave) into an electrical form, from which a computer is expected to make a decision. An analog to digital (A/D) converter translates these signals into a set of evenly-spaced (in time) discrete samples, or a time series! Time series analysis methods are the basis of almost all modern signal processing algorithms. For example, speech processing consists of using a microphone to convert a sound wave to an electrical voltage, which is sampled by an A/D, after which a time series model of the signal is created. For instance, linear predictive coders (LPC) in cell phones create an ARMA model of the words being spoken and transmit the model coefficients (along with an index representing an excitation signal from a pre-defined dictionary) instead of the data samples themselves to achieve data compression.
What's the point of time series analysis?
In addition to the excellent answers provided by others, I would like to comment on how time series analyses are used in electrical engineering. A large part of electrical engineering consists of mod
What's the point of time series analysis? In addition to the excellent answers provided by others, I would like to comment on how time series analyses are used in electrical engineering. A large part of electrical engineering consists of modulating voltages and currents to transmit information, or using sensors to convert a physical signal (such as a sound wave) into an electrical form, from which a computer is expected to make a decision. An analog to digital (A/D) converter translates these signals into a set of evenly-spaced (in time) discrete samples, or a time series! Time series analysis methods are the basis of almost all modern signal processing algorithms. For example, speech processing consists of using a microphone to convert a sound wave to an electrical voltage, which is sampled by an A/D, after which a time series model of the signal is created. For instance, linear predictive coders (LPC) in cell phones create an ARMA model of the words being spoken and transmit the model coefficients (along with an index representing an excitation signal from a pre-defined dictionary) instead of the data samples themselves to achieve data compression.
What's the point of time series analysis? In addition to the excellent answers provided by others, I would like to comment on how time series analyses are used in electrical engineering. A large part of electrical engineering consists of mod
7,805
What is normality?
The assumption of normality is just the supposition that the underlying random variable of interest is distributed normally, or approximately so. Intuitively, normality may be understood as the result of the sum of a large number of independent random events. More specifically, normal distributions are defined by the following function: $$ f(x) =\frac{1}{\sqrt{2\pi\sigma^2}}e^{ -\frac{(x-\mu)^2}{2\sigma^2} },$$ where $\mu$ and $\sigma^2$ are the mean and the variance, respectively, and which appears as follows: This can be checked in multiple ways, that may be more or less suited to your problem by its features, such as the size of n. Basically, they all test for features expected if the distribution were normal (e.g. expected quantile distribution).
What is normality?
The assumption of normality is just the supposition that the underlying random variable of interest is distributed normally, or approximately so. Intuitively, normality may be understood as the resul
What is normality? The assumption of normality is just the supposition that the underlying random variable of interest is distributed normally, or approximately so. Intuitively, normality may be understood as the result of the sum of a large number of independent random events. More specifically, normal distributions are defined by the following function: $$ f(x) =\frac{1}{\sqrt{2\pi\sigma^2}}e^{ -\frac{(x-\mu)^2}{2\sigma^2} },$$ where $\mu$ and $\sigma^2$ are the mean and the variance, respectively, and which appears as follows: This can be checked in multiple ways, that may be more or less suited to your problem by its features, such as the size of n. Basically, they all test for features expected if the distribution were normal (e.g. expected quantile distribution).
What is normality? The assumption of normality is just the supposition that the underlying random variable of interest is distributed normally, or approximately so. Intuitively, normality may be understood as the resul
7,806
What is normality?
One note: The assumption of normality is often NOT about your variables, but about the error, which is estimated by the residuals. For example, in linear regression $Y = a + bx + e$; there is no assumption that $Y$ is normally distributed, only that $e$ is.
What is normality?
One note: The assumption of normality is often NOT about your variables, but about the error, which is estimated by the residuals. For example, in linear regression $Y = a + bx + e$; there is no assum
What is normality? One note: The assumption of normality is often NOT about your variables, but about the error, which is estimated by the residuals. For example, in linear regression $Y = a + bx + e$; there is no assumption that $Y$ is normally distributed, only that $e$ is.
What is normality? One note: The assumption of normality is often NOT about your variables, but about the error, which is estimated by the residuals. For example, in linear regression $Y = a + bx + e$; there is no assum
7,807
What is normality?
A related question can be found here about the normal assumption of the error (or more generally of the data if we do not have prior knowledge about the data). Basically, It is mathematically convenient to use normal distribution. (It's related to Least Squares fitting and easy to solve with pseudoinverse) Due to Central Limit Theorem, we may assume that there are lots of underlying facts affecting the process and the sum of these individual effects will tend to behave like normal distribution. In practice, it seems to be so. An important note from there is that, as Terence Tao states here, "Roughly speaking, this theorem asserts that if one takes a statistic that is a combination of many independent and randomly fluctuating components, with no one component having a decisive influence on the whole, then that statistic will be approximately distributed according to a law called the normal distribution". To make this clear, let me write a Python code snippet # -*- coding: utf-8 -*- """ Illustration of the central limit theorem @author: İsmail Arı, http://ismailari.com @date: 31.03.2011 """ import scipy, scipy.stats import numpy as np import pylab #=============================================================== # Uncomment one of the distributions below and observe the result #=============================================================== x = scipy.linspace(0,10,11) #y = scipy.stats.binom.pmf(x,10,0.2) # binom #y = scipy.stats.expon.pdf(x,scale=4) # exp #y = scipy.stats.gamma.pdf(x,2) # gamma #y = np.ones(np.size(x)) # uniform y = scipy.random.random(np.size(x)) # random y = y / sum(y); N = 3 ax = pylab.subplot(N+1,1,1) pylab.plot(x,y) # Plotting details ax.set_xticks([10]) ax.axis([0, 2**N * 10, 0, np.max(y)*1.1]) ax.set_yticks([round(np.max(y),2)]) #=============================================================== # Plots #=============================================================== for i in np.arange(N)+1: y = np.convolve(y,y) y = y / sum(y); x = np.linspace(2*np.min(x), 2*np.max(x), len(y)) ax = pylab.subplot(N+1,1,i+1) pylab.plot(x,y) ax.axis([0, 2**N * 10, 0, np.max(y)*1.1]) ax.set_xticks([2**i * 10]) ax.set_yticks([round(np.max(y),3)]) pylab.show() As can be seen from the figures, the resulting distribution (sum) tends towards a normal distribution regardless of the individual distribution types. So, if we do not have enough information about the underlying effects in the data, normality assumption is reasonable.
What is normality?
A related question can be found here about the normal assumption of the error (or more generally of the data if we do not have prior knowledge about the data). Basically, It is mathematically conveni
What is normality? A related question can be found here about the normal assumption of the error (or more generally of the data if we do not have prior knowledge about the data). Basically, It is mathematically convenient to use normal distribution. (It's related to Least Squares fitting and easy to solve with pseudoinverse) Due to Central Limit Theorem, we may assume that there are lots of underlying facts affecting the process and the sum of these individual effects will tend to behave like normal distribution. In practice, it seems to be so. An important note from there is that, as Terence Tao states here, "Roughly speaking, this theorem asserts that if one takes a statistic that is a combination of many independent and randomly fluctuating components, with no one component having a decisive influence on the whole, then that statistic will be approximately distributed according to a law called the normal distribution". To make this clear, let me write a Python code snippet # -*- coding: utf-8 -*- """ Illustration of the central limit theorem @author: İsmail Arı, http://ismailari.com @date: 31.03.2011 """ import scipy, scipy.stats import numpy as np import pylab #=============================================================== # Uncomment one of the distributions below and observe the result #=============================================================== x = scipy.linspace(0,10,11) #y = scipy.stats.binom.pmf(x,10,0.2) # binom #y = scipy.stats.expon.pdf(x,scale=4) # exp #y = scipy.stats.gamma.pdf(x,2) # gamma #y = np.ones(np.size(x)) # uniform y = scipy.random.random(np.size(x)) # random y = y / sum(y); N = 3 ax = pylab.subplot(N+1,1,1) pylab.plot(x,y) # Plotting details ax.set_xticks([10]) ax.axis([0, 2**N * 10, 0, np.max(y)*1.1]) ax.set_yticks([round(np.max(y),2)]) #=============================================================== # Plots #=============================================================== for i in np.arange(N)+1: y = np.convolve(y,y) y = y / sum(y); x = np.linspace(2*np.min(x), 2*np.max(x), len(y)) ax = pylab.subplot(N+1,1,i+1) pylab.plot(x,y) ax.axis([0, 2**N * 10, 0, np.max(y)*1.1]) ax.set_xticks([2**i * 10]) ax.set_yticks([round(np.max(y),3)]) pylab.show() As can be seen from the figures, the resulting distribution (sum) tends towards a normal distribution regardless of the individual distribution types. So, if we do not have enough information about the underlying effects in the data, normality assumption is reasonable.
What is normality? A related question can be found here about the normal assumption of the error (or more generally of the data if we do not have prior knowledge about the data). Basically, It is mathematically conveni
7,808
What is normality?
You can't know whether there normality and that's why you have to make an assumption that's there. You can only prove the absence of normality with statistic tests. Even worse, when you work with real world data it's almost certain that there isn't true normality in your data. That means that your statistical test is always a bit biased. The question is whether you can live with it's bias. To do that you have to understand your data and the kind of normality that your statistical tool assumes. It's the reason why Frequentist tools are as subjective as Bayesian tools. You can't determine based on the data that it's normally distributed. You have to assume normality.
What is normality?
You can't know whether there normality and that's why you have to make an assumption that's there. You can only prove the absence of normality with statistic tests. Even worse, when you work with real
What is normality? You can't know whether there normality and that's why you have to make an assumption that's there. You can only prove the absence of normality with statistic tests. Even worse, when you work with real world data it's almost certain that there isn't true normality in your data. That means that your statistical test is always a bit biased. The question is whether you can live with it's bias. To do that you have to understand your data and the kind of normality that your statistical tool assumes. It's the reason why Frequentist tools are as subjective as Bayesian tools. You can't determine based on the data that it's normally distributed. You have to assume normality.
What is normality? You can't know whether there normality and that's why you have to make an assumption that's there. You can only prove the absence of normality with statistic tests. Even worse, when you work with real
7,809
What is normality?
The assumption of normality assumes your data is normally distributed (the bell curve, or gaussian distribution). You can check this by plotting the data or checking the measures for kurtosis (how sharp the peak is) and skewdness (?) (if more than half the data is on one side of the peak).
What is normality?
The assumption of normality assumes your data is normally distributed (the bell curve, or gaussian distribution). You can check this by plotting the data or checking the measures for kurtosis (how sha
What is normality? The assumption of normality assumes your data is normally distributed (the bell curve, or gaussian distribution). You can check this by plotting the data or checking the measures for kurtosis (how sharp the peak is) and skewdness (?) (if more than half the data is on one side of the peak).
What is normality? The assumption of normality assumes your data is normally distributed (the bell curve, or gaussian distribution). You can check this by plotting the data or checking the measures for kurtosis (how sha
7,810
What is normality?
Other answers have covered what is normality and suggested normality test methods. Christian highlighted that in practice perfect normality barely exists. I highlight that observed deviation from normality does not necessarily mean that methods assuming normality may not be used, and normality test may not be very useful. Deviation from normality may be caused by outliers that are due to errors in data collection. In many cases checking the data collection logs you can correct these figures and normality often improves. For large samples a normality test will be able to detect a negligible deviation from normality. Methods assuming normality may be robust to non-normality and give results of acceptable accuracy. The t-test is known to be robust in this sense, while the F test is not source. Concerning a specific method it's best to check the literature about robustness.
What is normality?
Other answers have covered what is normality and suggested normality test methods. Christian highlighted that in practice perfect normality barely exists. I highlight that observed deviation from norm
What is normality? Other answers have covered what is normality and suggested normality test methods. Christian highlighted that in practice perfect normality barely exists. I highlight that observed deviation from normality does not necessarily mean that methods assuming normality may not be used, and normality test may not be very useful. Deviation from normality may be caused by outliers that are due to errors in data collection. In many cases checking the data collection logs you can correct these figures and normality often improves. For large samples a normality test will be able to detect a negligible deviation from normality. Methods assuming normality may be robust to non-normality and give results of acceptable accuracy. The t-test is known to be robust in this sense, while the F test is not source. Concerning a specific method it's best to check the literature about robustness.
What is normality? Other answers have covered what is normality and suggested normality test methods. Christian highlighted that in practice perfect normality barely exists. I highlight that observed deviation from norm
7,811
What is normality?
To add to the answers above: The "normality assumption" is that, in a model $Y=\mu+X\beta +\epsilon$, the residual term $\epsilon$ is normally distributed. This assumption (as in ANOVA) often goes with some other: 2. The variance $\sigma^2$ of $\epsilon$ is constant, 3. independence of the observations. Of this three assumptions, 2) and 3) are mostly vastly more important than 1)! So you should preoccupy yourself more with them. George Box said something in the line of "To make a preliminary test on variances is rather like putting to sea in a row boat to find out whether conditions are sufficiently calm for an ocean liner to leave port!" - [Box, "Non-normality and tests on variances", 1953, Biometrika 40, pp. 318-335]" This means that, unequal variances are of great concern, but actually testing for them is very difficult, because the tests are influenced by non-normality so small that it is of no importance for tests of means. Today, there are non-parametric tests for unequal variances that DEFINITELY should be used. In short, preoccupy yourself FIRST about unequal variances, then about normality. When you have made yourself an opinion about them, you can think about normality! A lot of good advice can be found here.
What is normality?
To add to the answers above: The "normality assumption" is that, in a model $Y=\mu+X\beta +\epsilon$, the residual term $\epsilon$ is normally distributed. This assumption (as in ANOVA) often goes wit
What is normality? To add to the answers above: The "normality assumption" is that, in a model $Y=\mu+X\beta +\epsilon$, the residual term $\epsilon$ is normally distributed. This assumption (as in ANOVA) often goes with some other: 2. The variance $\sigma^2$ of $\epsilon$ is constant, 3. independence of the observations. Of this three assumptions, 2) and 3) are mostly vastly more important than 1)! So you should preoccupy yourself more with them. George Box said something in the line of "To make a preliminary test on variances is rather like putting to sea in a row boat to find out whether conditions are sufficiently calm for an ocean liner to leave port!" - [Box, "Non-normality and tests on variances", 1953, Biometrika 40, pp. 318-335]" This means that, unequal variances are of great concern, but actually testing for them is very difficult, because the tests are influenced by non-normality so small that it is of no importance for tests of means. Today, there are non-parametric tests for unequal variances that DEFINITELY should be used. In short, preoccupy yourself FIRST about unequal variances, then about normality. When you have made yourself an opinion about them, you can think about normality! A lot of good advice can be found here.
What is normality? To add to the answers above: The "normality assumption" is that, in a model $Y=\mu+X\beta +\epsilon$, the residual term $\epsilon$ is normally distributed. This assumption (as in ANOVA) often goes wit
7,812
Generating random variables from a mixture of Normal distributions
In general, one of the easiest ways to sample from a mixture distribution is the following: Algorithm Steps 1) Generate a random variable $U\sim\text{Uniform}(0,1)$ 2) If $U\in\left[\sum_{i=1}^kp_{k},\sum_{i=1}^{k+1}p_{k+1}\right)$ interval, where $p_{k}$ correspond to the the probability of the $k^{th}$ component of the mixture model, then generate from thedistribution of the $k^{th}$ component 3) Repeat steps 1) and 2) until you have the desired amount of samples from the mixture distribution Now using the general algorithm given above, you could sample from your example mixture of normals by using the following R code: #The number of samples from the mixture distribution N = 100000 #Sample N random uniforms U U =runif(N) #Variable to store the samples from the mixture distribution rand.samples = rep(NA,N) #Sampling from the mixture for(i in 1:N){ if(U[i]<.3){ rand.samples[i] = rnorm(1,0,1) }else if(U[i]<.8){ rand.samples[i] = rnorm(1,10,1) }else{ rand.samples[i] = rnorm(1,3,.1) } } #Density plot of the random samples plot(density(rand.samples),main="Density Estimate of the Mixture Model") #Plotting the true density as a sanity check x = seq(-20,20,.1) truth = .3*dnorm(x,0,1) + .5*dnorm(x,10,1) + .2*dnorm(x,3,.1) plot(density(rand.samples),main="Density Estimate of the Mixture Model",ylim=c(0,.2),lwd=2) lines(x,truth,col="red",lwd=2) legend("topleft",c("True Density","Estimated Density"),col=c("red","black"),lwd=2) Which generates: and as a sanity check:
Generating random variables from a mixture of Normal distributions
In general, one of the easiest ways to sample from a mixture distribution is the following: Algorithm Steps 1) Generate a random variable $U\sim\text{Uniform}(0,1)$ 2) If $U\in\left[\sum_{i=1}^kp_{k},
Generating random variables from a mixture of Normal distributions In general, one of the easiest ways to sample from a mixture distribution is the following: Algorithm Steps 1) Generate a random variable $U\sim\text{Uniform}(0,1)$ 2) If $U\in\left[\sum_{i=1}^kp_{k},\sum_{i=1}^{k+1}p_{k+1}\right)$ interval, where $p_{k}$ correspond to the the probability of the $k^{th}$ component of the mixture model, then generate from thedistribution of the $k^{th}$ component 3) Repeat steps 1) and 2) until you have the desired amount of samples from the mixture distribution Now using the general algorithm given above, you could sample from your example mixture of normals by using the following R code: #The number of samples from the mixture distribution N = 100000 #Sample N random uniforms U U =runif(N) #Variable to store the samples from the mixture distribution rand.samples = rep(NA,N) #Sampling from the mixture for(i in 1:N){ if(U[i]<.3){ rand.samples[i] = rnorm(1,0,1) }else if(U[i]<.8){ rand.samples[i] = rnorm(1,10,1) }else{ rand.samples[i] = rnorm(1,3,.1) } } #Density plot of the random samples plot(density(rand.samples),main="Density Estimate of the Mixture Model") #Plotting the true density as a sanity check x = seq(-20,20,.1) truth = .3*dnorm(x,0,1) + .5*dnorm(x,10,1) + .2*dnorm(x,3,.1) plot(density(rand.samples),main="Density Estimate of the Mixture Model",ylim=c(0,.2),lwd=2) lines(x,truth,col="red",lwd=2) legend("topleft",c("True Density","Estimated Density"),col=c("red","black"),lwd=2) Which generates: and as a sanity check:
Generating random variables from a mixture of Normal distributions In general, one of the easiest ways to sample from a mixture distribution is the following: Algorithm Steps 1) Generate a random variable $U\sim\text{Uniform}(0,1)$ 2) If $U\in\left[\sum_{i=1}^kp_{k},
7,813
Generating random variables from a mixture of Normal distributions
It's good practice to avoid for loops in R for performance reasons. An alternative solution which exploits the fact rnorm is vectorized: N <- 100000 components <- sample(1:3,prob=c(0.3,0.5,0.2),size=N,replace=TRUE) mus <- c(0,10,3) sds <- sqrt(c(1,1,0.1)) samples <- rnorm(n=N,mean=mus[components],sd=sds[components])
Generating random variables from a mixture of Normal distributions
It's good practice to avoid for loops in R for performance reasons. An alternative solution which exploits the fact rnorm is vectorized: N <- 100000 components <- sample(1:3,prob=c(0.3,0.5,0.2),size=
Generating random variables from a mixture of Normal distributions It's good practice to avoid for loops in R for performance reasons. An alternative solution which exploits the fact rnorm is vectorized: N <- 100000 components <- sample(1:3,prob=c(0.3,0.5,0.2),size=N,replace=TRUE) mus <- c(0,10,3) sds <- sqrt(c(1,1,0.1)) samples <- rnorm(n=N,mean=mus[components],sd=sds[components])
Generating random variables from a mixture of Normal distributions It's good practice to avoid for loops in R for performance reasons. An alternative solution which exploits the fact rnorm is vectorized: N <- 100000 components <- sample(1:3,prob=c(0.3,0.5,0.2),size=
7,814
Generating random variables from a mixture of Normal distributions
Conceptually, you are just picking one distribution (from $k$ possibilities) with some probability, and then generating pseudo-random variates from that distribution. In R, this would be (e.g.): set.seed(8) # this makes the example reproducible N = 1000 # this is how many data you want probs = c(.3,.8) # these are *cumulative* probabilities; since they # necessarily sum to 1, the last would be redundant dists = runif(N) # here I'm generating random variates from a uniform # to select the relevant distribution # this is where the actual data are generated, it's just some if->then # statements, followed by the normal distributions you were interested in data = vector(length=N) for(i in 1:N){ if(dists[i]<probs[1]){ data[i] = rnorm(1, mean=0, sd=1) } else if(dists[i]<probs[2]){ data[i] = rnorm(1, mean=10, sd=1) } else { data[i] = rnorm(1, mean=3, sd=.1) } } # here are a couple of ways of looking at the results summary(data) # Min. 1st Qu. Median Mean 3rd Qu. Max. # -3.2820 0.8443 3.1910 5.5350 10.0700 13.1600 plot(density(data))
Generating random variables from a mixture of Normal distributions
Conceptually, you are just picking one distribution (from $k$ possibilities) with some probability, and then generating pseudo-random variates from that distribution. In R, this would be (e.g.): se
Generating random variables from a mixture of Normal distributions Conceptually, you are just picking one distribution (from $k$ possibilities) with some probability, and then generating pseudo-random variates from that distribution. In R, this would be (e.g.): set.seed(8) # this makes the example reproducible N = 1000 # this is how many data you want probs = c(.3,.8) # these are *cumulative* probabilities; since they # necessarily sum to 1, the last would be redundant dists = runif(N) # here I'm generating random variates from a uniform # to select the relevant distribution # this is where the actual data are generated, it's just some if->then # statements, followed by the normal distributions you were interested in data = vector(length=N) for(i in 1:N){ if(dists[i]<probs[1]){ data[i] = rnorm(1, mean=0, sd=1) } else if(dists[i]<probs[2]){ data[i] = rnorm(1, mean=10, sd=1) } else { data[i] = rnorm(1, mean=3, sd=.1) } } # here are a couple of ways of looking at the results summary(data) # Min. 1st Qu. Median Mean 3rd Qu. Max. # -3.2820 0.8443 3.1910 5.5350 10.0700 13.1600 plot(density(data))
Generating random variables from a mixture of Normal distributions Conceptually, you are just picking one distribution (from $k$ possibilities) with some probability, and then generating pseudo-random variates from that distribution. In R, this would be (e.g.): se
7,815
Generating random variables from a mixture of Normal distributions
Already given perfect answers, so for those who want to achieve this in Python, here is my solution: import numpy as np import matplotlib.pyplot as plt %matplotlib inline mu = [0, 10, 3] sigma = [1, 1, 1] p_i = [0.3, 0.5, 0.2] n = 10000 x = [] for i in range(n): z_i = np.argmax(np.random.multinomial(1, p_i)) x_i = np.random.normal(mu[z_i], sigma[z_i]) x.append(x_i) def univariate_normal(x, mean, variance): """pdf of the univariate normal distribution.""" return ((1. / np.sqrt(2 * np.pi * variance)) * np.exp(-(x - mean)**2 / (2 * variance))) a = np.arange(-7, 18, 0.01) y = p_i[0] * univariate_normal(a, mean=mu[0], variance=sigma[0]**2) + p_i[1] * univariate_normal(a, mean=mu[1], variance=sigma[0]**2)+ p_i[2] * univariate_normal(a, mean=mu[2], variance=sigma[0]**2) fig, ax = plt.subplots(figsize=(8, 4)) ax.hist(x, bins=100, density=True) ax.plot(a, y)
Generating random variables from a mixture of Normal distributions
Already given perfect answers, so for those who want to achieve this in Python, here is my solution: import numpy as np import matplotlib.pyplot as plt %matplotlib inline mu = [0, 10, 3] sigma = [1,
Generating random variables from a mixture of Normal distributions Already given perfect answers, so for those who want to achieve this in Python, here is my solution: import numpy as np import matplotlib.pyplot as plt %matplotlib inline mu = [0, 10, 3] sigma = [1, 1, 1] p_i = [0.3, 0.5, 0.2] n = 10000 x = [] for i in range(n): z_i = np.argmax(np.random.multinomial(1, p_i)) x_i = np.random.normal(mu[z_i], sigma[z_i]) x.append(x_i) def univariate_normal(x, mean, variance): """pdf of the univariate normal distribution.""" return ((1. / np.sqrt(2 * np.pi * variance)) * np.exp(-(x - mean)**2 / (2 * variance))) a = np.arange(-7, 18, 0.01) y = p_i[0] * univariate_normal(a, mean=mu[0], variance=sigma[0]**2) + p_i[1] * univariate_normal(a, mean=mu[1], variance=sigma[0]**2)+ p_i[2] * univariate_normal(a, mean=mu[2], variance=sigma[0]**2) fig, ax = plt.subplots(figsize=(8, 4)) ax.hist(x, bins=100, density=True) ax.plot(a, y)
Generating random variables from a mixture of Normal distributions Already given perfect answers, so for those who want to achieve this in Python, here is my solution: import numpy as np import matplotlib.pyplot as plt %matplotlib inline mu = [0, 10, 3] sigma = [1,
7,816
How to represent an unbounded variable as number between 0 and 1
A very common trick to do so (e.g., in connectionist modeling) is to use the hyperbolic tangent tanh as the 'squashing function". It automatically fits all numbers into the interval between -1 and 1. Which in your case restricts the range from 0 to 1. In r and matlab you get it via tanh(). Another squashing function is the logistic function (thanks to Simon for the name), provided by $ f(x) = 1 / (1 + e ^{-x} ) $, which restricts the range from 0 to 1 (with 0 mapped to .5). So you would have to multiply the result by 2 and subtract 1 to fit your data into the interval between 0 and 1. Here is some simple R code which plots both functions (tanh in red, logistic in blue) so you can see how both squash: x <- seq(0,20,0.001) plot(x,tanh(x),pch=".", col="red", ylab="y") points(x,(1 / (1 + exp(-x)))*2-1, pch=".",col="blue")
How to represent an unbounded variable as number between 0 and 1
A very common trick to do so (e.g., in connectionist modeling) is to use the hyperbolic tangent tanh as the 'squashing function". It automatically fits all numbers into the interval between -1 and 1.
How to represent an unbounded variable as number between 0 and 1 A very common trick to do so (e.g., in connectionist modeling) is to use the hyperbolic tangent tanh as the 'squashing function". It automatically fits all numbers into the interval between -1 and 1. Which in your case restricts the range from 0 to 1. In r and matlab you get it via tanh(). Another squashing function is the logistic function (thanks to Simon for the name), provided by $ f(x) = 1 / (1 + e ^{-x} ) $, which restricts the range from 0 to 1 (with 0 mapped to .5). So you would have to multiply the result by 2 and subtract 1 to fit your data into the interval between 0 and 1. Here is some simple R code which plots both functions (tanh in red, logistic in blue) so you can see how both squash: x <- seq(0,20,0.001) plot(x,tanh(x),pch=".", col="red", ylab="y") points(x,(1 / (1 + exp(-x)))*2-1, pch=".",col="blue")
How to represent an unbounded variable as number between 0 and 1 A very common trick to do so (e.g., in connectionist modeling) is to use the hyperbolic tangent tanh as the 'squashing function". It automatically fits all numbers into the interval between -1 and 1.
7,817
How to represent an unbounded variable as number between 0 and 1
As often, my first question was going to be "why do you want to do this", then I saw you've already answered this in the comments to the question: "I am measuring content across many different dimensions and I want to be able to make comparisons in terms of how relevant a given piece of content is. Additionally, I want to display values across these dimensions that is explicable and easily understood." There is no reason to normalize the data so that the max is 1 and the min is zero in order to achieve this, and my opinion is that this would be a bad idea in general. The max or min values could very easily be outliers that are unrepresentative of the population distribution. @osknows parting remark about using $z$-scores is a much better idea. $z$-scores (aka standard scores) normalize each variable using its standard deviation rather than its range. The standard deviation is less influenced by outliers. In order to use $z$-scores, it's preferable that each variable has a roughly normal distribution, or at least has a roughly symmetric distribution (i.e. isn't severely skew) but if necessary you can apply some appropriate data transformation first in order to achieve this; which transformation to use could be determined by finding the best fitting Box–Cox transformation.
How to represent an unbounded variable as number between 0 and 1
As often, my first question was going to be "why do you want to do this", then I saw you've already answered this in the comments to the question: "I am measuring content across many different dimensi
How to represent an unbounded variable as number between 0 and 1 As often, my first question was going to be "why do you want to do this", then I saw you've already answered this in the comments to the question: "I am measuring content across many different dimensions and I want to be able to make comparisons in terms of how relevant a given piece of content is. Additionally, I want to display values across these dimensions that is explicable and easily understood." There is no reason to normalize the data so that the max is 1 and the min is zero in order to achieve this, and my opinion is that this would be a bad idea in general. The max or min values could very easily be outliers that are unrepresentative of the population distribution. @osknows parting remark about using $z$-scores is a much better idea. $z$-scores (aka standard scores) normalize each variable using its standard deviation rather than its range. The standard deviation is less influenced by outliers. In order to use $z$-scores, it's preferable that each variable has a roughly normal distribution, or at least has a roughly symmetric distribution (i.e. isn't severely skew) but if necessary you can apply some appropriate data transformation first in order to achieve this; which transformation to use could be determined by finding the best fitting Box–Cox transformation.
How to represent an unbounded variable as number between 0 and 1 As often, my first question was going to be "why do you want to do this", then I saw you've already answered this in the comments to the question: "I am measuring content across many different dimensi
7,818
How to represent an unbounded variable as number between 0 and 1
Any sigmoid function will work: The top half of the logistic function (multiply by 2, subtract 1) The error function tanh, as suggested by Henrik.
How to represent an unbounded variable as number between 0 and 1
Any sigmoid function will work: The top half of the logistic function (multiply by 2, subtract 1) The error function tanh, as suggested by Henrik.
How to represent an unbounded variable as number between 0 and 1 Any sigmoid function will work: The top half of the logistic function (multiply by 2, subtract 1) The error function tanh, as suggested by Henrik.
How to represent an unbounded variable as number between 0 and 1 Any sigmoid function will work: The top half of the logistic function (multiply by 2, subtract 1) The error function tanh, as suggested by Henrik.
7,819
How to represent an unbounded variable as number between 0 and 1
In addition to the good suggestions by Henrik and Simon Byrne, you could use f(x) = x/(x+1). By way of comparison, the logistic function will exaggerate differences as x grows larger. That is, the difference between f(x) and f(x+1) will be larger with the logistic function than with f(x) = x/(x+1). You may or may not want that effect.
How to represent an unbounded variable as number between 0 and 1
In addition to the good suggestions by Henrik and Simon Byrne, you could use f(x) = x/(x+1). By way of comparison, the logistic function will exaggerate differences as x grows larger. That is, the d
How to represent an unbounded variable as number between 0 and 1 In addition to the good suggestions by Henrik and Simon Byrne, you could use f(x) = x/(x+1). By way of comparison, the logistic function will exaggerate differences as x grows larger. That is, the difference between f(x) and f(x+1) will be larger with the logistic function than with f(x) = x/(x+1). You may or may not want that effect.
How to represent an unbounded variable as number between 0 and 1 In addition to the good suggestions by Henrik and Simon Byrne, you could use f(x) = x/(x+1). By way of comparison, the logistic function will exaggerate differences as x grows larger. That is, the d
7,820
How to represent an unbounded variable as number between 0 and 1
Another customisable approach that you can explore is to simply divide all values by the maximum value and take it to the power of a positive shape value ($\gamma$) that best satisfies your desired tranformation objectives. See example below in R in which the dashed line is the simple case of dividing x by max(x): scaled_power_transform <- function(x, gamma=0.25) { ## x must be nonnegative stopifnot(all(x >= 0)) ## scale to [0, 1] x_scaled <- x / max(x) ## customise the shape x_scaled <- x_scaled^gamma return(invisible(x_scaled)) } x <- seq(0, 1000) plot(x = x, y = scaled_power_transform(x, gamma = 0.1), col = 'blue', type = 'l', lwd = 2, ylab = 'x transformed') lines(x, x/max(x), lty = 2) lines(x = x, y = scaled_power_transform(x, gamma = 0.5), col = 'green', type = 'l', lwd = 2) lines(x = x, y = scaled_power_transform(x, gamma = 2), col = 'red', type = 'l', lwd = 2) legend(x = 0.6*max(x), y=0.3, legend = c(expression(paste(gamma,'= 0.1')), expression(paste(gamma,'= 0.5')), expression(paste(gamma,'= 2.0'))), pch = rep('*', 3), col = c('blue', 'green', 'red')) Created on 2020-10-10 by the reprex package (v0.3.0)
How to represent an unbounded variable as number between 0 and 1
Another customisable approach that you can explore is to simply divide all values by the maximum value and take it to the power of a positive shape value ($\gamma$) that best satisfies your desired tr
How to represent an unbounded variable as number between 0 and 1 Another customisable approach that you can explore is to simply divide all values by the maximum value and take it to the power of a positive shape value ($\gamma$) that best satisfies your desired tranformation objectives. See example below in R in which the dashed line is the simple case of dividing x by max(x): scaled_power_transform <- function(x, gamma=0.25) { ## x must be nonnegative stopifnot(all(x >= 0)) ## scale to [0, 1] x_scaled <- x / max(x) ## customise the shape x_scaled <- x_scaled^gamma return(invisible(x_scaled)) } x <- seq(0, 1000) plot(x = x, y = scaled_power_transform(x, gamma = 0.1), col = 'blue', type = 'l', lwd = 2, ylab = 'x transformed') lines(x, x/max(x), lty = 2) lines(x = x, y = scaled_power_transform(x, gamma = 0.5), col = 'green', type = 'l', lwd = 2) lines(x = x, y = scaled_power_transform(x, gamma = 2), col = 'red', type = 'l', lwd = 2) legend(x = 0.6*max(x), y=0.3, legend = c(expression(paste(gamma,'= 0.1')), expression(paste(gamma,'= 0.5')), expression(paste(gamma,'= 2.0'))), pch = rep('*', 3), col = c('blue', 'green', 'red')) Created on 2020-10-10 by the reprex package (v0.3.0)
How to represent an unbounded variable as number between 0 and 1 Another customisable approach that you can explore is to simply divide all values by the maximum value and take it to the power of a positive shape value ($\gamma$) that best satisfies your desired tr
7,821
How to represent an unbounded variable as number between 0 and 1
My earlier post has a method to rank between 0 and 1. Advice on classifier input correlation However, the ranking I have used, Tmin/Tmax uses the sample min/max but you may find the population min/max more appropriate. Also look up z scores
How to represent an unbounded variable as number between 0 and 1
My earlier post has a method to rank between 0 and 1. Advice on classifier input correlation However, the ranking I have used, Tmin/Tmax uses the sample min/max but you may find the population min/max
How to represent an unbounded variable as number between 0 and 1 My earlier post has a method to rank between 0 and 1. Advice on classifier input correlation However, the ranking I have used, Tmin/Tmax uses the sample min/max but you may find the population min/max more appropriate. Also look up z scores
How to represent an unbounded variable as number between 0 and 1 My earlier post has a method to rank between 0 and 1. Advice on classifier input correlation However, the ranking I have used, Tmin/Tmax uses the sample min/max but you may find the population min/max
7,822
How to represent an unbounded variable as number between 0 and 1
To add to the other answers suggesting pnorm... For a potentially optimal method for selecting parameters I suggest this approximation for pnorm. 1.0/(1.0+exp(-1.69897*(x-mean(x))/sd(x))) This is essentially Softmax Normalization. Reference Pnorm in a pinch
How to represent an unbounded variable as number between 0 and 1
To add to the other answers suggesting pnorm... For a potentially optimal method for selecting parameters I suggest this approximation for pnorm. 1.0/(1.0+exp(-1.69897*(x-mean(x))/sd(x))) This is es
How to represent an unbounded variable as number between 0 and 1 To add to the other answers suggesting pnorm... For a potentially optimal method for selecting parameters I suggest this approximation for pnorm. 1.0/(1.0+exp(-1.69897*(x-mean(x))/sd(x))) This is essentially Softmax Normalization. Reference Pnorm in a pinch
How to represent an unbounded variable as number between 0 and 1 To add to the other answers suggesting pnorm... For a potentially optimal method for selecting parameters I suggest this approximation for pnorm. 1.0/(1.0+exp(-1.69897*(x-mean(x))/sd(x))) This is es
7,823
How to represent an unbounded variable as number between 0 and 1
There are two ways to implement this that I use commonly. I am always working with realtime data, so this assumes continuous input. Here's some pseudo-code: Using a trainable minmax: define function peak: // keeps the highest value it has received define function trough: // keeps the lowest value it has received define function calibrate: // toggles whether peak() and trough() are receiving values or not define function scale: // maps input range [trough.value() to peak.value()] to [0.0 to 1.0] This function requires that you either perform an initial training phase (by using calibrate()) or that you re-train either at certain intervals or according to certain conditions. For instance, imagine a function like this: define function outBounds (val, thresh): if val > (thresh*peak.value()) || val < (trough.value() / thresh): calibrate() peak and trough are normally not receiving values, but if outBounds() receives a value that is more than 1.5 times the current peak or less than the current trough divided by 1.5, then calibrate() is called which allows the function to re-calibrate automatically. Using an historical minmax: var arrayLength = 1000 var histArray[arrayLength] define historyArray(f): histArray.pushFront(f) //adds f to the beginning of the array define max(array): // finds maximum element in histArray[] return max define min(array): // finds minimum element in histArray[] return min define function scale: // maps input range [min(histArray) to max(histArray)] to [0.0 to 1.0] main() historyArray(histArray) scale(min(histArray), max(histArray), histArray[0]) // histArray[0] is the current element
How to represent an unbounded variable as number between 0 and 1
There are two ways to implement this that I use commonly. I am always working with realtime data, so this assumes continuous input. Here's some pseudo-code: Using a trainable minmax: define function p
How to represent an unbounded variable as number between 0 and 1 There are two ways to implement this that I use commonly. I am always working with realtime data, so this assumes continuous input. Here's some pseudo-code: Using a trainable minmax: define function peak: // keeps the highest value it has received define function trough: // keeps the lowest value it has received define function calibrate: // toggles whether peak() and trough() are receiving values or not define function scale: // maps input range [trough.value() to peak.value()] to [0.0 to 1.0] This function requires that you either perform an initial training phase (by using calibrate()) or that you re-train either at certain intervals or according to certain conditions. For instance, imagine a function like this: define function outBounds (val, thresh): if val > (thresh*peak.value()) || val < (trough.value() / thresh): calibrate() peak and trough are normally not receiving values, but if outBounds() receives a value that is more than 1.5 times the current peak or less than the current trough divided by 1.5, then calibrate() is called which allows the function to re-calibrate automatically. Using an historical minmax: var arrayLength = 1000 var histArray[arrayLength] define historyArray(f): histArray.pushFront(f) //adds f to the beginning of the array define max(array): // finds maximum element in histArray[] return max define min(array): // finds minimum element in histArray[] return min define function scale: // maps input range [min(histArray) to max(histArray)] to [0.0 to 1.0] main() historyArray(histArray) scale(min(histArray), max(histArray), histArray[0]) // histArray[0] is the current element
How to represent an unbounded variable as number between 0 and 1 There are two ways to implement this that I use commonly. I am always working with realtime data, so this assumes continuous input. Here's some pseudo-code: Using a trainable minmax: define function p
7,824
How to represent an unbounded variable as number between 0 and 1
A very simple option is dividing each number in your data by the largest number in your data. If you have many small numbers and a few very large ones, this might not convey the information well. But it's relatively easy; if you think meaningful information is lost when you graph the data like this, you could try one of the more sophisticated techniques that others have suggested.
How to represent an unbounded variable as number between 0 and 1
A very simple option is dividing each number in your data by the largest number in your data. If you have many small numbers and a few very large ones, this might not convey the information well. Bu
How to represent an unbounded variable as number between 0 and 1 A very simple option is dividing each number in your data by the largest number in your data. If you have many small numbers and a few very large ones, this might not convey the information well. But it's relatively easy; if you think meaningful information is lost when you graph the data like this, you could try one of the more sophisticated techniques that others have suggested.
How to represent an unbounded variable as number between 0 and 1 A very simple option is dividing each number in your data by the largest number in your data. If you have many small numbers and a few very large ones, this might not convey the information well. Bu
7,825
How to represent an unbounded variable as number between 0 and 1
there's a simple formula for normalization in $[0,1]$: $$ x' = \begin{cases} \frac{1}{ 1 + 1 / x } & \text{if } x > 0\\ 0 & \text{else} \end{cases} $$ $$\lim_{x\rightarrow0} x' = 0$$ $$\lim_{x\rightarrow\infty} x' = 1$$ $$\lim_{x\rightarrow1} x' = 0.5$$ Is there a name for this function?
How to represent an unbounded variable as number between 0 and 1
there's a simple formula for normalization in $[0,1]$: $$ x' = \begin{cases} \frac{1}{ 1 + 1 / x } & \text{if } x > 0\\ 0 & \text{else} \end{cases} $$ $$\lim_{x\rightarrow0} x' = 0$$ $$\lim_{x\righta
How to represent an unbounded variable as number between 0 and 1 there's a simple formula for normalization in $[0,1]$: $$ x' = \begin{cases} \frac{1}{ 1 + 1 / x } & \text{if } x > 0\\ 0 & \text{else} \end{cases} $$ $$\lim_{x\rightarrow0} x' = 0$$ $$\lim_{x\rightarrow\infty} x' = 1$$ $$\lim_{x\rightarrow1} x' = 0.5$$ Is there a name for this function?
How to represent an unbounded variable as number between 0 and 1 there's a simple formula for normalization in $[0,1]$: $$ x' = \begin{cases} \frac{1}{ 1 + 1 / x } & \text{if } x > 0\\ 0 & \text{else} \end{cases} $$ $$\lim_{x\rightarrow0} x' = 0$$ $$\lim_{x\righta
7,826
Why study convex optimization for theoretical machine learning?
Machine learning algorithms use optimization all the time. We minimize loss, or error, or maximize some kind of score functions. Gradient descent is the "hello world" optimization algorithm covered on probably any machine learning course. It is obvious in the case of regression, or classification models, but even with tasks such as clustering we are looking for a solution that optimally fits our data (e.g. k-means minimizes the within-cluster sum of squares). So if you want to understand how the machine learning algorithms do work, learning more about optimization helps. Moreover, if you need to do things like hyperparameter tuning, then you are also directly using optimization. One could argue that convex optimization shouldn't be that interesting for machine learning since instead of dealing with convex functions, we often encounter loss surfaces like the one below, that are far from convex. (source: https://www.cs.umd.edu/~tomg/projects/landscapes/ and arXiv:1712.09913) Nonetheless, as mentioned in other answers, convex optimization is faster, simpler, and less computationally intensive. For example, gradient descent and alike algorithms are commonly used in machine learning, especially for neural networks, because they "work", scale, and are widely implemented in different software, nonetheless, they are not the best that we can get and have their pitfalls, as discussed by Ali Rahimi's talk at NIPS 2017. On another hand, non-convex optimization algorithms such as evolutionary algorithms seem to be gaining more and more recognition in the ML community, e.g. training neural networks by neuroevolution seems to be a recent research topic (see also arXiv:1712.07897).
Why study convex optimization for theoretical machine learning?
Machine learning algorithms use optimization all the time. We minimize loss, or error, or maximize some kind of score functions. Gradient descent is the "hello world" optimization algorithm covered on
Why study convex optimization for theoretical machine learning? Machine learning algorithms use optimization all the time. We minimize loss, or error, or maximize some kind of score functions. Gradient descent is the "hello world" optimization algorithm covered on probably any machine learning course. It is obvious in the case of regression, or classification models, but even with tasks such as clustering we are looking for a solution that optimally fits our data (e.g. k-means minimizes the within-cluster sum of squares). So if you want to understand how the machine learning algorithms do work, learning more about optimization helps. Moreover, if you need to do things like hyperparameter tuning, then you are also directly using optimization. One could argue that convex optimization shouldn't be that interesting for machine learning since instead of dealing with convex functions, we often encounter loss surfaces like the one below, that are far from convex. (source: https://www.cs.umd.edu/~tomg/projects/landscapes/ and arXiv:1712.09913) Nonetheless, as mentioned in other answers, convex optimization is faster, simpler, and less computationally intensive. For example, gradient descent and alike algorithms are commonly used in machine learning, especially for neural networks, because they "work", scale, and are widely implemented in different software, nonetheless, they are not the best that we can get and have their pitfalls, as discussed by Ali Rahimi's talk at NIPS 2017. On another hand, non-convex optimization algorithms such as evolutionary algorithms seem to be gaining more and more recognition in the ML community, e.g. training neural networks by neuroevolution seems to be a recent research topic (see also arXiv:1712.07897).
Why study convex optimization for theoretical machine learning? Machine learning algorithms use optimization all the time. We minimize loss, or error, or maximize some kind of score functions. Gradient descent is the "hello world" optimization algorithm covered on
7,827
Why study convex optimization for theoretical machine learning?
I think there are two questions here. Why study optimization Why convex optimization I think @Tim has a good answer on why optimization. I strongly agree and would recommend anyone interested in machine learning to master continuous optimization. Because the optimization process / finding the better solution over time, is the learning process for a computer. I want to talk more about why we are interested in convex functions. The reason is simple: convex optimizations are "easier to solve", and we have a lot of reliably algorithm to solve. But is the world convex? No. Why obsessed with convexity? Check this metaphor A policeman sees a drunk man searching for something under a streetlight and asks what the drunk has lost. He says he lost his keys and they both look under the streetlight together. After a few minutes the policeman asks if he is sure he lost them here, and the drunk replies, no, and that he lost them in the park. The policeman asks why he is searching here, and the drunk replies, "this is where the light is".
Why study convex optimization for theoretical machine learning?
I think there are two questions here. Why study optimization Why convex optimization I think @Tim has a good answer on why optimization. I strongly agree and would recommend anyone interested in ma
Why study convex optimization for theoretical machine learning? I think there are two questions here. Why study optimization Why convex optimization I think @Tim has a good answer on why optimization. I strongly agree and would recommend anyone interested in machine learning to master continuous optimization. Because the optimization process / finding the better solution over time, is the learning process for a computer. I want to talk more about why we are interested in convex functions. The reason is simple: convex optimizations are "easier to solve", and we have a lot of reliably algorithm to solve. But is the world convex? No. Why obsessed with convexity? Check this metaphor A policeman sees a drunk man searching for something under a streetlight and asks what the drunk has lost. He says he lost his keys and they both look under the streetlight together. After a few minutes the policeman asks if he is sure he lost them here, and the drunk replies, no, and that he lost them in the park. The policeman asks why he is searching here, and the drunk replies, "this is where the light is".
Why study convex optimization for theoretical machine learning? I think there are two questions here. Why study optimization Why convex optimization I think @Tim has a good answer on why optimization. I strongly agree and would recommend anyone interested in ma
7,828
Why study convex optimization for theoretical machine learning?
As hxd1011 said, convex problems are easier to solve, both theoretically and (typically) in practice. So, even for non-convex problems, many optimization algorithms start with "step 1. reduce the problem to a convex one" (possibly inside a while loop). A similar thing happens with nonlinear rootfinding. Usually the solution (e.g., with Newton's method) goes "step 1. Reduce to a linear problem, because we know how to solve those".
Why study convex optimization for theoretical machine learning?
As hxd1011 said, convex problems are easier to solve, both theoretically and (typically) in practice. So, even for non-convex problems, many optimization algorithms start with "step 1. reduce the prob
Why study convex optimization for theoretical machine learning? As hxd1011 said, convex problems are easier to solve, both theoretically and (typically) in practice. So, even for non-convex problems, many optimization algorithms start with "step 1. reduce the problem to a convex one" (possibly inside a while loop). A similar thing happens with nonlinear rootfinding. Usually the solution (e.g., with Newton's method) goes "step 1. Reduce to a linear problem, because we know how to solve those".
Why study convex optimization for theoretical machine learning? As hxd1011 said, convex problems are easier to solve, both theoretically and (typically) in practice. So, even for non-convex problems, many optimization algorithms start with "step 1. reduce the prob
7,829
Why study convex optimization for theoretical machine learning?
The most important takeaway is that machine learning is applied to problems where there is no optimal solution available. The best you can do is find a good approximation. In contrast, when you have an optimisation problem, there is an optimal solution, but it usually cannot be found in reasonable time or with reasonable processing power. The tools and algorithms you use are fundamentally different. So while I would say that there is no immediate benefit of taking an optimisation class, it is always good to know a bit about related fields. If you can recognise an optimisation problem you'll know that you should not tackle it with machine learning algorithms but with optimisation algorithms instead. That alone is worth a lot I'd say.
Why study convex optimization for theoretical machine learning?
The most important takeaway is that machine learning is applied to problems where there is no optimal solution available. The best you can do is find a good approximation. In contrast, when you have a
Why study convex optimization for theoretical machine learning? The most important takeaway is that machine learning is applied to problems where there is no optimal solution available. The best you can do is find a good approximation. In contrast, when you have an optimisation problem, there is an optimal solution, but it usually cannot be found in reasonable time or with reasonable processing power. The tools and algorithms you use are fundamentally different. So while I would say that there is no immediate benefit of taking an optimisation class, it is always good to know a bit about related fields. If you can recognise an optimisation problem you'll know that you should not tackle it with machine learning algorithms but with optimisation algorithms instead. That alone is worth a lot I'd say.
Why study convex optimization for theoretical machine learning? The most important takeaway is that machine learning is applied to problems where there is no optimal solution available. The best you can do is find a good approximation. In contrast, when you have a
7,830
Why study convex optimization for theoretical machine learning?
If your interests lie in (convex) optimisation applied to deep learning (you mention transfer learning, which is widely used in practice with neural networks) applications, I strongly encourage you to consider reading chapter 8 (optimization for training deep neural networks) of http://www.deeplearningbook.org/ There is a discussion of convex optimisation, and why it has not yet been so successful when applied deep neural networks. Of course, perhaps you could do research in this area that will change the current consensus!
Why study convex optimization for theoretical machine learning?
If your interests lie in (convex) optimisation applied to deep learning (you mention transfer learning, which is widely used in practice with neural networks) applications, I strongly encourage you to
Why study convex optimization for theoretical machine learning? If your interests lie in (convex) optimisation applied to deep learning (you mention transfer learning, which is widely used in practice with neural networks) applications, I strongly encourage you to consider reading chapter 8 (optimization for training deep neural networks) of http://www.deeplearningbook.org/ There is a discussion of convex optimisation, and why it has not yet been so successful when applied deep neural networks. Of course, perhaps you could do research in this area that will change the current consensus!
Why study convex optimization for theoretical machine learning? If your interests lie in (convex) optimisation applied to deep learning (you mention transfer learning, which is widely used in practice with neural networks) applications, I strongly encourage you to
7,831
Why study convex optimization for theoretical machine learning?
As I heard from Jerome H. Friedman methods developed in Machine Learning is in fact not belong to Machine Learning community by itself. From my point of view Machine Learning is more like a collection of various methods from another fields. From point of view of Statistical Learning the three main questions for regression and classification are: What is function family from which you pull approximator What is a criteria how you pull a function What is a method to find the best function To operate in some constructive way on (1) - it's not so obvious how use math optimizaion can help To operate in some constructive way on (2) - it's obvious that objective is the goal. And math optimizaion can help on it. To operate in some constructive way on (3) - you need math optimization. There several parts of math optimization: Convex Optimization/Convex Analysis - very cool area of math. Non-differentiablity is not a problem. And there are 50 generalization of convex functions from which more two usefull in terms of application is quasiconvex and log-concave. Also there are ways how to deal "stochasticity" in some way, even "Nobody know how to solve stochastic convex optimization" NonConvex Optimization - usually people by this mean something which is continious objective, but curvature can vary. People in this planet don't know how to solve it precisely. And in fact all mehtods make leverage into (1) Combinatorial optimizaion - it's even more wild then (2), now for parameters that you find you even can not apply minus operator. One example is "regions" in Decision Trees. So there are two way how to deal with it: a) Convexify problem and use methods from (1) b) Make brute force. Doesn't work for huge number of parameters. c) Make brute force but with some greedy steps. It's something that CART do. So at least I think I convice you that: I) Convex Optimization is central thing for most optimization problems. II) "01:15 Optimization is in fact more bigger subject then ML or AI, but it's bigger subject in fact." (https://www.youtube.com/watch?v=uF3htLwUHn0&t=992s)
Why study convex optimization for theoretical machine learning?
As I heard from Jerome H. Friedman methods developed in Machine Learning is in fact not belong to Machine Learning community by itself. From my point of view Machine Learning is more like a collection
Why study convex optimization for theoretical machine learning? As I heard from Jerome H. Friedman methods developed in Machine Learning is in fact not belong to Machine Learning community by itself. From my point of view Machine Learning is more like a collection of various methods from another fields. From point of view of Statistical Learning the three main questions for regression and classification are: What is function family from which you pull approximator What is a criteria how you pull a function What is a method to find the best function To operate in some constructive way on (1) - it's not so obvious how use math optimizaion can help To operate in some constructive way on (2) - it's obvious that objective is the goal. And math optimizaion can help on it. To operate in some constructive way on (3) - you need math optimization. There several parts of math optimization: Convex Optimization/Convex Analysis - very cool area of math. Non-differentiablity is not a problem. And there are 50 generalization of convex functions from which more two usefull in terms of application is quasiconvex and log-concave. Also there are ways how to deal "stochasticity" in some way, even "Nobody know how to solve stochastic convex optimization" NonConvex Optimization - usually people by this mean something which is continious objective, but curvature can vary. People in this planet don't know how to solve it precisely. And in fact all mehtods make leverage into (1) Combinatorial optimizaion - it's even more wild then (2), now for parameters that you find you even can not apply minus operator. One example is "regions" in Decision Trees. So there are two way how to deal with it: a) Convexify problem and use methods from (1) b) Make brute force. Doesn't work for huge number of parameters. c) Make brute force but with some greedy steps. It's something that CART do. So at least I think I convice you that: I) Convex Optimization is central thing for most optimization problems. II) "01:15 Optimization is in fact more bigger subject then ML or AI, but it's bigger subject in fact." (https://www.youtube.com/watch?v=uF3htLwUHn0&t=992s)
Why study convex optimization for theoretical machine learning? As I heard from Jerome H. Friedman methods developed in Machine Learning is in fact not belong to Machine Learning community by itself. From my point of view Machine Learning is more like a collection
7,832
Is the sum of two white noise processes necessarily a white noise?
No, you need more (at least under Hayashi's definition of white noise). For example, the sum of two independent white noise processes is white noise. Why is $a_t$ and $b_t$ white noise insufficient for $a_t+b_t$ to be white noise? Following Hayashi's Econometrics, a covariance stationary process $\{z_t\}$ is defined to be white noise if $\mathrm{E}[z_t] = 0$ and $\mathrm{Cov}\left(z_t, z_{t-j} \right) = 0$ for $j \neq 0$. Let $\{a_t\}$ and $\{b_t\}$ be white noise processes. Define $c_t = a_t + b_t$. Trivially we have $\mathrm{E}[c_t] = 0$. Checking the covariance condition: \begin{align*} \mathrm{Cov} \left( c_t, c_{t-j} \right) &= \mathrm{Cov} \left( a_t, a_{t-j}\right) + \mathrm{Cov} \left( a_t, b_{t-j}\right) + \mathrm{Cov} \left( b_t, a_{t-j}\right) + \mathrm{Cov} \left( b_t, b_{t-j}\right) \end{align*} Applying that $\{a_t\}$ and $\{b_t\}$ are white noise: \begin{align*} \mathrm{Cov} \left( c_t, c_{t-j} \right) &= \mathrm{Cov} \left( a_t, b_{t-j}\right) + \mathrm{Cov} \left( b_t, a_{t-j}\right) \end{align*} So whether $\{c_t\}$ is white noise depends on whether $\mathrm{Cov} \left( a_t, b_{t-j}\right) + \mathrm{Cov} \left( b_t, a_{t-j}\right) = 0$ for all $j\neq 0$. Example where sum of two white noise processes is not white noise: Let $\{a_t\}$ be white noise. Let $b_t = a_{t-1}$. Observe that process $\{b_t\}$ is also white noise. Let $c_t = a_t + b_t$, hence $c_t = a_t + a_{t-1}$, and observe that process $\{c_t\}$ is not white noise.
Is the sum of two white noise processes necessarily a white noise?
No, you need more (at least under Hayashi's definition of white noise). For example, the sum of two independent white noise processes is white noise. Why is $a_t$ and $b_t$ white noise insufficient fo
Is the sum of two white noise processes necessarily a white noise? No, you need more (at least under Hayashi's definition of white noise). For example, the sum of two independent white noise processes is white noise. Why is $a_t$ and $b_t$ white noise insufficient for $a_t+b_t$ to be white noise? Following Hayashi's Econometrics, a covariance stationary process $\{z_t\}$ is defined to be white noise if $\mathrm{E}[z_t] = 0$ and $\mathrm{Cov}\left(z_t, z_{t-j} \right) = 0$ for $j \neq 0$. Let $\{a_t\}$ and $\{b_t\}$ be white noise processes. Define $c_t = a_t + b_t$. Trivially we have $\mathrm{E}[c_t] = 0$. Checking the covariance condition: \begin{align*} \mathrm{Cov} \left( c_t, c_{t-j} \right) &= \mathrm{Cov} \left( a_t, a_{t-j}\right) + \mathrm{Cov} \left( a_t, b_{t-j}\right) + \mathrm{Cov} \left( b_t, a_{t-j}\right) + \mathrm{Cov} \left( b_t, b_{t-j}\right) \end{align*} Applying that $\{a_t\}$ and $\{b_t\}$ are white noise: \begin{align*} \mathrm{Cov} \left( c_t, c_{t-j} \right) &= \mathrm{Cov} \left( a_t, b_{t-j}\right) + \mathrm{Cov} \left( b_t, a_{t-j}\right) \end{align*} So whether $\{c_t\}$ is white noise depends on whether $\mathrm{Cov} \left( a_t, b_{t-j}\right) + \mathrm{Cov} \left( b_t, a_{t-j}\right) = 0$ for all $j\neq 0$. Example where sum of two white noise processes is not white noise: Let $\{a_t\}$ be white noise. Let $b_t = a_{t-1}$. Observe that process $\{b_t\}$ is also white noise. Let $c_t = a_t + b_t$, hence $c_t = a_t + a_{t-1}$, and observe that process $\{c_t\}$ is not white noise.
Is the sum of two white noise processes necessarily a white noise? No, you need more (at least under Hayashi's definition of white noise). For example, the sum of two independent white noise processes is white noise. Why is $a_t$ and $b_t$ white noise insufficient fo
7,833
Is the sum of two white noise processes necessarily a white noise?
Even simpler than @MatthewGunn's answer, Consider $b_t = -a_t$. Obviously $c_t \equiv 0$ is not white noise -- it'd be hard to call it any kind of noise. The broader point is, if we don't know anything about the joint distribution of $a_t$ and $b_t$, we won't be able to say what happens when we try and examine objects which depend on both of them. The covariance structure is essential to this end. Addendum: Of course, this is exactly the purpose of noise-cancelling headphones! -- to reverse the frequency of external noises and cancel them out -- so, going back to the physical definition of white noise, this sequence is literal silence. No noise at all.
Is the sum of two white noise processes necessarily a white noise?
Even simpler than @MatthewGunn's answer, Consider $b_t = -a_t$. Obviously $c_t \equiv 0$ is not white noise -- it'd be hard to call it any kind of noise. The broader point is, if we don't know anythin
Is the sum of two white noise processes necessarily a white noise? Even simpler than @MatthewGunn's answer, Consider $b_t = -a_t$. Obviously $c_t \equiv 0$ is not white noise -- it'd be hard to call it any kind of noise. The broader point is, if we don't know anything about the joint distribution of $a_t$ and $b_t$, we won't be able to say what happens when we try and examine objects which depend on both of them. The covariance structure is essential to this end. Addendum: Of course, this is exactly the purpose of noise-cancelling headphones! -- to reverse the frequency of external noises and cancel them out -- so, going back to the physical definition of white noise, this sequence is literal silence. No noise at all.
Is the sum of two white noise processes necessarily a white noise? Even simpler than @MatthewGunn's answer, Consider $b_t = -a_t$. Obviously $c_t \equiv 0$ is not white noise -- it'd be hard to call it any kind of noise. The broader point is, if we don't know anythin
7,834
Is the sum of two white noise processes necessarily a white noise?
In electronics, white noise is defined as having a flat frequency spectrum ('white') and being random ('noise'). Noise generally can be contrasted with 'interference', one or more undesired signals being picked up from elsewhere and being added to the signal of interest, and 'distortion', undesired signals being generated from nonlinear processes acting on the signal of interest itself. While it is possible for two different signals to have correlated parts, and therefore cancel differently at different frequencies or at different times, e.g. completely canceling over a certain band of frequencies or during a certain interval of time, but then not canceling, or even adding constructively over another band of frequencies or during a certain interval of time, the correlation between the two signals presumes a correlation, which is precluded by the presumably random aspect of 'noise', which is what was asked about. If, indeed, the signals are 'noise' and therefore independent and random, then no such correlations should/would exist, so adding them together will also have a flat frequency spectrum and will therefore also be white. Also, trivially, if the noises are exactly anti-correlated, then they could cancel to give zero output at all times, which also has a flat frequency spectrum, zero power at all frequencies, which could fall under a sort of degenerate definition of white noise, except that it isn't random and can be perfectly predicted. Noise in electronics can come from several places. For example, shot noise, arising from the random arrival of electrons in a photocurrent (coming from the random arrival times of photons), and Johnson noise, coming from the Brownian motion of electrons in a resistive element warmer than absolute zero, both produce white noise, although, always with a finite bandwidth at both ends of the spectrum in any real system measured over a finite length of time.
Is the sum of two white noise processes necessarily a white noise?
In electronics, white noise is defined as having a flat frequency spectrum ('white') and being random ('noise'). Noise generally can be contrasted with 'interference', one or more undesired signals be
Is the sum of two white noise processes necessarily a white noise? In electronics, white noise is defined as having a flat frequency spectrum ('white') and being random ('noise'). Noise generally can be contrasted with 'interference', one or more undesired signals being picked up from elsewhere and being added to the signal of interest, and 'distortion', undesired signals being generated from nonlinear processes acting on the signal of interest itself. While it is possible for two different signals to have correlated parts, and therefore cancel differently at different frequencies or at different times, e.g. completely canceling over a certain band of frequencies or during a certain interval of time, but then not canceling, or even adding constructively over another band of frequencies or during a certain interval of time, the correlation between the two signals presumes a correlation, which is precluded by the presumably random aspect of 'noise', which is what was asked about. If, indeed, the signals are 'noise' and therefore independent and random, then no such correlations should/would exist, so adding them together will also have a flat frequency spectrum and will therefore also be white. Also, trivially, if the noises are exactly anti-correlated, then they could cancel to give zero output at all times, which also has a flat frequency spectrum, zero power at all frequencies, which could fall under a sort of degenerate definition of white noise, except that it isn't random and can be perfectly predicted. Noise in electronics can come from several places. For example, shot noise, arising from the random arrival of electrons in a photocurrent (coming from the random arrival times of photons), and Johnson noise, coming from the Brownian motion of electrons in a resistive element warmer than absolute zero, both produce white noise, although, always with a finite bandwidth at both ends of the spectrum in any real system measured over a finite length of time.
Is the sum of two white noise processes necessarily a white noise? In electronics, white noise is defined as having a flat frequency spectrum ('white') and being random ('noise'). Noise generally can be contrasted with 'interference', one or more undesired signals be
7,835
Is the sum of two white noise processes necessarily a white noise?
if both white noise sound is traveling in same direction And if their frequency is in phase matched up, then only they get added. But, one thing i am not sure about is after adding up will it remain as white noise or it will become some other type of sound having different frequency.
Is the sum of two white noise processes necessarily a white noise?
if both white noise sound is traveling in same direction And if their frequency is in phase matched up, then only they get added. But, one thing i am not sure about is after adding up will it remain a
Is the sum of two white noise processes necessarily a white noise? if both white noise sound is traveling in same direction And if their frequency is in phase matched up, then only they get added. But, one thing i am not sure about is after adding up will it remain as white noise or it will become some other type of sound having different frequency.
Is the sum of two white noise processes necessarily a white noise? if both white noise sound is traveling in same direction And if their frequency is in phase matched up, then only they get added. But, one thing i am not sure about is after adding up will it remain a
7,836
Replacing outliers with mean
Clearly it's possible, but it's not clear that it could ever be a good idea. Let's spell out several ways in which this is a limited or deficient solution: In effect you are saying that the outlier value is completely untrustworthy, to the extent that your only possible guess is that the value should be the mean. If that's what you think, it is likely to be more honest just to omit the observation in question, as evidently you don't have enough information to make a better guess. With nothing else said, you need a criterion or criteria for identifying outliers in the first place (as implied by @Frank Harrell). Otherwise this is an arbitrary and subjective procedure, even if it is defended as a matter of judgment. With some criteria, it is possible that removing outliers in this way creates yet more outliers as a side-effect. An example could be that outliers are more than so many standard deviations away from the mean. Removing an outlier changes the standard deviation, and new data points may now qualify, and so on. Presumably the mean here means the mean of all the other values, a point made explicit by @David Marx. The idea is ambiguous without this stipulation. Using the mean may seem a safe or conservative procedure, but changing a value to the mean will change almost every other statistic, including measures of level, scale and shape and indicators of their uncertainty, a point emphasized by @whuber. The mean may not even be a feasible value: simple examples are when values are integers, but typically the mean isn't an integer. Even with the idea that using a summary measure is a cautious thing to do, using the mean rather than the median or any other measure needs some justification. Whenever there are other variables, modifying the value of one variable without reference to others may make a data point anomalous in other senses. What to do with outliers is an open and very difficult question. Loosely, different solutions and strategies have varying appeal. As a very broad-brush generalisation, there is a continuum of views on outliers in statistics and machine learning from extreme pessimists to extreme optimists. Extreme pessimists feel called to serve as if officers of a Statistical Inquisition, whose duty it is to find outliers as obnoxious contaminants in the data and to deal with them severely. This could be the position, say, of people dealing with financial transactions data, most honest or genuine, but some fraudulent or criminal. Extreme optimists know that outliers are likely, and usually genuine -- the Amazon, or Amazon, is real enough, and really big. Indeed, outliers are often interesting and important and instructive. Floods, fires, and financial crises are what they are, and some are very big. Here is a partial list of possibilities. The ordering is arbitrary and not meant to convey any order in terms of applicability, importance or any other criterion. Nor are these approaches mutually exclusive. One (in my view good) definition is that "[o]utliers are sample values that cause surprise in relation to the majority of the sample" (W.N. Venables and B.D. Ripley. 2002. Modern Applied Statistics with S. New York: Springer, p.119). However, surprise is in the mind of the beholder and is dependent on some tacit or explicit model of the data. There may be another model under which the outlier is not surprising at all, so the data really are (say) lognormal or gamma rather than normal. In short, be prepared to (re)consider your model. Go into the laboratory or the field and do the measurement again. Often this is not practicable, but it would seem standard in several sciences. Test whether outliers are genuine. Most of the tests look pretty contrived to me, but you might find one that you can believe fits your situation. Irrational faith that a test is appropriate is always needed to apply a test that is then presented as quintessentially rational. Throw them out as a matter of judgement. Throw them out using some more-or-less automated (usually not "objective") rule. Ignore them, partially or completely. This could be formal (e.g. trimming) or just a matter of leaving them in the dataset, but omitting them from analyses as too hot to handle. Pull them in using some kind of adjustment, e.g. Winsorizing. Downplay them by using some other robust estimation method. Downplay them by working on a transformed scale. Downplay them by using a non-identity link function. Accommodate them by fitting some appropriate fat-, long-, or heavy-tailed distribution, without or with predictors. Accommodate by using an indicator or dummy variable as an extra predictor in a model. Side-step the issue by using some non-parametric (e.g. rank-based) procedure. Get a handle on the implied uncertainty using bootstrapping, jackknifing or permutation-based procedure. Edit to replace an outlier with some more likely value, based on deterministic logic. "An 18- year-old grandmother is unlikely, but the person in question was born in 1932, and it's now 2013, so presumably is really 81." Edit to replace an impossible or implausible outlier using some imputation method that is currently acceptable not-quite-white magic. Analyse with and without, and seeing how much difference the outlier(s) make(s), statistically, scientifically or practically. Something Bayesian. My prior ignorance of quite what forbids from giving any details. EDIT This second edition benefits from other answers and comments. I've tried to flag my sources of inspiration.
Replacing outliers with mean
Clearly it's possible, but it's not clear that it could ever be a good idea. Let's spell out several ways in which this is a limited or deficient solution: In effect you are saying that the outlier v
Replacing outliers with mean Clearly it's possible, but it's not clear that it could ever be a good idea. Let's spell out several ways in which this is a limited or deficient solution: In effect you are saying that the outlier value is completely untrustworthy, to the extent that your only possible guess is that the value should be the mean. If that's what you think, it is likely to be more honest just to omit the observation in question, as evidently you don't have enough information to make a better guess. With nothing else said, you need a criterion or criteria for identifying outliers in the first place (as implied by @Frank Harrell). Otherwise this is an arbitrary and subjective procedure, even if it is defended as a matter of judgment. With some criteria, it is possible that removing outliers in this way creates yet more outliers as a side-effect. An example could be that outliers are more than so many standard deviations away from the mean. Removing an outlier changes the standard deviation, and new data points may now qualify, and so on. Presumably the mean here means the mean of all the other values, a point made explicit by @David Marx. The idea is ambiguous without this stipulation. Using the mean may seem a safe or conservative procedure, but changing a value to the mean will change almost every other statistic, including measures of level, scale and shape and indicators of their uncertainty, a point emphasized by @whuber. The mean may not even be a feasible value: simple examples are when values are integers, but typically the mean isn't an integer. Even with the idea that using a summary measure is a cautious thing to do, using the mean rather than the median or any other measure needs some justification. Whenever there are other variables, modifying the value of one variable without reference to others may make a data point anomalous in other senses. What to do with outliers is an open and very difficult question. Loosely, different solutions and strategies have varying appeal. As a very broad-brush generalisation, there is a continuum of views on outliers in statistics and machine learning from extreme pessimists to extreme optimists. Extreme pessimists feel called to serve as if officers of a Statistical Inquisition, whose duty it is to find outliers as obnoxious contaminants in the data and to deal with them severely. This could be the position, say, of people dealing with financial transactions data, most honest or genuine, but some fraudulent or criminal. Extreme optimists know that outliers are likely, and usually genuine -- the Amazon, or Amazon, is real enough, and really big. Indeed, outliers are often interesting and important and instructive. Floods, fires, and financial crises are what they are, and some are very big. Here is a partial list of possibilities. The ordering is arbitrary and not meant to convey any order in terms of applicability, importance or any other criterion. Nor are these approaches mutually exclusive. One (in my view good) definition is that "[o]utliers are sample values that cause surprise in relation to the majority of the sample" (W.N. Venables and B.D. Ripley. 2002. Modern Applied Statistics with S. New York: Springer, p.119). However, surprise is in the mind of the beholder and is dependent on some tacit or explicit model of the data. There may be another model under which the outlier is not surprising at all, so the data really are (say) lognormal or gamma rather than normal. In short, be prepared to (re)consider your model. Go into the laboratory or the field and do the measurement again. Often this is not practicable, but it would seem standard in several sciences. Test whether outliers are genuine. Most of the tests look pretty contrived to me, but you might find one that you can believe fits your situation. Irrational faith that a test is appropriate is always needed to apply a test that is then presented as quintessentially rational. Throw them out as a matter of judgement. Throw them out using some more-or-less automated (usually not "objective") rule. Ignore them, partially or completely. This could be formal (e.g. trimming) or just a matter of leaving them in the dataset, but omitting them from analyses as too hot to handle. Pull them in using some kind of adjustment, e.g. Winsorizing. Downplay them by using some other robust estimation method. Downplay them by working on a transformed scale. Downplay them by using a non-identity link function. Accommodate them by fitting some appropriate fat-, long-, or heavy-tailed distribution, without or with predictors. Accommodate by using an indicator or dummy variable as an extra predictor in a model. Side-step the issue by using some non-parametric (e.g. rank-based) procedure. Get a handle on the implied uncertainty using bootstrapping, jackknifing or permutation-based procedure. Edit to replace an outlier with some more likely value, based on deterministic logic. "An 18- year-old grandmother is unlikely, but the person in question was born in 1932, and it's now 2013, so presumably is really 81." Edit to replace an impossible or implausible outlier using some imputation method that is currently acceptable not-quite-white magic. Analyse with and without, and seeing how much difference the outlier(s) make(s), statistically, scientifically or practically. Something Bayesian. My prior ignorance of quite what forbids from giving any details. EDIT This second edition benefits from other answers and comments. I've tried to flag my sources of inspiration.
Replacing outliers with mean Clearly it's possible, but it's not clear that it could ever be a good idea. Let's spell out several ways in which this is a limited or deficient solution: In effect you are saying that the outlier v
7,837
Replacing outliers with mean
There are several problems implied by your question. What is an "outlier"? Should an "outlier" be replaced? What is special about the mean as opposed to some other estimate? How would you compensate to increase the apparent variance upon replacement by a single value that causes the variance too small? Why not use robust estimators that are resistant to outliers? Is this an independent or a dependent variable? None of 1-5 have an obvious answer. If you really feel that these "outliers" are wrong and you don't want to use a robust statistical method, you can make them missing and use multiple imputation as one possible solution. If the variable is a dependent variable, one robust choice is ordinal regression.
Replacing outliers with mean
There are several problems implied by your question. What is an "outlier"? Should an "outlier" be replaced? What is special about the mean as opposed to some other estimate? How would you compensate
Replacing outliers with mean There are several problems implied by your question. What is an "outlier"? Should an "outlier" be replaced? What is special about the mean as opposed to some other estimate? How would you compensate to increase the apparent variance upon replacement by a single value that causes the variance too small? Why not use robust estimators that are resistant to outliers? Is this an independent or a dependent variable? None of 1-5 have an obvious answer. If you really feel that these "outliers" are wrong and you don't want to use a robust statistical method, you can make them missing and use multiple imputation as one possible solution. If the variable is a dependent variable, one robust choice is ordinal regression.
Replacing outliers with mean There are several problems implied by your question. What is an "outlier"? Should an "outlier" be replaced? What is special about the mean as opposed to some other estimate? How would you compensate
7,838
Replacing outliers with mean
The proposal has numerous flaws in it. Here is perhaps the biggest. Suppose you are gathering data, and you see these values: $$2, 3, 1$$ The mean, so far is $6/3 = 2$. Then comes an outlier: $$2, 3, 1, 1000$$ So you replace it with the mean: $$2, 3, 1, 2$$ The next number is good: $$2, 3, 1, 2, 7$$ Now the mean is 3. Wait a minute, the mean is now 3, but we replaced 1000 with a mean of 2, just because it occurred as the fourth value. What if we change the order of the samples? $$2, 3, 1, 7, 1000$$ Now the mean prior to the 1000 is $(2 + 3 + 1 + 7)/4 = 13/4$. So should we replace 1000 with that mean? The problem is that the false datum we are substituting in place of 1000 is dependent on the other data. That's an epistemological problem if the samples are supposed to represent independent measurements. Then you have the obvious problem that you not merely withholding data that doesn't fit your assumptions, but you're falsifying it. When some unwanted result occurs, you increment $n$, and substitute a fake value. This is wrong because $n$ is supposed to be the count of samples. Now $n$ represents the number of samples, plus the number of fudge values added to the data. It basically destroys the validity of all calculations involving $n$: even those which do not use the fudge values. Your $n$ is a fudge value too! Basically, trimming away results that don't fit is one thing (and can be justified if it is done consistently according to an algorithm, rather than according to changing mood swings of the experimenter). Outright falsifying results is objectionable on philosophical, epistemological and ethical grounds. There may be some extenuating circumstances, which have to do with how the results are used. Like for instance, say that this substitution of outliers by the current mean is part of some embedded computer's algorithm, which enables it to implement a closed-loop control system. (It samples some system outputs, then adjusts inputs in order to achieve control.) Everything is real time, and so something must be supplied for a given time period in the place of missing data. If this fudging helps to overcome glitches, and ensures smooth operation, then all is good. Here is another example, from digital telephony: PLC (packet loss concealment). Crap happens, and packets get lost, yet communication is real time. PLC synthesizes fake pieces of voice based on recent pitch information from correctly received packets. So if a speaker was saying the vowel "aaa" and then a packet was lost, PLC can pad the missing packet by extrapolating the "aaa" for the frame duration (say 5 or 10 milliseconds or whatever). The "aaa" is such that it resembles the speaker's voice. This is analogous to using a "mean" to substitute for values regarded as bad. It's a good thing; it's better than the sound cutting in and out, and helps intelligibility. If the fudging of data is part of a program of lying to people to cover up failing work, that's something else. So, we cannot think about it independently of the application: how is the statistics being used? Will substitutions lead to invalid conclusions? Are there ethical implications?
Replacing outliers with mean
The proposal has numerous flaws in it. Here is perhaps the biggest. Suppose you are gathering data, and you see these values: $$2, 3, 1$$ The mean, so far is $6/3 = 2$. Then comes an outlier: $$2, 3,
Replacing outliers with mean The proposal has numerous flaws in it. Here is perhaps the biggest. Suppose you are gathering data, and you see these values: $$2, 3, 1$$ The mean, so far is $6/3 = 2$. Then comes an outlier: $$2, 3, 1, 1000$$ So you replace it with the mean: $$2, 3, 1, 2$$ The next number is good: $$2, 3, 1, 2, 7$$ Now the mean is 3. Wait a minute, the mean is now 3, but we replaced 1000 with a mean of 2, just because it occurred as the fourth value. What if we change the order of the samples? $$2, 3, 1, 7, 1000$$ Now the mean prior to the 1000 is $(2 + 3 + 1 + 7)/4 = 13/4$. So should we replace 1000 with that mean? The problem is that the false datum we are substituting in place of 1000 is dependent on the other data. That's an epistemological problem if the samples are supposed to represent independent measurements. Then you have the obvious problem that you not merely withholding data that doesn't fit your assumptions, but you're falsifying it. When some unwanted result occurs, you increment $n$, and substitute a fake value. This is wrong because $n$ is supposed to be the count of samples. Now $n$ represents the number of samples, plus the number of fudge values added to the data. It basically destroys the validity of all calculations involving $n$: even those which do not use the fudge values. Your $n$ is a fudge value too! Basically, trimming away results that don't fit is one thing (and can be justified if it is done consistently according to an algorithm, rather than according to changing mood swings of the experimenter). Outright falsifying results is objectionable on philosophical, epistemological and ethical grounds. There may be some extenuating circumstances, which have to do with how the results are used. Like for instance, say that this substitution of outliers by the current mean is part of some embedded computer's algorithm, which enables it to implement a closed-loop control system. (It samples some system outputs, then adjusts inputs in order to achieve control.) Everything is real time, and so something must be supplied for a given time period in the place of missing data. If this fudging helps to overcome glitches, and ensures smooth operation, then all is good. Here is another example, from digital telephony: PLC (packet loss concealment). Crap happens, and packets get lost, yet communication is real time. PLC synthesizes fake pieces of voice based on recent pitch information from correctly received packets. So if a speaker was saying the vowel "aaa" and then a packet was lost, PLC can pad the missing packet by extrapolating the "aaa" for the frame duration (say 5 or 10 milliseconds or whatever). The "aaa" is such that it resembles the speaker's voice. This is analogous to using a "mean" to substitute for values regarded as bad. It's a good thing; it's better than the sound cutting in and out, and helps intelligibility. If the fudging of data is part of a program of lying to people to cover up failing work, that's something else. So, we cannot think about it independently of the application: how is the statistics being used? Will substitutions lead to invalid conclusions? Are there ethical implications?
Replacing outliers with mean The proposal has numerous flaws in it. Here is perhaps the biggest. Suppose you are gathering data, and you see these values: $$2, 3, 1$$ The mean, so far is $6/3 = 2$. Then comes an outlier: $$2, 3,
7,839
Replacing outliers with mean
This article by Cousineau and Chartier discusses replacing outliers with the mean http://www.redalyc.org/pdf/2990/299023509004.pdf They write: Tabachnick and Fidell (2007) suggested replacing the missing data with the mean of the remaining data in the corresponding cell. However, this procedure will tend to reduce the spread of the population, make the observed distribution more leptokurtic, and possibly increase the likelihood of a type-I error. A more elaborate technique, multiple imputations, involves replacing outliers (or missing data) with possible values (Elliott & Stettler, 2007; Serfling & Dang, 2009). There is also an R package "outliers" that has a function to replace outliers with the mean. I also saw a number of hits in my Google search that implies that SPSS also has such a function, but I am not familiar with that program. Perhaps if you follow the threads you can discover the technical basis for the practice. References Cousineau, D., & Chartier, S. (2010). Outliers detection and treatment: a review. International Journal of Psychological Research, 3(1), 58-67.
Replacing outliers with mean
This article by Cousineau and Chartier discusses replacing outliers with the mean http://www.redalyc.org/pdf/2990/299023509004.pdf They write: Tabachnick and Fidell (2007) suggested replacing the mi
Replacing outliers with mean This article by Cousineau and Chartier discusses replacing outliers with the mean http://www.redalyc.org/pdf/2990/299023509004.pdf They write: Tabachnick and Fidell (2007) suggested replacing the missing data with the mean of the remaining data in the corresponding cell. However, this procedure will tend to reduce the spread of the population, make the observed distribution more leptokurtic, and possibly increase the likelihood of a type-I error. A more elaborate technique, multiple imputations, involves replacing outliers (or missing data) with possible values (Elliott & Stettler, 2007; Serfling & Dang, 2009). There is also an R package "outliers" that has a function to replace outliers with the mean. I also saw a number of hits in my Google search that implies that SPSS also has such a function, but I am not familiar with that program. Perhaps if you follow the threads you can discover the technical basis for the practice. References Cousineau, D., & Chartier, S. (2010). Outliers detection and treatment: a review. International Journal of Psychological Research, 3(1), 58-67.
Replacing outliers with mean This article by Cousineau and Chartier discusses replacing outliers with the mean http://www.redalyc.org/pdf/2990/299023509004.pdf They write: Tabachnick and Fidell (2007) suggested replacing the mi
7,840
Replacing outliers with mean
The main thing to bear in mind when dealing with outliers is whether they're providing useful information. If you expect them to occur on a regular basis then stripping them out of the data will guarantee that your model will never predict them. Of course, it depends what you want the model to do but it's worth bearing in mind that you shouldn't necessarily drop them. If they contain important information you may want to consider a model that can account for them. One, simple way to do that is to take logs of the variables, which can account for power law relationships. Alternatively, you could use a model that accounts for them with a fat-tailed distribution of errors. If you do want to cut them out then the usual ways are to either drop them or Winsorise them to remove the extreme values. I don't have a textbook to hand but the Wiki links there do refer to some if you want to read further. Most texts on applied statistics should have a section on outliers.
Replacing outliers with mean
The main thing to bear in mind when dealing with outliers is whether they're providing useful information. If you expect them to occur on a regular basis then stripping them out of the data will guara
Replacing outliers with mean The main thing to bear in mind when dealing with outliers is whether they're providing useful information. If you expect them to occur on a regular basis then stripping them out of the data will guarantee that your model will never predict them. Of course, it depends what you want the model to do but it's worth bearing in mind that you shouldn't necessarily drop them. If they contain important information you may want to consider a model that can account for them. One, simple way to do that is to take logs of the variables, which can account for power law relationships. Alternatively, you could use a model that accounts for them with a fat-tailed distribution of errors. If you do want to cut them out then the usual ways are to either drop them or Winsorise them to remove the extreme values. I don't have a textbook to hand but the Wiki links there do refer to some if you want to read further. Most texts on applied statistics should have a section on outliers.
Replacing outliers with mean The main thing to bear in mind when dealing with outliers is whether they're providing useful information. If you expect them to occur on a regular basis then stripping them out of the data will guara
7,841
Replacing outliers with mean
I'm aware of two related similar approaches in statistics. Trimmed means: when computing the mean, you drop the smallest and largest observations of your data (e.g. the top and bottom $1%$ each; you should do this symmetrically!) Winsorization: similar to the trimmed mean, you only modify extreme observations. However, instead of dropping them, you replace them with the largest/smallest non-extreme observation. This often works slightly better than trimming. For more detailed examples, see Wikipedia: https://en.wikipedia.org/wiki/Trimmed_estimator https://en.wikipedia.org/wiki/Winsorising Note that this works good for some statistics such as when computing the mean. The trimmed / winsorized mean is often a better estimate of the true mean than the artihmetic average. In other cases, it may ruin your statistics. For example when computing variance, trimming will always underestimate your true variance. Winsorization, assuming that indeed some of the extreme observations are faulty, will work a bit better then (it will probably still underestimate, but not by as much). I don't see how replacing the extreme values with the mean would fit in here. However, there is another practice that is related: missing value imputation. Assuming that your outlier is flawed, worthless data, so your remove it. When you then perform imputation, a typical substitute value would be the mean or mode: https://en.wikipedia.org/wiki/Imputation_%28statistics%29
Replacing outliers with mean
I'm aware of two related similar approaches in statistics. Trimmed means: when computing the mean, you drop the smallest and largest observations of your data (e.g. the top and bottom $1%$ each; you
Replacing outliers with mean I'm aware of two related similar approaches in statistics. Trimmed means: when computing the mean, you drop the smallest and largest observations of your data (e.g. the top and bottom $1%$ each; you should do this symmetrically!) Winsorization: similar to the trimmed mean, you only modify extreme observations. However, instead of dropping them, you replace them with the largest/smallest non-extreme observation. This often works slightly better than trimming. For more detailed examples, see Wikipedia: https://en.wikipedia.org/wiki/Trimmed_estimator https://en.wikipedia.org/wiki/Winsorising Note that this works good for some statistics such as when computing the mean. The trimmed / winsorized mean is often a better estimate of the true mean than the artihmetic average. In other cases, it may ruin your statistics. For example when computing variance, trimming will always underestimate your true variance. Winsorization, assuming that indeed some of the extreme observations are faulty, will work a bit better then (it will probably still underestimate, but not by as much). I don't see how replacing the extreme values with the mean would fit in here. However, there is another practice that is related: missing value imputation. Assuming that your outlier is flawed, worthless data, so your remove it. When you then perform imputation, a typical substitute value would be the mean or mode: https://en.wikipedia.org/wiki/Imputation_%28statistics%29
Replacing outliers with mean I'm aware of two related similar approaches in statistics. Trimmed means: when computing the mean, you drop the smallest and largest observations of your data (e.g. the top and bottom $1%$ each; you
7,842
Replacing outliers with mean
The traditional approach for handling outliers is to simply remove them such that your model is trained only on "good" data. Keep in mind that the mean value is affected by the presence of those outliers. If you replace outliers with the mean calculated after the outliers were removed from your dataset, it will make no difference since the regression line (from simple linear regression) will pass through the mean of your training data anyway (this will reduce the variance of your estimates though, which is probably the opposite of what you want given that you know there are outliers). The effect your approach will have on the model depends on the influence (leverage) of the outlier. I'd recommend against the approach you suggest in lieu of just removing the point entirely.
Replacing outliers with mean
The traditional approach for handling outliers is to simply remove them such that your model is trained only on "good" data. Keep in mind that the mean value is affected by the presence of those outli
Replacing outliers with mean The traditional approach for handling outliers is to simply remove them such that your model is trained only on "good" data. Keep in mind that the mean value is affected by the presence of those outliers. If you replace outliers with the mean calculated after the outliers were removed from your dataset, it will make no difference since the regression line (from simple linear regression) will pass through the mean of your training data anyway (this will reduce the variance of your estimates though, which is probably the opposite of what you want given that you know there are outliers). The effect your approach will have on the model depends on the influence (leverage) of the outlier. I'd recommend against the approach you suggest in lieu of just removing the point entirely.
Replacing outliers with mean The traditional approach for handling outliers is to simply remove them such that your model is trained only on "good" data. Keep in mind that the mean value is affected by the presence of those outli
7,843
Replacing outliers with mean
yes the outliers can be replaced in may forms, for example, let's take a data-set of the size of Human heights, let's say we have some outliers like 500 cm and 400 cm then, we can just replace those data points that appear in the dataset because of some error that was caused during the recording of the data. so the options you can try is 1. replace it with the Median of the Whole color of the data (not the mean, as it is prone to outliers). 2. replace with the most Occurring data point in the Column. 3. If Categorial values then you can try Response coding.(wherein you Record the Probability of the word or the values occurring by the total number of words )
Replacing outliers with mean
yes the outliers can be replaced in may forms, for example, let's take a data-set of the size of Human heights, let's say we have some outliers like 500 cm and 400 cm then, we can just replace those
Replacing outliers with mean yes the outliers can be replaced in may forms, for example, let's take a data-set of the size of Human heights, let's say we have some outliers like 500 cm and 400 cm then, we can just replace those data points that appear in the dataset because of some error that was caused during the recording of the data. so the options you can try is 1. replace it with the Median of the Whole color of the data (not the mean, as it is prone to outliers). 2. replace with the most Occurring data point in the Column. 3. If Categorial values then you can try Response coding.(wherein you Record the Probability of the word or the values occurring by the total number of words )
Replacing outliers with mean yes the outliers can be replaced in may forms, for example, let's take a data-set of the size of Human heights, let's say we have some outliers like 500 cm and 400 cm then, we can just replace those
7,844
Why do we take the square root of variance to create standard deviation?
In some sense this is a trivial question, but in another, it is actually quite deep! As others have mentioned, taking the square root implies $\operatorname{Stdev}(X)$ has the same units as $X$. Taking the square root gives you absolute homogeneity aka absolute scalability. For any scalar $\alpha$ and random variable $X$, we have: $$ \operatorname{Stdev}[\alpha X] = |\alpha| \operatorname{Stdev}[X]$$ Absolute homogeneity is a required property of a norm. The standard deviation can be interpreted as a norm (on the vector space of mean zero random variables) in a similar way that $\sqrt{x^2 + y^2+z^2}$ is the standard Euclidian norm in a three-dimensional space. The standard deviation is a measure of distance between a random variable and its mean. Standard deviation and the $L_2$ norm Finite dimension case: In an $n$ dimensional vector space, the standard Euclidian norm aka the $L_2$ norm is defined as: $$\|\mathbf{x}\|_2 = \sqrt{\sum_i x_i^2}$$ More broadly, the $p$-norm $\|\mathbf{x}\|_p = \left(\sum_i |x_i|^p \right)^{\frac{1}{p}}$ takes the $p$th root to get absolute homogeneity: $\|\alpha \mathbf{x}\|_p = \left( \sum_i |\alpha x_i|^p \right)^\frac{1}{p} = | \alpha | \left( \sum_i |x_i|^p \right)^\frac{1}{p} = |\alpha | \|\mathbf{x}\|_p $. If you have weights $q_i$ then the weighted sum $\sqrt{\sum_i x_i^2 q_i}$ is also a valid norm. Furthermore, it's the standard deviation if $q_i$ represent probabilities and $\operatorname{E}[\mathbf{x}] \equiv \sum_i x_i q_i = 0$ Infinite dimension case: In an infinite dimensional Hilbert Space we similarly may define the $L_2$ norm: $$ \|X\|_2 = \sqrt{\int_\omega X(\omega)^2 dP(\omega) }$$ If $X$ is a mean zero random variable and $P$ is the probability measure, what's the standard deviation? It's the same: $\sqrt{\int_\omega X(\omega)^2 dP(\omega) }$. Summary: Taking the square root makes means the standard deviation satisfies absolute homogeneity, a required property of a norm. On a space of random variables, $\langle X, Y \rangle = \operatorname{E}[XY]$ is an inner product and $\|X\|_2 = \sqrt{\operatorname{E}[X^2]}$ the norm induced by that inner product. Thus the standard deviation is the norm of a demeaned random variable: $$\operatorname{Stdev}[X] = \|X - \operatorname{E}[X]\|_2$$ It's a measure of distance from mean $\operatorname{E}[X]$ to $X$. (Technical point: while $\sqrt{\operatorname{E}[X^2]}$ is a norm, the standard deviation $\sqrt{\operatorname{E}[(X - \operatorname{E}[X])^2]}$ isn't a norm over random variables in general because a requirement for a normed vector space is $\|x\| = \mathbf{0}$ if and only if $x = \mathbf{0}$. A standard deviation of 0 doesn't imply the random variable is the zero element.)
Why do we take the square root of variance to create standard deviation?
In some sense this is a trivial question, but in another, it is actually quite deep! As others have mentioned, taking the square root implies $\operatorname{Stdev}(X)$ has the same units as $X$. Taki
Why do we take the square root of variance to create standard deviation? In some sense this is a trivial question, but in another, it is actually quite deep! As others have mentioned, taking the square root implies $\operatorname{Stdev}(X)$ has the same units as $X$. Taking the square root gives you absolute homogeneity aka absolute scalability. For any scalar $\alpha$ and random variable $X$, we have: $$ \operatorname{Stdev}[\alpha X] = |\alpha| \operatorname{Stdev}[X]$$ Absolute homogeneity is a required property of a norm. The standard deviation can be interpreted as a norm (on the vector space of mean zero random variables) in a similar way that $\sqrt{x^2 + y^2+z^2}$ is the standard Euclidian norm in a three-dimensional space. The standard deviation is a measure of distance between a random variable and its mean. Standard deviation and the $L_2$ norm Finite dimension case: In an $n$ dimensional vector space, the standard Euclidian norm aka the $L_2$ norm is defined as: $$\|\mathbf{x}\|_2 = \sqrt{\sum_i x_i^2}$$ More broadly, the $p$-norm $\|\mathbf{x}\|_p = \left(\sum_i |x_i|^p \right)^{\frac{1}{p}}$ takes the $p$th root to get absolute homogeneity: $\|\alpha \mathbf{x}\|_p = \left( \sum_i |\alpha x_i|^p \right)^\frac{1}{p} = | \alpha | \left( \sum_i |x_i|^p \right)^\frac{1}{p} = |\alpha | \|\mathbf{x}\|_p $. If you have weights $q_i$ then the weighted sum $\sqrt{\sum_i x_i^2 q_i}$ is also a valid norm. Furthermore, it's the standard deviation if $q_i$ represent probabilities and $\operatorname{E}[\mathbf{x}] \equiv \sum_i x_i q_i = 0$ Infinite dimension case: In an infinite dimensional Hilbert Space we similarly may define the $L_2$ norm: $$ \|X\|_2 = \sqrt{\int_\omega X(\omega)^2 dP(\omega) }$$ If $X$ is a mean zero random variable and $P$ is the probability measure, what's the standard deviation? It's the same: $\sqrt{\int_\omega X(\omega)^2 dP(\omega) }$. Summary: Taking the square root makes means the standard deviation satisfies absolute homogeneity, a required property of a norm. On a space of random variables, $\langle X, Y \rangle = \operatorname{E}[XY]$ is an inner product and $\|X\|_2 = \sqrt{\operatorname{E}[X^2]}$ the norm induced by that inner product. Thus the standard deviation is the norm of a demeaned random variable: $$\operatorname{Stdev}[X] = \|X - \operatorname{E}[X]\|_2$$ It's a measure of distance from mean $\operatorname{E}[X]$ to $X$. (Technical point: while $\sqrt{\operatorname{E}[X^2]}$ is a norm, the standard deviation $\sqrt{\operatorname{E}[(X - \operatorname{E}[X])^2]}$ isn't a norm over random variables in general because a requirement for a normed vector space is $\|x\| = \mathbf{0}$ if and only if $x = \mathbf{0}$. A standard deviation of 0 doesn't imply the random variable is the zero element.)
Why do we take the square root of variance to create standard deviation? In some sense this is a trivial question, but in another, it is actually quite deep! As others have mentioned, taking the square root implies $\operatorname{Stdev}(X)$ has the same units as $X$. Taki
7,845
Why do we take the square root of variance to create standard deviation?
Variance of $X$ is defined as $V(X) = E(X-E(X))^2$, so it is an expectation of a squared difference between X and its expected value. If $X$ is time in seconds, $X-E(X)$ is in seconds, but $V(X)$ is in $\mbox{seconds}^2$ and $\sqrt{V(X)}$ is again in seconds.
Why do we take the square root of variance to create standard deviation?
Variance of $X$ is defined as $V(X) = E(X-E(X))^2$, so it is an expectation of a squared difference between X and its expected value. If $X$ is time in seconds, $X-E(X)$ is in seconds, but $V(X)$ is i
Why do we take the square root of variance to create standard deviation? Variance of $X$ is defined as $V(X) = E(X-E(X))^2$, so it is an expectation of a squared difference between X and its expected value. If $X$ is time in seconds, $X-E(X)$ is in seconds, but $V(X)$ is in $\mbox{seconds}^2$ and $\sqrt{V(X)}$ is again in seconds.
Why do we take the square root of variance to create standard deviation? Variance of $X$ is defined as $V(X) = E(X-E(X))^2$, so it is an expectation of a squared difference between X and its expected value. If $X$ is time in seconds, $X-E(X)$ is in seconds, but $V(X)$ is i
7,846
Why do we take the square root of variance to create standard deviation?
The simple answer is that the units are on the same scale as the mean. Example: I estimate the mean for secondary student to be 160cm with a standard deviation (SD) of 20cm. It is intuitively easier to get a sense of the variation with the SD than the variance of 400cm^2.
Why do we take the square root of variance to create standard deviation?
The simple answer is that the units are on the same scale as the mean. Example: I estimate the mean for secondary student to be 160cm with a standard deviation (SD) of 20cm. It is intuitively easier
Why do we take the square root of variance to create standard deviation? The simple answer is that the units are on the same scale as the mean. Example: I estimate the mean for secondary student to be 160cm with a standard deviation (SD) of 20cm. It is intuitively easier to get a sense of the variation with the SD than the variance of 400cm^2.
Why do we take the square root of variance to create standard deviation? The simple answer is that the units are on the same scale as the mean. Example: I estimate the mean for secondary student to be 160cm with a standard deviation (SD) of 20cm. It is intuitively easier
7,847
Why do we take the square root of variance to create standard deviation?
In more simple terms standard deviation is designed to give us a positive number that says something about the spread of our data about it's mean. If we were to just add up the distances of all the points from the mean, then points in the positive and negative directions would combine in a way that would tend to gravitate back toward the mean and we would lose information about the spread. This is why we measure variance first, so that all of the distances are preserved as positive quantities via squaring and they don't cancel each other out. In the end we want a positive value that represents the units we started with - this has already been commented on above - so we take the positive square root.
Why do we take the square root of variance to create standard deviation?
In more simple terms standard deviation is designed to give us a positive number that says something about the spread of our data about it's mean. If we were to just add up the distances of all the p
Why do we take the square root of variance to create standard deviation? In more simple terms standard deviation is designed to give us a positive number that says something about the spread of our data about it's mean. If we were to just add up the distances of all the points from the mean, then points in the positive and negative directions would combine in a way that would tend to gravitate back toward the mean and we would lose information about the spread. This is why we measure variance first, so that all of the distances are preserved as positive quantities via squaring and they don't cancel each other out. In the end we want a positive value that represents the units we started with - this has already been commented on above - so we take the positive square root.
Why do we take the square root of variance to create standard deviation? In more simple terms standard deviation is designed to give us a positive number that says something about the spread of our data about it's mean. If we were to just add up the distances of all the p
7,848
Why do we take the square root of variance to create standard deviation?
It is a historical stupidity which we continue due to intellectual laziness. They chose to square the differences from the mean in order to get rid of the minus sign. Then they took the square root so as to bring it to a scale similar to the mean. Someone should generate new statistics, computing variance and SD using modulus or absolute values of deviance from the mean. This would get rid of this whole squaring and then taking the square root business.
Why do we take the square root of variance to create standard deviation?
It is a historical stupidity which we continue due to intellectual laziness. They chose to square the differences from the mean in order to get rid of the minus sign. Then they took the square root so
Why do we take the square root of variance to create standard deviation? It is a historical stupidity which we continue due to intellectual laziness. They chose to square the differences from the mean in order to get rid of the minus sign. Then they took the square root so as to bring it to a scale similar to the mean. Someone should generate new statistics, computing variance and SD using modulus or absolute values of deviance from the mean. This would get rid of this whole squaring and then taking the square root business.
Why do we take the square root of variance to create standard deviation? It is a historical stupidity which we continue due to intellectual laziness. They chose to square the differences from the mean in order to get rid of the minus sign. Then they took the square root so
7,849
Sample size for logistic regression?
There are several issues here. Typically, we want to determine a minimum sample size so as to achieve a minimally acceptable level of statistical power. The sample size required is a function of several factors, primarily the magnitude of the effect you want to be able to differentiate from 0 (or whatever null you are using, but 0 is most common), and the minimum probability of catching that effect you want to have. Working from this perspective, sample size is determined by a power analysis. Another consideration is the stability of your model (as @cbeleites notes). Basically, as the ratio of parameters estimated to the number of data gets close to 1, your model will become saturated, and will necessarily be overfit (unless there is, in fact, no randomness in the system). The 1 to 10 ratio rule of thumb comes from this perspective. Note that having adequate power will generally cover this concern for you, but not vice versa. The 1 to 10 rule comes from the linear regression world, however, and it's important to recognize that logistic regression has additional complexities. One issue is that logistic regression works best when the percentages of 1's and 0's is approximately 50% / 50% (as @andrea and @psj discuss in the comments above). Another issue to be concerned with is separation. That is, you don't want to have all of your 1's gathered on one extreme of an independent variable (or some combination of them), and all of the 0's at the other extreme. Although this would seem like a good situation, because it would make perfect prediction easy, it actually makes the parameter estimation process blow up. (@Scortchi has an excellent discussion of how to deal with separation in logistic regression here: How to deal with perfect separation in logistic regression?) With more IV's, this becomes more likely, even if the true magnitudes of the effects are held constant, and especially if your responses are unbalanced. Thus, you can easily need more than 10 data per IV. One last issue with that rule of thumb, is that it assumes your IV's are orthogonal. This is reasonable for designed experiments, but with observational studies such as yours, your IV's will almost never be roughly orthogonal. There are strategies for dealing with this situation (e.g., combining or dropping IV's, conducting a principal components analysis first, etc.), but if it isn't addressed (which is common), you will need more data. A reasonable question then, is what should your minimum N be, and/or is your sample size sufficient? To address this, I suggest you use the methods @cbeleites discusses; relying on the 1 to 10 rule will be insufficient.
Sample size for logistic regression?
There are several issues here. Typically, we want to determine a minimum sample size so as to achieve a minimally acceptable level of statistical power. The sample size required is a function of se
Sample size for logistic regression? There are several issues here. Typically, we want to determine a minimum sample size so as to achieve a minimally acceptable level of statistical power. The sample size required is a function of several factors, primarily the magnitude of the effect you want to be able to differentiate from 0 (or whatever null you are using, but 0 is most common), and the minimum probability of catching that effect you want to have. Working from this perspective, sample size is determined by a power analysis. Another consideration is the stability of your model (as @cbeleites notes). Basically, as the ratio of parameters estimated to the number of data gets close to 1, your model will become saturated, and will necessarily be overfit (unless there is, in fact, no randomness in the system). The 1 to 10 ratio rule of thumb comes from this perspective. Note that having adequate power will generally cover this concern for you, but not vice versa. The 1 to 10 rule comes from the linear regression world, however, and it's important to recognize that logistic regression has additional complexities. One issue is that logistic regression works best when the percentages of 1's and 0's is approximately 50% / 50% (as @andrea and @psj discuss in the comments above). Another issue to be concerned with is separation. That is, you don't want to have all of your 1's gathered on one extreme of an independent variable (or some combination of them), and all of the 0's at the other extreme. Although this would seem like a good situation, because it would make perfect prediction easy, it actually makes the parameter estimation process blow up. (@Scortchi has an excellent discussion of how to deal with separation in logistic regression here: How to deal with perfect separation in logistic regression?) With more IV's, this becomes more likely, even if the true magnitudes of the effects are held constant, and especially if your responses are unbalanced. Thus, you can easily need more than 10 data per IV. One last issue with that rule of thumb, is that it assumes your IV's are orthogonal. This is reasonable for designed experiments, but with observational studies such as yours, your IV's will almost never be roughly orthogonal. There are strategies for dealing with this situation (e.g., combining or dropping IV's, conducting a principal components analysis first, etc.), but if it isn't addressed (which is common), you will need more data. A reasonable question then, is what should your minimum N be, and/or is your sample size sufficient? To address this, I suggest you use the methods @cbeleites discusses; relying on the 1 to 10 rule will be insufficient.
Sample size for logistic regression? There are several issues here. Typically, we want to determine a minimum sample size so as to achieve a minimally acceptable level of statistical power. The sample size required is a function of se
7,850
Sample size for logistic regression?
I typically use a 15:1 rule (ratio of min(events, non-events) to number of candidate parameters in the model). More recent work found that for a more rigorous validation 20:1 is needed. More information may be found in my course handouts linked from http://hbiostat.org/rms, in particular an argument for a minimum sample size of 96 just to estimate the intercept. But the sample size requirement is more nuanced, and an even more recent paper addresses this more comprehensively.
Sample size for logistic regression?
I typically use a 15:1 rule (ratio of min(events, non-events) to number of candidate parameters in the model). More recent work found that for a more rigorous validation 20:1 is needed. More informa
Sample size for logistic regression? I typically use a 15:1 rule (ratio of min(events, non-events) to number of candidate parameters in the model). More recent work found that for a more rigorous validation 20:1 is needed. More information may be found in my course handouts linked from http://hbiostat.org/rms, in particular an argument for a minimum sample size of 96 just to estimate the intercept. But the sample size requirement is more nuanced, and an even more recent paper addresses this more comprehensively.
Sample size for logistic regression? I typically use a 15:1 rule (ratio of min(events, non-events) to number of candidate parameters in the model). More recent work found that for a more rigorous validation 20:1 is needed. More informa
7,851
Sample size for logistic regression?
Usually, too few cases wrt. the model complexity (number of parameters) means that the models are unstable. So if you want to know whether you sample size / model complexity is OK, check whether you obtain a reasonably stable model. There are (at least) two different kinds of instability: The model parameters vary a lot with only slight changes in the training data. The predictions (for the same case) of models trained with slight changes in the training data vary a lot. You can measure 1. by looking how much your model coefficients vary if the training data is slightly perturbed. A suitable bunch of models can be calculated e.g. during bootstrap or (iterated) cross validation procedures. For some types of models or problems, varying parameters do not imply varying predictions. You can directly check instability 2. by looking at the variation of predictions for the same case (regardless of whether they are correct or not) calculated during out-of-bootstrap or iterated cross validation.
Sample size for logistic regression?
Usually, too few cases wrt. the model complexity (number of parameters) means that the models are unstable. So if you want to know whether you sample size / model complexity is OK, check whether you o
Sample size for logistic regression? Usually, too few cases wrt. the model complexity (number of parameters) means that the models are unstable. So if you want to know whether you sample size / model complexity is OK, check whether you obtain a reasonably stable model. There are (at least) two different kinds of instability: The model parameters vary a lot with only slight changes in the training data. The predictions (for the same case) of models trained with slight changes in the training data vary a lot. You can measure 1. by looking how much your model coefficients vary if the training data is slightly perturbed. A suitable bunch of models can be calculated e.g. during bootstrap or (iterated) cross validation procedures. For some types of models or problems, varying parameters do not imply varying predictions. You can directly check instability 2. by looking at the variation of predictions for the same case (regardless of whether they are correct or not) calculated during out-of-bootstrap or iterated cross validation.
Sample size for logistic regression? Usually, too few cases wrt. the model complexity (number of parameters) means that the models are unstable. So if you want to know whether you sample size / model complexity is OK, check whether you o
7,852
Sample size for logistic regression?
Here is the actual answer from the MedCalc website user41466 wrote about http://www.medcalc.org/manual/logistic_regression.php Sample size considerations Sample size calculation for logistic regression is a complex problem, but based on the work of Peduzzi et al. (1996) the following guideline for a minimum number of cases to include in your study can be suggested. Let p be the smallest of the proportions of negative or positive cases in the population and k the number of covariates (the number of independent variables), then the minimum number of cases to include is: N = 10 k / p For example: you have 3 covariates to include in the model and the proportion of positive cases in the population is 0.20 (20%). The minimum number of cases required is N = 10 x 3 / 0.20 = 150 If the resulting number is less than 100 you should increase it to 100 as suggested by Long (1997). Peduzzi P, Concato J, Kemper E, Holford TR, Feinstein AR (1996) A simulation study of the number of events per variable in logistic regression analysis. Journal of Clinical Epidemiology 49:1373-1379.
Sample size for logistic regression?
Here is the actual answer from the MedCalc website user41466 wrote about http://www.medcalc.org/manual/logistic_regression.php Sample size considerations Sample size calculation for logistic regressi
Sample size for logistic regression? Here is the actual answer from the MedCalc website user41466 wrote about http://www.medcalc.org/manual/logistic_regression.php Sample size considerations Sample size calculation for logistic regression is a complex problem, but based on the work of Peduzzi et al. (1996) the following guideline for a minimum number of cases to include in your study can be suggested. Let p be the smallest of the proportions of negative or positive cases in the population and k the number of covariates (the number of independent variables), then the minimum number of cases to include is: N = 10 k / p For example: you have 3 covariates to include in the model and the proportion of positive cases in the population is 0.20 (20%). The minimum number of cases required is N = 10 x 3 / 0.20 = 150 If the resulting number is less than 100 you should increase it to 100 as suggested by Long (1997). Peduzzi P, Concato J, Kemper E, Holford TR, Feinstein AR (1996) A simulation study of the number of events per variable in logistic regression analysis. Journal of Clinical Epidemiology 49:1373-1379.
Sample size for logistic regression? Here is the actual answer from the MedCalc website user41466 wrote about http://www.medcalc.org/manual/logistic_regression.php Sample size considerations Sample size calculation for logistic regressi
7,853
Sample size for logistic regression?
There is no strict rules, but you can include all independent variables so long as the nominal variables dont have too many categories. You need one "beta" for all except one of the class for each nominal variable. So if a nominal variable was say "area of work" and you have 30 areas, then you'd need 29 betas. One way to overcome this problen it to regularise the betas - or penalise for large coefficients. This helps ensure that you model doesn't overfit the data. L2 and L1 regularisation are popular choices. Another issue to consider is how representative your sample is. What population do you want to make inference of? do you have all the different types of people in the sample that there is in the population? it will be difficult to make accurate inference if your sample has "holes" (eg no females aged 35-50 in the sample or no high income workers etc)
Sample size for logistic regression?
There is no strict rules, but you can include all independent variables so long as the nominal variables dont have too many categories. You need one "beta" for all except one of the class for each no
Sample size for logistic regression? There is no strict rules, but you can include all independent variables so long as the nominal variables dont have too many categories. You need one "beta" for all except one of the class for each nominal variable. So if a nominal variable was say "area of work" and you have 30 areas, then you'd need 29 betas. One way to overcome this problen it to regularise the betas - or penalise for large coefficients. This helps ensure that you model doesn't overfit the data. L2 and L1 regularisation are popular choices. Another issue to consider is how representative your sample is. What population do you want to make inference of? do you have all the different types of people in the sample that there is in the population? it will be difficult to make accurate inference if your sample has "holes" (eg no females aged 35-50 in the sample or no high income workers etc)
Sample size for logistic regression? There is no strict rules, but you can include all independent variables so long as the nominal variables dont have too many categories. You need one "beta" for all except one of the class for each no
7,854
Sample size for logistic regression?
Results from any logistic model with the number of observations per independent variable ranging from at least five to nine are reliable, especially so if results are statistically significant (Vittinghoff & McCulloch, 2007). Vittinghoff, E., & McCulloch, C. E. 2007. Relaxing the rule of ten events per variable in logistic and Cox regression. American Journal of Epidemiology, 165(6): 710–718.
Sample size for logistic regression?
Results from any logistic model with the number of observations per independent variable ranging from at least five to nine are reliable, especially so if results are statistically significant (Vittin
Sample size for logistic regression? Results from any logistic model with the number of observations per independent variable ranging from at least five to nine are reliable, especially so if results are statistically significant (Vittinghoff & McCulloch, 2007). Vittinghoff, E., & McCulloch, C. E. 2007. Relaxing the rule of ten events per variable in logistic and Cox regression. American Journal of Epidemiology, 165(6): 710–718.
Sample size for logistic regression? Results from any logistic model with the number of observations per independent variable ranging from at least five to nine are reliable, especially so if results are statistically significant (Vittin
7,855
How to teach students who fear statistics?
Try to personalize statistics. To show why understanding its concepts (even though they will forget the math, acknowledge it) is useful to them. For instance, how to interpret breast cancer test results. To quote from http://yudkowsky.net/rational/bayes: Here's a story problem about a situation that doctors often encounter: 1% of women at age forty who participate in routine screening have breast cancer. 80% of women with breast cancer will get positive mammographies. 9.6% of women without breast cancer will also get positive mammographies. A woman in this age group had a positive mammography in a routine screening. What is the probability that she actually has breast cancer? What do you think the answer is? If you haven't encountered this kind of problem before, please take a moment to come up with your own answer before continuing. Next, suppose I told you that most doctors get the same wrong answer on this problem - usually, only around 15% of doctors get it right. ("Really? 15%? Is that a real number, or an urban legend based on an Internet poll?" It's a real number. See Casscells, Schoenberger, and Grayboys 1978; Eddy 1982; Gigerenzer and Hoffrage 1995; and many other studies. It's a surprising result which is easy to replicate, so it's been extensively replicated.) Since your students will be medical doctors, make it clear: if they don't understand statistics, they will give the wrong interpretation of the results to their patients. This is not an academical matter. Also acknowledge that unless they go in research, they will forget the details you will teach them. Don't even hope it's not the case. Aim for them to understand the fundamental concepts (type I and II errors, correlations and causations and so on) so when faced with a situation, they will remember "hey, perhaps I shouldn't rush drawing a conclusion, but talk to someone who understand stats better." Preventing cognitive errors and teaching them to be inquisitive of the results provided by others (especially in an industry where large sums of money are at stake) will be signs you succeeded.
How to teach students who fear statistics?
Try to personalize statistics. To show why understanding its concepts (even though they will forget the math, acknowledge it) is useful to them. For instance, how to interpret breast cancer test resul
How to teach students who fear statistics? Try to personalize statistics. To show why understanding its concepts (even though they will forget the math, acknowledge it) is useful to them. For instance, how to interpret breast cancer test results. To quote from http://yudkowsky.net/rational/bayes: Here's a story problem about a situation that doctors often encounter: 1% of women at age forty who participate in routine screening have breast cancer. 80% of women with breast cancer will get positive mammographies. 9.6% of women without breast cancer will also get positive mammographies. A woman in this age group had a positive mammography in a routine screening. What is the probability that she actually has breast cancer? What do you think the answer is? If you haven't encountered this kind of problem before, please take a moment to come up with your own answer before continuing. Next, suppose I told you that most doctors get the same wrong answer on this problem - usually, only around 15% of doctors get it right. ("Really? 15%? Is that a real number, or an urban legend based on an Internet poll?" It's a real number. See Casscells, Schoenberger, and Grayboys 1978; Eddy 1982; Gigerenzer and Hoffrage 1995; and many other studies. It's a surprising result which is easy to replicate, so it's been extensively replicated.) Since your students will be medical doctors, make it clear: if they don't understand statistics, they will give the wrong interpretation of the results to their patients. This is not an academical matter. Also acknowledge that unless they go in research, they will forget the details you will teach them. Don't even hope it's not the case. Aim for them to understand the fundamental concepts (type I and II errors, correlations and causations and so on) so when faced with a situation, they will remember "hey, perhaps I shouldn't rush drawing a conclusion, but talk to someone who understand stats better." Preventing cognitive errors and teaching them to be inquisitive of the results provided by others (especially in an industry where large sums of money are at stake) will be signs you succeeded.
How to teach students who fear statistics? Try to personalize statistics. To show why understanding its concepts (even though they will forget the math, acknowledge it) is useful to them. For instance, how to interpret breast cancer test resul
7,856
How to teach students who fear statistics?
I agree that making statistics personal/relevant is important, but that's not ultimately going to dispel the fear of the student. I think how the student feels about something often has more to do with the personality of the person teaching it, and how comfortable that person feels in the classroom, even when teaching uninterested or scared students. The first thing to do to do away with their fear, is to do away with your own...you shouldn't be afraid of teaching students who may be afraid, because ultimately counseling them over their fears isn't your responsibility. You are not a therapist. And yet, by being natural, fun, casual, corny, and likable, the student will be able to let go of their fear as they can begin to replace their feelings towards statistics with their feelings about you as a person and the environment of curiosity, fun, and learning you create. That's my belief and experience. So, here's what I recommend: Reframe Statistics using mantras like "Information is Beautiful" and show them the blog of the same name. Mention things like how "measuring something allows you to manage it" and make wiser decisions. Yes, these are all ways of making it personal and relevant. Introduce them to sections of Freakonomics. It's a great book, and uses regular language to describe why statistical analysis is important and sexy. Tell corny jokes constantly. This endears you to them. Be a goof. Do whatever is necessary for them to feel that they are cooler than you. Do whatever is necessary for them to feel that they are smarter than you (even though they trust you secretly have everything under control). There was an article in the NYTimes some years ago about the power of a teacher who is uncool. It allows students to relax. Wear blue converse all stars, do something weird an idiosyncratic so they know they have a chance, and that they have nothing to fear. Give them things to play with. Get some colored markers (I've done this in university) and have them draw their graphs and notes in color. This makes them feel like they're in elementary school even if they're calculating standard deviation. Major help in overcoming fear. Get some measurement gear, measure heart rate and have them running around. Demonstrate concepts by collecting data from students live in the classroom. Make them forget it's a statistics class, make them feel like it's a study they are involved in, or administering. Demystify the math. An intro statistics course has no actual mathematical operation more difficult than an arithmetic class, it's just a sequence of many operations in row, and it's about learning to keep track of that. Tell them it's like a yoga practice in learning to be more organized. Memorize everyone's name on the first and second day, absolutely. Calling them by their names, poking fun at them sometimes, letting them poke fun at you, are all ways to overcome fear. They ultimately want to know that you aren't going to hit them over the head with something that they can't handle (that's what fear is). Give them ample warning, and exaggerate how difficult things are as they come up. Start off the class by saying "Boy, you guys are going to kill me, because today is going to be so hard your head might explode," and then when you teaching them variance, let's say, and they find it easy to calculate, then they'll get a greater confidence. When something is actually difficult to calculate, give them a whole period to do it out, and maybe a second shot the next class depending on your time constraints. And again, it's ultimately about you. Do you know your statistics back and forth? Does it daunt you at all? Are you a fun teacher who makes students laugh and relax, or are you bumbling and not sure how you're steering the ship? Do you have the class time well managed, or are you constantly not sure how long something will take to teach? When you need to, can you be stern with them (they are medical students after all)?
How to teach students who fear statistics?
I agree that making statistics personal/relevant is important, but that's not ultimately going to dispel the fear of the student. I think how the student feels about something often has more to do wit
How to teach students who fear statistics? I agree that making statistics personal/relevant is important, but that's not ultimately going to dispel the fear of the student. I think how the student feels about something often has more to do with the personality of the person teaching it, and how comfortable that person feels in the classroom, even when teaching uninterested or scared students. The first thing to do to do away with their fear, is to do away with your own...you shouldn't be afraid of teaching students who may be afraid, because ultimately counseling them over their fears isn't your responsibility. You are not a therapist. And yet, by being natural, fun, casual, corny, and likable, the student will be able to let go of their fear as they can begin to replace their feelings towards statistics with their feelings about you as a person and the environment of curiosity, fun, and learning you create. That's my belief and experience. So, here's what I recommend: Reframe Statistics using mantras like "Information is Beautiful" and show them the blog of the same name. Mention things like how "measuring something allows you to manage it" and make wiser decisions. Yes, these are all ways of making it personal and relevant. Introduce them to sections of Freakonomics. It's a great book, and uses regular language to describe why statistical analysis is important and sexy. Tell corny jokes constantly. This endears you to them. Be a goof. Do whatever is necessary for them to feel that they are cooler than you. Do whatever is necessary for them to feel that they are smarter than you (even though they trust you secretly have everything under control). There was an article in the NYTimes some years ago about the power of a teacher who is uncool. It allows students to relax. Wear blue converse all stars, do something weird an idiosyncratic so they know they have a chance, and that they have nothing to fear. Give them things to play with. Get some colored markers (I've done this in university) and have them draw their graphs and notes in color. This makes them feel like they're in elementary school even if they're calculating standard deviation. Major help in overcoming fear. Get some measurement gear, measure heart rate and have them running around. Demonstrate concepts by collecting data from students live in the classroom. Make them forget it's a statistics class, make them feel like it's a study they are involved in, or administering. Demystify the math. An intro statistics course has no actual mathematical operation more difficult than an arithmetic class, it's just a sequence of many operations in row, and it's about learning to keep track of that. Tell them it's like a yoga practice in learning to be more organized. Memorize everyone's name on the first and second day, absolutely. Calling them by their names, poking fun at them sometimes, letting them poke fun at you, are all ways to overcome fear. They ultimately want to know that you aren't going to hit them over the head with something that they can't handle (that's what fear is). Give them ample warning, and exaggerate how difficult things are as they come up. Start off the class by saying "Boy, you guys are going to kill me, because today is going to be so hard your head might explode," and then when you teaching them variance, let's say, and they find it easy to calculate, then they'll get a greater confidence. When something is actually difficult to calculate, give them a whole period to do it out, and maybe a second shot the next class depending on your time constraints. And again, it's ultimately about you. Do you know your statistics back and forth? Does it daunt you at all? Are you a fun teacher who makes students laugh and relax, or are you bumbling and not sure how you're steering the ship? Do you have the class time well managed, or are you constantly not sure how long something will take to teach? When you need to, can you be stern with them (they are medical students after all)?
How to teach students who fear statistics? I agree that making statistics personal/relevant is important, but that's not ultimately going to dispel the fear of the student. I think how the student feels about something often has more to do wit
7,857
How to teach students who fear statistics?
Not very much about how to deal with students' fear, but Andrew Gelman wrote an excellent book, Teaching Statistics, a bag of tricks (there's also some slides). I like introducing a course by talking about randomness, elementary probability as found in games, causal association, permutation tests (because parametric tests provide good approximation to them :). I just put an example that I like to show to students. This is from Phillip Good, in his book Permutation, Parametric, and Bootstrap Tests of Hypotheses (Springer, 2005 3rd ed.), where he introduces the general strategy of testing or decision making about statistical hypothesis and how to carry out a very simple and exact permutation test to solve the follwoing problem. Shortly after I received my doctorate in statistics, I decided that if I really wanted to help bench scientists apply statistics I ought to become a scientist myself. So I went back to school to learn physiology and aging in cells raised in petri dishes. I soon learned there was a great deal more to an experiment than the random assignment of subjects to treatments. In general, 90% of experimental effort was spent mastering various arcane laboratory techniques, another 9% in developing new techniques to span the gap between what had been done and what I really wanted to do, and a mere 1% on the experiment itself. But the moment of truth came finally–—it had to if I were to publish and not perish–—and I succeeded in cloning human diploid fibroblasts in eight culture dishes: Four of these dishes were filled with a conventional nutrient solution and four held an experimental "life-extending" solution to which vitamin E had been added. I waited three weeks with fingers crossed that there was no contamination of the cell cultures, but at the end of this test period three dishes of each type had survived. My technician and I transplanted the cells, let them grow for 24 hours in contact with a radioactive label, and then fixed and stained them before covering them with a photographic emulsion. Ten days passed and we were ready to examine the autoradiographs. Two years had elapsed since I first envisioned this experiment and now the results were in: I had the six numbers I needed. "I've lost the labels," my technician said as she handed me the results. This was a dire situation. Without the labels, I had no way of knowing which cell cultures had been treated with vitamin E and which had not.
How to teach students who fear statistics?
Not very much about how to deal with students' fear, but Andrew Gelman wrote an excellent book, Teaching Statistics, a bag of tricks (there's also some slides). I like introducing a course by talking
How to teach students who fear statistics? Not very much about how to deal with students' fear, but Andrew Gelman wrote an excellent book, Teaching Statistics, a bag of tricks (there's also some slides). I like introducing a course by talking about randomness, elementary probability as found in games, causal association, permutation tests (because parametric tests provide good approximation to them :). I just put an example that I like to show to students. This is from Phillip Good, in his book Permutation, Parametric, and Bootstrap Tests of Hypotheses (Springer, 2005 3rd ed.), where he introduces the general strategy of testing or decision making about statistical hypothesis and how to carry out a very simple and exact permutation test to solve the follwoing problem. Shortly after I received my doctorate in statistics, I decided that if I really wanted to help bench scientists apply statistics I ought to become a scientist myself. So I went back to school to learn physiology and aging in cells raised in petri dishes. I soon learned there was a great deal more to an experiment than the random assignment of subjects to treatments. In general, 90% of experimental effort was spent mastering various arcane laboratory techniques, another 9% in developing new techniques to span the gap between what had been done and what I really wanted to do, and a mere 1% on the experiment itself. But the moment of truth came finally–—it had to if I were to publish and not perish–—and I succeeded in cloning human diploid fibroblasts in eight culture dishes: Four of these dishes were filled with a conventional nutrient solution and four held an experimental "life-extending" solution to which vitamin E had been added. I waited three weeks with fingers crossed that there was no contamination of the cell cultures, but at the end of this test period three dishes of each type had survived. My technician and I transplanted the cells, let them grow for 24 hours in contact with a radioactive label, and then fixed and stained them before covering them with a photographic emulsion. Ten days passed and we were ready to examine the autoradiographs. Two years had elapsed since I first envisioned this experiment and now the results were in: I had the six numbers I needed. "I've lost the labels," my technician said as she handed me the results. This was a dire situation. Without the labels, I had no way of knowing which cell cultures had been treated with vitamin E and which had not.
How to teach students who fear statistics? Not very much about how to deal with students' fear, but Andrew Gelman wrote an excellent book, Teaching Statistics, a bag of tricks (there's also some slides). I like introducing a course by talking
7,858
How to teach students who fear statistics?
Frederick Mosteller said: When I think of teaching a class, I think of five main components, not all ordinarily used in one lecture. They are Large-scale application Physical demonstration Small-scale application (specific) Statistical or probabilistic principle Proof or plausibility argument Tufte also mentioned (I don't have the source here but I think it was from Mosteller as well) the PGP framework: Particular General Particular The idea is that you should start with an example (it helps if the example is relevant to the students), then develop the general solution, then close with another example.
How to teach students who fear statistics?
Frederick Mosteller said: When I think of teaching a class, I think of five main components, not all ordinarily used in one lecture. They are Large-scale application Physical demonstration Small-sca
How to teach students who fear statistics? Frederick Mosteller said: When I think of teaching a class, I think of five main components, not all ordinarily used in one lecture. They are Large-scale application Physical demonstration Small-scale application (specific) Statistical or probabilistic principle Proof or plausibility argument Tufte also mentioned (I don't have the source here but I think it was from Mosteller as well) the PGP framework: Particular General Particular The idea is that you should start with an example (it helps if the example is relevant to the students), then develop the general solution, then close with another example.
How to teach students who fear statistics? Frederick Mosteller said: When I think of teaching a class, I think of five main components, not all ordinarily used in one lecture. They are Large-scale application Physical demonstration Small-sca
7,859
How to teach students who fear statistics?
This is a topic that would be of interest to members of the Isolated Statisticians group in the ASA. You are likely to get many useful responses from experienced teachers there, so I'll limit what I share here. It's useful to understand where your students are coming from. A low-stress pre-test can help you identify their strengths, weaknesses, and fears. Sample tests for this purpose are provided in the instructor's manual to the Freedman, Pisani, Purves Statistics text. Get a copy of the manual through your institution. (I think the publisher will send it free.) (If you're really interested in this, I can post a version of these tests I have used for pre-assessment of undergraduates.) Another good source of test material related to intro statistics is the Artist Web site. As a working statistician, of course you will want to engage in some quantitative measurement of the learning that occurs in your class ;-). That site is a great resource for test questions. There is a large and growing literature about teaching intro stats. A place to start is the online Journal of Statistical Education. At a minimum you will find articles there about using case studies and datasets relevant to medical students; you might uncover some that specifically address teaching this population. When asked to teach such courses, I have always found it helpful to reach out to the other faculty and, when possible, the students themselves to find out what they really need to know and what might motivate them. Medical students are really busy and they didn't go to school to learn statistics, but they know they'll need to understand the papers they will be reading throughout their careers. If you're not familiar with medical literature, a few hours with the best journals, like the Lancet and JAMA, will help you appreciate what they're working towards.
How to teach students who fear statistics?
This is a topic that would be of interest to members of the Isolated Statisticians group in the ASA. You are likely to get many useful responses from experienced teachers there, so I'll limit what I
How to teach students who fear statistics? This is a topic that would be of interest to members of the Isolated Statisticians group in the ASA. You are likely to get many useful responses from experienced teachers there, so I'll limit what I share here. It's useful to understand where your students are coming from. A low-stress pre-test can help you identify their strengths, weaknesses, and fears. Sample tests for this purpose are provided in the instructor's manual to the Freedman, Pisani, Purves Statistics text. Get a copy of the manual through your institution. (I think the publisher will send it free.) (If you're really interested in this, I can post a version of these tests I have used for pre-assessment of undergraduates.) Another good source of test material related to intro statistics is the Artist Web site. As a working statistician, of course you will want to engage in some quantitative measurement of the learning that occurs in your class ;-). That site is a great resource for test questions. There is a large and growing literature about teaching intro stats. A place to start is the online Journal of Statistical Education. At a minimum you will find articles there about using case studies and datasets relevant to medical students; you might uncover some that specifically address teaching this population. When asked to teach such courses, I have always found it helpful to reach out to the other faculty and, when possible, the students themselves to find out what they really need to know and what might motivate them. Medical students are really busy and they didn't go to school to learn statistics, but they know they'll need to understand the papers they will be reading throughout their careers. If you're not familiar with medical literature, a few hours with the best journals, like the Lancet and JAMA, will help you appreciate what they're working towards.
How to teach students who fear statistics? This is a topic that would be of interest to members of the Isolated Statisticians group in the ASA. You are likely to get many useful responses from experienced teachers there, so I'll limit what I
7,860
How to teach students who fear statistics?
I teach undergraduate biology students, and The Fear is rife among them. I generally start by telling them three things: 1) Statistics is not maths, it's logic. And if you're doing a science degree at a respected university, you eveidently don't have any problems with using logic to solve problems. 2) If you can add, subtract, multiply, divide and tell whether one number is bigger than another, you can do all the maths necessary for an undergrad stats course. 3) People learn differently, so if you don't understand one lecturer/textbook/explanation, ask or find another one. (I try to give 2-3 types of explanation for a given idea where I can and tell them to remember the one that makes sense to them). Finally, I err on the side of visual explanations as opposed to purely verbal or mathematical ones, as this seems work for the majority of students.
How to teach students who fear statistics?
I teach undergraduate biology students, and The Fear is rife among them. I generally start by telling them three things: 1) Statistics is not maths, it's logic. And if you're doing a science degree
How to teach students who fear statistics? I teach undergraduate biology students, and The Fear is rife among them. I generally start by telling them three things: 1) Statistics is not maths, it's logic. And if you're doing a science degree at a respected university, you eveidently don't have any problems with using logic to solve problems. 2) If you can add, subtract, multiply, divide and tell whether one number is bigger than another, you can do all the maths necessary for an undergrad stats course. 3) People learn differently, so if you don't understand one lecturer/textbook/explanation, ask or find another one. (I try to give 2-3 types of explanation for a given idea where I can and tell them to remember the one that makes sense to them). Finally, I err on the side of visual explanations as opposed to purely verbal or mathematical ones, as this seems work for the majority of students.
How to teach students who fear statistics? I teach undergraduate biology students, and The Fear is rife among them. I generally start by telling them three things: 1) Statistics is not maths, it's logic. And if you're doing a science degree
7,861
How to teach students who fear statistics?
Some good answers here, but one addition. I start off by saying "Who was the first female member of the Royal Statistical Society." I might also say "You have heard of her." Usually no one gets it right. Then I say that it was Florence Nightingale, and I ask why she is famous. They respond about things like hygiene. I explain that she's famous not just because of what she discovered, but because she collected the data and explained it to policy makers. It's all very well having a good idea, but you need to be able to show other people that it's true. I then talk about pie charts (polar axis charts) and the coincidence that F.N. David, who went on to be a pretty well known statistician in her own right, was named after Nightingale.
How to teach students who fear statistics?
Some good answers here, but one addition. I start off by saying "Who was the first female member of the Royal Statistical Society." I might also say "You have heard of her." Usually no one gets it ri
How to teach students who fear statistics? Some good answers here, but one addition. I start off by saying "Who was the first female member of the Royal Statistical Society." I might also say "You have heard of her." Usually no one gets it right. Then I say that it was Florence Nightingale, and I ask why she is famous. They respond about things like hygiene. I explain that she's famous not just because of what she discovered, but because she collected the data and explained it to policy makers. It's all very well having a good idea, but you need to be able to show other people that it's true. I then talk about pie charts (polar axis charts) and the coincidence that F.N. David, who went on to be a pretty well known statistician in her own right, was named after Nightingale.
How to teach students who fear statistics? Some good answers here, but one addition. I start off by saying "Who was the first female member of the Royal Statistical Society." I might also say "You have heard of her." Usually no one gets it ri
7,862
How to teach students who fear statistics?
"Decision making in the face of uncertainty" sounds a lot more interesting than "statistics" even though that's essentially what statistics is about. Maybe you could lead with the decision-making aspect to build motivation for the course.
How to teach students who fear statistics?
"Decision making in the face of uncertainty" sounds a lot more interesting than "statistics" even though that's essentially what statistics is about. Maybe you could lead with the decision-making asp
How to teach students who fear statistics? "Decision making in the face of uncertainty" sounds a lot more interesting than "statistics" even though that's essentially what statistics is about. Maybe you could lead with the decision-making aspect to build motivation for the course.
How to teach students who fear statistics? "Decision making in the face of uncertainty" sounds a lot more interesting than "statistics" even though that's essentially what statistics is about. Maybe you could lead with the decision-making asp
7,863
How to teach students who fear statistics?
One resource that has not been mentioned but I feel would be the best resource for this situation is the book How to Lie with Statistics by Darrell Huff. The book is full of practical examples and intuitive reasoning; it helps cement the sometimes abstract methods of statistics. Despite having as Masters in Engineering, I struggle with math. I tend to struggle the most with symbolically writing what I know. For example, when learning to take limits to infinity, I could intuitively solve many of the word problems provided in the class, but it took a lot of effort to write the math and solve the equation. Much of statistics was the same struggle for me. Statistics in the mathematics courses I had taken were more concerned with the new mathematical notation I was expected to learn that how and why things were happening. The method that worked for me and opened my eyes to the wonders of statistics, was practical problem solving in my engineering courses, which just happened to use statistics. Using physical examples and conducting experiments helped me to understand the real basis for the notation that I was using. In developing a course on Design of Experiments, I was very pleased with the amount of free information available to help teach complex concepts in a very hands-on manner.
How to teach students who fear statistics?
One resource that has not been mentioned but I feel would be the best resource for this situation is the book How to Lie with Statistics by Darrell Huff. The book is full of practical examples and in
How to teach students who fear statistics? One resource that has not been mentioned but I feel would be the best resource for this situation is the book How to Lie with Statistics by Darrell Huff. The book is full of practical examples and intuitive reasoning; it helps cement the sometimes abstract methods of statistics. Despite having as Masters in Engineering, I struggle with math. I tend to struggle the most with symbolically writing what I know. For example, when learning to take limits to infinity, I could intuitively solve many of the word problems provided in the class, but it took a lot of effort to write the math and solve the equation. Much of statistics was the same struggle for me. Statistics in the mathematics courses I had taken were more concerned with the new mathematical notation I was expected to learn that how and why things were happening. The method that worked for me and opened my eyes to the wonders of statistics, was practical problem solving in my engineering courses, which just happened to use statistics. Using physical examples and conducting experiments helped me to understand the real basis for the notation that I was using. In developing a course on Design of Experiments, I was very pleased with the amount of free information available to help teach complex concepts in a very hands-on manner.
How to teach students who fear statistics? One resource that has not been mentioned but I feel would be the best resource for this situation is the book How to Lie with Statistics by Darrell Huff. The book is full of practical examples and in
7,864
How to teach students who fear statistics?
No recipe covers all cases, even if common elements may be lack of confidence and, sadly, lack of competence in mathematics; and perhaps most crucially a strong cultural preconception handed down from generation to generation that statistics will be difficult, tedious and pointless, and full of weird ideas to boot. The introductory course is difficult to do well. It's going to be at the wrong time (of day and of week, surprisingly often, because of mundane timetabling issues) and at the wrong time in people's careers. It will go at the wrong speed for almost all. They don't yet see the point (and in many cases never will). So what positives can I offer? I like to start with data and graphs and link to what they do know. Introduce not just the graphs they should know about but some new ones too. Students who fear equations are often happy with, and good at, thinking graphically. The real lift-off usually only comes when students have their "own" data they care about, usually for a project or dissertation. That gives focus and motivation; they can look at the literature and see what methods people use; they have an incentive to understand, as it's not just a matter of some silly little exercise that they can sleep-walk through (but still not understand). In the British system, this can happen as early as second-year undergraduate level. Disclosure: I am a geographer; I teach geographers; I often give talks at interdisciplinary meetings. I don't have any formal qualifications in statistics, but statistical applications have been my main research and teaching interest throughout most of my career.
How to teach students who fear statistics?
No recipe covers all cases, even if common elements may be lack of confidence and, sadly, lack of competence in mathematics; and perhaps most crucially a strong cultural preconception handed down from
How to teach students who fear statistics? No recipe covers all cases, even if common elements may be lack of confidence and, sadly, lack of competence in mathematics; and perhaps most crucially a strong cultural preconception handed down from generation to generation that statistics will be difficult, tedious and pointless, and full of weird ideas to boot. The introductory course is difficult to do well. It's going to be at the wrong time (of day and of week, surprisingly often, because of mundane timetabling issues) and at the wrong time in people's careers. It will go at the wrong speed for almost all. They don't yet see the point (and in many cases never will). So what positives can I offer? I like to start with data and graphs and link to what they do know. Introduce not just the graphs they should know about but some new ones too. Students who fear equations are often happy with, and good at, thinking graphically. The real lift-off usually only comes when students have their "own" data they care about, usually for a project or dissertation. That gives focus and motivation; they can look at the literature and see what methods people use; they have an incentive to understand, as it's not just a matter of some silly little exercise that they can sleep-walk through (but still not understand). In the British system, this can happen as early as second-year undergraduate level. Disclosure: I am a geographer; I teach geographers; I often give talks at interdisciplinary meetings. I don't have any formal qualifications in statistics, but statistical applications have been my main research and teaching interest throughout most of my career.
How to teach students who fear statistics? No recipe covers all cases, even if common elements may be lack of confidence and, sadly, lack of competence in mathematics; and perhaps most crucially a strong cultural preconception handed down from
7,865
Why is the expected value named so?
Imagine that you are in Paris in 1654 and you and your friend are observing a gambling game based on sequential rolling of a six sided dice. Now, gambling is highly illegal and busts by the gendarme are quite frequent, and to be caught at a table with stacks of livre is to almost surely guarantee a lengthy stint in the Chateau d'If. To get around this you and your friend have a gentleman's agreement on a bet made between two of you prior to the last die roll. He agrees to pay you five livre if you observe two sixes in the next five rolls of dice, and you agree to pay him the same amount if two ones are rolled, with no other action if these combinations do not come up. Now, the last die roll is a six so you are on the edge of your seat, figuratively. At this moment, heavily armed guardsmen burst into the den and arrests everyone at the table, and the crowd disperses. Your friend believes that the bet made between the two of you is now invalidated. However, you believe that he should pay you some amount as one six had already been rolled. What is a fair way of settling this dispute between the two of you? (This is my interpretation of the origins of the expected value as presented in here and discussed in greater detail here) Let's answer this question of fair value in a non rigorous way. The amount your friend should pay you can be calculated in the following manner. Consider all possible rolls of four dice. Some sets of rolls (namely those containing at least one six) will result in your friend paying out the agreed amount. However, on other sets (namely, those not containing a single six) will result in you receiving no money. How do you balance the possibility of these two types of rolls happening? Simple, average out the amount you would have been paid over ALL possible rolls. However, your friend, (quite unlikely), can still win his bet! You have to consider the number of times two ones will be rolled in the remaining four dice, and average out the amount you will pay him over the number of all possible rolls of four dice. This is the fair amount you should pay your friend for his bet. Thus the amount you end up getting is the amount your friend should pay you, minus what you should pay your friend. This is why we call it the "expected value". It is the average amount you expect to receive if you are able to simulate an event happening in multiple simultaneous universes.
Why is the expected value named so?
Imagine that you are in Paris in 1654 and you and your friend are observing a gambling game based on sequential rolling of a six sided dice. Now, gambling is highly illegal and busts by the gendarme a
Why is the expected value named so? Imagine that you are in Paris in 1654 and you and your friend are observing a gambling game based on sequential rolling of a six sided dice. Now, gambling is highly illegal and busts by the gendarme are quite frequent, and to be caught at a table with stacks of livre is to almost surely guarantee a lengthy stint in the Chateau d'If. To get around this you and your friend have a gentleman's agreement on a bet made between two of you prior to the last die roll. He agrees to pay you five livre if you observe two sixes in the next five rolls of dice, and you agree to pay him the same amount if two ones are rolled, with no other action if these combinations do not come up. Now, the last die roll is a six so you are on the edge of your seat, figuratively. At this moment, heavily armed guardsmen burst into the den and arrests everyone at the table, and the crowd disperses. Your friend believes that the bet made between the two of you is now invalidated. However, you believe that he should pay you some amount as one six had already been rolled. What is a fair way of settling this dispute between the two of you? (This is my interpretation of the origins of the expected value as presented in here and discussed in greater detail here) Let's answer this question of fair value in a non rigorous way. The amount your friend should pay you can be calculated in the following manner. Consider all possible rolls of four dice. Some sets of rolls (namely those containing at least one six) will result in your friend paying out the agreed amount. However, on other sets (namely, those not containing a single six) will result in you receiving no money. How do you balance the possibility of these two types of rolls happening? Simple, average out the amount you would have been paid over ALL possible rolls. However, your friend, (quite unlikely), can still win his bet! You have to consider the number of times two ones will be rolled in the remaining four dice, and average out the amount you will pay him over the number of all possible rolls of four dice. This is the fair amount you should pay your friend for his bet. Thus the amount you end up getting is the amount your friend should pay you, minus what you should pay your friend. This is why we call it the "expected value". It is the average amount you expect to receive if you are able to simulate an event happening in multiple simultaneous universes.
Why is the expected value named so? Imagine that you are in Paris in 1654 and you and your friend are observing a gambling game based on sequential rolling of a six sided dice. Now, gambling is highly illegal and busts by the gendarme a
7,866
Why is the expected value named so?
Excellent question. It's more subtle than it seems at first. It has to do with the random event and random variable (number, value). Your confusion stems from mixing together these two related but distinct concepts. Let's start with an event. From the way you formulated your question, it appears that you consider the outcome of a dice throw an event. It's random, so you may get one of its six sides with equal chance, as you wrote. It makes a perfect sense. What is expected value of this experiment? The expectations are defined for random variables (values) not events. For you the numbers 1 to 6 on the dice are simply the ways to distinguish its sides (in the context of your question's formulation). Imagine you instead used letters: A, B, C, D, E, and F. Replace the numbers with letters and repeat your question as follows: In other words, when asked the question 'what's the expected value of throwing a fair 6-sided die?', one should answer 'oh, it can be anything between A and F with equal chance' Now try to come up with an expected value. It's not defined! The expectations show up when you define the random values, such as 1 to 6. You map the values to the event space, for instance, you define that side A is 1, side B is 2 etc. Now you have 6 numbers and can calculate the expectation, which happens to be 3.5.
Why is the expected value named so?
Excellent question. It's more subtle than it seems at first. It has to do with the random event and random variable (number, value). Your confusion stems from mixing together these two related but dis
Why is the expected value named so? Excellent question. It's more subtle than it seems at first. It has to do with the random event and random variable (number, value). Your confusion stems from mixing together these two related but distinct concepts. Let's start with an event. From the way you formulated your question, it appears that you consider the outcome of a dice throw an event. It's random, so you may get one of its six sides with equal chance, as you wrote. It makes a perfect sense. What is expected value of this experiment? The expectations are defined for random variables (values) not events. For you the numbers 1 to 6 on the dice are simply the ways to distinguish its sides (in the context of your question's formulation). Imagine you instead used letters: A, B, C, D, E, and F. Replace the numbers with letters and repeat your question as follows: In other words, when asked the question 'what's the expected value of throwing a fair 6-sided die?', one should answer 'oh, it can be anything between A and F with equal chance' Now try to come up with an expected value. It's not defined! The expectations show up when you define the random values, such as 1 to 6. You map the values to the event space, for instance, you define that side A is 1, side B is 2 etc. Now you have 6 numbers and can calculate the expectation, which happens to be 3.5.
Why is the expected value named so? Excellent question. It's more subtle than it seems at first. It has to do with the random event and random variable (number, value). Your confusion stems from mixing together these two related but dis
7,867
Why is the expected value named so?
"Each of the values equally likely", or "some value most likely" is the definition of mode, not expected value. Imagine we are playing a coin-tossing game. Each time I toss heads, I give you 1\$, each time I toss tails, you give me 1\$. How much money would you expect to win or loose in the long run? Amounts are equal, probabilities of throwing them are equal, expected value is zero.
Why is the expected value named so?
"Each of the values equally likely", or "some value most likely" is the definition of mode, not expected value. Imagine we are playing a coin-tossing game. Each time I toss heads, I give you 1\$, each
Why is the expected value named so? "Each of the values equally likely", or "some value most likely" is the definition of mode, not expected value. Imagine we are playing a coin-tossing game. Each time I toss heads, I give you 1\$, each time I toss tails, you give me 1\$. How much money would you expect to win or loose in the long run? Amounts are equal, probabilities of throwing them are equal, expected value is zero.
Why is the expected value named so? "Each of the values equally likely", or "some value most likely" is the definition of mode, not expected value. Imagine we are playing a coin-tossing game. Each time I toss heads, I give you 1\$, each
7,868
Why is the expected value named so?
The expected value is called so because if you average all dice rolls you expect to get this expected value in the long run. The expected value is not related to any single dice roll.
Why is the expected value named so?
The expected value is called so because if you average all dice rolls you expect to get this expected value in the long run. The expected value is not related to any single dice roll.
Why is the expected value named so? The expected value is called so because if you average all dice rolls you expect to get this expected value in the long run. The expected value is not related to any single dice roll.
Why is the expected value named so? The expected value is called so because if you average all dice rolls you expect to get this expected value in the long run. The expected value is not related to any single dice roll.
7,869
Why is the expected value named so?
From an historical point of view, the concept seemed to appear in different countries, so I would consider the use of this word as a convenient convergence between similar concepts across languages. My starting point was the excellent Earliest Uses of Symbols in Probability and Statistics: Expectation. A large script E was used for the expectation in W. A. Whitworth's well-known textbook Choice and Chance (fifth edition) of 1901 but neither the symbol nor the calculus of expectations became established in the English literature until much later. For example, Rietz Mathematical Statistics (1927) used the symbol E and commented that "the expected value of the variable is a concept that has been much used by various continental European writers..." For the continental European writers E signified "Erwartung" or "espérance (editor's note: mathématique)." The term is sometimes "attributed to" Huyghens, which is discussed in Huygens Foundations Of Probability: It is generally accepted that Huygens based probability on expectation. The term "expectation," however, stems from Van-Schooten's Latin translation of Huygens' treatise. A literal translation of Huygens' Dutch text shows more clearly what Huygens actually meant and how he proceeded. Additional details with respect to Fermat, Pascal can be found in Expectation and the early probabilists.
Why is the expected value named so?
From an historical point of view, the concept seemed to appear in different countries, so I would consider the use of this word as a convenient convergence between similar concepts across languages.
Why is the expected value named so? From an historical point of view, the concept seemed to appear in different countries, so I would consider the use of this word as a convenient convergence between similar concepts across languages. My starting point was the excellent Earliest Uses of Symbols in Probability and Statistics: Expectation. A large script E was used for the expectation in W. A. Whitworth's well-known textbook Choice and Chance (fifth edition) of 1901 but neither the symbol nor the calculus of expectations became established in the English literature until much later. For example, Rietz Mathematical Statistics (1927) used the symbol E and commented that "the expected value of the variable is a concept that has been much used by various continental European writers..." For the continental European writers E signified "Erwartung" or "espérance (editor's note: mathématique)." The term is sometimes "attributed to" Huyghens, which is discussed in Huygens Foundations Of Probability: It is generally accepted that Huygens based probability on expectation. The term "expectation," however, stems from Van-Schooten's Latin translation of Huygens' treatise. A literal translation of Huygens' Dutch text shows more clearly what Huygens actually meant and how he proceeded. Additional details with respect to Fermat, Pascal can be found in Expectation and the early probabilists.
Why is the expected value named so? From an historical point of view, the concept seemed to appear in different countries, so I would consider the use of this word as a convenient convergence between similar concepts across languages.
7,870
Why is the expected value named so?
Interestingly, the more general concept than expected value is location. Thus, the concept of expected value has subtle implications that are somewhat confusing. It is reasonable to question what it means to have 3.5 as anything to do with an anticipated outcome for a die. The answer is that although the average value of rolled dice outcomes is 3.5, that the expected value concept only signifies mean or average value, and is only an expectation for a limited class of functions, that specific to the question here does not include die roll outcomes. To put it another way, although the average roll outcome is 3.5, So what? True enough, one can invent a context (in some alternate universe), where an average value has meaning, but, die outcomes $\leq 3$ pays $\$1$, and outcomes $\geq 4$ loses $1, works as well as an average, with the advantage of actually having outcomes in this universe. The reason for the inordinately restricted association between the term "expected value" and "mean value" appears to be historical rather than semantically correct, or even particularly cogent. That is, the context in which a calculated expected value is consistent the expectation of a location characterizing behaviour in a data set is limited to only certain distributions of data, and not others. That this is historical is supported by the notion of statistical moments. It is widely acknowledged that the first proof of the central limit theorem up to modern standards of rigor was given by Chebyshev in 1887. His argument introduced the method of moments.. Now the first moment of $f$ was, for Chebyshev, the mean value of a Borel set. The concept of a mean value being thus an expected value for the normal distribution, that is, the density function to which the central limit theorem applies is thus tracable to Chebyshev 1887. Such is the strength of the central limit theorem that it became a parenthetical expression to associate expected value with a mean value, as opposed to a more general measure of location. But what about data distributions that are not normal for which other measures are more stable and/or more representative of that data? For example, the mid-range value or average extreme value of data from a uniform distribution is more accurate and stable, i.e., precise and converges faster than the mean or median of that distribution. For log-normal distributions, e.g., (much of the treatment of) income data, the anti-log of the mean of the logarithm of data (A.K.A. geometric mean, e.g., moderate income data), rather than the data mean (e.g., mean income) itself, would be more indicative of what an individual thinking (or anticipated datum) to become inserted into that data might have as an anticipated outcome. That this is well-known is illustrated by the phrase, "I am anticipating a 5-figure salary." Here is an example of this for actual incomes. Another example, Pareto distributions, also used for income calculations, (see 80/20 law, and high income data) often have an undefined expected value (infinite first moment of $\alpha \beta ^{\alpha } t^{-\alpha -1}$ when $\alpha \leq 1$), such that for such distributions, it would be a mistake to anticipate an outcome to be an expected value. In that case, see Pareto distribution, the median, geometric mean, and harmonic mean are better measures of location, not only because the $\alpha \leq 1$ requirement is removed, but also because they are less variable even when $\alpha \gt 1$. Further information is found here in Clauset A, Shalizi CR, Newman ME. Power-law distributions in empirical data. SIAM review. 2009;51:661-703, and here.
Why is the expected value named so?
Interestingly, the more general concept than expected value is location. Thus, the concept of expected value has subtle implications that are somewhat confusing. It is reasonable to question what it m
Why is the expected value named so? Interestingly, the more general concept than expected value is location. Thus, the concept of expected value has subtle implications that are somewhat confusing. It is reasonable to question what it means to have 3.5 as anything to do with an anticipated outcome for a die. The answer is that although the average value of rolled dice outcomes is 3.5, that the expected value concept only signifies mean or average value, and is only an expectation for a limited class of functions, that specific to the question here does not include die roll outcomes. To put it another way, although the average roll outcome is 3.5, So what? True enough, one can invent a context (in some alternate universe), where an average value has meaning, but, die outcomes $\leq 3$ pays $\$1$, and outcomes $\geq 4$ loses $1, works as well as an average, with the advantage of actually having outcomes in this universe. The reason for the inordinately restricted association between the term "expected value" and "mean value" appears to be historical rather than semantically correct, or even particularly cogent. That is, the context in which a calculated expected value is consistent the expectation of a location characterizing behaviour in a data set is limited to only certain distributions of data, and not others. That this is historical is supported by the notion of statistical moments. It is widely acknowledged that the first proof of the central limit theorem up to modern standards of rigor was given by Chebyshev in 1887. His argument introduced the method of moments.. Now the first moment of $f$ was, for Chebyshev, the mean value of a Borel set. The concept of a mean value being thus an expected value for the normal distribution, that is, the density function to which the central limit theorem applies is thus tracable to Chebyshev 1887. Such is the strength of the central limit theorem that it became a parenthetical expression to associate expected value with a mean value, as opposed to a more general measure of location. But what about data distributions that are not normal for which other measures are more stable and/or more representative of that data? For example, the mid-range value or average extreme value of data from a uniform distribution is more accurate and stable, i.e., precise and converges faster than the mean or median of that distribution. For log-normal distributions, e.g., (much of the treatment of) income data, the anti-log of the mean of the logarithm of data (A.K.A. geometric mean, e.g., moderate income data), rather than the data mean (e.g., mean income) itself, would be more indicative of what an individual thinking (or anticipated datum) to become inserted into that data might have as an anticipated outcome. That this is well-known is illustrated by the phrase, "I am anticipating a 5-figure salary." Here is an example of this for actual incomes. Another example, Pareto distributions, also used for income calculations, (see 80/20 law, and high income data) often have an undefined expected value (infinite first moment of $\alpha \beta ^{\alpha } t^{-\alpha -1}$ when $\alpha \leq 1$), such that for such distributions, it would be a mistake to anticipate an outcome to be an expected value. In that case, see Pareto distribution, the median, geometric mean, and harmonic mean are better measures of location, not only because the $\alpha \leq 1$ requirement is removed, but also because they are less variable even when $\alpha \gt 1$. Further information is found here in Clauset A, Shalizi CR, Newman ME. Power-law distributions in empirical data. SIAM review. 2009;51:661-703, and here.
Why is the expected value named so? Interestingly, the more general concept than expected value is location. Thus, the concept of expected value has subtle implications that are somewhat confusing. It is reasonable to question what it m
7,871
What is a manifold?
In non technical terms, a manifold is a continuous geometrical structure having finite dimension : a line, a curve, a plane, a surface, a sphere, a ball, a cylinder, a torus, a "blob"... something like this : It is a generic term used by mathematicians to say "a curve" (dimension 1) or "surface" (dimension 2), or a 3D object (dimension 3)... for any possible finite dimension $n$. A one dimensional manifold is simply a curve (line, circle...). A two dimensional manifold is simply a surface (plane, sphere, torus, cylinder...). A three dimensional manifold is a "full object" (ball, full cube, the 3D space around us...). A manifold is often described by an equation : the set of points $(x,y)$ such as $x^2+y^2=1$ is a one dimensional manifold (a circle). A manifold has the same dimension everywhere. For example, if you append a line (dimension 1) to a sphere (dimension 2) then the resulting geometrical structure is not a manifold. Unlike the more general notions of metric space or topological space also intended to describe our natural intuition of a continuous set of points, a manifold is intended to be something locally simple: like a finite dimension vector space : $\mathbb{R}^n$. This rules out abstract spaces (like infinite dimension spaces) that often fail to have a geometric concrete meaning. Unlike a vector space, manifolds can have various shapes. Some manifolds can be easily visualized (sphere ,ball...), some are difficult to visualize, like the Klein bottle or the real projective plane. In statistics, machine learning, or applied maths generally, the word "manifold" is often used to say "like a linear subspace" but possibly curved. Anytime you write a linear equation like : $3x+2y-4z=1$ you get a linear (affine) subspace (here a plane). Usually, when the equation is non linear like $x^2+2y^2+3z^2=7$, this is a manifold (here a stretched sphere). For example the "manifold hypothesis" of ML says "high dimensional data are points in a low dimensional manifold with high dimensional noise added". You can imagine points of a 1D circle with some 2D noise added. While the points are not exactly on the circle, they satisfy statistically the equation $x^2+y^2=1$. The circle is the underlying manifold:
What is a manifold?
In non technical terms, a manifold is a continuous geometrical structure having finite dimension : a line, a curve, a plane, a surface, a sphere, a ball, a cylinder, a torus, a "blob"... something lik
What is a manifold? In non technical terms, a manifold is a continuous geometrical structure having finite dimension : a line, a curve, a plane, a surface, a sphere, a ball, a cylinder, a torus, a "blob"... something like this : It is a generic term used by mathematicians to say "a curve" (dimension 1) or "surface" (dimension 2), or a 3D object (dimension 3)... for any possible finite dimension $n$. A one dimensional manifold is simply a curve (line, circle...). A two dimensional manifold is simply a surface (plane, sphere, torus, cylinder...). A three dimensional manifold is a "full object" (ball, full cube, the 3D space around us...). A manifold is often described by an equation : the set of points $(x,y)$ such as $x^2+y^2=1$ is a one dimensional manifold (a circle). A manifold has the same dimension everywhere. For example, if you append a line (dimension 1) to a sphere (dimension 2) then the resulting geometrical structure is not a manifold. Unlike the more general notions of metric space or topological space also intended to describe our natural intuition of a continuous set of points, a manifold is intended to be something locally simple: like a finite dimension vector space : $\mathbb{R}^n$. This rules out abstract spaces (like infinite dimension spaces) that often fail to have a geometric concrete meaning. Unlike a vector space, manifolds can have various shapes. Some manifolds can be easily visualized (sphere ,ball...), some are difficult to visualize, like the Klein bottle or the real projective plane. In statistics, machine learning, or applied maths generally, the word "manifold" is often used to say "like a linear subspace" but possibly curved. Anytime you write a linear equation like : $3x+2y-4z=1$ you get a linear (affine) subspace (here a plane). Usually, when the equation is non linear like $x^2+2y^2+3z^2=7$, this is a manifold (here a stretched sphere). For example the "manifold hypothesis" of ML says "high dimensional data are points in a low dimensional manifold with high dimensional noise added". You can imagine points of a 1D circle with some 2D noise added. While the points are not exactly on the circle, they satisfy statistically the equation $x^2+y^2=1$. The circle is the underlying manifold:
What is a manifold? In non technical terms, a manifold is a continuous geometrical structure having finite dimension : a line, a curve, a plane, a surface, a sphere, a ball, a cylinder, a torus, a "blob"... something lik
7,872
What is a manifold?
A (topological) manifold is a space $M$ which is: (1) "locally" "equivalent" to $\mathbb{R}^n$ for some $n$. "Locally", the "equivalence" can be expressed via $n$ coordinate functions, $c_i: M \to \mathbb{R}$, which together form a "structure-preserving" function, $c: M \to \mathbb{R}^n$, called a chart. (2) can be realized in a "structure-preserving" way as a subset of $\mathbb{R}^N$ for some $N \ge n$. (1)(2) Note that in order to make "structure" precise here, one needs to understand basic notions of topology (def.), which allows one to make precise notions of "local" behavior, and thus "locally" above. When I say "equivalent", I mean equivalent topological structure (homeomorphic), and when I say "structure-preserving" I mean the same thing (creates an equivalent topological structure). Note also that in order to do calculus on manifolds, one needs an additional condition which doesn't follow from the above two conditions, which basically says something like "the charts are well-behaved enough to allow us to do calculus". These are the manifolds most often used in practice. Unlike general topological manifolds, in addition to calculus they also allow triangulations, which is very important in applications like yours involving point cloud data. Note that not all people use the same definition for a (topological) manifold. Several authors will define it as satisfying only condition (1) above, not necessarily also (2). However, the definition which satisfies both (1) and (2) is much better behaved, therefore more useful for practitioners. One might expect intuitively that (1) implies (2), but it actually doesn't. EDIT: If you are interested in learning about what precisely a "topology" is, the most important example of a topology to understand is the Euclidean topology of $\mathbb{R}^n$. This will be covered in-depth in any (good) introductory book about "real analysis".
What is a manifold?
A (topological) manifold is a space $M$ which is: (1) "locally" "equivalent" to $\mathbb{R}^n$ for some $n$. "Locally", the "equivalence" can be expressed via $n$ coordinate functions, $c_i: M \to \
What is a manifold? A (topological) manifold is a space $M$ which is: (1) "locally" "equivalent" to $\mathbb{R}^n$ for some $n$. "Locally", the "equivalence" can be expressed via $n$ coordinate functions, $c_i: M \to \mathbb{R}$, which together form a "structure-preserving" function, $c: M \to \mathbb{R}^n$, called a chart. (2) can be realized in a "structure-preserving" way as a subset of $\mathbb{R}^N$ for some $N \ge n$. (1)(2) Note that in order to make "structure" precise here, one needs to understand basic notions of topology (def.), which allows one to make precise notions of "local" behavior, and thus "locally" above. When I say "equivalent", I mean equivalent topological structure (homeomorphic), and when I say "structure-preserving" I mean the same thing (creates an equivalent topological structure). Note also that in order to do calculus on manifolds, one needs an additional condition which doesn't follow from the above two conditions, which basically says something like "the charts are well-behaved enough to allow us to do calculus". These are the manifolds most often used in practice. Unlike general topological manifolds, in addition to calculus they also allow triangulations, which is very important in applications like yours involving point cloud data. Note that not all people use the same definition for a (topological) manifold. Several authors will define it as satisfying only condition (1) above, not necessarily also (2). However, the definition which satisfies both (1) and (2) is much better behaved, therefore more useful for practitioners. One might expect intuitively that (1) implies (2), but it actually doesn't. EDIT: If you are interested in learning about what precisely a "topology" is, the most important example of a topology to understand is the Euclidean topology of $\mathbb{R}^n$. This will be covered in-depth in any (good) introductory book about "real analysis".
What is a manifold? A (topological) manifold is a space $M$ which is: (1) "locally" "equivalent" to $\mathbb{R}^n$ for some $n$. "Locally", the "equivalence" can be expressed via $n$ coordinate functions, $c_i: M \to \
7,873
What is a manifold?
In this context, the term manifold is accurate, but is unnecessarily highfalutin. Technically, a manifold is any space (set of points with a topology) that is sufficiently smooth and continuous (in a way that can, with some effort, be made mathematically well-defined). Imagine the space of all possible values of your original factors. After a dimensional reduction technique, not all points in that space are attainable. Instead, only points on some embedded sub-space inside in that space will be attainable. That embedded sub-space happens to fulfill the mathematical definition of a manifold. For a linear dimensional reduction technique like PCA, that sub-space is just a linear sub-space (e.g. a hyper-plane), which is a relatively trivial manifold. But for non-linear dimensional reduction technique, that sub-space could be more complicated (e.g. a curved hyper-surface). For data analysis purposes, understanding that these are sub-spaces is much more important than any inference you would draw from knowing that they fulfill the definition of manifold.
What is a manifold?
In this context, the term manifold is accurate, but is unnecessarily highfalutin. Technically, a manifold is any space (set of points with a topology) that is sufficiently smooth and continuous (in a
What is a manifold? In this context, the term manifold is accurate, but is unnecessarily highfalutin. Technically, a manifold is any space (set of points with a topology) that is sufficiently smooth and continuous (in a way that can, with some effort, be made mathematically well-defined). Imagine the space of all possible values of your original factors. After a dimensional reduction technique, not all points in that space are attainable. Instead, only points on some embedded sub-space inside in that space will be attainable. That embedded sub-space happens to fulfill the mathematical definition of a manifold. For a linear dimensional reduction technique like PCA, that sub-space is just a linear sub-space (e.g. a hyper-plane), which is a relatively trivial manifold. But for non-linear dimensional reduction technique, that sub-space could be more complicated (e.g. a curved hyper-surface). For data analysis purposes, understanding that these are sub-spaces is much more important than any inference you would draw from knowing that they fulfill the definition of manifold.
What is a manifold? In this context, the term manifold is accurate, but is unnecessarily highfalutin. Technically, a manifold is any space (set of points with a topology) that is sufficiently smooth and continuous (in a
7,874
What is a manifold?
As Bronstein and others have put it in Geometric deep learning: going beyond Euclidean data (Read the article here) Roughly, a manifold is a space that is locally Euclidean. One of the simplest examples is a spherical surface modeling our planet: around a point, it seems to be planar, which has led generations of people to believe in the flatness of the Earth. Formally speaking, a (differentiable) d-dimensional manifold X is a topological space where each point x has a neighborhood that is topologically equivalent (homeomorphic) to a d-dimensional Euclidean space, called the tangent space.
What is a manifold?
As Bronstein and others have put it in Geometric deep learning: going beyond Euclidean data (Read the article here) Roughly, a manifold is a space that is locally Euclidean. One of the simplest examp
What is a manifold? As Bronstein and others have put it in Geometric deep learning: going beyond Euclidean data (Read the article here) Roughly, a manifold is a space that is locally Euclidean. One of the simplest examples is a spherical surface modeling our planet: around a point, it seems to be planar, which has led generations of people to believe in the flatness of the Earth. Formally speaking, a (differentiable) d-dimensional manifold X is a topological space where each point x has a neighborhood that is topologically equivalent (homeomorphic) to a d-dimensional Euclidean space, called the tangent space.
What is a manifold? As Bronstein and others have put it in Geometric deep learning: going beyond Euclidean data (Read the article here) Roughly, a manifold is a space that is locally Euclidean. One of the simplest examp
7,875
Why are symmetric positive definite (SPD) matrices so important?
A (real) symmetric matrix has a complete set of orthogonal eigenvectors for which the corresponding eigenvalues are are all real numbers. For non-symmetric matrices this can fail. For example, a rotation in two dimensional space has no eigenvector or eigenvalues in the real numbers, you must pass to a vector space over the complex numbers to find them. If the matrix is additionally positive definite, then these eigenvalues are all positive real numbers. This fact is much easier than the first, for if $v$ is an eigenvector with unit length, and $\lambda$ the corresponding eigenvalue, then $$ \lambda = \lambda v^t v = v^t A v > 0 $$ where the last equality uses the definition of positive definiteness. The importance here for intuition is that the eigenvectors and eigenvalues of a linear transformation describe the coordinate system in which the transformation is most easily understood. A linear transformation can be very difficult to understand in a "natural" basis like the standard coordinate system, but each comes with a "preferred" basis of eigenvectors in which the transformation acts as a scaling in all directions. This makes the geometry of the transformation much easier to understand. For example, the second derivative test for the local extrema of a function $R^2 \rightarrow R$ is often given as a series of mysterious conditions involving an entry in the second derivative matrix and some determinants. In fact, these conditions simply encode the following geometric observation: If the matrix of second derivatives is positive definite, you're at a local minimum. If the matrix of second derivatives is negative definite, you're at a local maximum. Otherwise, you are at neither, a saddle point. You can understand this with the geometric reasoning above in an eigenbasis. The first derivative at a critical point vanishes, so the rates of change of the function here are controlled by the second derivative. Now we can reason geometrically In the first case there are two eigen-directions, and if you move along either the function increases. In the second, two eigen-directions, and if you move in either the function decreases. In the last, there are two eigen-directions, but in one of them the function increases, and in the other it decreases. Since the eigenvectors span the whole space, any other direction is a linear combination of eigen-directions, so the rates of change in those directions are linear combinations of the rates of change in the eigen directions. So in fact, this holds in all directions (this is more or less what it means for a function defined on a higher dimensional space to be differentiable). Now if you draw a little picture in your head, this makes a lot of sense out of something that is quite mysterious in beginner calculus texts. This applies directly to one of your bullet points The quadratic form $\frac 1 2 x^\top Ax-b^\top x +c$ is convex, if $A$ is SPD. Convex is a nice property that can make sure the local solution is global solution The matrix of second derivatives is $A$ everywhere, which is symmetric positive definite. Geometrically, this means that if we move away in any eigen-direction (and hence any direction, because any other is a linear combination of eigen-directions) the function itself will bend away above it's tangent plane. This means the whole surface is convex.
Why are symmetric positive definite (SPD) matrices so important?
A (real) symmetric matrix has a complete set of orthogonal eigenvectors for which the corresponding eigenvalues are are all real numbers. For non-symmetric matrices this can fail. For example, a rot
Why are symmetric positive definite (SPD) matrices so important? A (real) symmetric matrix has a complete set of orthogonal eigenvectors for which the corresponding eigenvalues are are all real numbers. For non-symmetric matrices this can fail. For example, a rotation in two dimensional space has no eigenvector or eigenvalues in the real numbers, you must pass to a vector space over the complex numbers to find them. If the matrix is additionally positive definite, then these eigenvalues are all positive real numbers. This fact is much easier than the first, for if $v$ is an eigenvector with unit length, and $\lambda$ the corresponding eigenvalue, then $$ \lambda = \lambda v^t v = v^t A v > 0 $$ where the last equality uses the definition of positive definiteness. The importance here for intuition is that the eigenvectors and eigenvalues of a linear transformation describe the coordinate system in which the transformation is most easily understood. A linear transformation can be very difficult to understand in a "natural" basis like the standard coordinate system, but each comes with a "preferred" basis of eigenvectors in which the transformation acts as a scaling in all directions. This makes the geometry of the transformation much easier to understand. For example, the second derivative test for the local extrema of a function $R^2 \rightarrow R$ is often given as a series of mysterious conditions involving an entry in the second derivative matrix and some determinants. In fact, these conditions simply encode the following geometric observation: If the matrix of second derivatives is positive definite, you're at a local minimum. If the matrix of second derivatives is negative definite, you're at a local maximum. Otherwise, you are at neither, a saddle point. You can understand this with the geometric reasoning above in an eigenbasis. The first derivative at a critical point vanishes, so the rates of change of the function here are controlled by the second derivative. Now we can reason geometrically In the first case there are two eigen-directions, and if you move along either the function increases. In the second, two eigen-directions, and if you move in either the function decreases. In the last, there are two eigen-directions, but in one of them the function increases, and in the other it decreases. Since the eigenvectors span the whole space, any other direction is a linear combination of eigen-directions, so the rates of change in those directions are linear combinations of the rates of change in the eigen directions. So in fact, this holds in all directions (this is more or less what it means for a function defined on a higher dimensional space to be differentiable). Now if you draw a little picture in your head, this makes a lot of sense out of something that is quite mysterious in beginner calculus texts. This applies directly to one of your bullet points The quadratic form $\frac 1 2 x^\top Ax-b^\top x +c$ is convex, if $A$ is SPD. Convex is a nice property that can make sure the local solution is global solution The matrix of second derivatives is $A$ everywhere, which is symmetric positive definite. Geometrically, this means that if we move away in any eigen-direction (and hence any direction, because any other is a linear combination of eigen-directions) the function itself will bend away above it's tangent plane. This means the whole surface is convex.
Why are symmetric positive definite (SPD) matrices so important? A (real) symmetric matrix has a complete set of orthogonal eigenvectors for which the corresponding eigenvalues are are all real numbers. For non-symmetric matrices this can fail. For example, a rot
7,876
Why are symmetric positive definite (SPD) matrices so important?
With respect to optimization (because you tagged your question with the optimization tag), SPD matrices are extremely important for one simple reason - an SPD Hessian guarantees that the search direction is a descent direction. Consider the derivation of Newton's method for unconstrained optimization. First, we form the Taylor expansion of $f(x + \Delta x)$: $$f(x + \Delta x)\approx f(x) + \Delta x^T \nabla f(x)+ \frac{1}{2} \Delta x^T \nabla^2 f(x) \Delta x$$ Next, we take the derivative with respect to $\Delta x$: $$f'(x + \Delta x)\approx \nabla f(x) + \nabla^2 f(x) \Delta x$$ Finally, set the derivative equal to 0 and solve for $\Delta x$: $$\Delta x = -\nabla^2 f(x)^{-1} \nabla f(x)$$ Assuming $\nabla^2 f(x)$ is SPD, it is easy to see that $\Delta x$ is a descent direction because: $$\nabla f(x)^T \Delta x = -\nabla f(x)^T \nabla^2 f(x)^{-1} \nabla f(x) < 0$$ When using Newton's method, non-SPD Hessian matrices are typically "nudged" to be SPD. There's a neat algorithm called modified Cholesky that will detect a non-SPD Hessian, "nudge" it appropriately in the right direction and factorize the result, all for (essentially) the same cost as a Cholesky factorization. Quasi-Newton methods avoid this problem by forcing the approximate Hessian to be SPD. As an aside, symmetric indefinite systems are receiving a lot of attention these days. They come up in the context of interior point methods for constrained optimization.
Why are symmetric positive definite (SPD) matrices so important?
With respect to optimization (because you tagged your question with the optimization tag), SPD matrices are extremely important for one simple reason - an SPD Hessian guarantees that the search direct
Why are symmetric positive definite (SPD) matrices so important? With respect to optimization (because you tagged your question with the optimization tag), SPD matrices are extremely important for one simple reason - an SPD Hessian guarantees that the search direction is a descent direction. Consider the derivation of Newton's method for unconstrained optimization. First, we form the Taylor expansion of $f(x + \Delta x)$: $$f(x + \Delta x)\approx f(x) + \Delta x^T \nabla f(x)+ \frac{1}{2} \Delta x^T \nabla^2 f(x) \Delta x$$ Next, we take the derivative with respect to $\Delta x$: $$f'(x + \Delta x)\approx \nabla f(x) + \nabla^2 f(x) \Delta x$$ Finally, set the derivative equal to 0 and solve for $\Delta x$: $$\Delta x = -\nabla^2 f(x)^{-1} \nabla f(x)$$ Assuming $\nabla^2 f(x)$ is SPD, it is easy to see that $\Delta x$ is a descent direction because: $$\nabla f(x)^T \Delta x = -\nabla f(x)^T \nabla^2 f(x)^{-1} \nabla f(x) < 0$$ When using Newton's method, non-SPD Hessian matrices are typically "nudged" to be SPD. There's a neat algorithm called modified Cholesky that will detect a non-SPD Hessian, "nudge" it appropriately in the right direction and factorize the result, all for (essentially) the same cost as a Cholesky factorization. Quasi-Newton methods avoid this problem by forcing the approximate Hessian to be SPD. As an aside, symmetric indefinite systems are receiving a lot of attention these days. They come up in the context of interior point methods for constrained optimization.
Why are symmetric positive definite (SPD) matrices so important? With respect to optimization (because you tagged your question with the optimization tag), SPD matrices are extremely important for one simple reason - an SPD Hessian guarantees that the search direct
7,877
Why are symmetric positive definite (SPD) matrices so important?
You'll find some intuition in the many elementary ways of showing the eigenvalues of a real symmetric matrix are all real: https://mathoverflow.net/questions/118626/real-symmetric-matrix-has-real-eigenvalues-elementary-proof/118640#118640 In particular, the quadratic form $x^TAx$ occurs naturally in the Rayleigh quotient, and symmetric matrices provide what's arguably the most natural way of exhibiting a large family of matrices whose eigenvalues are real. See the Courant minimax theorem for example: https://en.wikipedia.org/wiki/Courant_minimax_principle Also symmetric, strictly positive definite matrices are the only set of matrices which can define a non-trivial inner product, along with an induced norm: $d(x,y)=\langle x,Ay\rangle=x^TAy$. This is because by definition for real vectors $x,y$ $d(x,y)=d(y,x)$ for all $x,y$ and $\|x\|^2=x^TAx>0$ for $x\neq 0$. In this way, symmetric positive definite matrices can be viewed as ideal candidates for coordinate transforms. This latter property is absolutely key in the area of support vector machines , specifically kernel methods and the kernel trick, where the kernel must be symmetric positive to induce the right inner product. Indeed Mercer's theorem generalizes the intuitive properties of symmetric matrices to functional spaces.
Why are symmetric positive definite (SPD) matrices so important?
You'll find some intuition in the many elementary ways of showing the eigenvalues of a real symmetric matrix are all real: https://mathoverflow.net/questions/118626/real-symmetric-matrix-has-real-eige
Why are symmetric positive definite (SPD) matrices so important? You'll find some intuition in the many elementary ways of showing the eigenvalues of a real symmetric matrix are all real: https://mathoverflow.net/questions/118626/real-symmetric-matrix-has-real-eigenvalues-elementary-proof/118640#118640 In particular, the quadratic form $x^TAx$ occurs naturally in the Rayleigh quotient, and symmetric matrices provide what's arguably the most natural way of exhibiting a large family of matrices whose eigenvalues are real. See the Courant minimax theorem for example: https://en.wikipedia.org/wiki/Courant_minimax_principle Also symmetric, strictly positive definite matrices are the only set of matrices which can define a non-trivial inner product, along with an induced norm: $d(x,y)=\langle x,Ay\rangle=x^TAy$. This is because by definition for real vectors $x,y$ $d(x,y)=d(y,x)$ for all $x,y$ and $\|x\|^2=x^TAx>0$ for $x\neq 0$. In this way, symmetric positive definite matrices can be viewed as ideal candidates for coordinate transforms. This latter property is absolutely key in the area of support vector machines , specifically kernel methods and the kernel trick, where the kernel must be symmetric positive to induce the right inner product. Indeed Mercer's theorem generalizes the intuitive properties of symmetric matrices to functional spaces.
Why are symmetric positive definite (SPD) matrices so important? You'll find some intuition in the many elementary ways of showing the eigenvalues of a real symmetric matrix are all real: https://mathoverflow.net/questions/118626/real-symmetric-matrix-has-real-eige
7,878
Why are symmetric positive definite (SPD) matrices so important?
Geometrically, a positive definite matrix defines a metric, for instance a Riemannian metric, so we can immediately use geometric concepts. If $x$ and $y$ are vectors and $A$ a positive definite matrix, then $$ d(x,y) = \sqrt{(x-y)^T A (x-y)} $$ is a metric (also called distance function). In addition, positive definite matrices are related to inner product: In $\mathbb{R}^n$, we can define an inner product by $$ \langle x,y \rangle = x^T A y $$ where $A$ as above is positive definite. More, all inner products on $\mathbb{R}^n$ arises in this way.
Why are symmetric positive definite (SPD) matrices so important?
Geometrically, a positive definite matrix defines a metric, for instance a Riemannian metric, so we can immediately use geometric concepts. If $x$ and $y$ are vectors and $A$ a positive definite matri
Why are symmetric positive definite (SPD) matrices so important? Geometrically, a positive definite matrix defines a metric, for instance a Riemannian metric, so we can immediately use geometric concepts. If $x$ and $y$ are vectors and $A$ a positive definite matrix, then $$ d(x,y) = \sqrt{(x-y)^T A (x-y)} $$ is a metric (also called distance function). In addition, positive definite matrices are related to inner product: In $\mathbb{R}^n$, we can define an inner product by $$ \langle x,y \rangle = x^T A y $$ where $A$ as above is positive definite. More, all inner products on $\mathbb{R}^n$ arises in this way.
Why are symmetric positive definite (SPD) matrices so important? Geometrically, a positive definite matrix defines a metric, for instance a Riemannian metric, so we can immediately use geometric concepts. If $x$ and $y$ are vectors and $A$ a positive definite matri
7,879
Why are symmetric positive definite (SPD) matrices so important?
You already cited a bunch of reasons why SPD are important yet you still posted the question. So, it seems to me that you need to answer this question first: Why do positive quantities matter? My answer is that some quantities ought to be positive in order to reconcile with our experiences or models. For instance, the distances between items in the space have to be positive. The coordinates can be negative, but the distances are always non-negative. Hence, if you have a data set and some algorithm that processes it you may well end up with one that breaks down when you feed a negative distance into it. So, you say "my algorithm requires positive distance inputs at all times", and it wouldn't sound like an unreasonable demand. In the context of statistics, a better analogy would be the variance. So, we calculate the variance as $$\sum_i (x_i-\mu)^2/n$$ It's obvious from the definition that if you feed in the real numbers $x_i$ into the equation the output is always non-negative. Hence, you may build algorithms that work with non-negative numbers, and they may be more efficient than algorithm without this restriction. That's the reason we use them. So, variance-covariance matrices are positive semi-definite, i.e. "non-negative" in this analogy. The example of an algorithm that requires this condition is Cholesky decomposition, it's very handy. It's often called a "square root of the matrix". So, like the square root of a real number that requires non-negativity, Cholesky wants non-negative matrices. We don't find this constraining when dealing with covariance matrices because they always are. So, that's my utilitarian answer. The constraints such as non-negativity or SPD allow us build more efficient calculation algorithm or convenient modeling tools that are available when your inputs satisfy these constraints.
Why are symmetric positive definite (SPD) matrices so important?
You already cited a bunch of reasons why SPD are important yet you still posted the question. So, it seems to me that you need to answer this question first: Why do positive quantities matter? My ans
Why are symmetric positive definite (SPD) matrices so important? You already cited a bunch of reasons why SPD are important yet you still posted the question. So, it seems to me that you need to answer this question first: Why do positive quantities matter? My answer is that some quantities ought to be positive in order to reconcile with our experiences or models. For instance, the distances between items in the space have to be positive. The coordinates can be negative, but the distances are always non-negative. Hence, if you have a data set and some algorithm that processes it you may well end up with one that breaks down when you feed a negative distance into it. So, you say "my algorithm requires positive distance inputs at all times", and it wouldn't sound like an unreasonable demand. In the context of statistics, a better analogy would be the variance. So, we calculate the variance as $$\sum_i (x_i-\mu)^2/n$$ It's obvious from the definition that if you feed in the real numbers $x_i$ into the equation the output is always non-negative. Hence, you may build algorithms that work with non-negative numbers, and they may be more efficient than algorithm without this restriction. That's the reason we use them. So, variance-covariance matrices are positive semi-definite, i.e. "non-negative" in this analogy. The example of an algorithm that requires this condition is Cholesky decomposition, it's very handy. It's often called a "square root of the matrix". So, like the square root of a real number that requires non-negativity, Cholesky wants non-negative matrices. We don't find this constraining when dealing with covariance matrices because they always are. So, that's my utilitarian answer. The constraints such as non-negativity or SPD allow us build more efficient calculation algorithm or convenient modeling tools that are available when your inputs satisfy these constraints.
Why are symmetric positive definite (SPD) matrices so important? You already cited a bunch of reasons why SPD are important yet you still posted the question. So, it seems to me that you need to answer this question first: Why do positive quantities matter? My ans
7,880
Why are symmetric positive definite (SPD) matrices so important?
There are already several answers explaining why symmetric positive definite matrices are so important, so I will provide an answer explaining why they are not as important as some people, including the authors of some of those answers, think. For the sake of simplicity, I will limit focus to symmetric matrices, and concentrate on Hessians and optimization. If God had made the world convex, there wouldn't be convex optimization, there would just be optimization. Similarly, there wouldn't be (symmetric) positive definite matrices, there would just be (symmetric) matrices. But that's not the case, so deal with it. If a Quadratic Programming problem is convex, it can be solved "easily". If it is non-convex, a global optimum can still be found using branch and bound methods (but it may take longer and more memory). If a Newton method is used for optimization and the Hessian at some iterate is indefinite, then it is not necessary to "finagle" it to positive definiteness. If using a line search, directions of negative curvature can be found and the line search executed along them, and if using a trust region, then there is some small enough trust region such that the solution of the trust region problem achieves descent. As for Quasi-Newton methods, BFGS (damped if the problem is constrained) and DFP maintain positive definiteness of the Hessian or inverse Hessian approximation. Other Quasi-Newton methods, such as SR1 (Symmetric Rank One) do not necessarily maintain positive definiteness. Before you get all bent out of shape over that, that is a good reason for choosing SR1 for many problems - if the Hessian really isn't positive definite along the path to the optimum, then forcing the Quasi-Newton approximation to be positive definite may result in a lousy quadratic approximation to the objective function. By contrast, the SR1 updating method is "loose as a goose", and can writhely morph its definiteness as it proceeds along. For nonlinearly constrained optimization problems, what really matters is not the Hessian of the objective function, but the Hessian of the Lagrangian. The Hessian of the Lagrangian may be indefinite even at an (the) optimum, and indeed, it is only the projection of the Hessian of the Lagrangian into the nullspace of the Jacobian of the active (linear and nonlinear) constraints which need be positive semi-definite at the optimum. If you model the Hessian of the Lagrangian via BFGS and thereby constrain it to be positive definite, it might be a terrible fit everywhere, and not work well. By contrast, SR1 can adapt its eigenvalues to what it actually "sees". There's much more that I could say about all of this, but this is enough to give you a flavor. Edit: What I wrote 2 paragraphs up is correct. However, I forgot to point out that it also applies to linearly constrained problems. In the case of linearly constrained problems, the Hessian of the Lagrangian is just (reduces down to) the Hessian of the objective function. So the 2nd order optimality condition for a local minimum is that the projection of the Hessian of the objective function into the nullspace of the Jacobian of the active constraints is positive semi-definite. Most notably, the Hessian of the objective function need not (necessarily) be psd at the optimum, and often isn't, even on linearly constrained problems.
Why are symmetric positive definite (SPD) matrices so important?
There are already several answers explaining why symmetric positive definite matrices are so important, so I will provide an answer explaining why they are not as important as some people, including t
Why are symmetric positive definite (SPD) matrices so important? There are already several answers explaining why symmetric positive definite matrices are so important, so I will provide an answer explaining why they are not as important as some people, including the authors of some of those answers, think. For the sake of simplicity, I will limit focus to symmetric matrices, and concentrate on Hessians and optimization. If God had made the world convex, there wouldn't be convex optimization, there would just be optimization. Similarly, there wouldn't be (symmetric) positive definite matrices, there would just be (symmetric) matrices. But that's not the case, so deal with it. If a Quadratic Programming problem is convex, it can be solved "easily". If it is non-convex, a global optimum can still be found using branch and bound methods (but it may take longer and more memory). If a Newton method is used for optimization and the Hessian at some iterate is indefinite, then it is not necessary to "finagle" it to positive definiteness. If using a line search, directions of negative curvature can be found and the line search executed along them, and if using a trust region, then there is some small enough trust region such that the solution of the trust region problem achieves descent. As for Quasi-Newton methods, BFGS (damped if the problem is constrained) and DFP maintain positive definiteness of the Hessian or inverse Hessian approximation. Other Quasi-Newton methods, such as SR1 (Symmetric Rank One) do not necessarily maintain positive definiteness. Before you get all bent out of shape over that, that is a good reason for choosing SR1 for many problems - if the Hessian really isn't positive definite along the path to the optimum, then forcing the Quasi-Newton approximation to be positive definite may result in a lousy quadratic approximation to the objective function. By contrast, the SR1 updating method is "loose as a goose", and can writhely morph its definiteness as it proceeds along. For nonlinearly constrained optimization problems, what really matters is not the Hessian of the objective function, but the Hessian of the Lagrangian. The Hessian of the Lagrangian may be indefinite even at an (the) optimum, and indeed, it is only the projection of the Hessian of the Lagrangian into the nullspace of the Jacobian of the active (linear and nonlinear) constraints which need be positive semi-definite at the optimum. If you model the Hessian of the Lagrangian via BFGS and thereby constrain it to be positive definite, it might be a terrible fit everywhere, and not work well. By contrast, SR1 can adapt its eigenvalues to what it actually "sees". There's much more that I could say about all of this, but this is enough to give you a flavor. Edit: What I wrote 2 paragraphs up is correct. However, I forgot to point out that it also applies to linearly constrained problems. In the case of linearly constrained problems, the Hessian of the Lagrangian is just (reduces down to) the Hessian of the objective function. So the 2nd order optimality condition for a local minimum is that the projection of the Hessian of the objective function into the nullspace of the Jacobian of the active constraints is positive semi-definite. Most notably, the Hessian of the objective function need not (necessarily) be psd at the optimum, and often isn't, even on linearly constrained problems.
Why are symmetric positive definite (SPD) matrices so important? There are already several answers explaining why symmetric positive definite matrices are so important, so I will provide an answer explaining why they are not as important as some people, including t
7,881
Why are symmetric positive definite (SPD) matrices so important?
Here are two more reasons which haven't been mentioned for why positive-semidefinite matrices are important: The graph Laplacian matrix is diagonally dominant and thus PSD. Positive semidefiniteness defines a partial order on the set of symmetric matrices (this is the foundation of semidefinite programming).
Why are symmetric positive definite (SPD) matrices so important?
Here are two more reasons which haven't been mentioned for why positive-semidefinite matrices are important: The graph Laplacian matrix is diagonally dominant and thus PSD. Positive semidefiniteness
Why are symmetric positive definite (SPD) matrices so important? Here are two more reasons which haven't been mentioned for why positive-semidefinite matrices are important: The graph Laplacian matrix is diagonally dominant and thus PSD. Positive semidefiniteness defines a partial order on the set of symmetric matrices (this is the foundation of semidefinite programming).
Why are symmetric positive definite (SPD) matrices so important? Here are two more reasons which haven't been mentioned for why positive-semidefinite matrices are important: The graph Laplacian matrix is diagonally dominant and thus PSD. Positive semidefiniteness
7,882
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is not symmetrical?
Consider discrete distributions. One that is supported on $k$ values $x_1, x_2,\ldots, x_k$ is determined by non-negative probabilities $p_1, p_2,\ldots, p_k$ subject to the conditions that (a) they sum to 1 and (b) the skewness coefficient equals 0 (which is equivalent to the third central moment being zero). That leaves $k-2$ degrees of freedom (in the equation-solving sense, not the statistical one!). We can hope to find solutions that are unimodal. To make the search for examples easier, I sought solutions supported on a small symmetrical vector $\mathbf{x}=(-3,-2,-1,0,1,2,3)$ with a unique mode at $0$, zero mean, and zero skewness. One such solution is $(p_1, \ldots, p_7) = (1396, 3286, 9586, 47386, 8781, 3930, 1235)/75600$. You can see it is asymmetric. Here's a more obviously asymmetric solution with $\mathbf{x} = (-3,-1,0,1,2)$ (which is asymmetric) and $p = (1,18, 72, 13, 4)/108$: Now it's obvious what's going on: because the mean equals $0$, the negative values contribute $(-3)^3=-27$ and $18 \times (-1)^3=-18$ to the third moment while the positive values contribute $4\times 2^3 = 32$ and $13 \times 1^3 = 13$, exactly balancing the negative contributions. We can take a symmetric distribution about $0$, such as $\mathbf{x}=(-1,0,1)$ with $\mathbf{p}=(1,4,1)/6$, and shift a little mass from $+1$ to $+2$, a little mass from $+1$ down to $-1$, and a slight amount of mass down to $-3$, keeping the mean at $0$ and the skewness at $0$ as well, while creating an asymmetry. The same approach will work to maintain zero mean and zero skewness of a continuous distribution while making it asymmetric; if we're not too aggressive with the mass shifting, it will remain unimodal. Edit: Continuous Distributions Because the issue keeps coming up, let's give an explicit example with continuous distributions. Peter Flom had a good idea: look at mixtures of normals. A mixture of two normals won't do: when its skewness vanishes, it will be symmetric. The next simplest case is a mixture of three normals. Mixtures of three normals, after an appropriate choice of location and scale, depend on six real parameters and therefore should have more than enough flexibility to produce an asymmetric, zero-skewness solution. To find some, we need to know how to compute skewnesses of mixtures of normals. Among these, we will search for any that are unimodal (it is possible there are none). Now, in general, the $r^\text{th}$ (non-central) moment of a standard normal distribution is zero when $r$ is odd and otherwise equals $2^{r/2}\Gamma\left(\frac{1-r}{2}\right)/\sqrt{\pi}$. When we rescale that standard normal distribution to have a standard deviation of $\sigma$, the $r^\text{th}$ moment is multiplied by $\sigma^r$. When we shift any distribution by $\mu$, the new $r^\text{th}$ moment can be expressed in terms of moments up to and including $r$. The moment of a mixture of distributions (that is, a weighted average of them) is the same weighted average of the individual moments. Finally, the skewness is zero exactly when the third central moment is zero, and this is readily computed in terms of the first three moments. This gives us an algebraic attack on the problem. One solution I found is an equal mixture of three normals with parameters $(\mu, \sigma)$ equal to $(0,1)$, $(1/2,1)$, and $(0, \sqrt{127/18}) \approx (0, 2.65623)$. Its mean equals $(0 + 1/2 + 0)/3 = 1/6$. This image shows the pdf in blue and the pdf of the distribution flipped about its mean in red. That they differ shows they are both asymmetric. (The mode is approximately $0.0519216$, unequal to the mean of $1/6$.) They both have zero skewness by construction. The plots indicate these are unimodal. (You can check using Calculus to find local maxima.)
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is n
Consider discrete distributions. One that is supported on $k$ values $x_1, x_2,\ldots, x_k$ is determined by non-negative probabilities $p_1, p_2,\ldots, p_k$ subject to the conditions that (a) they
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is not symmetrical? Consider discrete distributions. One that is supported on $k$ values $x_1, x_2,\ldots, x_k$ is determined by non-negative probabilities $p_1, p_2,\ldots, p_k$ subject to the conditions that (a) they sum to 1 and (b) the skewness coefficient equals 0 (which is equivalent to the third central moment being zero). That leaves $k-2$ degrees of freedom (in the equation-solving sense, not the statistical one!). We can hope to find solutions that are unimodal. To make the search for examples easier, I sought solutions supported on a small symmetrical vector $\mathbf{x}=(-3,-2,-1,0,1,2,3)$ with a unique mode at $0$, zero mean, and zero skewness. One such solution is $(p_1, \ldots, p_7) = (1396, 3286, 9586, 47386, 8781, 3930, 1235)/75600$. You can see it is asymmetric. Here's a more obviously asymmetric solution with $\mathbf{x} = (-3,-1,0,1,2)$ (which is asymmetric) and $p = (1,18, 72, 13, 4)/108$: Now it's obvious what's going on: because the mean equals $0$, the negative values contribute $(-3)^3=-27$ and $18 \times (-1)^3=-18$ to the third moment while the positive values contribute $4\times 2^3 = 32$ and $13 \times 1^3 = 13$, exactly balancing the negative contributions. We can take a symmetric distribution about $0$, such as $\mathbf{x}=(-1,0,1)$ with $\mathbf{p}=(1,4,1)/6$, and shift a little mass from $+1$ to $+2$, a little mass from $+1$ down to $-1$, and a slight amount of mass down to $-3$, keeping the mean at $0$ and the skewness at $0$ as well, while creating an asymmetry. The same approach will work to maintain zero mean and zero skewness of a continuous distribution while making it asymmetric; if we're not too aggressive with the mass shifting, it will remain unimodal. Edit: Continuous Distributions Because the issue keeps coming up, let's give an explicit example with continuous distributions. Peter Flom had a good idea: look at mixtures of normals. A mixture of two normals won't do: when its skewness vanishes, it will be symmetric. The next simplest case is a mixture of three normals. Mixtures of three normals, after an appropriate choice of location and scale, depend on six real parameters and therefore should have more than enough flexibility to produce an asymmetric, zero-skewness solution. To find some, we need to know how to compute skewnesses of mixtures of normals. Among these, we will search for any that are unimodal (it is possible there are none). Now, in general, the $r^\text{th}$ (non-central) moment of a standard normal distribution is zero when $r$ is odd and otherwise equals $2^{r/2}\Gamma\left(\frac{1-r}{2}\right)/\sqrt{\pi}$. When we rescale that standard normal distribution to have a standard deviation of $\sigma$, the $r^\text{th}$ moment is multiplied by $\sigma^r$. When we shift any distribution by $\mu$, the new $r^\text{th}$ moment can be expressed in terms of moments up to and including $r$. The moment of a mixture of distributions (that is, a weighted average of them) is the same weighted average of the individual moments. Finally, the skewness is zero exactly when the third central moment is zero, and this is readily computed in terms of the first three moments. This gives us an algebraic attack on the problem. One solution I found is an equal mixture of three normals with parameters $(\mu, \sigma)$ equal to $(0,1)$, $(1/2,1)$, and $(0, \sqrt{127/18}) \approx (0, 2.65623)$. Its mean equals $(0 + 1/2 + 0)/3 = 1/6$. This image shows the pdf in blue and the pdf of the distribution flipped about its mean in red. That they differ shows they are both asymmetric. (The mode is approximately $0.0519216$, unequal to the mean of $1/6$.) They both have zero skewness by construction. The plots indicate these are unimodal. (You can check using Calculus to find local maxima.)
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is n Consider discrete distributions. One that is supported on $k$ values $x_1, x_2,\ldots, x_k$ is determined by non-negative probabilities $p_1, p_2,\ldots, p_k$ subject to the conditions that (a) they
7,883
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is not symmetrical?
Here is one I found at https://www.qualitydigest.com/inside/quality-insider-article/problems-skewness-and-kurtosis-part-one.html# which I find nice and reproduced in R: an inverse Burr or Dagum distribution with shape parameters $k=0.0629$ and $c=18.1484$: $$g(x) = ckx^{-(c+1)}[1+x^{-c}]^{-(k+1)}$$ It has mean 0.5387, standard deviation 0.2907, skewness 0.0000, and kurtosis 2.0000. The source also calls it the "elephant distribution": My reproduction in R was created with library(actuar) library(knotR) # a nonsymmetric distribution with zero skewness # see https://www.qualitydigest.com/inside/quality-insider-article/problems-skewness-and-kurtosis-part-one.html# c <- 18.1484 k <- 0.0629 x <- seq(0,1.5,by=.0001) elephant.density <- dinvburr(x, k, c) plot(x,elephant.density, type="l") polygon(c(min(x),x),c(min(elephant.density),elephant.density), col="grey") points(0.8,0.8, pch=19, cex=2) # "ears" created via https://www.desmos.com/calculator/cahqdxeshd ear.x <- c(0.686, 0.501, 0.42, 0.68) ear.y <- c(0.698, 0.315, 1.095, 0.983) myseg(bezier(cbind(ear.x, ear.y)), type="l") EX <- gamma(k+1/c)*gamma(1-1/c)/gamma(k) # see p6 of https://wwz.unibas.ch/uploads/tx_x4epublication/23_07.pdf EX2 <- gamma(k+2/c)*gamma(1-2/c)/gamma(k) EX3 <- gamma(k+3/c)*gamma(1-3/c)/gamma(k) (skewness <- (EX3 - 3*EX*(EX2-EX^2)-EX^3)/(EX2-EX^2)^(3/2)) # zero to three digits: 0.0003756196 As this output shows, skewness is not quite zero to four digits for these parameter values. Here is a little optimizer for $k$ and $c$: # optimize skewness a bit further skewval <- 1 while (skewval > 10^(-10)){ optskew.k <- uniroot(skewness.fun, lower = k*.95, upper = k*1.1, tol=skewval^2, c=c) skewval <- optskew.k$f.root k <- optskew.k$root optskew.c <- uniroot(skewness.fun, lower = c*.95, upper = c*1.1, tol=skewval^2, k=k) skewval <- optskew.c$f.root c <- optskew.c$root } yielding > print(c) [1] 18.89306 > print(k) [1] 0.05975542 > print(skewval) [1] -1.131464e-15
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is n
Here is one I found at https://www.qualitydigest.com/inside/quality-insider-article/problems-skewness-and-kurtosis-part-one.html# which I find nice and reproduced in R: an inverse Burr or Dagum distri
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is not symmetrical? Here is one I found at https://www.qualitydigest.com/inside/quality-insider-article/problems-skewness-and-kurtosis-part-one.html# which I find nice and reproduced in R: an inverse Burr or Dagum distribution with shape parameters $k=0.0629$ and $c=18.1484$: $$g(x) = ckx^{-(c+1)}[1+x^{-c}]^{-(k+1)}$$ It has mean 0.5387, standard deviation 0.2907, skewness 0.0000, and kurtosis 2.0000. The source also calls it the "elephant distribution": My reproduction in R was created with library(actuar) library(knotR) # a nonsymmetric distribution with zero skewness # see https://www.qualitydigest.com/inside/quality-insider-article/problems-skewness-and-kurtosis-part-one.html# c <- 18.1484 k <- 0.0629 x <- seq(0,1.5,by=.0001) elephant.density <- dinvburr(x, k, c) plot(x,elephant.density, type="l") polygon(c(min(x),x),c(min(elephant.density),elephant.density), col="grey") points(0.8,0.8, pch=19, cex=2) # "ears" created via https://www.desmos.com/calculator/cahqdxeshd ear.x <- c(0.686, 0.501, 0.42, 0.68) ear.y <- c(0.698, 0.315, 1.095, 0.983) myseg(bezier(cbind(ear.x, ear.y)), type="l") EX <- gamma(k+1/c)*gamma(1-1/c)/gamma(k) # see p6 of https://wwz.unibas.ch/uploads/tx_x4epublication/23_07.pdf EX2 <- gamma(k+2/c)*gamma(1-2/c)/gamma(k) EX3 <- gamma(k+3/c)*gamma(1-3/c)/gamma(k) (skewness <- (EX3 - 3*EX*(EX2-EX^2)-EX^3)/(EX2-EX^2)^(3/2)) # zero to three digits: 0.0003756196 As this output shows, skewness is not quite zero to four digits for these parameter values. Here is a little optimizer for $k$ and $c$: # optimize skewness a bit further skewval <- 1 while (skewval > 10^(-10)){ optskew.k <- uniroot(skewness.fun, lower = k*.95, upper = k*1.1, tol=skewval^2, c=c) skewval <- optskew.k$f.root k <- optskew.k$root optskew.c <- uniroot(skewness.fun, lower = c*.95, upper = c*1.1, tol=skewval^2, k=k) skewval <- optskew.c$f.root c <- optskew.c$root } yielding > print(c) [1] 18.89306 > print(k) [1] 0.05975542 > print(skewval) [1] -1.131464e-15
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is n Here is one I found at https://www.qualitydigest.com/inside/quality-insider-article/problems-skewness-and-kurtosis-part-one.html# which I find nice and reproduced in R: an inverse Burr or Dagum distri
7,884
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is not symmetrical?
Consider a distribution on the positive half of the real line which increases linearly from 0 to the mode and then is exponential to the right of the mode, but is continuous at the mode. This could be called a triangular-exponential distribution (though it does often look a bit like a shark fin). Let $\theta$ be the location of the mode and $\lambda$ be the rate parameter of the exponential. As $\lambda\theta$ increases the distribution becomes progressively less skew. As $\lambda\theta$ increases past $\approx 6.15$ the third moment crosses from positive to negative: Brizzi (2006)$^{[1]}$ refers to this family of distributions as the "two-face" distribution, and discusses this crossover point where the third-moment-skewness is zero. von Hippel (2005)$^{[2]}$ presents an example that's almost at that crossover point here The thread Non-normal distributions with zero skewness and zero excess kurtosis? has some asymmetric examples, including a small discrete example and another continuous unimodal one: Discrete unimodal distributions - or equivalently, samples - with zero skewness are quite easy to construct, of large or small size. Here's an example, which you can treat as a sample or (by dividing the raw frequencies by 3000) as a pmf (the 'x' values are the values taken, the 'n' are the number of times that value occurs in the sample): x: -2 -1 0 1 2 3 4 5 6 7 8 9 10 n: 496 498 562 1434 2 1 1 1 1 1 1 1 1 This example is built up from 3-point distributions: x: -2 1 c n: c(c-1)(c+1)/6 c(c-1)(c+1)/3 - c 1 across various values of $c$ between 3 and 10. This parameterized (by $c$) 3-point "atom" has $\sum_i n_ix_i =0$ and $\sum_i n_ix_i^3 =0$, which in turn means that mixtures across various choices of $c$ have zero skewness. (You can't make anything smaller than a distribution across three points that has asymmetry and third central moment zero. A collection of simple pieces over only a few points, such as these make neat building blocks from which larger structures may be made.) There are all manner of other such "atoms" one can construct, but this example uses only this one kind. To some combination of atoms such as these is added a few symmetrically placed values to fill in remaining holes and guarantee unimodality without destroying the structure of mean and third moment. $[1]$ Brizzi, M. (2006), "A Skewed Model Combining Triangular and Exponential Features: The Two-faced Distribution and its Statistical Properties" Austrian Journal of Statistics, 35:4, p455–462 http://www.stat.tugraz.at/AJS/ausg064/ $[2]$ von Hippel, P. T. (2005), "Mean, Median, and Skew: Correcting a Textbook Rule" Journal of Statistics Education Volume 13, Number 2, http://ww2.amstat.org/publications/jse/v13n2/vonhippel.html
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is n
Consider a distribution on the positive half of the real line which increases linearly from 0 to the mode and then is exponential to the right of the mode, but is continuous at the mode. This could be
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is not symmetrical? Consider a distribution on the positive half of the real line which increases linearly from 0 to the mode and then is exponential to the right of the mode, but is continuous at the mode. This could be called a triangular-exponential distribution (though it does often look a bit like a shark fin). Let $\theta$ be the location of the mode and $\lambda$ be the rate parameter of the exponential. As $\lambda\theta$ increases the distribution becomes progressively less skew. As $\lambda\theta$ increases past $\approx 6.15$ the third moment crosses from positive to negative: Brizzi (2006)$^{[1]}$ refers to this family of distributions as the "two-face" distribution, and discusses this crossover point where the third-moment-skewness is zero. von Hippel (2005)$^{[2]}$ presents an example that's almost at that crossover point here The thread Non-normal distributions with zero skewness and zero excess kurtosis? has some asymmetric examples, including a small discrete example and another continuous unimodal one: Discrete unimodal distributions - or equivalently, samples - with zero skewness are quite easy to construct, of large or small size. Here's an example, which you can treat as a sample or (by dividing the raw frequencies by 3000) as a pmf (the 'x' values are the values taken, the 'n' are the number of times that value occurs in the sample): x: -2 -1 0 1 2 3 4 5 6 7 8 9 10 n: 496 498 562 1434 2 1 1 1 1 1 1 1 1 This example is built up from 3-point distributions: x: -2 1 c n: c(c-1)(c+1)/6 c(c-1)(c+1)/3 - c 1 across various values of $c$ between 3 and 10. This parameterized (by $c$) 3-point "atom" has $\sum_i n_ix_i =0$ and $\sum_i n_ix_i^3 =0$, which in turn means that mixtures across various choices of $c$ have zero skewness. (You can't make anything smaller than a distribution across three points that has asymmetry and third central moment zero. A collection of simple pieces over only a few points, such as these make neat building blocks from which larger structures may be made.) There are all manner of other such "atoms" one can construct, but this example uses only this one kind. To some combination of atoms such as these is added a few symmetrically placed values to fill in remaining holes and guarantee unimodality without destroying the structure of mean and third moment. $[1]$ Brizzi, M. (2006), "A Skewed Model Combining Triangular and Exponential Features: The Two-faced Distribution and its Statistical Properties" Austrian Journal of Statistics, 35:4, p455–462 http://www.stat.tugraz.at/AJS/ausg064/ $[2]$ von Hippel, P. T. (2005), "Mean, Median, and Skew: Correcting a Textbook Rule" Journal of Statistics Education Volume 13, Number 2, http://ww2.amstat.org/publications/jse/v13n2/vonhippel.html
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is n Consider a distribution on the positive half of the real line which increases linearly from 0 to the mode and then is exponential to the right of the mode, but is continuous at the mode. This could be
7,885
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is not symmetrical?
For zero skewness, we need $$ \operatorname{E}\Big[\big(\tfrac{X-\mu}{\sigma}\big)^{\!3}\, \Big] = 0 $$ or, equivalently, $$ \operatorname{E}\Big[\big(\tfrac{X-\mu}{\sigma}\big)^{\!3}\, \Big | X \leq \mu \Big] + \operatorname{E}\Big[\big(\tfrac{X-\mu}{\sigma}\big)^{\!3}\, \Big | X \gt \mu \Big] = 0. $$ Now, for given mean and variance, pick any two distributions $Y$ and $Z$ with zero mass on the right side of $\mu$ and $$ \operatorname{E}\Big[\big(\tfrac{Y-\mu}{\sigma}\big)^{\!3}\, \Big] = \operatorname{E}\Big[\big(\tfrac{Z-\mu}{\sigma}\big)^{\!3}\, \Big] $$ and define $X$ to match $Y$ if left of $\mu$ and $(\mu - Z)$ otherwise. (Don't know the exact notation for this, anyone care to help?) The resulting distribution will be unimodal if the PDFs of $Y$ and $Z$ are increasing at the left of $\mu$ (in addition to being zero at the right of $\mu$).
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is n
For zero skewness, we need $$ \operatorname{E}\Big[\big(\tfrac{X-\mu}{\sigma}\big)^{\!3}\, \Big] = 0 $$ or, equivalently, $$ \operatorname{E}\Big[\big(\tfrac{X-\mu}{\sigma}\big)^{\!3}\, \Big | X \l
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is not symmetrical? For zero skewness, we need $$ \operatorname{E}\Big[\big(\tfrac{X-\mu}{\sigma}\big)^{\!3}\, \Big] = 0 $$ or, equivalently, $$ \operatorname{E}\Big[\big(\tfrac{X-\mu}{\sigma}\big)^{\!3}\, \Big | X \leq \mu \Big] + \operatorname{E}\Big[\big(\tfrac{X-\mu}{\sigma}\big)^{\!3}\, \Big | X \gt \mu \Big] = 0. $$ Now, for given mean and variance, pick any two distributions $Y$ and $Z$ with zero mass on the right side of $\mu$ and $$ \operatorname{E}\Big[\big(\tfrac{Y-\mu}{\sigma}\big)^{\!3}\, \Big] = \operatorname{E}\Big[\big(\tfrac{Z-\mu}{\sigma}\big)^{\!3}\, \Big] $$ and define $X$ to match $Y$ if left of $\mu$ and $(\mu - Z)$ otherwise. (Don't know the exact notation for this, anyone care to help?) The resulting distribution will be unimodal if the PDFs of $Y$ and $Z$ are increasing at the left of $\mu$ (in addition to being zero at the right of $\mu$).
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is n For zero skewness, we need $$ \operatorname{E}\Big[\big(\tfrac{X-\mu}{\sigma}\big)^{\!3}\, \Big] = 0 $$ or, equivalently, $$ \operatorname{E}\Big[\big(\tfrac{X-\mu}{\sigma}\big)^{\!3}\, \Big | X \l
7,886
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is not symmetrical?
The following discrete distribution is asymmetric and has null skewness: Prob(-4)=1/3, Prob(1)=1/2, Prob(5)=1/6. I found it in the paper of Doric et al., Qual Quant (2009) 43:481-493; DOI 10.1007/s11135-007-9128-9
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is n
The following discrete distribution is asymmetric and has null skewness: Prob(-4)=1/3, Prob(1)=1/2, Prob(5)=1/6. I found it in the paper of Doric et al., Qual Quant (2009) 43:481-493; DOI 10.1007/s111
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is not symmetrical? The following discrete distribution is asymmetric and has null skewness: Prob(-4)=1/3, Prob(1)=1/2, Prob(5)=1/6. I found it in the paper of Doric et al., Qual Quant (2009) 43:481-493; DOI 10.1007/s11135-007-9128-9
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is n The following discrete distribution is asymmetric and has null skewness: Prob(-4)=1/3, Prob(1)=1/2, Prob(5)=1/6. I found it in the paper of Doric et al., Qual Quant (2009) 43:481-493; DOI 10.1007/s111
7,887
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is not symmetrical?
Sure. Try this: skew= function (x, na.rm = FALSE) { if (na.rm) x <- x[!is.na(x)] #remove missing values sum((x - mean(x))^3)/(length(x) * sd(x)^3) #calculate skew } set.seed(12929883) x = c(rnorm(100, 1, .1), rnorm(100, 3.122, .1), rnorm(100,5, .1), rnorm(100, 4, .1), rnorm(100,1.1, .1)) skew(x) plot(density(x)) (You did the hard stuff already!)
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is n
Sure. Try this: skew= function (x, na.rm = FALSE) { if (na.rm) x <- x[!is.na(x)] #remove missing values sum((x - mean(x))^3)/(length(x) * sd(x)^3) #calculate skew } set.
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is not symmetrical? Sure. Try this: skew= function (x, na.rm = FALSE) { if (na.rm) x <- x[!is.na(x)] #remove missing values sum((x - mean(x))^3)/(length(x) * sd(x)^3) #calculate skew } set.seed(12929883) x = c(rnorm(100, 1, .1), rnorm(100, 3.122, .1), rnorm(100,5, .1), rnorm(100, 4, .1), rnorm(100,1.1, .1)) skew(x) plot(density(x)) (You did the hard stuff already!)
Can somebody offer an example of a unimodal distribution which has a skewness of zero but which is n Sure. Try this: skew= function (x, na.rm = FALSE) { if (na.rm) x <- x[!is.na(x)] #remove missing values sum((x - mean(x))^3)/(length(x) * sd(x)^3) #calculate skew } set.
7,888
finding p-value in pearson correlation in R
you can use cor.test : col1 = c(1,2,3,4) col2 = c(1,4,3,5) cor.test(col1,col2) which gives : # Pearson's product-moment correlation # data: col1 and col2 # t = 2.117, df = 2, p-value = 0.1685 # alternative hypothesis: true correlation is not equal to 0 # 95 percent confidence interval: # -0.6451325 0.9963561 # sample estimates: # cor # 0.8315218 More information about the statistics and extra parameters at the official page: https://stat.ethz.ch/R-manual/R-patched/library/stats/html/cor.test.html
finding p-value in pearson correlation in R
you can use cor.test : col1 = c(1,2,3,4) col2 = c(1,4,3,5) cor.test(col1,col2) which gives : # Pearson's product-moment correlation # data: col1 and col2 # t = 2.117, df = 2, p-value = 0.16
finding p-value in pearson correlation in R you can use cor.test : col1 = c(1,2,3,4) col2 = c(1,4,3,5) cor.test(col1,col2) which gives : # Pearson's product-moment correlation # data: col1 and col2 # t = 2.117, df = 2, p-value = 0.1685 # alternative hypothesis: true correlation is not equal to 0 # 95 percent confidence interval: # -0.6451325 0.9963561 # sample estimates: # cor # 0.8315218 More information about the statistics and extra parameters at the official page: https://stat.ethz.ch/R-manual/R-patched/library/stats/html/cor.test.html
finding p-value in pearson correlation in R you can use cor.test : col1 = c(1,2,3,4) col2 = c(1,4,3,5) cor.test(col1,col2) which gives : # Pearson's product-moment correlation # data: col1 and col2 # t = 2.117, df = 2, p-value = 0.16
7,889
finding p-value in pearson correlation in R
If you want only the P value: > cor.test(col1,col2)$p.value [1] 0.1684782
finding p-value in pearson correlation in R
If you want only the P value: > cor.test(col1,col2)$p.value [1] 0.1684782
finding p-value in pearson correlation in R If you want only the P value: > cor.test(col1,col2)$p.value [1] 0.1684782
finding p-value in pearson correlation in R If you want only the P value: > cor.test(col1,col2)$p.value [1] 0.1684782
7,890
finding p-value in pearson correlation in R
The following will do as you ask: library(Hmisc) # You need to download it first. rcorr(x, type="pearson") # type can be pearson or spearman Here x is a data frame, and rcorr returns every correlation which it is possible to form from the "x" data frame. Or you could calculate the statistic yourself: $$ t = \frac{\hat{\rho}}{\sqrt{\frac{1-\hat{\rho}^2}{n-2}}} $$ Where $\hat{\rho}$ is the pearson correlation estimated from the data, and n is the sample size.
finding p-value in pearson correlation in R
The following will do as you ask: library(Hmisc) # You need to download it first. rcorr(x, type="pearson") # type can be pearson or spearman Here x is a data frame, and rcorr returns every correlat
finding p-value in pearson correlation in R The following will do as you ask: library(Hmisc) # You need to download it first. rcorr(x, type="pearson") # type can be pearson or spearman Here x is a data frame, and rcorr returns every correlation which it is possible to form from the "x" data frame. Or you could calculate the statistic yourself: $$ t = \frac{\hat{\rho}}{\sqrt{\frac{1-\hat{\rho}^2}{n-2}}} $$ Where $\hat{\rho}$ is the pearson correlation estimated from the data, and n is the sample size.
finding p-value in pearson correlation in R The following will do as you ask: library(Hmisc) # You need to download it first. rcorr(x, type="pearson") # type can be pearson or spearman Here x is a data frame, and rcorr returns every correlat
7,891
Can anyone clarify the concept of a "sum of random variables"
A physical, intuitive model of a random variable is to write down the name of every member of a population on one or more slips of paper--"tickets"--and put those tickets into a box. The process of thoroughly mixing the contents of the box, followed by blindly pulling out one ticket--exactly as in a lottery--models randomness. Non-uniform probabilities are modeled by introducing variable numbers of tickets in the box: more tickets for the more probable members, fewer for the less probable. A random variable is a number associated with each member of the population. (Therefore, for consistency, every ticket for a given member has to have the same number written on it.) Multiple random variables are modeled by reserving spaces on the tickets for more than one number. We usually give those spaces names like $X,$ $Y,$ and $Z$. The sum of those random variables is the usual sum: reserve a new space on every ticket for the sum, read off the values of $X,$ $Y,$ etc. on each ticket, and write their sum in that new space. This is a consistent way of writing numbers on the tickets, so it's another random variable. This figure portrays a box representing a population $\Omega=\{\alpha,\beta,\gamma\}$ and three random variables $X$, $Y$, and $X+Y$. It contains six tickets: the three for $\alpha$ (blue) give it a probability of $3/6$, the two for $\beta$ (yellow) give it a probability of $2/6$, and the one for $\gamma$ (green) give it a probability of $1/6$. In order to display what is written on the tickets, they are shown before being mixed. The beauty of this approach is that all the paradoxical parts of the question turn out to be correct: the sum of random variables is indeed a single, definite number (for each member of the population), yet it also leads to a distribution (given by the frequencies with which the sum appears in the box), and it still effectively models a random process (because the tickets are still blindly drawn from the box). In this fashion the sum can simultaneously have a definite value (given by the rules of addition as applied to numbers on each of the tickets) while the realization--which will be a ticket drawn from the box--does not have a value until it is carried out. This physical model of drawing tickets from a box is adopted in the theoretical literature and made rigorous with the definitions of sample space (the population), sigma algebras (with their associated probability measures), and random variables as measurable functions defined on the sample space. This account of random variables is elaborated, with realistic examples, at "What is meant by a random variable?".
Can anyone clarify the concept of a "sum of random variables"
A physical, intuitive model of a random variable is to write down the name of every member of a population on one or more slips of paper--"tickets"--and put those tickets into a box. The process of th
Can anyone clarify the concept of a "sum of random variables" A physical, intuitive model of a random variable is to write down the name of every member of a population on one or more slips of paper--"tickets"--and put those tickets into a box. The process of thoroughly mixing the contents of the box, followed by blindly pulling out one ticket--exactly as in a lottery--models randomness. Non-uniform probabilities are modeled by introducing variable numbers of tickets in the box: more tickets for the more probable members, fewer for the less probable. A random variable is a number associated with each member of the population. (Therefore, for consistency, every ticket for a given member has to have the same number written on it.) Multiple random variables are modeled by reserving spaces on the tickets for more than one number. We usually give those spaces names like $X,$ $Y,$ and $Z$. The sum of those random variables is the usual sum: reserve a new space on every ticket for the sum, read off the values of $X,$ $Y,$ etc. on each ticket, and write their sum in that new space. This is a consistent way of writing numbers on the tickets, so it's another random variable. This figure portrays a box representing a population $\Omega=\{\alpha,\beta,\gamma\}$ and three random variables $X$, $Y$, and $X+Y$. It contains six tickets: the three for $\alpha$ (blue) give it a probability of $3/6$, the two for $\beta$ (yellow) give it a probability of $2/6$, and the one for $\gamma$ (green) give it a probability of $1/6$. In order to display what is written on the tickets, they are shown before being mixed. The beauty of this approach is that all the paradoxical parts of the question turn out to be correct: the sum of random variables is indeed a single, definite number (for each member of the population), yet it also leads to a distribution (given by the frequencies with which the sum appears in the box), and it still effectively models a random process (because the tickets are still blindly drawn from the box). In this fashion the sum can simultaneously have a definite value (given by the rules of addition as applied to numbers on each of the tickets) while the realization--which will be a ticket drawn from the box--does not have a value until it is carried out. This physical model of drawing tickets from a box is adopted in the theoretical literature and made rigorous with the definitions of sample space (the population), sigma algebras (with their associated probability measures), and random variables as measurable functions defined on the sample space. This account of random variables is elaborated, with realistic examples, at "What is meant by a random variable?".
Can anyone clarify the concept of a "sum of random variables" A physical, intuitive model of a random variable is to write down the name of every member of a population on one or more slips of paper--"tickets"--and put those tickets into a box. The process of th
7,892
Can anyone clarify the concept of a "sum of random variables"
There is no secret behind this phrase, it is as simple as you can think: if $X$ and $Y$ are two random variables, their sum is $X + Y$ and this sum is a random variable as well. If $X_1, X_2, X_3,\ldots,X_n$ and are $n$ random variables, their sum is $X_1 + X_2 + X_3 +\ldots+ X_n$ and this sum is also a random variable (and a realization of this sum is a single number, namely a sum of n realizations). Why do you talk so much about sums of random variables in the class? One reason is the (amazing) central limit theorem: if we sum many independent random variables, then we can "predict" the distribution of this sum (almost) independently of the distribution of the single variables in the sum! The sum tends to become a normal distribution and this is the likely reason why we observe the normal distribution so often in the real world.
Can anyone clarify the concept of a "sum of random variables"
There is no secret behind this phrase, it is as simple as you can think: if $X$ and $Y$ are two random variables, their sum is $X + Y$ and this sum is a random variable as well. If $X_1, X_2, X_3,\ldo
Can anyone clarify the concept of a "sum of random variables" There is no secret behind this phrase, it is as simple as you can think: if $X$ and $Y$ are two random variables, their sum is $X + Y$ and this sum is a random variable as well. If $X_1, X_2, X_3,\ldots,X_n$ and are $n$ random variables, their sum is $X_1 + X_2 + X_3 +\ldots+ X_n$ and this sum is also a random variable (and a realization of this sum is a single number, namely a sum of n realizations). Why do you talk so much about sums of random variables in the class? One reason is the (amazing) central limit theorem: if we sum many independent random variables, then we can "predict" the distribution of this sum (almost) independently of the distribution of the single variables in the sum! The sum tends to become a normal distribution and this is the likely reason why we observe the normal distribution so often in the real world.
Can anyone clarify the concept of a "sum of random variables" There is no secret behind this phrase, it is as simple as you can think: if $X$ and $Y$ are two random variables, their sum is $X + Y$ and this sum is a random variable as well. If $X_1, X_2, X_3,\ldo
7,893
Can anyone clarify the concept of a "sum of random variables"
r.v. is a relation between the occurrence of an event and a real number. Say, if it's raining the value X is 1, if it's not then 0. You can have another r.v. Y equal to 10 when it's cold, and 100 when it's hot. So, if it's raining and cold then X=1, Y=10, and X+Y=11. X+Y values are 10 (not raining cold); 11 (raining,cold), 100 (not raining,hot) and 110 (raining, hot). If you figure our probabilities of the events, then you'll get PMF of this new r.v. X+Y.
Can anyone clarify the concept of a "sum of random variables"
r.v. is a relation between the occurrence of an event and a real number. Say, if it's raining the value X is 1, if it's not then 0. You can have another r.v. Y equal to 10 when it's cold, and 100 when
Can anyone clarify the concept of a "sum of random variables" r.v. is a relation between the occurrence of an event and a real number. Say, if it's raining the value X is 1, if it's not then 0. You can have another r.v. Y equal to 10 when it's cold, and 100 when it's hot. So, if it's raining and cold then X=1, Y=10, and X+Y=11. X+Y values are 10 (not raining cold); 11 (raining,cold), 100 (not raining,hot) and 110 (raining, hot). If you figure our probabilities of the events, then you'll get PMF of this new r.v. X+Y.
Can anyone clarify the concept of a "sum of random variables" r.v. is a relation between the occurrence of an event and a real number. Say, if it's raining the value X is 1, if it's not then 0. You can have another r.v. Y equal to 10 when it's cold, and 100 when
7,894
Can anyone clarify the concept of a "sum of random variables"
None of these answers gives a mathematically rigorous way to think about sum of random variable. Note that $X,Y$ needs not to be defined on the same outcome domain and even if they do, $X+Y$ cannot be understood as summing up two functions. Rather, they should be first extended to the domain $\Omega_1\times \Omega_2$. For example, let $X,Y$ be identical function of $\Omega=\{Head,Tail\}$ where $X(Head)=Y(Head)=1, X(Tail)=Y(Tail)=0$. Domain of $(X+Y)$ should be {(Head,Tail),(Tail,Head),(Head, Head),(Tail,Tail)}. Now $X,Y$ are functions on this product space where their value is determined solely by the 1st and 2nd coordinate respectively. The sum now can be understood as summation of functions as the usual sense. Note also that the $\sigma-$field and probability measure should also be defined anew. Saying $X,Y$ are independent is one way to specify the product measure.
Can anyone clarify the concept of a "sum of random variables"
None of these answers gives a mathematically rigorous way to think about sum of random variable. Note that $X,Y$ needs not to be defined on the same outcome domain and even if they do, $X+Y$ cannot be
Can anyone clarify the concept of a "sum of random variables" None of these answers gives a mathematically rigorous way to think about sum of random variable. Note that $X,Y$ needs not to be defined on the same outcome domain and even if they do, $X+Y$ cannot be understood as summing up two functions. Rather, they should be first extended to the domain $\Omega_1\times \Omega_2$. For example, let $X,Y$ be identical function of $\Omega=\{Head,Tail\}$ where $X(Head)=Y(Head)=1, X(Tail)=Y(Tail)=0$. Domain of $(X+Y)$ should be {(Head,Tail),(Tail,Head),(Head, Head),(Tail,Tail)}. Now $X,Y$ are functions on this product space where their value is determined solely by the 1st and 2nd coordinate respectively. The sum now can be understood as summation of functions as the usual sense. Note also that the $\sigma-$field and probability measure should also be defined anew. Saying $X,Y$ are independent is one way to specify the product measure.
Can anyone clarify the concept of a "sum of random variables" None of these answers gives a mathematically rigorous way to think about sum of random variable. Note that $X,Y$ needs not to be defined on the same outcome domain and even if they do, $X+Y$ cannot be
7,895
How can I interpret a confusion matrix
The confusion matrix is a way of tabulating the number of misclassifications, i.e., the number of predicted classes which ended up in a wrong classification bin based on the true classes. While sklearn.metrics.confusion_matrix provides a numeric matrix, I find it more useful to generate a 'report' using the following: import pandas as pd y_true = pd.Series([2, 0, 2, 2, 0, 1, 1, 2, 2, 0, 1, 2]) y_pred = pd.Series([0, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 2]) pd.crosstab(y_true, y_pred, rownames=['True'], colnames=['Predicted'], margins=True) which results in: Predicted 0 1 2 All True 0 3 0 0 3 1 0 1 2 3 2 2 1 3 6 All 5 2 5 12 This allows us to see that: The diagonal elements show the number of correct classifications for each class: 3, 1 and 3 for the classes 0, 1 and 2. The off-diagonal elements provides the misclassifications: for example, 2 of the class 2 were misclassified as 0, none of the class 0 were misclassified as 2, etc. The total number of classifications for each class in both y_true and y_pred, from the "All" subtotals This method also works for text labels, and for a large number of samples in the dataset can be extended to provide percentage reports. import numpy as np import pandas as pd # create some data lookup = {0: 'biscuit', 1:'candy', 2:'chocolate', 3:'praline', 4:'cake', 5:'shortbread'} y_true = pd.Series([lookup[_] for _ in np.random.random_integers(0, 5, size=100)]) y_pred = pd.Series([lookup[_] for _ in np.random.random_integers(0, 5, size=100)]) pd.crosstab(y_true, y_pred, rownames=['True'], colnames=['Predicted']).apply(lambda r: 100.0 * r/r.sum()) The output then is: Predicted biscuit cake candy chocolate praline shortbread True biscuit 23.529412 10 23.076923 13.333333 15.384615 9.090909 cake 17.647059 20 0.000000 26.666667 15.384615 18.181818 candy 11.764706 20 23.076923 13.333333 23.076923 31.818182 chocolate 11.764706 5 15.384615 6.666667 15.384615 13.636364 praline 17.647059 10 30.769231 20.000000 0.000000 13.636364 shortbread 17.647059 35 7.692308 20.000000 30.769231 13.636364 where the numbers now represent the percentage (rather than number of cases) of the outcomes that were classified. Although note, that the sklearn.metrics.confusion_matrix output can be directly visualized using: import matplotlib.pyplot as plt conf = sklearn.metrics.confusion_matrix(y_true, y_pred) plt.imshow(conf, cmap='binary', interpolation='None') plt.show()
How can I interpret a confusion matrix
The confusion matrix is a way of tabulating the number of misclassifications, i.e., the number of predicted classes which ended up in a wrong classification bin based on the true classes. While sklear
How can I interpret a confusion matrix The confusion matrix is a way of tabulating the number of misclassifications, i.e., the number of predicted classes which ended up in a wrong classification bin based on the true classes. While sklearn.metrics.confusion_matrix provides a numeric matrix, I find it more useful to generate a 'report' using the following: import pandas as pd y_true = pd.Series([2, 0, 2, 2, 0, 1, 1, 2, 2, 0, 1, 2]) y_pred = pd.Series([0, 0, 2, 1, 0, 2, 1, 0, 2, 0, 2, 2]) pd.crosstab(y_true, y_pred, rownames=['True'], colnames=['Predicted'], margins=True) which results in: Predicted 0 1 2 All True 0 3 0 0 3 1 0 1 2 3 2 2 1 3 6 All 5 2 5 12 This allows us to see that: The diagonal elements show the number of correct classifications for each class: 3, 1 and 3 for the classes 0, 1 and 2. The off-diagonal elements provides the misclassifications: for example, 2 of the class 2 were misclassified as 0, none of the class 0 were misclassified as 2, etc. The total number of classifications for each class in both y_true and y_pred, from the "All" subtotals This method also works for text labels, and for a large number of samples in the dataset can be extended to provide percentage reports. import numpy as np import pandas as pd # create some data lookup = {0: 'biscuit', 1:'candy', 2:'chocolate', 3:'praline', 4:'cake', 5:'shortbread'} y_true = pd.Series([lookup[_] for _ in np.random.random_integers(0, 5, size=100)]) y_pred = pd.Series([lookup[_] for _ in np.random.random_integers(0, 5, size=100)]) pd.crosstab(y_true, y_pred, rownames=['True'], colnames=['Predicted']).apply(lambda r: 100.0 * r/r.sum()) The output then is: Predicted biscuit cake candy chocolate praline shortbread True biscuit 23.529412 10 23.076923 13.333333 15.384615 9.090909 cake 17.647059 20 0.000000 26.666667 15.384615 18.181818 candy 11.764706 20 23.076923 13.333333 23.076923 31.818182 chocolate 11.764706 5 15.384615 6.666667 15.384615 13.636364 praline 17.647059 10 30.769231 20.000000 0.000000 13.636364 shortbread 17.647059 35 7.692308 20.000000 30.769231 13.636364 where the numbers now represent the percentage (rather than number of cases) of the outcomes that were classified. Although note, that the sklearn.metrics.confusion_matrix output can be directly visualized using: import matplotlib.pyplot as plt conf = sklearn.metrics.confusion_matrix(y_true, y_pred) plt.imshow(conf, cmap='binary', interpolation='None') plt.show()
How can I interpret a confusion matrix The confusion matrix is a way of tabulating the number of misclassifications, i.e., the number of predicted classes which ended up in a wrong classification bin based on the true classes. While sklear
7,896
How can I interpret a confusion matrix
On y-axis confusion matrix has the actual values, and on the x-axis the values given by the predictor. Therefore, the counts on the diagonal are the number of correct predictions. And elements of the diagonal are incorrect predictions. In your case: >>> confusion_matrix(y_true, y_pred) array([[2, 0, 0], # two zeros were predicted as zeros [0, 0, 1], # one 1 was predicted as 2 [1, 0, 2]]) # two 2s were predicted as 2, and one 2 was 0
How can I interpret a confusion matrix
On y-axis confusion matrix has the actual values, and on the x-axis the values given by the predictor. Therefore, the counts on the diagonal are the number of correct predictions. And elements of the
How can I interpret a confusion matrix On y-axis confusion matrix has the actual values, and on the x-axis the values given by the predictor. Therefore, the counts on the diagonal are the number of correct predictions. And elements of the diagonal are incorrect predictions. In your case: >>> confusion_matrix(y_true, y_pred) array([[2, 0, 0], # two zeros were predicted as zeros [0, 0, 1], # one 1 was predicted as 2 [1, 0, 2]]) # two 2s were predicted as 2, and one 2 was 0
How can I interpret a confusion matrix On y-axis confusion matrix has the actual values, and on the x-axis the values given by the predictor. Therefore, the counts on the diagonal are the number of correct predictions. And elements of the
7,897
How can I interpret a confusion matrix
I would like to specify graphically the need to understand this. It's a simple matrix that needs to be well understood before reaching to conclusions. So here's a simplified explainable version of above answers. 0 1 2 <- Predicted 0 [2, 0, 0] TRUE 1 [0, 0, 1] 2 [1, 0, 2] # At 0,0: True value was 0, Predicted value was 0, - 2 times predicted # At 1,1: True value was 1, Predicted value was 1, - 0 times predicted # At 2,2: True value was 2, Predicted value was 2, - 2 times predicted # At 1,2: True value was 1, Predicted value was 2, - 1 time predicted # At 2,0: True value was 2, Predicted value was 0, - 1 time predicted... ...Like that And, as asked by my friend @fu DL, here's the code: from sklearn.metrics import confusion_matrix Y_true = [0,0,0,1,1,1,2,2,0,1,2] Y_pred = [0,0,1,1,1,2,2,2,0,0,0] confusion = confusion_matrix(Y_true, Y_pred) # PUT YOUR DESIRED LABELS HERE... row_label = "True" col_label = "Predicted" # For printing column label right in the middle col_space = len(row_label) index_middle = int(int(len(set(Y_true)))/2) # Prints first row print(" "*(col_space + 4), " ".join([str(i) for i in set(Y_true)]), " <- {}".format(col_label)) # Prints rest of the table for index in range(len(set(Y_true))): if index == index_middle: print(row_label, " ", index, confusion[index]) else: print(" "*(col_space+2), index, confusion[index])
How can I interpret a confusion matrix
I would like to specify graphically the need to understand this. It's a simple matrix that needs to be well understood before reaching to conclusions. So here's a simplified explainable version of abo
How can I interpret a confusion matrix I would like to specify graphically the need to understand this. It's a simple matrix that needs to be well understood before reaching to conclusions. So here's a simplified explainable version of above answers. 0 1 2 <- Predicted 0 [2, 0, 0] TRUE 1 [0, 0, 1] 2 [1, 0, 2] # At 0,0: True value was 0, Predicted value was 0, - 2 times predicted # At 1,1: True value was 1, Predicted value was 1, - 0 times predicted # At 2,2: True value was 2, Predicted value was 2, - 2 times predicted # At 1,2: True value was 1, Predicted value was 2, - 1 time predicted # At 2,0: True value was 2, Predicted value was 0, - 1 time predicted... ...Like that And, as asked by my friend @fu DL, here's the code: from sklearn.metrics import confusion_matrix Y_true = [0,0,0,1,1,1,2,2,0,1,2] Y_pred = [0,0,1,1,1,2,2,2,0,0,0] confusion = confusion_matrix(Y_true, Y_pred) # PUT YOUR DESIRED LABELS HERE... row_label = "True" col_label = "Predicted" # For printing column label right in the middle col_space = len(row_label) index_middle = int(int(len(set(Y_true)))/2) # Prints first row print(" "*(col_space + 4), " ".join([str(i) for i in set(Y_true)]), " <- {}".format(col_label)) # Prints rest of the table for index in range(len(set(Y_true))): if index == index_middle: print(row_label, " ", index, confusion[index]) else: print(" "*(col_space+2), index, confusion[index])
How can I interpret a confusion matrix I would like to specify graphically the need to understand this. It's a simple matrix that needs to be well understood before reaching to conclusions. So here's a simplified explainable version of abo
7,898
Line graph has too many lines, is there a better solution?
I would like to suggest a (standard) preliminary analysis to remove the principal effects of (a) variation among users, (b) the typical response among all users to the change, and (c) typical variation from one time period to the next. A simple (but by no means the best) way to do this is to perform a few iterations of "median polish" on the data to sweep out user medians and time period medians, then smooth the residuals over time. Identify the smooths that change a lot: they are the users you want to emphasize in the graphic. Because these are count data, it's a good idea to re-express them using a square root. As an example of what can result, here is a simulated 60-week dataset of 240 users who typically undertake 10 to 20 actions per week. A change in all users occurred after week 40. Three of these were "told" to respond negatively to the change. The left plot shows the raw data: counts of action by user (with users distinguished by color) over time. As asserted in the question, it's a mess. The right plot shows the results of this EDA--in the same colors as before--with the unusually responsive users automatically identified and highlighted. The identification--although it is somewhat ad hoc--is complete and correct (in this example). Here is the R code that produced these data and carried out the analysis. It could be improved in several ways, including Using a full median polish to find the residuals, rather than just one iteration. Smoothing the residuals separately before and after the change point. Perhaps using a more sophisticated outlier detection algorithm. The current one merely flags all users whose range of residuals is more than twice the median range. Albeit simple, it is robust and appears to work well. (A user-settable value, threshold, can be adjusted to make this identification more or less stringent.) Testing nevertheless suggests this solution works well for a wide range of user counts, 12 - 240 or more. n.users <- 240 # Number of users (here limited to 657, the number of colors) n.periods <- 60 # Number of time periods i.break <- 40 # Period after which change occurs n.outliers <- 3 # Number of greatly changed users window <- 1/5 # Temporal smoothing window, fraction of total period response.all <- 1.1 # Overall response to the change threshold <- 2 # Outlier detection threshold # Create a simulated dataset set.seed(17) base <- exp(rnorm(n.users, log(10), 1/2)) response <- c(rbeta(n.users - n.outliers, 9, 1), rbeta(n.outliers, 5, 45)) * response.all actual <- cbind(base %o% rep(1, i.break), base * response %o% rep(response.all, n.periods-i.break)) observed <- matrix(rpois(n.users * n.periods, actual), nrow=n.users) # ---------------------------- The analysis begins here ----------------------------# # Plot the raw data as lines set.seed(17) colors = sample(colors(), n.users) # (Use a different method when n.users > 657) par(mfrow=c(1,2)) plot(c(1,n.periods), c(min(observed), max(observed)), type="n", xlab="Time period", ylab="Number of actions", main="Raw data") i <- 0 apply(observed, 1, function(a) {i <<- i+1; lines(a, col=colors[i])}) abline(v = i.break, col="Gray") # Mark the last period before a change # Analyze the data by time period and user by sweeping out medians and smoothing x <- sqrt(observed + 1/6) # Re-express the counts mean.per.period <- apply(x, 2, median) residuals <- sweep(x, 2, mean.per.period) mean.per.user <- apply(residuals, 1, median) residuals <- sweep(residuals, 1, mean.per.user) smooth <- apply(residuals, 1, lowess, f=window) # Smooth the residuals smooth.y <- sapply(smooth, function(s) s$y) # Extract the smoothed values ends <- ceiling(window * n.periods / 4) # Prepare to drop near-end values range <- apply(smooth.y[-(1:ends), ], 2, function(x) max(x) - min(x)) # Mark the apparent outlying users thick <- rep(1, n.users) thick[outliers <- which(range >= threshold * median(range))] <- 3 type <- ifelse(thick==1, 3, 1) cat(outliers) # Print the outlier identifiers (ideally, the last `n.outliers`) # Plot the residuals plot(c(1,n.periods), c(min(smooth.y), max(smooth.y)), type="n", xlab="Time period", ylab="Smoothed residual root", main="Residuals") i <- 0 tmp <- lapply(smooth, function(a) {i <<- i+1; lines(a, lwd=thick[i], lty=type[i], col=colors[i])}) abline(v = i.break, col="Gray")
Line graph has too many lines, is there a better solution?
I would like to suggest a (standard) preliminary analysis to remove the principal effects of (a) variation among users, (b) the typical response among all users to the change, and (c) typical variatio
Line graph has too many lines, is there a better solution? I would like to suggest a (standard) preliminary analysis to remove the principal effects of (a) variation among users, (b) the typical response among all users to the change, and (c) typical variation from one time period to the next. A simple (but by no means the best) way to do this is to perform a few iterations of "median polish" on the data to sweep out user medians and time period medians, then smooth the residuals over time. Identify the smooths that change a lot: they are the users you want to emphasize in the graphic. Because these are count data, it's a good idea to re-express them using a square root. As an example of what can result, here is a simulated 60-week dataset of 240 users who typically undertake 10 to 20 actions per week. A change in all users occurred after week 40. Three of these were "told" to respond negatively to the change. The left plot shows the raw data: counts of action by user (with users distinguished by color) over time. As asserted in the question, it's a mess. The right plot shows the results of this EDA--in the same colors as before--with the unusually responsive users automatically identified and highlighted. The identification--although it is somewhat ad hoc--is complete and correct (in this example). Here is the R code that produced these data and carried out the analysis. It could be improved in several ways, including Using a full median polish to find the residuals, rather than just one iteration. Smoothing the residuals separately before and after the change point. Perhaps using a more sophisticated outlier detection algorithm. The current one merely flags all users whose range of residuals is more than twice the median range. Albeit simple, it is robust and appears to work well. (A user-settable value, threshold, can be adjusted to make this identification more or less stringent.) Testing nevertheless suggests this solution works well for a wide range of user counts, 12 - 240 or more. n.users <- 240 # Number of users (here limited to 657, the number of colors) n.periods <- 60 # Number of time periods i.break <- 40 # Period after which change occurs n.outliers <- 3 # Number of greatly changed users window <- 1/5 # Temporal smoothing window, fraction of total period response.all <- 1.1 # Overall response to the change threshold <- 2 # Outlier detection threshold # Create a simulated dataset set.seed(17) base <- exp(rnorm(n.users, log(10), 1/2)) response <- c(rbeta(n.users - n.outliers, 9, 1), rbeta(n.outliers, 5, 45)) * response.all actual <- cbind(base %o% rep(1, i.break), base * response %o% rep(response.all, n.periods-i.break)) observed <- matrix(rpois(n.users * n.periods, actual), nrow=n.users) # ---------------------------- The analysis begins here ----------------------------# # Plot the raw data as lines set.seed(17) colors = sample(colors(), n.users) # (Use a different method when n.users > 657) par(mfrow=c(1,2)) plot(c(1,n.periods), c(min(observed), max(observed)), type="n", xlab="Time period", ylab="Number of actions", main="Raw data") i <- 0 apply(observed, 1, function(a) {i <<- i+1; lines(a, col=colors[i])}) abline(v = i.break, col="Gray") # Mark the last period before a change # Analyze the data by time period and user by sweeping out medians and smoothing x <- sqrt(observed + 1/6) # Re-express the counts mean.per.period <- apply(x, 2, median) residuals <- sweep(x, 2, mean.per.period) mean.per.user <- apply(residuals, 1, median) residuals <- sweep(residuals, 1, mean.per.user) smooth <- apply(residuals, 1, lowess, f=window) # Smooth the residuals smooth.y <- sapply(smooth, function(s) s$y) # Extract the smoothed values ends <- ceiling(window * n.periods / 4) # Prepare to drop near-end values range <- apply(smooth.y[-(1:ends), ], 2, function(x) max(x) - min(x)) # Mark the apparent outlying users thick <- rep(1, n.users) thick[outliers <- which(range >= threshold * median(range))] <- 3 type <- ifelse(thick==1, 3, 1) cat(outliers) # Print the outlier identifiers (ideally, the last `n.outliers`) # Plot the residuals plot(c(1,n.periods), c(min(smooth.y), max(smooth.y)), type="n", xlab="Time period", ylab="Smoothed residual root", main="Residuals") i <- 0 tmp <- lapply(smooth, function(a) {i <<- i+1; lines(a, lwd=thick[i], lty=type[i], col=colors[i])}) abline(v = i.break, col="Gray")
Line graph has too many lines, is there a better solution? I would like to suggest a (standard) preliminary analysis to remove the principal effects of (a) variation among users, (b) the typical response among all users to the change, and (c) typical variatio
7,899
Line graph has too many lines, is there a better solution?
Generally I find more than two or three lines on a single facet of a plot starts to be hard to read (although I still do it all the time). So this is an interesting example of what to do when you have something that conceptually could be a 100 facet plot. One possible way is to draw all 100 facets but instead of trying to get them all on the page at once, looking at them one at a time in an animation. We've actually used this technique at my work - we originally made the animation showing 60 different line plots as background for an event (the launch of a new data series), then found that doing so we actually picked up some features of the data that hadn't been visible in faceted plots with 15 or 30 facets per page. So here is an alternative way of presenting the raw data, before you start removing the user and typical time effects as recommended by @whuber. This is presented just as an additional alternative to his presentation of the raw data - I fully recommend that you then proceed with analysis along lines such as those he suggests. One way of getting around this problem is to produce the 100 (or 240 in @whuber's example) time series plots separately and knit them together into an animation. The code below will produce 240 separate images of this sort and then you can use free movie making software to turn that into a movie. Unfortunately the only way I could do this and keep acceptable quality was a 9MB file, but if you don't need to send it across the internet that may not be a problem and anyway I'm sure there's ways around that with a bit more animation savvy. The animation package in R could be useful here (lets you do it all in a call from R) but I've kept it simple for this illustration. I have made the animation such that it draws each line in heavy black then leaves a pale semi-transparent green shadow behind so the eye gets a gradual picture of the accumulating data. There are both risks and opportunities in this - the order that the lines are added will leave a different impression, so you should consider making it meaningful in some way. Here are some of the stills from the movie, which uses the same data that @whuber generated: # ---------------------------- Data generation - by @whuber ----------------------------# n.users <- 240 # Number of users (here limited to 657, the number of colors) n.periods <- 60 # Number of time periods i.break <- 40 # Period after which change occurs n.outliers <- 3 # Number of greatly changed users window <- 1/5 # Temporal smoothing window, fraction of total period response.all <- 1.1 # Overall response to the change threshold <- 2 # Outlier detection threshold # Create a simulated dataset set.seed(17) base <- exp(rnorm(n.users, log(10), 1/2)) response <- c(rbeta(n.users - n.outliers, 9, 1), rbeta(n.outliers, 5, 45)) * response.all actual <- cbind(base %o% rep(1, i.break), base * response %o% rep(response.all, n.periods-i.break)) observed <- matrix(rpois(n.users * n.periods, actual), nrow=n.users) # ---------------------------- The analysis begins here ----------------------------# # Alternative presentation of original data # setwd("eg animation") for (i in 1:n.users){ png(paste("line plot", i, ".png"),600,600,res=60) plot(c(1,n.periods), c(min(observed), max(observed)), xlab="Time period", ylab="Number of actions", main="Raw data", bty="l", type="n") if(i>1){apply(observed[1:i,], 1, function(a) {lines(a, col=rgb(0,100,0,50,maxColorValue=255))})} lines(observed[i,], col="black", lwd=2) abline(v = i.break, col="Gray") # Mark the last period before a change text(1,60,i) dev.off() } ## # Then proceed to further analysis eg as set out by @whuber
Line graph has too many lines, is there a better solution?
Generally I find more than two or three lines on a single facet of a plot starts to be hard to read (although I still do it all the time). So this is an interesting example of what to do when you hav
Line graph has too many lines, is there a better solution? Generally I find more than two or three lines on a single facet of a plot starts to be hard to read (although I still do it all the time). So this is an interesting example of what to do when you have something that conceptually could be a 100 facet plot. One possible way is to draw all 100 facets but instead of trying to get them all on the page at once, looking at them one at a time in an animation. We've actually used this technique at my work - we originally made the animation showing 60 different line plots as background for an event (the launch of a new data series), then found that doing so we actually picked up some features of the data that hadn't been visible in faceted plots with 15 or 30 facets per page. So here is an alternative way of presenting the raw data, before you start removing the user and typical time effects as recommended by @whuber. This is presented just as an additional alternative to his presentation of the raw data - I fully recommend that you then proceed with analysis along lines such as those he suggests. One way of getting around this problem is to produce the 100 (or 240 in @whuber's example) time series plots separately and knit them together into an animation. The code below will produce 240 separate images of this sort and then you can use free movie making software to turn that into a movie. Unfortunately the only way I could do this and keep acceptable quality was a 9MB file, but if you don't need to send it across the internet that may not be a problem and anyway I'm sure there's ways around that with a bit more animation savvy. The animation package in R could be useful here (lets you do it all in a call from R) but I've kept it simple for this illustration. I have made the animation such that it draws each line in heavy black then leaves a pale semi-transparent green shadow behind so the eye gets a gradual picture of the accumulating data. There are both risks and opportunities in this - the order that the lines are added will leave a different impression, so you should consider making it meaningful in some way. Here are some of the stills from the movie, which uses the same data that @whuber generated: # ---------------------------- Data generation - by @whuber ----------------------------# n.users <- 240 # Number of users (here limited to 657, the number of colors) n.periods <- 60 # Number of time periods i.break <- 40 # Period after which change occurs n.outliers <- 3 # Number of greatly changed users window <- 1/5 # Temporal smoothing window, fraction of total period response.all <- 1.1 # Overall response to the change threshold <- 2 # Outlier detection threshold # Create a simulated dataset set.seed(17) base <- exp(rnorm(n.users, log(10), 1/2)) response <- c(rbeta(n.users - n.outliers, 9, 1), rbeta(n.outliers, 5, 45)) * response.all actual <- cbind(base %o% rep(1, i.break), base * response %o% rep(response.all, n.periods-i.break)) observed <- matrix(rpois(n.users * n.periods, actual), nrow=n.users) # ---------------------------- The analysis begins here ----------------------------# # Alternative presentation of original data # setwd("eg animation") for (i in 1:n.users){ png(paste("line plot", i, ".png"),600,600,res=60) plot(c(1,n.periods), c(min(observed), max(observed)), xlab="Time period", ylab="Number of actions", main="Raw data", bty="l", type="n") if(i>1){apply(observed[1:i,], 1, function(a) {lines(a, col=rgb(0,100,0,50,maxColorValue=255))})} lines(observed[i,], col="black", lwd=2) abline(v = i.break, col="Gray") # Mark the last period before a change text(1,60,i) dev.off() } ## # Then proceed to further analysis eg as set out by @whuber
Line graph has too many lines, is there a better solution? Generally I find more than two or three lines on a single facet of a plot starts to be hard to read (although I still do it all the time). So this is an interesting example of what to do when you hav
7,900
Line graph has too many lines, is there a better solution?
One of the easiest things to is a boxplot. You can immediately see how your sample medians move and what days have the most outliers. day <- rep(1:10, 100) likes <- rpois(1000, 10) d <- data.frame(day, likes) library(ggplot2) qplot(x=day, y=likes, data=d, geom="boxplot", group=day) For individual analysis I suggest taking a small random sample from your data and analysing separate time series.
Line graph has too many lines, is there a better solution?
One of the easiest things to is a boxplot. You can immediately see how your sample medians move and what days have the most outliers. day <- rep(1:10, 100) likes <- rpois(1000, 10) d <- data.frame(day
Line graph has too many lines, is there a better solution? One of the easiest things to is a boxplot. You can immediately see how your sample medians move and what days have the most outliers. day <- rep(1:10, 100) likes <- rpois(1000, 10) d <- data.frame(day, likes) library(ggplot2) qplot(x=day, y=likes, data=d, geom="boxplot", group=day) For individual analysis I suggest taking a small random sample from your data and analysing separate time series.
Line graph has too many lines, is there a better solution? One of the easiest things to is a boxplot. You can immediately see how your sample medians move and what days have the most outliers. day <- rep(1:10, 100) likes <- rpois(1000, 10) d <- data.frame(day