<prompt> Human: I submitted this to rdataisbeautiful some time last week and it got some traction, so I wanted to post it here but with a more in-depth writeup.Note that this data is from Robert Shillers work. An up-to-date repository is kept at this link Up next, Ill probably find some bond data and see if I can simulate a three-fund portfolio or something. But for now, enjoy some visuals based around the stock market:Image Gallery: Main image After 145 years all data Your chance of selling at a loss AnimatedThe plots above were generated based on past returns in the SP. So at Year 1, we take every point on the SP curve, look at every point on the SP thats one year ahead, add in dividends and subtract inflation, and record all points as a relative gain or loss for Year 1. Then we do the same thing for Year 2. Then Year 3. And so on, ad nauseum. The program took a couple hours to finish crunching all the numbers.In short, for the plots above: If you invest for X years, you have a distribution of Y possible returns, based on previous history.Some of the worst market downturns are also represented here, like the Great Depression the 1970s recession Black Monday the Dot-Com Bubble the 2008 Financial Crisis But note how they completely recover to turn a profit after some more time in the market. Heres the list of years you can invest, and still be down. Take note that some of these years cover the same eras: Down after 10 years 11.8 chance historically: 1908 1909 1910 1911 1912 1929 1930 1936 1937 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1998 1999 2000 2001 Down after 15 years 4.73 chance historically: 1905 1906 1907 1929 1964 1965 1966 1967 1968 1969 Down after 20 years 0.0664 chance historically: 1901 Down after 25 years 0 chance historically: none---Disclaimer:Note that this stock market simulation assumes a portfolio that is invested in 100 US Stocks. While a lot of the results show that 100 Stocks can generate an impressive return, this is not an ideal portfolio.A portfolio should be diversified with a good mix of US Stocks, International Stocks, and Bonds. This diversification helps to hedge against market swings, and will help the investor to optimize returns on their investment with lower risk than this visual demonstrates. This is especially true closer to retirement age.In addition to this, this curve only looks at one lump sum of initial investing. A typical investor will not have the capital to employ a single lump sum as a basis for a long-term investment, and will instead rely on dollar cost averaging, where cash is deposited across multiple years which helps to smooth out the curve as well.---If you want the code used to generate, sort, and display this data, I have made this entire project open-source hereFurther reading: Personalfinance Wiki on Investing I have X. What do I do with it? The Bogleheads Wiki on Three Fund Portfolios cFIREsim - open-source portfolio simulator  <response>: The SP 500 hasnt existed nearly that long, and its an actively managed index as opposed to the popular misconception that its simply the 500 largest companies in the US so its impossible to use a deterministic methodology to say what it would have been if it had been invented earlier. 