concept distribution in category javascript

appears as: distribution, distributions, distribution
Data Wrangling with JavaScript

This is an excerpt from Manning's book Data Wrangling with JavaScript.

Table 9.1 Tools used in chapter 9
Technique Function Notes
Basic statistics sum Sum the total from a set of values.
average Compute the average or central value from a set of values.
std Compute the standard deviation from a set of values; this is a measure of volatility, fluctuation, or dispersion of our data.
Group and summarize groupBy, select Condense a data set and make it easier to understand by grouping records and summarizing them with sum, average, or standard deviation.
Frequency distribution bucket, detectValues Determine the distribution of values in a data set, and if it matches a normal distribution, this gives us certain predictive powers.
Time series rollingAverage Smooth out time series data, removing noise so that we can better detect trends and patterns.
rollingStandardDeviation See the fluctuation or variability of a data series over time.
linearRegression Use for forecasting and detecting trends.
difference Understand the difference between time series and determine if they’re diverging.
Data standardization average, std Standardize two data sets for direct comparison.
Correlation coefficient sampleCorrelation Understand the relationship between data variables and how strongly (or weakly) correlated they are.
Listing 9.9 Computing frequency distribution and histogram for NYC temperatures (listing-9.9.js)
const dataForge = require('data-forge');
const renderBarChart = require('./toolkit/charts.js').renderBarChart;

function createDistribution (series, chartFileName) {    #1  
 const bucketed = series.bucket(20);    #2  
    const frequencyTable = bucketed
 .deflate(r => r.Mid)    #3  
 .detectValues()    #4  
 .orderBy(row => row.Value);    #5  
 console.log(frequencyTable.toString());    #6  

    const categories = frequencyTable
 .deflate(r => r.Value.toFixed(2))    #7  
        .toArray();

 return renderBarChart(    #8  
 "Frequency",    #8  
 frequencyTable,    #8  
 categories,    #8  
 chartFileName    #8  
 );    #8  
};

function isWinter (monthNo) {    #9  
 return monthNo === 1 ||    #9  
 monthNo === 2 ||    #9  
 monthNo === 12;    #9  
};    #9  

const dataFrame = dataForge.readFileSync("./data/nyc-weather.csv")    #10  
 .parseCSV()    #10  
 .parseInts("Month")    #10  
 .parseFloats(["MinTemp", "MaxTemp"])    #10  
 .generateSeries({    #10  
 AvgTemp: row => (row.MinTemp + row.MaxTemp) / 2    #10  
 });    #10  

console.log("Winter temperature distribution:");
const winterTemperatures = dataFrame    #11  
 .where(row => isWinter(row.Month))    #11  
 .getSeries("AvgTemp");    #11  

const outputChartFile = "./output/nyc-winter-temperature-distribution.png";
createDistribution(winterTemperatures, outputChartFile)    #12  
    .catch(err => {
        console.error(err);
    });

#1   This is a helper function that creates a distribution from a series and renders a histogram from it.
#2   Sorts the series into 20 evenly spaced buckets
#3   Extracts the midpoint of each bucket to a new series
#4   Determines the frequency of values in the new series
#5   Orders by ascending bucket value; this is the correct order for rendering the histogram.
#6   Prints to console so we can double-check
#7   Formats the X axis labels for display in the histogram
#8   Renders the histogram
#9   Determines if the specified month is a winter month
#10   Reads the input CSV file and generates a new column for average daily temperature
#11   Filters down to only winter temperatures
#12   Creates the distribution of winter temperatures and renders the histogram from it
JavaScript Application Design: A Build First Approach

This is an excerpt from Manning's book JavaScript Application Design: A Build First Approach.

The bottom of figure 1.2 zooms into the deployment process (originally shown in figure 1.1), which takes either the debug or release distribution (what I call distinct process flows with a specific purpose throughout the book) and deploys it to a hosted environment.

Figure 3.2. Environment-level configuration—environments, configuration, and distributions, coming together in an application. Environment configuration consists of secret credentials and any other configuration that might change across environments.

You’ve now learned what build distributions are and how they define the different flows created when putting together a build process; let’s turn our attention to the application configuration within each environment, or what I call environment-level configuration.

Prototype and Scriptaculous in Action

This is an excerpt from Manning's book Prototype and Scriptaculous in Action.

  • On Windows, you should avoid any folders with spaces in their names, so I usually unpack the distribution right to C:\.