Giter Site home page Giter Site logo

guess-age's Introduction

NPM version Build Status Coverage Status Dependencies

guess-age

Guess the age of a person only from their first name.

Installation

$ npm install guess-age

For use in the browser, use browserify.

Usage

var guess = require( 'guess-age' );

guess( name[, gender] )

Retrieves the median and interquartile range of the age of all persons with a certain name estimated to be currently living in the US.

var out;

out = guess( 'Noah' );
/*
	{
		median: 9,
		iqr: [ 4, 15.004656730414027 ]
	}
*/

out = guess( 'Jack' );
/*
	{
		median: 50.04038167193148,
		iqr: [ 11.092877845442404, 70.04441983912463 ]
	}
*/

Since some names can be given to both boys and girls, there is some ambiguity in the gender associated with a name. The function supports an optional gender argument which should be used if the gender is known. If the gender argument is omitted, the statistics are calculated separately for each gender group and then a weighted average is computed based on the distribution of the two genders for persons with the name in question.

out = guess( 'Lindsay', 'male' );
/*
	{
		iqr: [ 35, 62 ],
		median: 53
	}
*/

out = guess( 'Lindsay', 'female' );
/*
	{
		iqr: [ 21, 32 ],
		median: 27
	}
*/

Reference

See the article on FiveThirtyEight which was the inspiration for this module. The statistics are based on data collected by the Social Security Administration, namely their actuarial tables and data on birth frequencies.

Examples

var guess = require( 'guess-age' ),
	out;

// Statistics for Herbert:
out = guess( 'Herbert' );

// Statistics for Jason:
out = guess( 'Jason' );

// Statistics for Connor:
out = guess( 'Connor' );

To run the example code from the top-level application directory,

$ node ./examples/index.js

Tests

Unit

Unit tests use the Mocha test framework with Chai assertions. To run the tests, execute the following command in the top-level application directory:

$ make test

All new feature development should have corresponding unit tests to validate correct functionality.

Test Coverage

This repository uses Istanbul as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:

$ make test-cov

Istanbul creates a ./reports/coverage directory. To access an HTML version of the report,

$ make view-cov

License

MIT license.

guess-age's People

Contributors

planeshifter avatar

Stargazers

Angus H. avatar  avatar Ricky Reusser avatar  avatar

Watchers

James Cloos avatar  avatar Athan avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.