jasondavies / science.js

Scientific and statistical computing in JavaScript.
http://www.jasondavies.com/
Other
886 stars 93 forks source link

Documentation #12

Open ndarville opened 10 years ago

ndarville commented 10 years ago

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.

jasondavies commented 10 years ago

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.)

ndarville commented 10 years ago

Thanks, @jasondavies.

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

curran commented 8 years ago

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);