This blog is for generating names, based on the frequency they occur. It can be easily adjusted for any country if you have similar data.
It’s generating the names based on the statistics how often they occur in the USA, based on data from United State Census Bureau. Using this approach makes the generated data to look more real, than just randomizing the first and last name from an array.
The code is available in GitHub: https://github.com/tachev/RandomDataGenerator.git
The usage is straight forward:
string firstFemaleName = NameGenerator.GetRandomFirstFemaleName(); string firstMaleName = NameGenerator.GetRandomFirstMaleName(); string firstName = NameGenerator.GetRandomFirstName(); string lastName = NameGenerator.GetRandomLastName(); string fullName = NameGenerator.GetRandomFullName();
If you want to change the code to work for another country you just need to replace the data files.
Each of the three files, (dist.all.last), (dist. male.first), and (dist female.first) contain four items of data. The four items are:
- A “Name”
- Frequency in percent
- Cumulative Frequency in percent
Let me know if you have any questions or comments on how I can improve the blog and/or the source code.