“Imagining the future is a kind of nostalgia.” This is a line from John Green’s young-adult book Looking for Alaska. It’s pretty, and melancholy, and very popular on Tumblr. It’s also scientifically accurate.

Imagining the future is a kind of nostalgia, because humans predict what the future will be like by using their memories. This is how things you do over and over again become routine. For example, you know generally what your day will be like at the office tomorrow based on what your day at the office was like today, and all the other days you’ve spent there. But memory also helps people predict what it will be like to do things they haven’t done before.

Say that you are imagining your future wedding (if you’ve never gotten married before). You probably see it as a scene—at a church, or on the beach, or under a wooded canopy in a forest with the bridal party all wearing elf ears. There are flowers, or twinkling lights, or mason jars everywhere. You can envision the guests, how they might look, what your soon-to-be spouse is wearing, what look they have on their face. All of these details come from your memory—of weddings you’ve been to before, as well as weddings you’ve seen depicted in pop culture, or in photo albums. The scene also relies on your memory of your friends and family.

“When somebody’s preparing for a date with someone they’ve never been on a date with before, or a job interview—these situations where we don’t have past experience, that’s where we think this ability to imagine the future really matters,” says Karl Szpunar, a professor of psychology at the University of Illinois at Chicago. People “can take bits and pieces, like who’s going to be there, where it’s going to be, and try to put all that together into a novel simulation of events.”

The first clue that memory and imagining the future might go hand in hand came from amnesia patients. When they lost their pasts, it seemed, they lost their futures as well. This was the case with the famous patient known by his initials, “H.M.” H.M. had epilepsy, and to treat it, he received an experimental surgery in 1953 that removed several portions of his brain, including almost his entire hippocampus, which is a vital brain structure for memory. After the surgery, H.M. had severe amnesia, and also appeared to struggle with the future. A researcher once asked H.M., “What do you think you’ll do tomorrow?” He replied, “Whatever is beneficial.”

Since then, functional MRI scans have allowed researchers to determine that many of the same brain structures are indeed involved in both remembering and forecasting. In a study Szpunar did, he and his colleagues looked at activity in the brain’s default network, which includes the hippocampus as well as regions that involve processing personal information, spatial navigation, and sensory information. They found that activity in many of these regions was “almost completely overlapping” when people remembered and imagined future events, Szpunar says.

Researchers are still trying to pin down exactly how different brain regions are involved in these processes, but much of it has to do with the construction of scenes. You can remember facts, sure, and you can make purely informational predictions—“We will have jet packs by 2050”—but often, when you remember, you are reliving a scene from your memory. You have a mental map of the space; you can “hear” what’s being said and “smell” smells and “taste” flavors; you can feel your emotions from that moment anew. Similarly, when you imagine something you might experience in the future, you are essentially “pre-living” that scene. And just as memories are more detailed the more recent they are, imagined future scenes are more detailed the nearer in the future they are.

“It takes so much cognitive effort to come up with detailed simulations,” Szpunar says. “So it’s like, why would you spend all that time when it’s not going to happen for 30 or 40 years? Whereas if it’s something happening this weekend, and you’re like ‘How’s this date going to go?’—those things, people just anguish over them and really come up with these detailed simulations.”

When people try to imagine the more distant future—that classic interview question, “Where do you see yourself in 10 years?”—they tend to rely heavily on something called a cultural life script. This is the progression of events that a life in a certain culture is expected to contain. In much of the West, the cultural life script is something like: go to school, move out of your parents’ house, get one or more college degrees, find a job, fall in love, get married, buy a house, have kids, retire, have grandchildren, die. Not everyone expects their life to contain all of those events, but they’re aware of those milestones and will generally tell their life story using them as a framework. The further into the future you try to imagine, the more unknowns there are, so people reach for these events.

“We can’t really imagine or think that far into the future, and we can’t remember that far back, if we don’t have this cultural life script as a kind of skeleton for our life story,” says Annette Bohn, a professor of psychology at Aarhus University in Denmark. In studies Bohn has done with adolescents, their conception of a script seemed to develop in parallel with their ability to remember the past and imagine the future. (At the other end of the life course, older people’s ability to imagine the future declines in tandem with their memory.)

It’s not hard to see how this ability to imagine the future gives humans an evolutionary advantage. If you can plan for the future, you’re more likely to survive it. But there’s are limitations as well. Your accumulated experiences—and your cultural life script—are the only building blocks you have to construct a vision of the future. This can make it hard to expect the unexpected, and it means people often expect the future to be more like the past, or the present, than it will be.

In a similar vein, people tend to underestimate how much their feelings and desires will change over time. Even though they know that their personalities have changed a lot in the past, they have a tendency to think that the person they are now is the person they will be forever. This applies more broadly, too. You can see it in the technological advances imagined in science fiction. As my colleague Adrienne LaFrance wrote, while Back to the Future II (made in 1989 and set in 2015) made a lot of canny predictions—it got videoconferencing and drones right—it also thought people would still be using pay phones and fax machines. Which makes sense, given how ubiquitous those technologies were at the time the film was made.

There’s also an “optimistic, extreme positivity bias toward the future,” Bohn says. To the point that people “always say future events are more important to their identity and life story than the past events.” Talk about being nostalgic for the future.

But it might help people temper their expectations if they keep in mind that even though they can dream up detailed, novel scenes of things yet to come, their imagined futures are really just projections of their pasts. The future holds more surprises—and, potentially, more disappointments—than we might predict.