The juttle predict proc combines trend, seasonal, and level prediction. Although it is native javascript, many of its components can also be written in juttle, and those examples are here.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Predict: | |
// Trend, seasonality, and noise estimation for metric streams. | |
// | |
// Predict is a sub which consumes a metric stream and emits a | |
// prediction stream based on estimated trend, seasonality, and a | |
// smoothed version of the input. Prediction errors (the difference | |
// between predict's output and the input) can signal anomalies in the | |
// stream. | |
// | |
// usage: predict [options] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{"time":"2016-01-01T00:00:00.000Z", "cust_id":1, "email":"lou@grainger.com"}, | |
{"time":"2016-01-01T00:00:02.000Z", "cust_id":2, "email":"bubba@nytimes.com"}, | |
{"time":"2016-01-01T00:00:03.000Z", "cust_id":3, "email":"sam@hotmail.com"} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// example of ingesting multiple metrics at a regular 20s pulse from | |
// collectd (timestamps are aligned across streams, simulated here), | |
// and merging them onto a single point so relative percentages can be computed. | |
// | |
// Useful patterns in add_streams: | |
// put *name = value applied to points having {name=foo, value=bar} layout, | |
// gives the values unique names in preparation for joining | |
// use of single-stream join to combine a variable number of input streams | |
// reduce -groupby by, which is the same as reduce by, but is convenient inside a sub. | |
// reduce time=first(time) gives reducer results same timestamp as their inputs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// stdlib.random demos: | |
// | |
import "random.juttle" as random; | |
export sub poissonHisto() { | |
// render draws from 3 poisson distributions as a scatter chart. | |
// see https://en.wikipedia.org/wiki/Poisson_distribution | |
emit -limit 10000 -from 0 | |
| put lambda_1=random.poisson(1), lambda_4=random.poisson(4), lambda_10=random.poisson(10) | |
| split lambda_1, lambda_4, lambda_10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// stats demos: statistics 101 for juttle data flows | |
// | |
// Each of the stream standardization approaches offered in stats is | |
// appropriate in a different setting. The demos here show some good | |
// and some bad choices. | |
// | |
import "stats.juttle" as stats; | |
// cpuZ: visualize z-scores for a cpu metric. | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Alerting with context: | |
// | |
// This example shows how to annotate an alert event with recent lines from | |
// a logging stream, to give context for the alert. This is accomplished with | |
// a custom reducer that tails the log stream, and a join of the current tail | |
// against each alert event as it occurs. | |
// | |
// The log-tailing stream is joined using the -table option, which means the | |
// join will fire only when the alert stream gets a new point, but not fire | |
// when the log stream gets new points. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function pairs = readzmax(FileName) | |
fileID = fopen(FileName); | |
% read the file data | |
vals = fileread(FileName); | |
fclose(fileID); | |
% Convert to string | |
dstr = sprintf('%s',vals); | |
% keep only lens data | |
GLDstart = regexp(dstr, 'GENEARL LENS DATA:','end'); | |
dstr = dstr(GLDstart+2:end); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
zmx2csv.py: convert zemax output to csv for matlab import | |
usage: zmx2csv.py filename.txt ... | |
reads each filename.txt, outputting filename.csv | |
sample input file: forPupilMapping_Prescription.txt | |
""" | |
import sys |
NewerOlder