Sleep
Sleep is a natural state of bodily rest observed throughout the animal kingdom. It is common to all mammals and birds, and is also seen in many reptiles, amphibians and fish.
In humans, other mammals, and a substantial majority of other animals which have been studied  such as fish, birds, ants, and fruit-flies  regular sleep is essential for survival. However its purposes are only partly clear and are the subject of intense research.

# Physiology
In mammals and birds the measurement of eye movement during sleep is used to divide sleep into two broad types:
- rapid eye movement (REM) and
- non-rapid eye movement (NREM) sleep.
Each type has a distinct set of associated physiological, neurological and psychological features.
Sleep proceeds in cycles of REM and the four stages of NREM, the order normally being:
In humans this cycle is on average 90 to 110 minutes, with a greater amount of  stages 3 and 4 early in the night and more REM later in the night. Each phase may have a distinct physiological function.
Drugs such as sleeping pills and alcoholic beverages can suppress certain stages of sleep (see Sleep deprivation). This can result in a sleep that exhibits loss of consciousness but does not fulfill its physiological functions.
Rechtschaffen and Kales originally outlined the criteria for staging sleep in 1968.  The American Academy of Sleep Medicine (AASM) updated the staging rules in 2007.

## Stages of sleep
Criteria for REM sleep include not only rapid eye movements but also a rapid low voltage EEG. In mammals, at least, low muscle tone is also seen. Most memorable dreaming occurs in this stage.
NREM accounts for 7580% of total sleep time in normal human adults. In NREM sleep, there is relatively little dreaming.  Non-REM encompasses four stages; stages 1 and 2 are considered 'light sleep', and 3 and 4 'deep sleep' or slow-wave sleep, SWS.  They are differentiated solely using EEG, unlike REM sleep which is characterized by rapid eye movements and relative absence of muscle tone.  In non-REM sleep there are often limb movements, and parasomnias such as sleepwalking may occur.
A cyclical alternating pattern may sometimes be observed during a stage.
NREM consists of four stages according to the 2007 AASM standards:
- During Stage N1 the brain transitions from alpha waves (common to people who are awake and having a frequency of 8 to 13 Hz) to theta waves (frequency of 4 to 7 Hz).  This stage is sometimes referred to as somnolence, or "drowsy sleep".  Associated with the onset of sleep during N1 may be sudden twitches and hypnic jerks. Some people may also experience hypnagogic hallucinations during this stage, which can be more troublesome to the subject. During N1 the subject loses some muscle tone, and conscious awareness of the external environment.
- Stage N2, is characterized by "sleep spindles" (12 to 16 Hz) and "K-complexes." During this stage, muscular activity as measured by electromyography (EMG) lowers and conscious awareness of the external environment disappears. This stage occupies 45 to 55% of total sleep.
- In Stage N3, the delta waves, also called delta rhythms (0.5 to 4 Hz) make up less than 50% of the total wave-patterns. This is considered part of deep or slow-wave sleep (SWS) and appears to function primarily as a transition into stage N4. This is the stage in which night terrors, bedwetting, sleepwalking and sleep-talking occur.
- In Stage N4, delta-waves make up more than 50% of the wave-patterns. Stages N3 and N4 are the deepest forms of sleep; N4 is effectively a deeper version of N3, in which the deep-sleep characteristics, such as delta-waves, are more pronounced.
Both REM sleep and NREM sleep stages 3 and 4 are homeostatically driven; that is, if a person or animal is selectively deprived of one of these, it rebounds once uninhibited sleep again is allowed. This suggests that both are essential to the functions of the sleep process.

## Sleep timing
Sleep timing is controlled by the circadian clock, by homeostasis and, in humans, by willed behavior.
The circadian clock, an inner time-keeping, temperature-fluctuating, enzyme-controlling device, works in tandem with adenosine, a neurotransmitter which inhibits many of the bodily processes that are associated with wakefulness. Adenosine is created over the course of the day; high levels of adenosine lead to sleepiness. In diurnal animals, sleepiness occurs as the circadian element causes the release of the hormone melatonin and a gradual decrease in core body temperature.  The timing is affected by one's chronotype.  It is the circadian rhythm which determines the ideal timing of a correctly structured and restorative sleep episode.
Homeostatic sleep propensity, the need for sleep as a function of the amount of time elapsed since the last adequate sleep episode, is also important and must be balanced against the circadian element for satisfactory sleep.  Along with corresponding messages from the circadian clock, this tells the body it needs to sleep.
Sleep offset, awakening, is primarily determined by circadian rhythm.  A normal person who regularly awakens at an early hour will generally not be able to sleep much later than the person's normal waking time, even if moderately sleep deprived.

## Optimal amount in humans

### Adults
The optimal amount of sleep is not a meaningful concept unless the timing of that sleep is seen in relation to an individual's circadian rhythms.  A person's major sleep episode is relatively inefficient and inadequate when it occurs at the "wrong" time of day.  The timing is correct when the following two circadian markers occur after the middle of the sleep episode but before awakening:
- maximum concentration of the hormone melatonin, and
- minimum core body temperature.
The National Sleep Foundation in the United States maintains that eight to nine hours of sleep for adult humans is optimal and that sufficient sleep benefits alertness, memory and problem solving, and overall health, as well as reducing the risk of accidents. A widely publicized 2003 study performed at the University of Pennsylvania School of Medicine demonstrated that cognitive performance declines with fewer than eight hours of sleep.
However, a University of California, San Diego psychiatry study of more than one million adults found that people who live the longest self-report sleeping for six to seven hours each night. Another study of sleep duration and mortality risk in women showed similar results. Other studies show that "sleeping more than 7 to 8 hours per day has been consistently associated with increased mortality"
Causal links are currently speculative: the available data may only reflect comorbid depression, socioeconomic status, or even alcohol use, for example. These studies cannot be used to determine optimal sleep habits, only correlation  and empirically observed correlation is a necessary but not sufficient condition for causality. A need for nine or ten hours of sleep a day, or only five to six, may or may not have the same cause as the shortened life span.  In other words, long or short sleep duration itself has not been shown to be a cause of early death.
Researchers from the University of Warwick and University College London have found that lack of sleep can more than double the risk of death from cardiovascular disease, but that too much sleep can also double the risk of death. Professor Francesco Cappuccio said: Short sleep has been shown to be a risk factor for weight gain, hypertension and Type 2 diabetes sometimes leading  to mortality but in contrast to the short sleep-mortality association it appears that no potential mechanisms by which long sleep could be associated with increased mortality have yet been investigated. Some candidate causes for this include depression, low socioeconomic status and cancer-related fatigue.   In terms of prevention, our findings indicate that consistently sleeping around 7  hours per night is optimal for health and a sustained reduction may predispose to ill-health.

### Hours by age
Children need a greater amount of sleep per day than adults to develop and function properly: up to 18 hours for newborn babies, with a declining rate as a child ages. A newborn baby spends almost half of its sleep time in REM-sleep.  By the age of five or so, only a bit over two hours are spent in REM.

## Sleep debt
Sleep debt is the effect of not getting enough rest and sleep; a large debt causes mental and physical fatigue.  Scientists do not agree on how much sleep debt it is possible to accumulate, nor on whether the prevalence of sleep debt among adults has changed appreciably in the industrialized world in recent decades.  It is likely that children are sleeping less than previously in Western societies.

# Functions
The multiple theories proposed to explain the function of sleep are reflective of the as yet incomplete understanding of the subject.
It is likely that sleep evolved to fulfill some primeval function, but has taken over multiple functions over time as organisms have evolved. An analogy would be that of the larynx, which performs multiple functions such as controlling the passage of food and air, phonation for communicating and social purposes, etc. These are all functions of the larynx but just one of them likely represents the original function. Some of the many proposed functions of sleep are as follows:

## Restoration
Wound healing has been shown to be affected by sleep.  A study conducted by Gumustekin et al. in 2004 shows sleep deprivation hindering the healing of burns on rats.
It has also been shown that sleep deprivation affects the immune system and metabolism. In a study by Zager et al in 2007, rats were deprived of sleep for 24 hours. When compared with a control group, the sleep-deprived rats' blood tests indicated a 20% decrease in white blood cell count, a significant change in the immune system.
A study by Bonnet and Arand in 2003 indicates that sleep affects metabolism. Comparing normal human sleepers and sleepers with sleep state misperception insomnia, where patients complain of poor sleep but have normal sleep by electroencephalographic (EEG) criteria, the researchers found significantly greater metabolism values for the normal sleepers.
It has yet to be clearly proven that sleep duration affects somatic growth. One study by Jenni et al in 2007 recorded growth, height and weight, as correlated to parent-reported time-in-bed in 305 children over a period of nine years (age 1-10).  It was found that "the variation of sleep duration among children does not seem to have an effect on growth".  It has been shown that sleep, more specifically slow-wave sleep (SWS), does affect growth hormone levels in adult men.  During eight hours sleep, Van Cauter, Leproult, and Plat found that the men with a high percentage of SWS (average 24%) also had high growth hormone secretion, while subjects with a low percentage of SWS (average 9%) had low growth hormone secretion.
There are multiple arguments supporting the restorative function of sleep. We feel rested after sleeping, and it is natural to assume that this is a basic purpose of sleep. Overall metabolic rate goes down during sleep and certain anabolic hormones such as growth hormones as mentioned above are secreted preferentially during sleep. Sleep among species is, in general, inversely related to the animal size and basal metabolic rate. Rats with a very high basal metabolic rate sleep for up to 14 hours a day whereas elephants and giraffes with lower BMRs sleep only 3-4 hours per day.
Energy conservation could as well have been accomplished by resting quiescent without shutting off the organism from the environment, potentially a dangerous situation. A sedentary non-sleeping animal is more likely to survive predators, while still preserving energy.  Sleep therefore does something else other than conserving energy. Most interestingly, hibernating animals, when they wake up from hibernation go into rebound sleep because of lack of sleep during the hibernation period. They are definitely well rested and are conserving energy during hibernation, but need sleep for something else.
One study that was conducted kept rats awake indefinitely. They started dying after 5 days.

## Anabolic/catabolic
Non-REM sleep may be an anabolic state marked by physiological processes of growth and rejuvenation of the organism's immune, nervous, muscular, and skeletal systems (but see above). Wakefulness may perhaps be viewed as a cyclical, temporary, hyperactive catabolic state during which the organism acquires nourishment and procreates.

## Ontogenesis
According to the ontogenetic hypothesis of REM sleep, the activity occurring during neonatal REM sleep (or active sleep) seems to be particularly important to the developing organism (Marks et al., 1995). Studies investigating the effects of deprivation of active sleep have shown that deprivation early in life can result in behavioral problems, permanent sleep disruption, decreased brain mass (Mirmiran et al. 1983), and an abnormal amount of neuronal cell death (Morrissey, Duntley & Anch, 2004).
REM sleep appears to be important for development of the brain. REM sleep occupies majority of time of sleep of infants, which spend most of their time sleeping. Among different species, the more immature the baby is born, the more time it spends in REM sleep. Proponents also suggest that REM-induced muscle inhibition in the presence of brain activation exists to allow for brain development by activating the synapses yet without any motor consequences which may get the infant in trouble. Additionally, REM deprivation results in developmental abnormalities later in life.
However, this does not explain why older adults still need REM sleep, and why the fraction of time spent does not change significantly as one ages. Aquatic mammal infants do not have REM sleep in infancy. REM sleep in those animals increases as they age. Obviously, REM sleep is not needed for development in these animals.

## Memory processing
Scientists have shown numerous ways in which sleep is related to memory.  In a study conducted by Turner, Drummond, Salamat, and Brown working memory was shown to be affected by sleep deprivation.  Working memory is important because it keeps information active for further processing and supports higher-level cognitive functions such as decision making, reasoning, and episodic memory.   Turner et al. allowed 18 women and 22 men to sleep only 26 minutes per night over a 4-day period.  Subjects were given initial cognitive tests while well rested and then tested again twice a day during the 4 days of sleep deprivation. On the final test the average working memory span of the sleep deprived group had dropped by 38% in comparison to the control group.
Memory also seems to be affected differently by certain stages of sleep such as REM and slow-wave sleep (SWS).  In one study cited in Born, Rasch, and Gais multiple groups of human subjects were used: wake control groups and sleep test groups. Sleep and wake groups were taught a task and then tested on it both on early and late nights, with the order of nights balanced across participants. When the subjects brains were scanned during sleep, hypnograms revealed that SWS was the dominant sleep stage during the early night representing around 23% on average for sleep stage activity. The early night test group performed 16% better on the declarative memory test than the control group.  During late night sleep, REM became the most active sleep stage at about 24%, and the late night test group performed 25% better on the procedural memory test than the control group.  This indicates that procedural memory benefits from late REM-rich sleep where as declarative memory benefits from early SWS-rich sleep.
Another study conducted by Datta indirectly supports these results.  The subjects chosen were 22 male rats.  A box was constructed where a single rat could move freely from one end to the other. The bottom of the box was made of a steel grate.  A light would shine in the box accompanied by a sound. After a 5 second delay an electrical shock would be applied. Once the shock commenced the rat could move to the other end of the box, ending the shock immediately. The rat could also use the 5 second delay to move to the other end of the box and avoid the shock entirely. The length of the shock never exceeded 5 seconds.  This was repeated 30 times for half the rats. The other half, the control group, was placed in the same trial but the rats were shocked regardless of their reaction. After each of the training sessions the rat would be placed in a recording cage for 6 hours of polygraphic recordings.  This process was repeated for 3 consecutive days.  This study found that during the post-trial sleep recording session rats spent 25.47% more time in REM sleep after learning trials than after control trials. These trials support the results of the Born et al. study, indicating an obvious correlation between REM sleep and procedural knowledge.
Another interesting observation of the Datta study is that the learning group spent 180% more time in SWS than did the control group during the post-trial sleep-recording session.  This phenomenon is supported by a study performed by Kudrimoti, Barnes, and McNaughton. This study shows that after spatial exploration activity, patterns of hippocampal place cells are reactivated during SWS following the experiment.  In a study by Kudrimoti et al seven rats were run through a linear track using rewards on either end.  The rats would then be placed in the track for 30 minutes to allow them to adjust (PRE), then they ran the track with reward based training for 30 minutes (RUN), and then they were allowed to rest for 30 minutes.  During each of these three periods EEG data was collected for information on the rats sleep stages.  Kudrimoti et al computed the mean firing rates of hippocampal place cells during pre-behavior SWS (PRE) and three 10 min intervals in post-behavior SWS (POST) by averaging across 22 track-running sessions from seven rats.  The results showed that 10 min after the trial RUN session there was a 12% increase in the mean firing rate of hippocampal place cells from the PRE level, however after 20 minutes the mean firing rate returned rapidly toward the PRE level. The elevated firing of hippocampal place cells during SWS after spatial exploration could explain why there were elevated levels of SWS sleep in Dattas study as it also dealt with a form of spatial exploration.
The different studies all suggest that there is a correlation between sleep and the many complex functions of memory.

## Preservation
The "Preservation and Protection" theory holds that sleep serves an adaptive function. It protects the person during that portion of the 24-hour day in which being awake, and hence roaming around, would place the individual at greatest risk. Organisms do not require 24 hours to feed themselves and meet other necessities. From this perspective of adaptation, organisms are safer by staying out of harm's way where potentially they could be prey to other, stronger organisms. They sleep at times that maximize their safety, given their physical capacities and their habitats. (Allison & Cicchetti, 1976; Webb, 1982).
However, this theory fails to explain why the brain disengages from the external environment during normal sleep.  Another argument against the theory is that sleep is not simply a passive consequence of removing the animal from the environment, but is a "drive": animals alter their behaviors in order to obtain sleep. Therefore, circadian regulation is more than sufficient to explain periods of activity and quiescence that are adaptive to an organism, but the more peculiar specializations of sleep probably serve different and unknown functions.
Moreover, the preservation theory does not explain why carnivores like lions, which are on top of the food chain, sleep the most. By the preservation logic, these top carnivores should not need any sleep at all. Preservation does not explain why aquatic mammals sleep while moving. Lethargy during these vulnerable hours would do the same, and will be more advantageous because the animal will be quiescent but still be able to respond to environmental challenges like predators etc. Sleep rebound that occurs after a sleepless night will be maladaptive, but still occurs for a reason. For example, a zebra falling asleep the day after it spent the sleeping time running from a lion is more and not less vulnerable to predation.

# Dreaming
Dreaming is the perception of sensory images during sleep, in a sequence which the sleeper/dreamer usually perceives more as an apparent participant than an observer. Dreaming is stimulated by the pons and mostly occurs during the REM phase of sleep.
People have proposed many hypotheses about the functions of dreaming. Sigmund Freud postulated that dreams are the symbolic expression of frustrated desires that had been relegated to the subconscious, and he used dream interpretation in the form of psychoanalysis to uncover these desires. Scientists have become skeptical about the Freudian interpretation, and place more emphasis on dreaming as a requirement for organization and consolidation of recent memory and experience. See Freud:The Interpretation of Dreams
Rosalind Cartwright stated that "One Function of dreams may be to restore our sense of competence...it is also probable that in many times of stress, dreams have more work to do in resolving our problems and are thus more salient and memorable."Template:Citequote
J. Allan Hobson's and Robert McCarley's activation synthesis theory proposes that dreams are caused by the random firing of neurons in the cerebral cortex during the REM period.  According to the theory, the forebrain then creates a story in an attempt to reconcile and make sense of the nonsensical sensory information presented to it, hence the odd nature of many dreams.

# Effect of food and drink on sleep

## Drowsiness
- Tryptophan
The amino acid tryptophan is a building block of the protein found in foods.  It contributes to sleepiness. Carbohydrates make tryptophan more available to the brain, which is why carbohydrate-heavy meals containing tryptophan tend to cause drowsiness.
- Melatonin
Melatonin is a naturally occurring hormone that regulates sleepiness. It is made in the brain where tryptophan is converted into serotonin and then into melatonin, which is released at night by the pineal gland to induce and maintain sleep. Melatonin supplementation may be used as a sleep aid, both as a hypnotic and as a chronobiotic (see phase response curve, PRC).
- The "Post-Lunch Dip"
Many people have a temporary drop in alertness in early afternoon, commonly known as the post-lunch dip. While a large meal, rich in carbohydrates, can make a person feel sleepy, the post-lunch dip is mostly an effect of the biological clock. People naturally feel most sleepy (have the greatest "drive for sleep") at two times of the day about 12 hours apart, for example at 2:00 AM and 2:00 PM.  At those two times, the body clock "kicks in".  At about 2 p.m. (14:00), it overrides the homeostatic build-up of sleep debt, allowing several more hours of wakefulness.  At about 2 a.m. (02:00), with the daily sleep debt paid off, it "kicks in" again to ensure a few more hours of sleep.
- Alcohol
Alcoholic beverages aid relaxation and commonly are used as a sleep aid. Alcohol tends, however, to disrupt sleep throughout the night and can prevent the deeper stages of sleep from occurring.

## Stimulation
- Caffeine
Caffeine is a stimulant that works by slowing the action of the hormones in the brain that cause sleepiness.  Effective dosage is individual, in part dependent on prior usage.  It can cause a rapid reduction in alertness as it wears off.
- Amphetamines
Amphetamines are often used to treat narcolepsy, the most common effects are decreased appetite, decreased stamina, and physical energy.
- Energy Drinks
The stimulating effects of energy drinks comes from natural stimulants such as caffeine, sugars, and essential amino acids, and eventually will create a rapid reduction in alertness similar to that of caffeine.
Further reading: National Sleep Foundation - Topics: A to Zzzzs

# Causes of difficulty in sleeping
There are a great many possible reasons for sleeping poorly.  Following sleep hygienic principles may solve problems of physical or emotional discomfort. When pain, illness, drugs or stress are the culprit, the cause must be treated. Sleep disorders, including the sleep apneas, narcolepsy, primary insomnia, periodic limb movement disorder (PLMD), restless leg syndrome (RLS) and the circadian rhythm sleep disorders, are treatable.
Elderly people may to some degree lose the ability to consolidate sleep.  They need the same amount per day as they've always needed, but may need to take some of their sleep as daytime naps.

# Anthropology of sleep
Recent research suggests that sleep patterns vary significantly across human cultures. The most striking differences are between societies that have plentiful artificial light and ones that do not. Cultures without artificial light have more broken-up sleep patterns. This is called polyphasic sleep or segmented sleep and has led to expressions such as "first sleep," "watch," and "second sleep" which appear in literature from all over the world.
Some cultures have fragmented sleep patterns in which people sleep at all times of the day, and for shorter periods at night. For example, many Mediterranean and Latin American cultures have a siesta, in which people sleep for a period in the afternoon. In many nomadic or hunter-gatherer societies people sleep off and on throughout the day or night depending on what is happening.

# Sleep in non-humans
Horses and other herbivorous ungulates can sleep while standing, but must necessarily lie down for REM sleep (which causes muscular atony) for short periods - giraffes, for example, only need to lie down for REM sleep for a few minutes at a time.  Bats sleep while hanging upside down. Some aquatic mammals and some birds can sleep with one half of the brain, while the other half is awake, so called unihemispheric slow-wave sleep. Birds and mammals have cycles of non-REM and REM sleep as described above for humans, though birds cycles are much shorter and they do not lose muscle tone (go limp) to the same extent that most mammals do.
Many animals sleep, but neurological sleep states are difficult to define in lower order animals. In these animals, sleep is defined using behavioral characteristics such as minimal movement, postures typical for the species and reduced responsiveness to external stimulation. It is quickly reversible, as opposed to hibernation or coma, and sleep deprivation is followed by longer and/or deeper sleep.
Many species of mammals sleep for a large proportion of each 24-hour period when they are very young. However, killer whales and some dolphins do not sleep during the first month after they are born.

# Longest period without sleep
Depending on how sleep is defined, there are several people who can claim the record for having gone the longest without sleep:
- Thai Ngoc, born 1942, claimed in 2006 to have been awake for 33 years or 11,700 nights, according to Vietnamese news organization Thanh Nien. It was said that Ngoc acquired the ability to go without sleep after a bout of fever in 1973, but other reports indicate he stopped sleeping in 1976 with no known trigger.  At the time of the Thanh Nien report, Ngoc suffered from no apparent ill effect (other than a minor decline in liver function), was mentally sound and could carry 100 kg of pig feed down a 4 km road, but another report indicates that he was healthy before the sleepless episode but that now he was not feeling well because of the lack of sleep.
- In January 2005, the RIA Novosti published an article about Fyodor Nesterchuk from the Ukrainian town of Kamen-Kashirsky who claimed to have not slept in more than 20 years. Local doctor Fyodor Koshel, chief of the Lutsk city health department, claimed to have examined him extensively and failed to make him sleep. Koshel also said however that Nesterchuck did not suffer any of the normally deleterious effects of sleep deprivation. Several bloggers have commented that people who claim not to sleep are usually shown to sleep when studied in sleep laboratories with EEG. Another blog stated that Ananova's reprinting of the story is indicative of their having a reputation for not being a credible source of news. The "problem" may lie in that Nesterchuck and people like him don't remember sleeping, which may be cause for further study. Whether he doesn't sleep or doesn't remember sleeping, either event indicates a condition not present in most humans. Nesterchuck reports experiencing drowsiness at night, commenting that he attempts to sleep "in vain" when he notices his eyelids drooping. Many people also experience microsleep episodes during sleep deprivation, in which they sleep for periods of seconds to fractions of a second and frequently don't remember these episodes. Because microsleep is frequently not remembered, microsleep or a related phenomenon may be responsible for lack of sleep and/or lack of memory in individuals like Nesterchuk and Thai Ngoc.
- Randy Gardner holds the Guinness World Record for intentionally having gone the longest without sleep. In 1965, Gardner, then 18, stayed awake for 264 hours (about 11 days) for a high school science project. He experienced significant deficits in concentration, motivation, perception and other higher mental processes during his sleep deprivation. However, he recovered normal cognitive functions after a few nights' sleep.
- On May 25 2007 the BBC reported that Tony Wright beat the Guinness World Record by staying awake for 11 days and nights. The Guinness Book of Records has, however, withdrawn its backing of a sleep deprivation class because of the associated health risks.
- A 3-year-old boy named Rhett Lamb of St. Petersburg Florida has a rare condition and has only slept for one to two hours per day in the past three years. He has a rare abnormality called an Arnold-Chiari malformation where brain tissue protrudes into the spinal canal. The skull puts pressure on the protruding part of the brain. It is not yet known if the brain malformation is directly related to his sleep deprivation. Rhett checked into a hospital for an experimental surgery to relieve the issue.