npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

xmplr

v1.0.2

Published

Statistical object generator.

Downloads

6

Readme

xmplr -- Exemplar -- Statistical object generator

Build Status

This library creates "Exemplars" or statistical object generator for defining and creating an arbitrary object where each attribute conforms to a statistical distribution.

Note - This library creates random fictitious people

All of the people created are randomly generated and fictitious. Any resemblance to a real person is coincidental (obviously).

At some point, this project will add address, social security numbers, credit cards, etc to facilitate testing.

Example - generate a single customer at a time (typescript)

Generate customers as an xmplr Object model that will have a random but reasonable: first name, last name, adult age, date of purchase, and model from a list.

    let personModel = {
        first: new xFirstNames(),
        last: new xLastNames(),
        age: new xAdultAges(),
        location: new xZipCodes()
    }

    let xPerson = new xObject(personModel)
    let person = xPerson.next()
    console.log(person)

Generates a person

{ 
    first: 'Pamala',
    last: 'Berlin',
    age: 21,
    location: { 
      Zip: '78216', 
      Lat: '29.537264', 
      Lon: '-98.487882'
    } 
}

Example - an arrival rate of customers at a time

Return a list of models as "arrivals" satisfying a poisson distribution of number of arrivals per moment.

Wait for delayMsec milliseconds and return rate (10) per second. xRateRand/xRateModel work on millisecond rates, so divide you per second rate by 1000.

xRateModel takes a minimum arrival rate (1 in this case) to add to the randomly generated rate to act as a floor. This guarantees minimum number of arrivals per next() call.

async function arrivals(){
    let rate = 10/1000
    let xReceipts = new xRateModel(xPerson, new xRateRand(rate), 1)
    let delays = [100,400,1000,200]
    for( let i = 0; i < delays.length; i++ ){
        let delay = delays[i]
        await wait(delay)
        let receipts = xReceipts.next()
        assert( receipts.length > 0, `Receipts Has ${receipts.length} > 0` )
        let person:any = receipts[0]
        assert( typeof person.first === "string", `person has first name ${person.first}`)
    }
}
arrivals()

Simulating packet arrivals per second on a 1Gb network

1-Gb/s Ethernet interface can deliver between 80k and 1.4 million packets per second. An average network with larger packets may deliver about 100k packets per second. A xBetaRand shape (1,5) heavily weights in the first 40% and can approximate small office network traffic rates with spikes.

> import {xRateRand,xBetaRand} from "xmplr"
> var avg = 100000 // average of 100,000 packets per second
> var network = new xRateRand(avg,new x.xBetaRand(1,5))
> var pkts = () => Math.trunc(network.next())
> pkts()
22779
> pkts()
290768
> pkts()
7073
> pkts()
97729

Simulation Data

There are a number of US related source files in the "./data" directory.

Simulating names using Common US First and Last Names

The default names are contained in "First_Names.csv" and "last_Names.csv" files in the "./data" directory.

The names were downloaded from here

No license information was provided.

Supply your own array to xList() to create your own list of names, with possibly distributions.

Simulating locations using US Zip Codes

The default zip codes are contained in "US_Zip_Codes.csv" in the "./data" directory.

The data was downloaded from github user erichurst

Original source information:

All US zip codes with their corresponding latitude and longitude coordinates. Comma delimited for your database goodness.

Census Source

Monty Hall Problem

An example of the Monty Hall Problem is test/montyhall.tape.ts.

The test demonstrates a simple usage of xLists to simulate the Monty Hall Problem.

  1. Behind 3 doors, place 1 car and 2 goats
  2. Player chooses a door (in this game we "don't look" at our choice until the end)
  3. Game show host shows a goat behind one of the remaining doors.
  4. You can Stay on your first choice, or Switch to the other door.

Switching improves your odds from 1/3 to 2/3!

Run this test and see for yourself.