Birthday Buddies

Which famous people share my birthday?

We will access real-world data using the Wolfram Language and create some visualizations that summarize the information we gather.

Review of Entity

Holding the Ctrl key while pressing the = key will open a box for inline free-form input.

LinguisticAssistant

Type in something of interest.

LinguisticAssistant

This will create an entity. We can treat the entity as the head of a function, like the “f” in f[x], when asking for information about that entity.

(Entity["Abraham Lincoln", Entity["Person","AbrahamLincoln::sjv3j"], "Entity[\"Person\", \"AbrahamLincoln::sjv3j\"]", "person"])["Image"]

What types of information can we ask for? To see all of the available properties for an entity, just ask.

(Entity["Abraham Lincoln", Entity["Person","AbrahamLincoln::sjv3j"], "Entity[\"Person\", \"AbrahamLincoln::sjv3j\"]", "person"])["Properties"]

For people, something we can specifically ask about is their birthdate.

(Entity["Abraham Lincoln", Entity["Person","AbrahamLincoln::sjv3j"], "Entity[\"Person\", \"AbrahamLincoln::sjv3j\"]", "person"])["BirthDate"]

Note that this result is its own kind of item within the Wolfram Language. It is a DateObject.

DateObject[{1809,2,12}]

Finding People by Birthdate

Among all of the entities of type “Person” we can find those with a specific birthdate. Use EntityList to display the elements within the implicitly defined entity group.

EntityList[Entity["Person","BirthDate"->DateObject[{1809,2,12}]]]

How interesting! Let’s go off on a little computational thinking tangent about this.

Aside: Can we learn more about their commonalities?

Another way to access real-world data within the Wolfram Language is to send a query to Wolfram|Alpha. We can do this by pressing the = key twice at the beginning of an input cell. (Note: A single = will also access Wolfram|Alpha but returns a single result.) Or use the WolframAlpha function directly with a string.

Evaluate either of the below and browse the results. Be sure to scroll to the bottom.

WolframAlpha["What do Abraham Lincoln and Charles Darwin have in common?"]

Do you see the spikes in Wikipedia page hits around 2009 and 2013?

WolframAlphaQueryResults

Why do you think the page hits increased at that point in 2009?

What is going on around 2013?

Within the full Wolfram|Alpha result, click on the circled + in the upper right corner of the pod with the plot and select “Time series data.” The following will be pasted into your notebook and automatically evaluated.

WolframAlpha["What do Abraham Lincoln and Charles Darwin have in common?",{{"PopularityPod:WikipediaStatsData",1},"TimeSeriesData"}]

Let’s give that a name. Remember that % is the previous output from the kernel and the semi-colon ; will prevent the output from appearing again.

data=%;

We can graph this data ourselves and zoom in on the range we are interested in.

DateListPlot[data,PlotRange->{{{2012},{2014}},All}]

I remember that the movie Lincoln was in theaters a few years ago.

LinguisticAssistant

(Entity["Lincoln", Entity["Movie","Lincoln::ywsw3"], "Entity[\"Movie\", \"Lincoln::ywsw3\"]", "movie"])[(EntityProperty["release date", EntityProperty["Movie","ReleaseDate"], "EntityProperty[\"Movie\", \"ReleaseDate\"]"])]

That sounds about right and corresponds to the maximum of the graph. Why the second spike, just after the start of 2013? Use the = twice again for Wolfram|Alpha.

When was the actual ceremony?

Oh, that’s too funny! That’s my birthday! And my birthday is what I was going to do next.

Back to Finding People by Birthdate

My birthdate is February 24, 1974 so I’ll put that into a DateObject. Try using your own birthday.

DateObject[{1974,2,24}]

We can copy and paste that DateObject box directly into our implicitly defined entity and ask for the list of elements, as before.

EntityList[Entity["Person","BirthDate"->(DateObject["Day: ""Sun 24 Feb 1974", DateObject[{1974,2,24},"Day","Gregorian",-7.`]])]]

Or the DateObject may be typed in directly.

EntityList[Entity["Person","BirthDate"->DateObject[{1974,2,24}]]]

I recognize one of these names (an actress I had learned some time ago has my same birthdate), but what about the others?

Aside: What if you have an empty list? Or a very short list?

There is a chance that your birthday will have no matches or very few matches. This is most likely if you are young (such as a high school or middle school student). Below are some ideas for options to create a list that may be of interest to you.

Use your birthdate 20 or 50 years earlier or use the birthdate of one of your parents.

EntityList[Entity["Person","BirthDate"->DateObject[{1954,2,24}]]]

Try your birth month. Just remove the “day” element from the list in DateObject.

EntityList[Entity["Person","BirthDate"->DateObject[{1974,2}]]]

In my case this list would be too long. Take a random sample of 8 or 9 elements.

RandomSample[EntityList[Entity["Person","BirthDate"->DateObject[{1974,2}]]],8]

Use a random sample from your birth year.

RandomSample[EntityList[Entity["Person","BirthDate"->DateObject[{1974}]]],8]

This makes me wonder . . . Are there any famous babies this year?

EntityList[Entity["Person","BirthDate"->DateObject[{Today["Year"]}]]]

Make up a date or use a holiday such as Thanksgiving 1960. Note that it will automatically figure out the date using the inline free-form input.

LinguisticAssistant (* Evaluate this *)

EntityList[Entity["Person","BirthDate"->LinguisticAssistant]]

Try 100 years ago today.

EntityList[Entity["Person","BirthDate"->LinguisticAssistant]]

Or use the birthday of someone famous.

EntityList[Entity["Person","BirthDate"->LinguisticAssistant]]

(Entity["Stephen Wolfram", Entity["Person","StephenWolfram::j276d"], "Entity[\"Person\", \"StephenWolfram::j276d\"]", "person"])[(EntityProperty["date of birth", EntityProperty["Person","BirthDate"], "EntityProperty[\"Person\", \"BirthDate\"]"])]

Ha! August 29 is my husband’s birthday, though in a different year. By the way, Michael Jackson was also born on August 29. This leads to the question of whether we can find folks with the same birthday by month and day.

Unfortunately, at this time I am unable to find a good way to do that without downloading over 350,000 people and having the code check them one by one. A couple of my students suggested using Table to find people with the same birthday within a span of years.

Flatten[Table[EntityList[Entity["Person","BirthDate"->DateObject[{year,8,29}]]],{year,1950,1960}]]

Who are these people?

For whichever list you choose, give it a name so it is easier to refer to along the way. A list of about 8 to 10 people will work well for what is planned next.

buddies=EntityList[Entity["Person","BirthDate"->DateObject[{1974,2,24}]]]

Who are these people? One way to answer this is by finding their occupations.

Through[buddies["Occupation"]]

The function Through allows a list of function heads to all be evaluated with the same argument.

Through[{f,g,h}[x]]

Or recall how we can use Map and pure functions with # and & to so something similar.

Map[#[x]&,{f,g,h}]

For each person, let’s make a column with their name, image, and occupation. We can do this with Map. In our example, our list of functions is the list of people entities.

Map[Column[{#,#["Image"],#["Occupation"]}]&,buddies]

Where were these people born?

This was actually my original idea, to create a map of birthplaces of famous people. First we need to create a list of all of the birthplaces. We will use Through again.

Through[buddies["BirthPlace"]]

There may be some missing values, but we will work with what we have. If you are missing a lot, you may want to generate a different list of “buddies.”

GeoListPlot[Through[buddies["BirthPlace"]]]

It worked! However, it would be nice to know which marker goes with which person. Let’s set up the data to be ordered pairs of each person and their birthplace. Back to using Map.

data=Map[{#,#["BirthPlace"]}&,buddies]

To see just the birthplaces, we can ask for the second part of all of the sublists.

data[[All,2]]

It is possible to label the markers. One way is with automatic labels that state the location names.

GeoListPlot[data[[All,2]],GeoLabels->Automatic]

Though that isn’t useful for identifying who whas born where. Tooltip allows custom labels to appear when you mouse over a marker. Below #1 indicates the marker and #2 is the marker location entity.

GeoListPlot[data[[All,2]],GeoLabels->(Tooltip[#1,#2]&)]

We could even have the tooltips give some details from within the entity. For the cities, using the 2nd part of the #2 slot with #2[[2]] displays more information than what we had above.

GeoListPlot[data[[All,2]],GeoLabels->(Tooltip[#1,#2[[2]]]&)]

To have our labels show the name of the person we need to extract corresponding names from our data. Consider this example below.

samplelist={{1,a},{2,b},{3,c},{4,a},{5,b}}

Cases will pull out the pairs that match a specific pattern.

Cases[samplelist,{_,a}]

Now we can incorporate this into the second argument of Tooltip for our data. (Note that I added Column before Cases since this will make it look better if more than one person in the list has the same birthplace.) Be sure to hover over the markers to see the tooltips.

GeoListPlot[data[[All,2]],GeoLabels->(Tooltip[#1,Column@Cases[data,{_,#2}]]&)]

Let’s put it all together and try a new date. I’m using August 29, 1973.

buddies=EntityList[Entity["Person","BirthDate"->DateObject[{1973,8,29}]]];
data=Map[{#,#["BirthPlace"]}&,buddies];
GeoListPlot[data[[All,2]],GeoLabels->(Tooltip[#1,Column@Cases[data,{_,#2}]]&)]

If you used this date, did you notice the twins?

Below has some more work with the labels to include additional details with extra formatting.

buddies=EntityList[Entity["Person","BirthDate"->DateObject[{1973,8,29}]]];
data=Map[{#,#["BirthPlace"]}&,buddies];
GeoListPlot[data[[All,2]],GeoLabels->(Tooltip[#1,
Column[(Map[Column[{Row[{Style[#[[1]]["Name"],14,Bold,Blue],"  ",#[[1]]["Occupation"]}],#[[2,2]]}]&,Cases[data,{_,#2}]]),Dividers->{None,{False,{True},False}}]
]&)]

How can I learn more?

WikipediaData will call up the text of the corresponding Wikipedia article about a topic.

WikipediaData["Stephen Wolfram"]

We can use Pane to put the result in its own box of a size we specify.

Pane[WikipediaData["Stephen Wolfram"],{400,250}]

Did you notice that the text is scrollable within the pane? If you would like that to be more obvious, you can add scrollbars.

Pane[WikipediaData["Stephen Wolfram"],{400,250},Scrollbars->Automatic]

Let’s create a Wikipedia viewer for all of the people in our list.

Manipulate[Pane[WikipediaData[person],{400,250}],{person,buddies}]

We can add the image to their article using Grid.

Manipulate[
Grid[{{
person["Image"],
Pane[WikipediaData[person],{400,250}]
}}],
{person,buddies}]

With a little more work, we can include their occupation(s) beneath the image. (Using column will nicely format any with more than one occupation.)

Manipulate[
Grid[{{
Column[{person["Image"],Column[person["Occupation"]]}],
Pane[WikipediaData[person],{400,250}]
}}],
{person,buddies}]

Putting it all Together

You can list any date you want. For my example here, let’s use Stephen Wolfram’s birthday. We can find it with inline free-form input.

LinguisticAssistant

Or use entity functions directly.

(Entity["Stephen Wolfram", Entity["Person","StephenWolfram::j276d"], "Entity[\"Person\", \"StephenWolfram::j276d\"]", "person"])[(EntityProperty["date of birth", EntityProperty["Person","BirthDate"], "EntityProperty[\"Person\", \"BirthDate\"]"])]

Either style may be used within the input after the “BirthDate” → or we can type the DateObject directly.

buddies=EntityList[Entity["Person","BirthDate"->LinguisticAssistant]]

I’d like Stephen Wolfram to show up first, so I’m going to reverse the order of the list.

buddies=Reverse@EntityList[Entity["Person","BirthDate"->LinguisticAssistant]]

We can make the birthplace map. (This is a copy/paste from above.)

data=Map[{#,#["BirthPlace"]}&,buddies];
GeoListPlot[data[[All,2]],GeoLabels->(Tooltip[#1,Column@Cases[data,{_,#2}]]&)]

We can find all of their occupations.

Through[buddies["Occupation"]]

We can make a Wikipedia viewer. (This is a copy/paste from above and I added Scrollbars within the Pane.)

Manipulate[
Grid[{{
Column[{person["Image"],Column[person["Occupation"]]}],
Pane[WikipediaData[person],{400,250},Scrollbars->Automatic]
}}],
{person,buddies}]

Really Putting it all Together (with some extra formatting)

Below shows the birthplace map with extra formatting and the Wikipedia viewer. I also added the date of interest and learned a little about date formatting along the way. Remember that for the date you can use either inline free-form input or type the values in the list for DateObject directly.

date=DateObject[{1809,2,12}];

datelabel=Framed[Column[{
Style[Block[{$DateStringFormat="DayName"},DateString[DateList[date]]],20],
Style[Block[{$DateStringFormat={"MonthName"," ","Day"}},DateString[DateList[date]]],25,Blue,Bold],
Style[Block[{$DateStringFormat="Year"},DateString[DateList[date]]],25,Blue,Bold]
},Alignment->Center],RoundingRadius->5,Background->LightYellow];

buddies=EntityList[Entity["Person","BirthDate"->date]];
Framed[Column[{
Row[{
datelabel,Spacer[10],
data=Map[{#,#["BirthPlace"]}&,buddies];
GeoListPlot[data[[All,2]],GeoLabels->(Tooltip[#1,
Column[(Map[Column[{Row[{Style[#[[1]]["Name"],14,Bold,Blue],"  ",#[[1]]["Occupation"]}],#[[2,2]]}]&,Cases[data,{_,#2}]]),Dividers->{None,{False,{True},False}}]
]&),ImageSize->400]
}],
Manipulate[
Grid[{{
Column[{person["Image"],Column[person["Occupation"]]}],
Pane[WikipediaData[person],{400,250},Scrollbars->Automatic]
}}],
{person,buddies}]
}],FrameStyle->None,Background->LightGray]

To view this result without evaluating, open the example below.

Option: Reversing the Activity

While working through the activity with our computational thinking club, one of my students asked if we could find people by birthplace. Certainly! Although, that wouldn’t make for a very interesting GeoListPlot. Earlier we found people by birthdate and plotted their birthplaces. What could we do now? We could find people by birthplace and plot their birthdates!

EntityList[Entity["Person","BirthPlace"->LinguisticAssistant]]

For me, that’s quite a long list, so I’ll make a list of buddies by randomly sampling eight people from the list.

buddies=RandomSample[EntityList[Entity["Person","BirthPlace"->LinguisticAssistant]],8]

We can find their birthdates.

Through[buddies["BirthDate"]]

Let’s try a TimelinePlot.

TimelinePlot[Through[buddies["BirthDate"]]]

It worked, but as we initially saw with GeoListPlot above, we cannot really tell which points go with which people. TimelinePlot will label the points automatically if we organize the data as an association.

data=AssociationMap[#["BirthDate"]&,buddies]

TimelinePlot[data]

If we organize the data a little differently, we can include additional details about the people in the plot.

TimelinePlot[Association[Map[{Column[{Style[#["Name"],12,Bold],Column[#["Occupation"]]}]->#["BirthDate"]}&,buddies]]]

This is an example of output for San Diego, California.

I put it all together and added a couple more details. Try moving the mouse over names after evaluating this.

location=LinguisticAssistant;
buddies=RandomSample[EntityList[Entity["Person","BirthPlace"->location]],UpTo[8]];
TimelinePlot[Association[Map[{Tooltip[Column[{Style[#["Name"],12,Bold],Column[#["Occupation"]]}],#["Image"]]->#["BirthDate"]}&,buddies]],PlotLabel->Style[Row[{"Birthplace: ",location[[2]]}],Darker[Orange],Bold,14]]

Below is a screenshot of an example for Seattle, Washington. Mouseover Ray J. Johnson and Jimi Hendrix.

Option: 20 Years of Birthdays

Using the idea from earlier of finding people who have the same birthday by month and day within a multiyear span, I was curious what a timeline might look like if I search for people who have my birthday within a twenty-year range. I will select just one person from each year.

buddies=Table[RandomChoice[EntityList[Entity["Person","BirthDate"->DateObject[{year,2,24}]]]],{year,1965,1985}];
TimelinePlot[Association[Map[{Column[{Style[#["Name"],12,Bold],Column[#["Occupation"]]}]->#["BirthDate"]}&,buddies]]]

Below is a sample output for February 24 from 1965 through 1985 if you don’t want to evaluate it.

Abby Brown
www.abbymath.com
CT@TP: Computational Thinking at Torrey Pines High School
October 2018