# Random sampling (Real data) is so important, why?

How it is understandable for computer (or software) that a sampling method is Random? In fact, it is possible to data sampling by random method in N cases but one of the N cases been like as non-random! That means sampled data randomly is like non-randomly. Now, in this case, how computer find out that selecting samples distribution is based on random selecting? and why random sampling is so important?

### Edit

Ok. thanks for answer but also i have a question: Assume your sampled data located at almost one case e.g. age in heigh of population. so, you have a pattern in collected data while i did random sampling (this is one of cese of random sampling). now, what is important in random sampling than non-random that sampled data is accepted to following analysis? why random sampling is important to non-random?

-
If you wanted to estimate the average height in a city, it might not make sense just to measure the heights of the college basketball team. – Henry Nov 2 '12 at 17:45
You seem to have 2 questions here: (1) How does the computer / software know whether your data were randomly sampled or not? & (2) Why is random sampling important? – gung Nov 2 '12 at 19:18

Random sampling is important because it helps cancel out the effects of unobserved factors. for example, if you want to calculate the average height of people in a city and do your sampling in an elementary school, you are not going to get a good estimate. This is because the heights are conditional on a certain value of the unobserved factor "age". So you do not have the unconditional mean. To make sure that specific levels of the hundreds of unboserved factors, like age, ethnicity, nutrition, gender, air quality, etc. are not conditionalizing your measurement of height, you have to make sure that your sample is collected in a way that on average, different levels of unobserved factors are represented. As a result, your measurements are not conditional on any specific level of any specific unobserved variable. The best way to do this is to use a random sample.

For example, in a random sample, you have people of different ages, ethnicities, nutrition, etc.. As a result, the height measurement is not conditional on a specific level of age, etc. any more. Random sampling evens out the effect of all unobserved factors, so you don't have a biased estimate of whatever you're estimating.

If you draw, N-1 cases randomly and add one non-random Nth case, the sample is by definition non-random.

Computer methods that require random sampling don't usually check whether a sample is random or not and in non-trivial cases they can't check it; but if the sample is not random, it could affect the results that your method spits out.

A sampling is random if no patterns or relationships can be observed among the sampled values. For example, if all the people in your height have the same age, there's a pattern and your sample is not random, unless your study is only interested in height within that specific age group.

Random sampling helps you get rid of the effect of nuisance factors that you are not measuring, so take it seriously, otherwise your results will not be reliable.

-
Is it that "no correlation could exist between possible unobserved factors and your measurement", or that the correlations that exist between other variables & your measurement in the population are accurately reflected (to the degree afforded by sampling error) in your data? Certainly age and height are related to each other whether your sample was random or not. – gung Nov 2 '12 at 19:15
Yes, you're right. I'll correct the answer shortly. – Moe Nov 2 '12 at 19:58
My apologies, @Moe, but I'm a bit nit-picky today. I would disagree w/ a couple more things in your improved answer: (1) I wouldn't say "create" N-1 random samples (I might use draw or some such), (2) if you added 1 non-random case, your sample is no longer purely random (or, better put, is no longer as representative of the population in question, albeit the effect would probably be minimal, depending on N), & (3) a sample is random if every unit in the population has an equal probability of being selected. – gung Nov 2 '12 at 20:21
It doesn't hurt to be as correct as possible. Thanks for the comments. – Moe Nov 2 '12 at 22:31