text:
André Gide

André Paul Guillaume Gide (22 November 1869 – 19 February 1951) was a French author whose writings spanned a wide variety of styles and topics. He was awarded the 1947 Nobel Prize in Literature. Gide's career ranged from his beginnings in the symbolist movement, to criticising imperialism between the two World Wars. The author of more than fifty books, he was described in his obituary in The New York Times as "France's greatest contemporary man of letters" and "judged the greatest French writer of this century by the literary cognoscenti."

Known for his fiction as well as his autobiographical works, Gide expressed the conflict and eventual reconciliation of the two sides of his personality (characterized by a Protestant austerity and a transgressive sexual adventurousness, respectively). He suggested that a strict and moralistic education had helped set these facets at odds. Gide's work can be seen as an investigation of freedom and empowerment in the face of moralistic and puritanical constraints. He worked to achieve intellectual honesty. As a self-professed pederast, he used his writing to explore his struggle to be fully oneself, including owning one's sexual nature, without betraying one's values. His political activity was shaped by the same ethos. While sympathetic to Communism in the early 1930s, as were many intellectuals, after his 1936 journey to the USSR he supported the anti-Stalinist left; during the 1940s he shifted towards more traditional values and repudiated Communism as an idea that breaks with the traditions of the Christian civilization.

Early life
Gide was born in Paris on 22 November 1869, into a middle-class Protestant family. His father Jean Paul Guillaume Gide was a professor of law at University of Paris; he died in 1880, when the boy was eleven years old. His mother was Juliette Maria Rondeaux. His uncle was political economist Charles Gide. His paternal family traced its roots to Italy. The ancestral Guidos had moved to France and other western and northern European countries after converting to Protestantism during the 16th century, and facing persecution in Catholic Italy.

Gide was brought up in isolated conditions in Normandy. He became a prolific writer at an early age, publishing his first novel The Notebooks of André Walter (French: Les Cahiers d'André Walter), in 1891, at the age of twenty-one.

In 1893 and 1894, Gide traveled in Northern Africa. There he came to accept his attraction to boys and youths.

Gide befriended Irish playwright Oscar Wilde in Paris, where the latter was in exile. In 1895 the two men met in Algiers. Wilde had the impression that he had introduced Gide to homosexuality, but Gide had discovered homosexuality on his own.

The middle years
In 1895, after his mother's death, Gide married his cousin Madeleine Rondeaux, but the marriage remained unconsummated. In 1896, he was elected mayor of La Roque-Baignard, a commune in Normandy.

In 1901, Gide rented the property Maderia in St. Brélade's Bay and lived there while residing on the island of Jersey. This period, 1901–07, is commonly seen as a time of apathy and turmoil for him.

In 1908, Gide helped found the literary magazine Nouvelle Revue Française (The New French Review).

During World War I, Gide visited England. One of his friends there was artist William Rothenstein. Rothenstein described Gide's visit to his Gloucestershire home in his autobiography:

"André Gide was in England during the war...He came to stay with us for a time, and brought with him a young nephew, whose English was better than his own. The boy made friends with my son John, while Gide and I discussed everything under the sun. Once again I delighted in the range and subtlety of a Frenchman's intelligence; and I regretted my long severance from France. Nobody understood art more profoundly than Gide, no one's view of life was more penetrating. ...

Gide had a half satanic, half monk-like mien; he put one in mind of portraits of Baudelaire. Withal there was something exotic about him. He would appear in a red waistcoat, black velvet jacket and beige-coloured trousers and, in lieu of collar and tie, a loosely knotted scarf. ...

The heart of man held no secrets for Gide. There was little that he didn't understand, or discuss. He suffered, as I did, from the banishment of truth, one of the distressing symptoms of war. The Germans were not all black, and the Allies all white, for Gide."

In 1916, Gide was about 47 years old when he took Marc Allégret, age 15, as a lover. Marc was one of five children of Élie Allégret and his wife. Gide had become friends with the senior Allégret during his own school years when Gide's mother had hired Allégret as a tutor for her son. Élie Allégret had been best man at Gide's wedding. After Gide fled with Marc to London, his wife Madeleine burned all his correspondence in retaliation– "the best part of myself," Gide later commented.

In 1918, Gide met and befriended Dorothy Bussy; they were friends for more than 30 years, and she translated many of his works into English.

Gide also became close friends with the critic Charles Du Bos. Together they were part of the Foyer Franco-Belge, in which capacity they worked to find employment, food and housing for Franco-Belgian refugees who arrived in Paris following the 1914 German invasion of Belgium. Their friendship later declined, due to Du Bos's perception that Gide had disavowed or betrayed his spiritual faith, in contrast to Du Bos's own return to faith.

Du Bos's essay Dialogue avec André Gide was published in 1929. The essay, informed by Du Bos's Catholic convictions, condemned Gide's homosexuality. Gide and Du Bos's mutual friend Ernst Robert Curtius criticised the book in a letter to Gide, writing that "he [Du Bos] judges you according to Catholic morals suffices to neglect his complete indictment. It can only touch those who think like him and are convinced in advance. He has abdicated his intellectual liberty."

In the 1920s, Gide became an inspiration for such writers as Albert Camus and Jean-Paul Sartre. In 1923, he published a book on Fyodor Dostoyevsky. When he defended homosexuality in the public edition of Corydon (1924), he received widespread condemnation. He later considered this his most important work.

In 1923, Gide sired a daughter, Catherine, by Elisabeth van Rysselberghe, a much younger woman. He had known her for a long time, as she was the daughter of his friends Maria Monnom and Théo van Rysselberghe, a Belgian neo-impressionist painter. This caused the only crisis in the long-standing relationship between Allégret and Gide, and damaged his friendship with van Rysselberghe. This was possibly Gide's only sexual relationship with a woman, and it was brief in the extreme. Catherine was his only descendant by blood. He liked to call Elisabeth "La Dame Blanche" ("The White Lady").

Elisabeth eventually left her husband to move to Paris and manage the practical aspects of Gide's life (they had adjoining apartments built on the rue Vavin). She worshipped him, but evidently they no longer had a sexual relationship.

In 1924, he published an autobiography If it Die... (French: Si le grain ne meurt). In the same year, he produced the first French-language editions of Joseph Conrad's Heart of Darkness and Lord Jim.

After 1925, Gide began to campaign for more humane conditions for convicted criminals. His legal wife, Madeleine Gide, died in 1938. Later he explored their unconsummated marriage in Et nunc manet in te, his memoir of Madeleine, published in English in the United States in 1952.

Africa
From July 1926 to May 1927, Gide traveled through the colony of French Equatorial Africa with his lover Marc Allégret. They went successively to Middle Congo (now the Republic of the Congo), Ubangi-Shari (now the Central African Republic), briefly to Chad and then to Cameroon. He kept a journal, which he published as Travels in the Congo (French: Voyage au Congo) and Return from Chad (French: Retour du Tchad).

In this work, he criticized the behavior of French business interests in the Congo and inspired reform. In particular, he strongly criticized the Large Concessions regime (French: Régime des Grandes Concessions). The government had conceded part of the colony to French companies, allowing them to exploit the area's natural resources, in particular rubber. He related that native workers were forced to leave their village for several weeks to collect rubber in the forest, and compared their exploitation by the companies to slavery. The book contributed to the growing anti-colonialism movements in France and helped thinkers to re-evaluate the effects of colonialism in Africa.

Political views and the Soviet Union
During the 1930s, Gide briefly became a Communist, or more precisely, a fellow traveler (he never formally joined any Communist party), but he, an individualist himself, advocated the idea of Communist individualism. Despite supporting the Soviet Union, he acknowledged the political repression in the USSR. Gide insisted on the release of Victor Serge, a Soviet writer and a member of the Left Opposition who was prosecuted by the Stalinist regime for his views. As a distinguished writer sympathizing with the cause of Communism, he was invited to speak at Maxim Gorky's funeral and to tour the Soviet Union as a guest of the Soviet Union of Writers. He encountered censorship of his speeches and was particularly disillusioned with the state of culture under Soviet Communism. In his work, Retour de L'U.R.S.S. (Return from the USSR, 1936), he broke with such socialist friends as Jean-Paul Sartre; the book was addressed to pro-Soviet readers, so the purpose was to expose a reader to doubts instead of presenting harsh criticism. While admitting the economic and social achievements of the USSR compared to the Russian Empire, he noted the decay of culture, the erasure of the individuality of Soviet citizens, and the suppression of any dissent: "Then would it not be better to, instead of playing on words, simply to acknowledge that the revolutionary spirit (or even simply the critical spirit) is no longer the correct thing, that it is not wanted any more? What is wanted now is compliance, conformism. What is desired and demanded is approval of all that is done in the U. S. S. R.; and an attempt is being made to obtain an approval that is not mere resignation, but a sincere, an enthusiastic approval. What is most astounding is that this attempt is successful. On the other hand the smallest protest, the least criticism, is liable to the severest penalties, and in fact is immediately stifled. And I doubt whether in any other country in the world, even Hitler's Germany, thought to be less free, more bowed down, more fearful (terrorized), more vassalized."

- André Gide Return from the U. S. S. R.

Gide does not express his attitude towards Stalin, but he describes the signs of his personality cult: "in each [home], ... the same portrait of Stalin, and nothing else"; "portrait of Stalin..., in the same place no doubt where the icon used to be. Is it adoration, love, or fear? I do not know; always and everywhere he is present." However, Gide wrote that these problems could be solved by raising the cultural level of Soviet society.

When Gide began preparing his manuscript for publication, the Kremlin was immediately informed about it, and the soon Gide would be visited by the Soviet author Ilya Ehrenburg, who said that he agreed with Gide, but asked to postpone the publication, as the Soviet Union assisted the Republicans in Spain; two days later, Louis Aragon delivered a letter from Jef Last asking to postpone the publication. These measures didn't help, and as the book was published, Gide was condemned in the Soviet press and by the "friends of the USSR": Nordahl Grieg wrote that the reason of writing the book was Gide's impatience, and that with his book he made a favour to the Fascists, who greeted it with joy. In 1937, in response, Gide published Afterthoughts on the U. S. S. R.; earlier, Gide read Trotsky's The Revolution Betrayed and met Victor Serge who provided him more information about the Soviet Union. In Afterthoughts, Gide is more direct in his criticism of the Soviet society: "Citrine, Trotsky, Mercier, Yvon, Victor Serge, Leguay, Rudolf and many others have helped me with their documentation. Everything they have taught me so far I had only suspected it – has confirmed and reinforced my fears". The main points of Afterthoughts were that the dictatorship of the proletariat became the dictatorship of Stalin, and that the privileged bureaucracy became the new ruling class which profited by the workers' surplus labour, spending the state budget on projects like the Palace of Soviets or to raise its own standards of living, while the working class lived in extreme poverty; Gide cited the official Soviet newspapers to prove his statements.

During the World War II Gide came to a conclusion that "absolute liberty destroys the individual and also society unless it be closely linked to tradition and discipline"; he rejected the revolutionary idea of Communism as breaking with the traditions, and wrote that "if civilization depended solely on those who initiated revolutionary theories, then it would perish, since culture needs for its survival a continuous and developing tradition." In Thesee, written in 1946, he showed that an individual may safely leave the Maze only if "he had clung tightly to the thread which linked him with the past". In 1947, he said that although during the human history the civilizations rose up and died, the Christian civilization may be saved from doom "if we accepted the responsibility of the sacred charge laid on us by our traditions and our past." He also said that he remained an individualist and protested against "the submersion of individual responsibility in organized authority, in that escape from freedom which is characteristic of our age."

Gide contributed to the 1949 anthology The God That Failed. He could not write an essay because of his state of health, so the text was written by Enid Starkie, based on paraphrases of Return from the USSR, Afterthoughts, from a discussion held in Paris at l'Union pour la Verite in 1935, and from his Journal; the text was approved by Gide.

1930s and 1940s
In 1930 Gide published a book about the Blanche Monnier case titled La Séquestrée de Poitiers, changing little but the names of the protagonists. Monnier was a young woman who was kept captive by her own mother for more than 25 years.

In 1939, Gide became the first living author to be published in the prestigious Bibliothèque de la Pléiade.

He left France for Africa in 1942 and lived in Tunis from December 1942 until it was re-taken by French, British and American forces in May 1943 and he was able to travel to Algiers where he stayed until the end of World War II. In 1947, he received the Nobel Prize in Literature "for his comprehensive and artistically significant writings, in which human problems and conditions have been presented with a fearless love of truth and keen psychological insight". He devoted much of his last years to publishing his Journal. Gide died in Paris on 19 February 1951. The Roman Catholic Church placed his works on the Index of Forbidden Books in 1952.

Gide's life as a writer
Gide's biographer Alan Sheridan summed up Gide's life as a writer and an intellectual:

"Gide was, by general consent, one of the dozen most important writers of the 20th century. Moreover, no writer of such stature had led such an interesting life, a life accessibly interesting to us as readers of his autobiographical writings, his journal, his voluminous correspondence and the testimony of others. It was the life of a man engaging not only in the business of artistic creation, but reflecting on that process in his journal, reading that work to his friends and discussing it with them; a man who knew and corresponded with all the major literary figures of his own country and with many in Germany and England; who found daily nourishment in the Latin, French, English and German classics, and, for much of his life, in the Bible; [who enjoyed playing Chopin and other classic works on the piano;] and who engaged in commenting on the moral, political and sexual questions of the day."

"Gide's fame rested ultimately, of course, on his literary works. But, unlike many writers, he was no recluse: he had a need of friendship and a genius for sustaining it." But his "capacity for love was not confined to his friends: it spilled over into a concern for others less fortunate than himself."

Writings
André Gide's writings spanned many genres – "As a master of prose narrative, occasional dramatist and translator, literary critic, letter writer, essayist, and diarist, André Gide provided twentieth-century French literature with one of its most intriguing examples of the man of letters."

But as Gide's biographer Alan Sheridan points out, "It is the fiction that lies at the summit of Gide's work." "Here, as in the oeuvre as a whole, what strikes one first is the variety. Here, too, we see Gide's curiosity, his youthfulness, at work: a refusal to mine only one seam, to repeat successful formulas...The fiction spans the early years of Symbolism, to the "comic, more inventive, even fantastic" pieces, to the later "serious, heavily autobiographical, first-person narratives"...In France Gide was considered a great stylist in the classical sense, "with his clear, succinct, spare, deliberately, subtly phrased sentences."

Gide's surviving letters run into the thousands. But it is the Journal that Sheridan calls "the pre-eminently Gidean mode of expression." "His first novel emerged from Gide's own journal, and many of the first-person narratives read more or less like journals. In Les faux-monnayeurs, Edouard's journal provides an alternative voice to the narrator's." "In 1946, when Pierre Herbert asked Gide which of his books he would choose if only one were to survive," Gide replied, 'I think it would be my Journal.'" Beginning at the age of 18 or 19, Gide kept a journal all of his life and when these were first made available to the public, they ran to 1,300 pages.

Struggle for values
"Each volume that Gide wrote was intended to challenge itself, what had preceded it, and what could conceivably follow it. This characteristic, according to Daniel Moutote in his Cahiers de André Gide essay, is what makes Gide's work 'essentially modern': the 'perpetual renewal of the values by which one lives.'" Gide wrote in his Journal in 1930: "The only drama that really interests me and that I should always be willing to depict anew, is the debate of the individual with whatever keeps him from being authentic, with whatever is opposed to his integrity, to his integration. Most often the obstacle is within him. And all the rest is merely accidental."

As a whole, "The works of André Gide reveal his passionate revolt against the restraints and conventions inherited from 19th-century France. He sought to uncover the authentic self beneath its contradictory masks."

Sexuality
In his journal, Gide distinguishes between adult-attracted "sodomites" and boy-loving "pederasts", categorizing himself as the latter. "I call a pederast the man who, as the word indicates, falls in love with young boys. I call a sodomite ("The word is sodomite, sir," said Verlaine to the judge who asked him if it were true that he was a sodomist) the man whose desire is addressed to mature men...The pederasts, of whom I am one (why cannot I say this quite simply, without your immediately claiming to see a brag in my confession?), are much rarer, and the sodomites much more numerous, than I first thought...That such loves can spring up, that such relationships can be formed, it is not enough for me to say that this is natural; I maintain that it is good; each of the two finds exaltation, protection, a challenge in them; and I wonder whether it is for the youth or the elder man that they are more profitable."

Gide's journal documents his behavior in the company of Oscar Wilde. "Wilde took a key out of his pocket and showed me into a tiny apartment of two rooms...The youths followed him, each of them wrapped in a burnous that hid his face. Then the guide left us and Wilde sent me into the further room with little Mohammed and shut himself up in the other with the [other boy]. Every time since then that I have sought after pleasure, it is the memory of that night I have pursued...My joy was unbounded, and I cannot imagine it greater, even if love had been added. How should there have been any question of love? How should I have allowed desire to dispose of my heart? No scruple clouded my pleasure and no remorse followed it. But what name then am I to give the rapture I felt as I clasped in my naked arms that perfect little body, so wild, so ardent, so sombrely lascivious? For a long time after Mohammed had left me, I remained in a state of passionate jubilation, and though I had already achieved pleasure five times with him, I renewed my ecstasy again and again, and when I got back to my room in the hotel, I prolonged its echoes until morning."

Gide's novel Corydon, which he considered his most important work, includes a defense of pederasty. At that time, the age of consent for any type of sexual activity was set at 13.

title: André Gide


text:
Algorithms for calculating variance

Algorithms for calculating variance play a major role in computational statistics. A key difficulty in the design of good algorithms for this problem is that formulas for the variance may involve sums of squares, which can lead to numerical instability as well as to arithmetic overflow when dealing with large values.

Naïve algorithm
A formula for calculating the variance of an entire population of size N is:

 * $$\sigma^2 = \overline{(x^2)} - \bar x^2 = \frac {\sum_{i=1}^N x_i^2 - (\sum_{i=1}^N x_i)^2/N}{N}.$$

Using Bessel's correction to calculate an unbiased estimate of the population variance from a finite sample of n observations, the formula is:

 * $$s^2 = \left(\frac {\sum_{i=1}^n x_i^2} n - \left( \frac {\sum_{i=1}^n x_i} n \right)^2\right) \cdot \frac {n}{n-1}. $$

Therefore, a naïve algorithm to calculate the estimated variance is given by the following:

 * Let $n ← 0, Sum ← 0, SumSq ← 0$
 * For each datum $x$:

This algorithm can easily be adapted to compute the variance of a finite population: simply divide by n instead of n − 1 on the last line.

Because $n ← n + 1$ and $Sum ← Sum + x$ can be very similar numbers, cancellation can lead to the precision of the result to be much less than the inherent precision of the floating-point arithmetic used to perform the computation. Thus this algorithm should not be used in practice, and several alternate, numerically stable, algorithms have been proposed. This is particularly bad if the standard deviation is small relative to the mean.

Computing shifted data
The variance is invariant with respect to changes in a location parameter, a property which can be used to avoid the catastrophic cancellation in this formula.

 * $$\operatorname{Var}(X-K)=\operatorname{Var}(X).$$

with $$K$$ any constant, which leads to the new formula

 * $$\sigma^2 = \frac {\sum_{i=1}^n (x_i-K)^2 - (\sum_{i=1}^n (x_i-K))^2/n}{n-1}. $$

the closer $$K$$ is to the mean value the more accurate the result will be, but just choosing a value inside the samples range will guarantee the desired stability. If the values $$(x_i - K)$$ are small then there are no problems with the sum of its squares, on the contrary, if they are large it necessarily means that the variance is large as well. In any case the second term in the formula is always smaller than the first one therefore no cancellation may occur.

If just the first sample is taken as $$K$$ the algorithm can be written in Python programming language as

This formula also facilitates the incremental computation that can be expressed as

Two-pass algorithm
An alternative approach, using a different formula for the variance, first computes the sample mean,
 * $$\bar x = \frac {\sum_{j=1}^n x_j} n,$$

and then computes the sum of the squares of the differences from the mean,
 * $$\text{sample variance} = s^2 = \dfrac {\sum_{i=1}^n (x_i - \bar x)^2}{n-1}, $$

where s is the standard deviation. This is given by the following code:

This algorithm is numerically stable if n is small. However, the results of both of these simple algorithms ("naïve" and "two-pass") can depend inordinately on the ordering of the data and can give poor results for very large data sets due to repeated roundoff error in the accumulation of the sums. Techniques such as compensated summation can be used to combat this error to a degree.

Welford's online algorithm
It is often useful to be able to compute the variance in a single pass, inspecting each value $$x_i$$ only once; for example, when the data is being collected without enough storage to keep all the values, or when costs of memory access dominate those of computation. For such an online algorithm, a recurrence relation is required between quantities from which the required statistics can be calculated in a numerically stable fashion.

The following formulas can be used to update the mean and (estimated) variance of the sequence, for an additional element xn. Here, $\overline{x}_n = \frac{1}{n} \sum_{i=1}^n x_i $ denotes the sample mean of the first n samples $$(x_1,\dots,x_n)$$, $\sigma^2_n = \frac{1}{n} \sum_{i=1}^n \left(x_i - \overline{x}_n \right)^2$  their biased sample variance, and $s^2_n = \frac{1}{n - 1} \sum_{i=1}^n \left(x_i - \overline{x}_n \right)^2$  their unbiased sample variance.

 * $$\bar x_n = \frac{(n-1) \, \bar x_{n-1} + x_n}{n} = \bar x_{n-1} + \frac{x_n - \bar x_{n-1}}{n} $$

 * $$\sigma^2_n = \frac{(n-1) \, \sigma^2_{n-1} + (x_n - \bar x_{n-1})(x_n - \bar x_n)}{n} = \sigma^2_{n-1} + \frac{(x_n - \bar x_{n-1})(x_n - \bar x_n) - \sigma^2_{n-1}}{n}.$$

 * $$s^2_n = \frac{n-2}{n-1} \, s^2_{n-1} + \frac{(x_n - \bar x_{n-1})^2}{n} = s^2_{n-1} + \frac{(x_n - \bar x_{n-1})^2}{n} - \frac{s^2_{n-1}}{n-1}, \quad n>1 $$

These formulas suffer from numerical instability, as they repeatedly subtract a small number from a big number which scales with n. A better quantity for updating is the sum of squares of differences from the current mean, $\sum_{i=1}^n (x_i - \bar x_n)^2$, here denoted $$M_{2,n}$$:

 * $$\begin{align}

M_{2,n} & = M_{2,n-1} + (x_n - \bar x_{n-1})(x_n - \bar x_n) \\[4pt] \sigma^2_n & = \frac{M_{2,n}}{n} \\[4pt] s^2_n & = \frac{M_{2,n}}{n-1} \end{align}$$

This algorithm was found by Welford, and it has been thoroughly analyzed. It is also common to denote $$M_k = \bar x_k$$ and $$S_k = M_{2,k}$$.

An example Python implementation for Welford's algorithm is given below.

This algorithm is much less prone to loss of precision due to catastrophic cancellation, but might not be as efficient because of the division operation inside the loop. For a particularly robust two-pass algorithm for computing the variance, one can first compute and subtract an estimate of the mean, and then use this algorithm on the residuals.

The parallel algorithm below illustrates how to merge multiple sets of statistics calculated online.

Weighted incremental algorithm
The algorithm can be extended to handle unequal sample weights, replacing the simple counter n with the sum of weights seen so far. West (1979) suggests this incremental algorithm:

Parallel algorithm
Chan et al. note that Welford's online algorithm detailed above is a special case of an algorithm that works for combining arbitrary sets $$A$$ and $$B$$:
 * $$\begin{align}

n_{AB} & = n_A + n_B \\ \delta & = \bar x_B - \bar x_A \\ \bar x_{AB} & = \bar x_A + \delta\cdot\frac{n_B}{n_{AB}} \\ M_{2,AB} & = M_{2,A} + M_{2,B} + \delta^2\cdot\frac{n_A n_B}{n_{AB}} \\ \end{align}$$. This may be useful when, for example, multiple processing units may be assigned to discrete parts of the input.

Chan's method for estimating the mean is numerically unstable when $$n_A \approx n_B$$ and both are large, because the numerical error in $$\delta = \bar x_B - \bar x_A$$ is not scaled down in the way that it is in the $$n_B = 1$$ case. In such cases, prefer $\bar x_{AB} = \frac{n_A \bar x_A + n_B \bar x_B}{n_{AB}}$. This can be generalized to allow parallelization with AVX, with GPUs, and computer clusters, and to covariance.

Example
Assume that all floating point operations use standard IEEE 754 double-precision arithmetic. Consider the sample (4, 7, 13, 16) from an infinite population. Based on this sample, the estimated population mean is 10, and the unbiased estimate of population variance is 30. Both the naïve algorithm and two-pass algorithm compute these values correctly.

Next consider the sample (108 + 4, 108 + 7, 108 + 13, 108 + 16), which gives rise to the same estimated variance as the first sample. The two-pass algorithm computes this variance estimate correctly, but the naïve algorithm returns 29.333333333333332 instead of 30.

While this loss of precision may be tolerable and viewed as a minor flaw of the naïve algorithm, further increasing the offset makes the error catastrophic. Consider the sample (109 + 4, 109 + 7, 109 + 13, 109 + 16). Again the estimated population variance of 30 is computed correctly by the two-pass algorithm, but the naïve algorithm now computes it as −170.66666666666666. This is a serious problem with naïve algorithm and is due to catastrophic cancellation in the subtraction of two similar numbers at the final stage of the algorithm.

Higher-order statistics
Terriberry extends Chan's formulae to calculating the third and fourth central moments, needed for example when estimating skewness and kurtosis:

\begin{align} M_{3,X} = M_{3,A} + M_{3,B} & {} + \delta^3\frac{n_A n_B (n_A - n_B)}{n_X^2} + 3\delta\frac{n_AM_{2,B} - n_BM_{2,A}}{n_X} \\[6pt] M_{4,X} = M_{4,A} + M_{4,B} & {} + \delta^4\frac{n_A n_B \left(n_A^2 - n_A n_B + n_B^2\right)}{n_X^3} \\[6pt] & {} + 6\delta^2\frac{n_A^2 M_{2,B} + n_B^2 M_{2,A}}{n_X^2} + 4\delta\frac{n_AM_{3,B} - n_BM_{3,A}}{n_X} \end{align}$$

Here the $$M_k$$ are again the sums of powers of differences from the mean $\sum(x - \overline{x})^k$, giving

\begin{align} & \text{skewness} = g_1 = \frac{\sqrt{n} M_3}{M_2^{3/2}}, \\[4pt] & \text{kurtosis} = g_2 = \frac{n M_4}{M_2^2}-3. \end{align} $$

For the incremental case (i.e., $$B = \{x\}$$), this simplifies to:

\begin{align} \delta & = x - m \\[5pt] m' & = m + \frac{\delta}{n} \\[5pt] M_2' & = M_2 + \delta^2 \frac{n-1}{n} \\[5pt] M_3' & = M_3 + \delta^3 \frac{ (n - 1) (n - 2)}{n^2} - \frac{3\delta M_2}{n} \\[5pt] M_4' & = M_4 + \frac{\delta^4 (n - 1) (n^2 - 3n + 3)}{n^3} + \frac{6\delta^2 M_2}{n^2} - \frac{4\delta M_3}{n} \end{align} $$

By preserving the value $$\delta / n$$, only one division operation is needed and the higher-order statistics can thus be calculated for little incremental cost.

An example of the online algorithm for kurtosis implemented as described is:

Pébaÿ further extends these results to arbitrary-order central moments, for the incremental and the pairwise cases, and subsequently Pébaÿ et al. for weighted and compound moments. One can also find there similar formulas for covariance.

Choi and Sweetman offer two alternative methods to compute the skewness and kurtosis, each of which can save substantial computer memory requirements and CPU time in certain applications. The first approach is to compute the statistical moments by separating the data into bins and then computing the moments from the geometry of the resulting histogram, which effectively becomes a one-pass algorithm for higher moments. One benefit is that the statistical moment calculations can be carried out to arbitrary accuracy such that the computations can be tuned to the precision of, e.g., the data storage format or the original measurement hardware. A relative histogram of a random variable can be constructed in the conventional way: the range of potential values is divided into bins and the number of occurrences within each bin are counted and plotted such that the area of each rectangle equals the portion of the sample values within that bin:

 * $$ H(x_k)=\frac{h(x_k)}{A}$$

where $$h(x_k)$$ and $$H(x_k)$$ represent the frequency and the relative frequency at bin $$x_k$$ and $A= \sum_{k=1}^K h(x_k) \,\Delta x_k$ is the total area of the histogram. After this normalization, the $$n$$ raw moments and central moments of $$x(t)$$ can be calculated from the relative histogram:

m_n^{(h)} = \sum_{k=1}^{K} x_k^n H(x_k) \, \Delta x_k = \frac{1}{A} \sum_{k=1}^K x_k^n h(x_k) \, \Delta x_k $$

\theta_n^{(h)}= \sum_{k=1}^{K} \Big(x_k-m_1^{(h)}\Big)^n \, H(x_k) \, \Delta x_k = \frac{1}{A} \sum_{k=1}^{K} \Big(x_k-m_1^{(h)}\Big)^n h(x_k) \, \Delta x_k $$

where the superscript $$^{(h)}$$ indicates the moments are calculated from the histogram. For constant bin width $$\Delta x_k=\Delta x$$ these two expressions can be simplified using $$I= A/\Delta x$$:

m_n^{(h)}= \frac{1}{I} \sum_{k=1}^K x_k^n \, h(x_k) $$

\theta_n^{(h)}= \frac{1}{I} \sum_{k=1}^K \Big(x_k-m_1^{(h)}\Big)^n h(x_k) $$

The second approach from Choi and Sweetman is an analytical methodology to combine statistical moments from individual segments of a time-history such that the resulting overall moments are those of the complete time-history. This methodology could be used for parallel computation of statistical moments with subsequent combination of those moments, or for combination of statistical moments computed at sequential times.

If $$Q$$ sets of statistical moments are known: $$(\gamma_{0,q},\mu_{q},\sigma^2_{q},\alpha_{3,q},\alpha_{4,q}) \quad $$ for $$q=1,2,\ldots,Q $$, then each $$\gamma_n$$ can be expressed in terms of the equivalent $$n$$ raw moments:

\gamma_{n,q}= m_{n,q} \gamma_{0,q} \qquad \quad \textrm{for} \quad n=1,2,3,4 \quad \text{ and } \quad q = 1,2, \dots ,Q $$

where $$\gamma_{0,q}$$ is generally taken to be the duration of the $$q^{th}$$ time-history, or the number of points if $$\Delta t$$ is constant.

The benefit of expressing the statistical moments in terms of $$\gamma$$ is that the $$Q$$ sets can be combined by addition, and there is no upper limit on the value of $$Q$$.

\gamma_{n,c}= \sum_{q=1}^Q \gamma_{n,q} \quad \quad \text{for } n=0,1,2,3,4 $$

where the subscript $$_c$$ represents the concatenated time-history or combined $$\gamma$$. These combined values of $$\gamma$$ can then be inversely transformed into raw moments representing the complete concatenated time-history

m_{n,c}=\frac{\gamma_{n,c}}{\gamma_{0,c}} \quad \text{for } n=1,2,3,4 $$

Known relationships between the raw moments ($$m_n$$) and the central moments ($$ \theta_n = \operatorname E[(x-\mu)^n])$$) are then used to compute the central moments of the concatenated time-history. Finally, the statistical moments of the concatenated history are computed from the central moments:

\mu_c=m_{1,c} \qquad \sigma^2_c=\theta_{2,c} \qquad \alpha_{3,c}=\frac{\theta_{3,c}}{\sigma_c^3} \qquad \alpha_{4,c}={\frac{\theta_{4,c}}{\sigma_c^4}}-3 $$

Covariance
Very similar algorithms can be used to compute the covariance.

Naïve algorithm
The naïve algorithm is
 * $$\operatorname{Cov}(X,Y) = \frac {\sum_{i=1}^n x_i y_i - (\sum_{i=1}^n x_i)(\sum_{i=1}^n y_i)/n}{n}. $$

For the algorithm above, one could use the following Python code:

With estimate of the mean
As for the variance, the covariance of two random variables is also shift-invariant, so given any two constant values $$k_x$$ and $$k_y,$$ it can be written:

 * $$\operatorname{Cov}(X,Y) = \operatorname{Cov}(X-k_x,Y-k_y) = \dfrac {\sum_{i=1}^n (x_i-k_x) (y_i-k_y) - (\sum_{i=1}^n (x_i-k_x))(\sum_{i=1}^n (y_i-k_y))/n}{n}. $$

and again choosing a value inside the range of values will stabilize the formula against catastrophic cancellation as well as make it more robust against big sums. Taking the first value of each data set, the algorithm can be written as:

Two-pass
The two-pass algorithm first computes the sample means, and then the covariance:
 * $$\bar x = \sum_{i=1}^n x_i/n$$
 * $$\bar y = \sum_{i=1}^n y_i/n$$
 * $$\operatorname{Cov}(X,Y) = \frac {\sum_{i=1}^n (x_i - \bar x)(y_i - \bar y)}{n}. $$

The two-pass algorithm may be written as:

A slightly more accurate compensated version performs the full naive algorithm on the residuals. The final sums $\sum_i x_i$ and $\sum_i y_i$  should be zero, but the second pass compensates for any small error.

Online
A stable one-pass algorithm exists, similar to the online algorithm for computing the variance, that computes co-moment $ C_n = \sum_{i=1}^n (x_i - \bar x_n)(y_i - \bar y_n)$ :
 * $$\begin{alignat}{2}

\bar x_n &= \bar x_{n-1} &\,+\,& \frac{x_n - \bar x_{n-1}}{n} \\[5pt] \bar y_n &= \bar y_{n-1} &\,+\,& \frac{y_n - \bar y_{n-1}}{n} \\[5pt] C_n     &= C_{n-1}      &\,+\,& (x_n - \bar x_n)(y_n - \bar y_{n-1}) \\[5pt] &= C_{n-1}     &\,+\,& (x_n - \bar x_{n-1})(y_n - \bar y_n) \end{alignat}$$ The apparent asymmetry in that last equation is due to the fact that $ (x_n - \bar x_n) = \frac{n-1}{n}(x_n - \bar x_{n-1})$, so both update terms are equal to $ \frac{n-1}{n}(x_n - \bar x_{n-1})(y_n - \bar y_{n-1})$. Even greater accuracy can be achieved by first computing the means, then using the stable one-pass algorithm on the residuals.

Thus the covariance can be computed as
 * $$\begin{align}

\operatorname{Cov}_N(X,Y) = \frac{C_N}{N} &= \frac{\operatorname{Cov}_{N-1}(X,Y)\cdot(N-1) + (x_n - \bar x_n)(y_n - \bar y_{n-1})}{N}\\ &= \frac{\operatorname{Cov}_{N-1}(X,Y)\cdot(N-1) + (x_n - \bar x_{n-1})(y_n - \bar y_n)}{N}\\ &= \frac{\operatorname{Cov}_{N-1}(X,Y)\cdot(N-1) + \frac{N-1}{N}(x_n - \bar x_{n-1})(y_n - \bar y_{n-1})}{N}\\ &= \frac{\operatorname{Cov}_{N-1}(X,Y)\cdot(N-1) + \frac{N}{N-1}(x_n - \bar x_{n})(y_n - \bar y_{n})}{N}. \end{align}$$

A small modification can also be made to compute the weighted covariance:

Likewise, there is a formula for combining the covariances of two sets that can be used to parallelize the computation:

 * $$C_X = C_A + C_B + (\bar x_A - \bar x_B)(\bar y_A - \bar y_B)\cdot\frac{n_A n_B}{n_X}. $$

Weighted batched version
A version of the weighted online algorithm that does batched updated also exists: let $$w_1, \dots w_N$$ denote the weights, and write

 * $$\begin{alignat}{2}

\bar x_{n+k} &= \bar x_n &\,+\,& \frac{\sum_{i=n+1}^{n+k} w_i (x_i - \bar x_n)}{\sum_{i=1}^{n+k} w_i} \\ \bar y_{n+k} &= \bar y_n &\,+\,& \frac{\sum_{i=n+1}^{n+k} w_i (y_i - \bar y_n)}{\sum_{i=1}^{n+k} w_i} \\ C_{n+k}     &= C_n      &\,+\,& \sum_{i=n+1}^{n+k} w_i (x_i - \bar x_{n+k})(y_i - \bar y_n) \\ &= C_n     &\,+\,& \sum_{i=n+1}^{n+k} w_i (x_i - \bar x_n)(y_i - \bar y_{n+k}) \\ \end{alignat}$$

The covariance can then be computed as

 * $$\operatorname{Cov}_N(X,Y) = \frac{C_N}{\sum_{i=1}^{N} w_i}$$

license: Creative Commons - Attribution Share-Alike - https://creativecommons.org/licenses/by-sa/4.0/

title: Algorithms for calculating variance


text:
Almond

The almond (Prunus amygdalus, syn. Prunus dulcis) is a species of tree from the genus Prunus. Along with the peach, it is classified in the subgenus Amygdalus, distinguished from the other subgenera by corrugations on the shell (endocarp) surrounding the seed.

The fruit of the almond is a drupe, consisting of an outer hull and a hard shell with the seed, which is not a true nut. Shelling almonds refers to removing the shell to reveal the seed. Almonds are sold shelled or unshelled. Blanched almonds are shelled almonds that have been treated with hot water to soften the seedcoat, which is then removed to reveal the white embryo. Once almonds are cleaned and processed, they can be stored over time. Almonds are used in many cuisines, often featuring prominently in desserts, such as marzipan.

The almond tree prospers in a moderate Mediterranean climate with cool winter weather. Almond is rarely found wild in its original setting. Almonds were one of the earliest domesticated fruit trees, due to the ability to produce quality offspring entirely from seed, without using suckers and cuttings. Evidence of domesticated almonds in the Early Bronze Age has been found in the archeological sites of the Middle East, and subsequently across the Mediterranean region and similar arid climates with cool winters.

California produces about 80% of the world's almond supply. Due to high acreage and water demand for almond cultivation, and need for pesticides, California almond production may be unsustainable, especially during the persistent drought and heat from climate change in the 21st century. Droughts in California have caused some producers to leave the industry, leading to lower supply and increased prices.

Description
The almond is a deciduous tree growing to 3 - 4.5 m in height, with a trunk of up to 30 cm in diameter. The young twigs are green at first, becoming purplish where exposed to sunlight, then gray in their second year. The leaves are 3 - 5 in long, with a serrated margin and a 2.5 cm petiole.

The fragrant flowers are white to pale pink, 3 - 5 cm diameter with five petals, produced singly or in pairs and appearing before the leaves in early spring. Almond trees thrive in Mediterranean climates with warm, dry summers and mild, wet winters. The optimal temperature for their growth is between 15 and 30 C and the tree buds have a chilling requirement of 200 to 700 hours below 7.2 °C to break dormancy.

Almonds begin bearing an economic crop in the third year after planting. Trees reach full bearing five to six years after planting. The fruit matures in the autumn, 7–8 months after flowering.

The almond fruit is 3.5 - 6 cm long. It is not a nut but a drupe. The outer covering, consisting of an outer exocarp, or skin, and mesocarp, or flesh, fleshy in other members of Prunus such as the plum and cherry, is instead a thick, leathery, gray-green coat (with a downy exterior), called the hull. Inside the hull is a woody endocarp which forms a reticulated, hard shell (like the outside of a peach pit) called the pyrena. Inside the shell is the edible seed, commonly called a nut. Generally, one seed is present, but occasionally two occur. After the fruit matures, the hull splits and separates from the shell, and an abscission layer forms between the stem and the fruit so that the fruit can fall from the tree. During harvest, mechanized tree shakers are used to expedite fruits falling to the ground for collection.

Sweet and bitter almonds

The seeds of Prunus dulcis var. dulcis are predominantly sweet but some individual trees produce seeds that are somewhat more bitter. The genetic basis for bitterness involves a single gene, the bitter flavor furthermore being recessive, both aspects making this trait easier to domesticate. The fruits from Prunus dulcis var. amara are always bitter, as are the kernels from other species of genus Prunus, such as apricot, peach and cherry (although to a lesser extent).

The bitter almond is slightly broader and shorter than the sweet almond and contains about 50% of the fixed oil that occurs in sweet almonds. It also contains the enzyme emulsin which, in the presence of water, acts on the two soluble glucosides amygdalin and prunasin yielding glucose, cyanide and the essential oil of bitter almonds, which is nearly pure benzaldehyde, the chemical causing the bitter flavor. Bitter almonds may yield 4–9 milligrams of hydrogen cyanide per almond and contain 42 times higher amounts of cyanide than the trace levels found in sweet almonds. The origin of cyanide content in bitter almonds is via the enzymatic hydrolysis of amygdalin. P450 monooxygenases are involved in the amygdalin biosynthetic pathway. A point mutation in a bHLH transcription factor prevents transcription of the two cytochrome P450 genes, resulting in the sweet kernel trait.

Etymology
The word almond is a loanword from Old French almande or alemande, descended from Late Latin amandula, amindula, modified from Classical Latin amygdala, which is in turn borrowed from Ancient Greek (ἀμυγδάλη) (cf. amygdala, an almond-shaped portion of the brain). Late Old English had amygdales 'almonds'.

The adjective amygdaloid (literally 'like an almond, almond-like') is used to describe objects which are roughly almond-shaped, particularly a shape which is part way between a triangle and an ellipse. For example, the amygdala of the brain uses a direct borrowing of the Greek term.

Origin and distribution
The precise origin of the almond is controversial due to estimates for its emergence across wide geographic regions. Sources indicate that its origins were in Central Asia between Iran, Turkmenistan, Tajikistan, Kurdistan, Afghanistan, and Iraq, or in an eastern Asian subregion between Mongolia and Uzbekistan. In other assessments, both botanical and archaeological evidence indicates that almonds originated and were first cultivated in West Asia, particularly in countries of the Levant. Other estimates specified Iran and Anatolia (present day Turkey) as origin locations of the almond, with botanical evidence for Iran as a possible origin center.

The wild form of domesticated almond also grew in parts of the Levant. Almond cultivation was spread by humans centuries ago along the shores of the Mediterranean Sea into northern Africa and southern Europe, and more recently to other world regions, notably California.

Selection of the sweet type from the many bitter types in the wild marked the beginning of almond domestication. The wild ancestor of the almond used to breed the domesticated species is unknown. The species Prunus fenzliana may be the most likely wild ancestor of the almond, in part because it is native to Armenia and western Azerbaijan, where it was apparently domesticated. Wild almond species were grown by early farmers, "at first unintentionally in the garbage heaps, and later intentionally in their orchards".

Cultivation

Almonds were one of the earliest domesticated fruit trees, due to "the ability of the grower to raise attractive almonds from seed. Thus, in spite of the fact that this plant does not lend itself to propagation from suckers or from cuttings, it could have been domesticated even before the introduction of grafting". Domesticated almonds appear in the Early Bronze Age (3000–2000 BC), such as the archaeological sites of Numeira (Jordan), or possibly earlier. Another well-known archaeological example of the almond is the fruit found in Tutankhamun's tomb in Egypt (c. 1325 BC), probably imported from the Levant. An article on almond tree cultivation in Spain is brought down in Ibn al-'Awwam's 12th-century agricultural work, Book on Agriculture.

Of the European countries that the Royal Botanic Garden Edinburgh reported as cultivating almonds, Germany is the northernmost, though the domesticated form can be found as far north as Iceland.

Varieties
Almond trees are small to medium sized but commercial cultivars can be grafted onto a different root-stock to produce smaller trees. Varieties include:
 * Nonpareil – originates in the 1800s. A large tree that produces large, smooth, thin-shelled almonds with 60–65% edible kernel per nut. Requires pollination from other almond varieties for good nut production.
 * Tuono – originates in Italy. Has thicker, hairier shells with only 32% of edible kernel per nut. The thicker shell gives some protection from pests such as the navel orangeworm. Does not require pollination by other almond varieties.
 * Mariana – used as a rootstock to result in smaller trees

Breeding
Breeding programmes have found the high shell-seal trait.

Pollination
The most widely planted varieties of almond are self-incompatible; hence these trees require pollen from a tree with different genetic characters to produce seeds. Almond orchards therefore must grow mixtures of almond varieties. In addition, the pollen is transferred from flower to flower by insects; therefore commercial growers must ensure there are enough insects to perform this task. The large scale of almond production in the U.S. creates a significant problem of providing enough pollinating insects. Additional pollinating insects are therefore brought to the trees. The pollination of California's almonds is the largest annual managed pollination event in the world, with over 1 million hives (nearly half of all beehives in the US) being brought to the almond orchards each February.

Much of the supply of bees is managed by pollination brokers, who contract with migratory beekeepers from at least 49 states for the event. This business was heavily affected by colony collapse disorder at the turn of the 21st century, causing a nationwide shortage of honey bees and increasing the price of insect pollination. To partially protect almond growers from these costs, researchers at the Agricultural Research Service, part of the United States Department of Agriculture (USDA), developed self-pollinating almond trees that combine this character with quality characters such as a flavor and yield. Self-pollinating almond varieties exist, but they lack some commercial characters. However, through natural hybridisation between different almond varieties, a new variety that was self-pollinating with a high yield of commercial quality nuts was produced.

Diseases
Almond trees can be attacked by an array of damaging microbes, fungal pathogens, plant viruses, and bacteria.

Pests
Pavement ants (Tetramorium caespitum), southern fire ants (Solenopsis xyloni), and thief ants (Solenopsis molesta) are seed predators. Bryobia rubrioculus mites are most known for their damage to this crop.

Sustainability
Almond production in California is concentrated mainly in the Central Valley, where the mild climate, rich soil, abundant sunshine and water supply make for ideal growing conditions. Due to the persistent droughts in California in the early 21st century, it became more difficult to raise almonds in a sustainable manner. The issue is complex because of the high amount of water needed to produce almonds: a single almond requires roughly 1.1 usgal of water to grow properly. Regulations related to water supplies are changing so some growers have destroyed their current almond orchards to replace with either younger trees or a different crop such as pistachio that needs less water. Sustainability strategies implemented by the Almond Board of California and almond farmers include:
 * tree and soil health, and other farming practices
 * minimizing dust production during the harvest
 * bee health
 * irrigation guidelines for farmers
 * food safety
 * use of waste biomass as coproducts with a goal to achieve zero waste
 * use of solar energy during processing
 * job development
 * support of scientific research to investigate potential health benefits of consuming almonds
 * international education about sustainability practices

Production
In 2022, world production of almonds was 3.6 million tonnes, led by the United States (table). Secondary producers were Australia and Spain.

United States
In the United States, production is concentrated in California where 1000000 acre and six different almond varieties were under cultivation in 2017, with a yield of 2.25 e9lb of shelled almonds. California production is marked by a period of intense pollination during late winter by rented commercial bees transported by truck across the U.S. to almond groves, requiring more than half of the total U.S. commercial honeybee population. The value of total U.S. exports of shelled almonds in 2016 was $3.2 billion.

All commercially grown almonds sold as food in the U.S. are sweet cultivars. The U.S. Food and Drug Administration reported in 2010 that some fractions of imported sweet almonds were contaminated with bitter almonds, which contain cyanide.

Australia
Australia is the largest almond production region in the Southern Hemisphere. Most of the almond orchards are located along the Murray River corridor in New South Wales, Victoria, and South Australia.

Spain
Spain has diverse commercial cultivars of almonds grown in Catalonia, Valencia, Murcia, Andalusia, and Aragón regions, and the Balearic Islands. Production in 2016 declined 2% nationally compared to 2015 production data.

The 'Marcona' almond cultivar is recognizably different from other almonds and is marketed by name. The kernel is short, round, relatively sweet, and delicate in texture. Its origin is unknown and has been grown in Spain for a long time; the tree is very productive, and the shell of the nut is hard.

Toxicity
Bitter almonds contain 42 times higher amounts of cyanide than the trace levels found in sweet almonds. Extract of bitter almond was once used medicinally but even in small doses, effects are severe or lethal, especially in children; the cyanide must be removed before consumption. The acute oral lethal dose of cyanide for adult humans is reported to be 0.5 – of body weight (approximately 50 bitter almonds), so that for children consuming 5–10 bitter almonds may be fatal. Symptoms of eating such almonds include vertigo and other typical cyanide poisoning effects.

Almonds may cause allergy or intolerance. Cross-reactivity is common with peach allergens (lipid transfer proteins) and tree nut allergens. Symptoms range from local signs and symptoms (e.g., oral allergy syndrome, contact urticaria) to systemic signs and symptoms including anaphylaxis (e.g., urticaria, angioedema, gastrointestinal and respiratory symptoms).

Almonds are susceptible to aflatoxin-producing molds. Aflatoxins are potent carcinogenic chemicals produced by molds such as Aspergillus flavus and Aspergillus parasiticus. The mold contamination may occur from soil, previously infested almonds, and almond pests such as navel-orange worm. High levels of mold growth typically appear as gray to black filament-like growth. It is unsafe to eat mold-infected tree nuts.

Some countries have strict limits on allowable levels of aflatoxin contamination of almonds and require adequate testing before the nuts can be marketed to their citizens. The European Union, for example, introduced a requirement since 2007 that all almond shipments to the EU be tested for aflatoxin. If aflatoxin does not meet the strict safety regulations, the entire consignment may be reprocessed to eliminate the aflatoxin or it must be destroyed.

Breeding programs have found the trait. High shell-seal provides resistance against these Aspergillus species and so against the development of their toxins.

Mandatory pasteurization in California
After tracing cases of salmonellosis to almonds, the USDA approved a proposal by the Almond Board of California to pasteurize almonds sold to the public. After publishing the rule in March 2007, the almond pasteurization program became mandatory for California companies effective 1 September 2007. Raw, untreated California almonds have not been available in the U.S. since then.

California almonds labeled "raw" must be steam-pasteurized or chemically treated with propylene oxide (PPO). This does not apply to imported almonds or almonds sold from the grower directly to the consumer in small quantities. The treatment also is not required for raw almonds sold for export outside of North America.

The Almond Board of California states: "PPO residue dissipates after treatment". The U.S. Environmental Protection Agency has reported: "Propylene oxide has been detected in fumigated food products; consumption of contaminated food is another possible route of exposure". PPO is classified as Group 2B ("possibly carcinogenic to humans").

The USDA-approved marketing order was challenged in court by organic farmers organized by the Cornucopia Institute, a Wisconsin-based farm policy research group which filed a lawsuit in September 2008. According to the institute, this almond marketing order has imposed significant financial burdens on small-scale and organic growers and damaged domestic almond markets. A federal judge dismissed the lawsuit in early 2009 on procedural grounds. In August 2010, a federal appeals court ruled that the farmers have a right to appeal the USDA regulation. In March 2013, the court vacated the suit on the basis that the objections should have been raised in 2007 when the regulation was first proposed.

Nutrition

Almonds are 4% water, 22% carbohydrates, 21% protein, and 50% fat. In a 100 g reference amount, almonds supply 579 kcal of food energy. The almond is a nutritionally dense food, providing a rich source (20% or more of the Daily Value, DV) of the B vitamins riboflavin and niacin, vitamin E, and the essential minerals calcium, copper, iron, magnesium, manganese, phosphorus, and zinc. Almonds are a moderate source (10–19% DV) of the B vitamins thiamine, vitamin B6, and folate, choline, and the essential mineral potassium. They also contain substantial dietary fiber, the monounsaturated fat, oleic acid, and the polyunsaturated fat, linoleic acid. Typical of nuts and seeds, almonds are a source of phytosterols such as beta-sitosterol, stigmasterol, campesterol, sitostanol, and campestanol.

Health
Almonds are included as a good source of protein among recommended healthy foods by the U.S. Department of Agriculture (USDA). A 2016 review of clinical research indicated that regular consumption of almonds may reduce the risk of heart disease by lowering blood levels of LDL cholesterol.

Culinary
While the almond is often eaten on its own, raw or toasted, it is also a component of various dishes. Almonds are available in many forms, such as whole, slivered, and ground into flour. Almond pieces around 2–3 mm in size, called "nibs", are used for special purposes such as decoration.

Almonds are a common addition to breakfast muesli or oatmeal.

Desserts
A wide range of classic sweets feature almonds as a central ingredient. Marzipan was developed in the Middle Ages. Since the 19th century almonds have been used to make bread, almond butter, cakes and puddings, candied confections, almond cream-filled pastries, nougat, cookies (macaroons, biscotti and qurabiya), and cakes (financiers, Esterházy torte), and other sweets and desserts.

The young, developing fruit of the almond tree can be eaten whole (green almonds) when they are still green and fleshy on the outside and the inner shell has not yet hardened. The fruit is somewhat sour, but is a popular snack in parts of the Middle East, eaten dipped in salt to balance the sour taste. Also in the Middle East they are often eaten with dates. They are available only from mid-April to mid-June in the Northern Hemisphere; pickling or brining extends the fruit's shelf life.

Marzipan
Marzipan, a smooth, sweetened almond paste, is used in a number of elegant cakes and desserts. Princess cake is covered by marzipan (similar to fondant), as is Battenberg cake. In Sicily, sponge cake is covered with marzipan to make cassatella di sant'Agata and cassata siciliana, and marzipan is dyed and crafted into realistic fruit shapes to make frutta martorana. The Andalusian Christmas pastry pan de Cádiz is filled with marzipan and candied fruit.

World cuisines
Certain natural food stores sell "bitter almonds" or "apricot kernels" labeled as such, requiring significant caution by consumers for how to prepare and eat these products.
 * In French cuisine, alternating layers of almond and hazelnut meringue are used to make the dessert dacquoise. Pithivier is one of many almond cream-filled pastries.
 * In Germany, Easter bread called Deutsches Osterbrot is baked with raisins and almonds.
 * In Greece almond flour is used to make amygdalopita, a glyka tapsiou dessert cake baking in a tray. Almonds are used for kourabiedes, a Greek version of the traditional quarabiya almond biscuits. A soft drink known as soumada is made from almonds in various regions.
 * In Saudi Arabia, almonds are a typical embellishment for the rice dish kabsa.
 * In Iran, green almonds are dipped in sea salt and eaten as snacks on street markets; they are called chaqale bâdam. Candied almonds called noghl are served alongside tea and coffee. Also, sweet almonds are used to prepare special food for babies, named harire badam. Almonds are added to some foods, cookies, and desserts, or are used to decorate foods. People in Iran consume roasted nuts for special events, for example, during New Year (Nowruz) parties.
 * In Italy, colomba di Pasqua is a traditional Easter cake made with almonds. Bitter almonds are the base for amaretti cookies, a common dessert. Almonds are also a common choice as the nuts to include in torrone.
 * In Morocco, almonds in the form of sweet almond paste are the main ingredient in pastry fillings, and several other desserts. Fried blanched whole almonds are also used to decorate sweet tajines such as lamb with prunes. Southwestern Berber regions of Essaouira and Souss are also known for amlou, a spread made of almond paste, argan oil, and honey. Almond paste is also mixed with toasted flour and among others, honey, olive oil or butter, anise, fennel, sesame seeds, and cinnamon to make sellou (also called zamita in Meknes or slilou in Marrakech), a sweet snack known for its long shelf life and high nutritive value.
 * In Indian cuisine, almonds are the base ingredients of pasanda-style and Mughlai curries. Badam halva is a sweet made from almonds with added coloring. Almond flakes are added to many sweets (such as sohan barfi), and are usually visible sticking to the outer surface. Almonds form the base of various drinks which are supposed to have cooling properties. Almond sherbet or sherbet-e-badaam, is a common summer drink. Almonds are also sold as a snack with added salt.
 * In Israel almonds are used as a topping for tahini cookies or eaten as a snack.
 * In Spain Marcona almonds are usually toasted in oil and lightly salted. They are used by Spanish confectioners to prepare a sweet called turrón.
 * In Arabian cuisine, almonds are commonly used as garnishing for Mansaf.

Milk
Almonds can be processed into a milk substitute called almond milk; the nut's soft texture, mild flavor, and light coloring (when skinned) make for an efficient analog to dairy, and a soy-free choice for lactose intolerant people and vegans. Raw, blanched, and lightly toasted almonds work well for different production techniques, some of which are similar to that of soy milk and some of which use no heat, resulting in raw milk.

Almond milk, along with almond butter and almond oil, are versatile products used in both sweet and savoury dishes.

In Moroccan cuisine, sharbat billooz, a common beverage, is made by blending blanched almonds with milk, sugar and other flavorings.

Flour and skins
Almond flour or ground almond meal combined with sugar or honey as marzipan is often used as a gluten-free alternative to wheat flour in cooking and baking.

Almonds contain polyphenols in their skins consisting of flavonols, flavan-3-ols, hydroxybenzoic acids and flavanones analogous to those of certain fruits and vegetables. These phenolic compounds and almond skin prebiotic dietary fiber have commercial interest as food additives or dietary supplements.

Syrup
Historically, almond syrup was an emulsion of sweet and bitter almonds, usually made with barley syrup (orgeat syrup) or in a syrup of orange flower water and sugar, often flavored with a synthetic aroma of almonds. Orgeat syrup is an important ingredient in the Mai Tai and many other Tiki drinks.

Due to the cyanide found in bitter almonds, modern syrups generally are produced only from sweet almonds. Such syrup products do not contain significant levels of hydrocyanic acid, so are generally considered safe for human consumption.

Oils

Almonds are a rich source of oil, with 50% of kernel dry mass as fat (whole almond nutrition table). In relation to total dry mass of the kernel, almond oil contains 32% monounsaturated oleic acid (an omega-9 fatty acid), 13% linoleic acid (a polyunsaturated omega-6 essential fatty acid), and 10% saturated fatty acid (mainly as palmitic acid). Linolenic acid, a polyunsaturated omega-3 fat, is not present (table). Almond oil is a rich source of vitamin E, providing 261% of the Daily Value per 100 millilitres.

When almond oil is analyzed separately and expressed per 100 grams as a reference mass, the oil provides 884 kcal of food energy, 8 grams of saturated fat (81% of which is palmitic acid), 70 grams of oleic acid, and 17 grams of linoleic acid (oil table).

Oleum amygdalae, the fixed oil, is prepared from either sweet or bitter almonds, and is a glyceryl oleate with a slight odour and a nutty taste. It is almost insoluble in alcohol but readily soluble in chloroform or ether. Almond oil is obtained from the dried kernel of almonds. Sweet almond oil is used as a carrier oil in aromatherapy and cosmetics while bitter almond oil, containing benzaldehyde, is used as a food flavouring and in perfume.

In culture

The almond is highly revered in some cultures. The tree originated in the Middle East. In the Bible, the almond is mentioned ten times, beginning with Genesis 43:11, where it is described as "among the best of fruits". In Numbers 17, Levi is chosen from the other tribes of Israel by Aaron's rod, which brought forth almond flowers. The almond blossom supplied a model for the menorah which stood in the Holy Temple, "Three cups, shaped like almond blossoms, were on one branch, with a knob and a flower; and three cups, shaped like almond blossoms, were on the other … on the candlestick itself were four cups, shaped like almond blossoms, with its knobs and flowers" (Exodus 25:33–34; 37:19–20). Many Sephardic Jews give five almonds to each guest before special occasions like weddings.

Similarly, Christian symbolism often uses almond branches as a symbol of the virgin birth of Jesus; paintings and icons often include almond-shaped haloes encircling the Christ Child and as a symbol of Mary. The word "luz", which appears in Genesis 30:37, sometimes translated as "hazel", may actually be derived from the Aramaic name for almond (Luz), and is translated as such in the New International Version and other versions of the Bible. The Arabic name for almond is لوز "lauz" or "lūz". In some parts of the Levant and North Africa, it is pronounced "loz", which is very close to its Aramaic origin.

The Entrance of the flower (La entrada de la flor) is an event celebrated on 1 February in Torrent, Spain, in which the clavarios and members of the Confrerie of the Mother of God deliver a branch of the first-blooming almond-tree to the Virgin.

title: Almond


text:
Talk:Almond

Sometimes a shrub
@Zerf in the Levant the plant never exceeds 4 meters and only grows as a shrub. דולב חולב (talk) 00:39, 24 February 2024 (UTC)

Featured picture scheduled for POTD
Hello! This is to let editors know that File:Almonds -_in_shell,_shell_cracked_open,_shelled,_blanched.jpg, a featured picture used in this article, has been selected as the English Wikipedia's picture of the day (POTD) for June 16, 2024. A preview of the POTD is displayed below and can be edited at Template:POTD/2024-06-16. For the greater benefit of readers, any potential improvements or maintenance that could benefit the quality of this article should be done before its scheduled appearance on the Main Page. If you have any concerns, please place a message at Wikipedia talk:Picture of the day. Thank you! — Amakuru (talk) 09:52, 14 June 2024 (UTC)

Iran-focused editing
This edit and several others made today use an Iran-based source ("Iranica Online") and interpretations which are not supported by WP:SCIRS sources for the origin and distribution of almond.

Encyclopedia Britannica establishes the broad region of southwestern Asia (not specifically mentioning Iran) as the origin region of almond, a conclusion supported by the Ladizinsky review. There is no source-supported reason to attribute almond's origin or present-day distribution to Iran, which is not among the top five countries in 2022 almond production (production section and table).

The Iranica Online site does not impress as an objective, reliable source for the almond article. Iranica Online lays claims to almond origin and current distribution in Iran, while the peer-reviewed Ladizinsky article shows a wider origin and distribution not specific to Iran or any one country.

Further, Iran appears to be 7th in world production of almonds, according to the FAOSTAT source for the production section.

Please discuss issues here with other editors without continuous edit warring for your point of view based on the Iranica Online website. Zefr (talk) 17:13, 26 June 2024 (UTC)

 * Disagreed, Encyclopedia Iranica is a high quality (tertiary) source, it is written by prominent experts of any topic that is dealt with in it. Besides, replacing Iranica with Britannica, a low quality source was all but a good idea. Also, I think that the warnings on the talk page of IP are, for many of them, irrelevant, as their edits were made in good faith and, ultimately, they are right when they mention Iran as a center of origin of almonds. I humbly suggest you consider removing them, as per WP:BITE. Best. ---Wikaviani  (talk) (contribs)  20:59, 26 June 2024 (UTC)
 * I don't see any consensus on Wikipedia or published evidence that Iranica Online is high-quality or superior as a source compared to Encyclopedia Britannica, which is widely used as a general source across Wikipedia. The Doug Weller criticism is from one person in a discussion 7 years ago that Britannica is unreliable, whereas a review of the many discussions about Britannica at WP:RSN shows plentiful defense and favor of using it as a source that should be fine for general statements like "almonds are native to southwestern Asia"; this wide regional origin is practical and is also what the Ladizinsky source states.
 * The Iranica article clearly is an Iran-centric view, stating that "Prunus amygdalus is undoubtedly native to the Iranian land-mass", which could be claimed by any country in southwestern Asia. There is nothing in peer-reviewed literature that states "Iran is a center of origin of almonds."
 * Concerning the incoherent message by the IP user below, a talk page is for discussing an improvement to the article with support by a WP:RS reference, WP:TALK. It is not a place for airing out opinions, WP:NOTFORUM. Zefr (talk) 23:04, 26 June 2024 (UTC)
 * I think that you are mistaken by the name of Encyclopedia Iranica. Besides, the doubts about Britannica raised by Doug Weller are shared by many editors here, including me and others and his concerns still stand i.e. Britannica articles are often written by one person and "fact checked" by Britannica editors, which means that Britannica is not as strong as you seem to believe. ---Wikaviani  (talk) (contribs)  07:34, 27 June 2024 (UTC)

Dear user It seems better that Correct it because you didn't read correctly. Iranika did not say what the plant's distribution is like today, he said about the origin of the plant, while your source examines today's trade, Iranika mentions the historical origin.

Your words are very irrelevant,for example, "If we trade bananas in another country today and we are the first rank, while India does not have a trade rank with the origin of bananas, then we can say that bananas aren't for India." It is not because today it does not have a rank in business or does not do business at all?!"" This is a historical discussion, not business.

it seems that you are not looking at the sources correctly, or you seem to think that it is clearly mentioned several times in this reliable site that it is of historical origin in Iran, while the wild nature of this plant is rarely found in Iran or elsewhere today. It seems that you are clearly trying to remove the name of Iran from the article because you are deleting the reliable sources, you are deleting the content, you said that you do not accept the source, we put a very reliable and clear source, but you still deleted the sources and even wrote Iran-focused here. In addition, what is clear is that today's commercial production of the country has nothing to do with the historical origin of the plant .It should be noted, you said almonds Wikipedia does not support Iranica. A page on wikipedia doesn't support anything, it's wikipedia that supports it or not, Iranica is one of the most reliable References, it's better, it's very biased.2A02:4540:61:28A9:FAE5:6B08:39B2:33A6 (talk) 20:05, 26 June 2024 (UTC)

I suggest you discuss your edits here instead of edit-warring. The sources that are cited mainly mention Iran and some surrounding countries as the center of origin, I don't get well why you refuse to follow WP:WEIGHT and keep mentioning many countries just as if they were considered the center of origin of almond like Iran or the levant. ---Wikaviani  (talk) (contribs)  00:16, 7 July 2024 (UTC)

New sources and expanded text
The several improvements contained in this edit are being challenged by a user with no feedback in edit summaries or here on the talk page. Per WP:BURDEN, the challenge needs to identify better sources and reasons for not accepting the sourced content. Zefr (talk) 00:14, 7 July 2024 (UTC)

 * What is the problem with the quality of sources ? Both Iranica and Imani are good sources. ---Wikaviani  (talk) (contribs)  00:18, 7 July 2024 (UTC)
 * Those two sources are in use, but are not the only sources discussing the hypothesis (also called controversy) of what geographic location is the origin or almonds. Your adherence to mention only Iran displays an absence of possibility that the origin of almonds is not Iran, but a wide geographic area from the Mediterranean to China - the sources discuss this. Zefr (talk) 00:21, 7 July 2024 (UTC)
 * But your edits do no comply with WP:WEIGHT, the Iranian or Levant claim is more strong than the Iraqi, Turkish etc. Also, you should wait to achieve consensus instead of edit-warring. ---Wikaviani  (talk) (contribs)  00:32, 7 July 2024 (UTC)
 * Sentences in the origin section that were improved with sources and sourced content:
 * 1. the geographic origin is controversial (described by authors as an hypothesis or a riddle): sourced by Imani, Martínez-Gómez, Ladizinsky and Chin
 * 2. origins were in Central Asia between Iran, Turkmenistan, Tajikistan, Kurdistan, Afghanistan, and Iraq, or in an eastern Asian subregion between Mongolia and Uzbekistan: sourced by the same 4 references above (mentions Iran, which seems to be your main focus for attributing origin, when a much wider geographic area is botanically likely and supported by archeological findings)
 * 3. only Iranica and selected parts of the Imani ref focus on Iran (both are Iranian sources).
 * Your claim of WP:WEIGHT is false, as only two refs focus on an Iran origin when other sources describe a wide geographic origin is likely. A claim of WEIGHT cannot apply to an unknown. Zefr (talk) 00:40, 7 July 2024 (UTC)
 * This is the paragraph Wikiviani disputes, when it was prepared with reputable sources and given neutral treatment per WP:BALANCE:
 * Rather than warring over your singular view that Iran is a specific origin, please address the content of this paragraph. Zefr (talk) 00:51, 7 July 2024 (UTC)
 * There are only few sources cited for the origin of almond, 2 are supporting an iranian claim, the fact that these sources are Iranian is irrelevant, they are reliable. Also, another editor reverted a similar edit of yours few days ago, what is the purpose of edit-warring against several editors to impose your version ? ---Wikaviani  (talk) (contribs)  00:52, 7 July 2024 (UTC)
 * Could you wait for the discussion to conclude before retoring your dodgy edits ??? ---Wikaviani  (talk) (contribs)  00:20, 7 July 2024 (UTC)
 * Could you wait for the discussion to conclude before retoring your dodgy edits ??? ---Wikaviani  (talk) (contribs)  00:20, 7 July 2024 (UTC)

title: Talk:Almond


text:
Talk:The Amazing Spider-Man

Some missing facts
--Muhandes (talk) 19:31, 20 May 2018 (UTC)
 * Lee and Conway are credited together on #116-118. The text implies Lee's last credit was for #110.
 * Bill Mantlo wrote #181 with Sal Buscema and Mike Esposito credited as artists.
 * Marv Wolfman's last issue was #204. Three is quite a mess from #205 to #223:
 * David Michelinie wrote #205 with Keith Pollard/Jim Mooney doing pencils/inks.
 * Roger Stern wrote #206 with John Byrne & Gene Day as artists.
 * Dennis O'Neil took the reins as writer for #207-218 with various art teams:
 * For #207 Mooney/Pablo Marcos doing pencils/inks.
 * For #208 John Romita Jr. did the layouts with Al Milgrom/Brett Breeding finishing the art (Jim Shooter and Mark Gruenwald were given thanks for plotting).
 * For #209 Alan Weiss did pencils with Klaus Janson/Bob McLeod/Joe Rubinstein/ Bob Wiacek/Milgrom doing inks.
 * For #210 Romita Jr. and Joe Sinnott did art.
 * Some stability was reached for #211-217 with Romita Jr./Mooney credited for art. On #218 Romita Jr. is credited for pencils and Mooney/Milgrom for inks.
 * On #219 Luke McDonnell did pencils and Mooney continued doing inks.
 * Michael L. Fleisher wrote #220 and McLeod did the art.
 * O'Neil returned for #221 with Alan Kupperberg/Mooney on pencils/inks.
 * Mantlo wrote #222 with Bob Hall/Mooney on pencils/inks.
 * O'Neil returned again to plot #223 with J.M. DeMatteis doing the script and the art is by Romita Jr./Milgrom as penciler/inker.
 * Stern took over writing at #224.

title: Talk:The Amazing Spider-Man