science.js icon indicating copy to clipboard operation
science.js copied to clipboard

Documentation

Open ndarville opened this issue 11 years ago • 3 comments

A guide would probably be better than a wiki; personally, I am trying to use loess.js for a project of mine, but some documentation beyond the included loess example would definitely help. :)

I’ve created a basic docco webpage for science.v1.js here as an alternative to the basic GitHub inspection.

#d3.js at freenode is really low on activity, but maybe I could try asking around to see which other parts of science.js people would like to see documentation/guides for.

ndarville avatar Jun 01 '14 14:06 ndarville

The problem with your code is that you’re calling loess(x, y), for each point, instead of loess(xs, ys) where xs and ys are arrays. (Sorry for the lack of documentation.)

jasondavies avatar Jun 01 '14 16:06 jasondavies

Thanks, @jasondavies.

I’ll try to get loess() to plot the trend, and do a post mortem with instructions, once/if I’m done. :)

ndarville avatar Jun 02 '14 14:06 ndarville

Here's another example that uses the loess function with D3.

I made this to try to understand the API.

Here's a stab at partial API documentation (in the style of @mbostock) based on my limited understanding so far:

# stats.loess()

Constructs a LOESS curve generator instance.

var myLoess = science.stats.loess();

# loess.bandwidth(bandwidth)

Specifies the bandwidth (smoothing parameter) that controls how fine or coarse the smoothing is. Lower values fit the curve closer to the data, higher values make the curve more straight.

myLoess.bandwidth(0.2);

# loess(xValues,yValues)

Invokes the LOESS algorithm to generate the smoothed curve. Accepts as input two arrays of values in data space. These two arrays must be of the same length. Returns an array of smoothed Y values that has the same number of elements as the input arrays.

var yValuesSmooth = myLoess(xValues, yValues);

curran avatar Dec 04 '15 19:12 curran