0
|
18705 Views
|
7 Replies
|
2 Total Likes
View groups...
Share

# How to use expected total number alive today on many names?

Posted 10 years ago
 Okay I would love any and all help; I have been using Wolfram Alpha to find the estimated number of people with different names in the united states and it has been working great. However, now I need to find the expected number of people alive with over a thousand different names for a project I am working on. Is there anyway to input the names and get this process automated or do I need to do this one at a time?
7 Replies
Sort By:
Posted 10 years ago
 See the attached notebook for a formatted version of this and which you can use to experiment with. For others, here is the quick example code that I put together: (*These are the names imported from the Excel spread sheet on my \ computer:*) In[3]:= names = Flatten[First[ Import["/Users/dreiss/Downloads/Mathematica test.xlsx"]]]; (*For testing purposes I am only going to analyze some of them*) In[4]:= names = Take[names, 25]; In[9]:= names Out[9]= {"Adam", "Adan", "Aiden", "Al", "Alan", "Albert", "Alec", \ "Alex", "Alexander", "Alexis", "Alfred", "Ali", "Allan", "Allen", \ "Alton", "Alva", "Alvin", "Anderson", "Andrea", "Andy", "Angela", \ "Anthony", "Arden", "Ariel", "Arlen"} (*Here is a function that can determing how many people there are of \ the specified sex with the name and returns a list with the name, \ number with that name that are male and the number with that name \ which are female.*) In[23]:= numberOfPeopleWithName[name_String] := Module[{resultM, resultF}, resultM = EntityValue[Entity["GivenName", {name, "UnitedStates", "male"}], EntityProperty["GivenName", "GivenNameTotal"]]; resultF = EntityValue[Entity["GivenName", {name, "UnitedStates", "female"}], EntityProperty["GivenName", "GivenNameTotal"]]; resultM = If[Head[resultM] === Missing, 0, QuantityMagnitude[resultM]]; resultF = If[Head[resultF] === Missing, 0, QuantityMagnitude[resultF]]; {name, resultM, resultF} ] (*Let's test it:*) In[25]:= numberOfPeopleWithName["Tyler"] Out[25]= {"Tyler", 524010, 14821} In[24]:= numberOfPeopleWithName["Alex"] Out[24]= {"Alex", 216282, 7267} (*Now let's try it out on the list of names that we \ have. Rememner that queries sent to the cloud curated databases can \ take some time. So doing this with 1000 names may take a bit. Here \ we are only doing it on 25.*) In[26]:= Map[numberOfPeopleWithName, names] Out[26]= {{"Adam", 485665, 1941}, {"Adan", 18580, 61}, {"Aiden", 84601, 1287}, {"Al", 12140, 182}, {"Alan", 289465, 953}, {"Albert", 265911, 1649}, {"Alec", 45289, 323}, {"Alex", 216282, 7267}, {"Alexander", 504649, 4069}, {"Alexis", 52158, 296527}, {"Alfred", 134681, 885}, {"Ali", 17791, 7671}, {"Allan", 71835, 220}, {"Allen", 203055, 1374}, {"Alton", 29744, 223}, {"Alva", 4658, 4717}, {"Alvin", 100602, 801}, {"Anderson", 12532, 362}, {"Andrea", 5311, 396766}, {"Andy", 69737, 810}, {"Angela", 1987, 623561}, {"Anthony", 1191047, 6424}, {"Arden", 4118, 3386}, {"Ariel", 14025, 51398}, {"Arlen", 4908, 486}}  Attachments:
Posted 10 years ago
 It is not clear how to (or whether it is possible to) get Wolfram|Alpha to return data for that large a dataset of names. However, in Mathematica one can request the data for a particular name using, with "Alphonse" as an example, EntityValue[Entity["GivenName", {"Alphonse", "UnitedStates", "male"}], EntityProperty["GivenName", "GivenNameTotal"]] so this can easily be converted to a function that can be mapped onto a list of names of any given length.
Posted 10 years ago
 Thank you I really appreciate it,Yet, I am afraid I am quite lost in thisI currently have all the names in an excel file and I have been attempting to learn how to input them into Mathematica and then change around the program you gave me to do it but I am not sure how to do that
Posted 10 years ago
 If you post your excel file to this form, I can show you how to do this. However I may not be able to get to it until late tomorrow or early the next day. Though it is possible that somebody else will pick up on this thread and show you.
Posted 10 years ago
 Alright thank you I appreciate it hopefully one day I will have this down Attachments:
Posted 10 years ago
 Thank you very much, I really appreciate the help you have just saved me countless man hours of work. Saved my whole weekend and many more weekends.
Posted 10 years ago
 :-)