You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by jb...@apache.org on 2018/08/28 21:02:59 UTC
lucene-solr:branch_7x: SOLR-12634: Add gaussfit to the Math
Expressions user guide
Repository: lucene-solr
Updated Branches:
refs/heads/branch_7x 9c79275d8 -> 751519909
SOLR-12634: Add gaussfit to the Math Expressions user guide
Project: http://git-wip-us.apache.org/repos/asf/lucene-solr/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucene-solr/commit/75151990
Tree: http://git-wip-us.apache.org/repos/asf/lucene-solr/tree/75151990
Diff: http://git-wip-us.apache.org/repos/asf/lucene-solr/diff/75151990
Branch: refs/heads/branch_7x
Commit: 751519909ce7c00bcd85f7767b1f93e1bc9b3b94
Parents: 9c79275
Author: Joel Bernstein <jb...@apache.org>
Authored: Tue Aug 28 17:00:47 2018 -0400
Committer: Joel Bernstein <jb...@apache.org>
Committed: Tue Aug 28 17:02:40 2018 -0400
----------------------------------------------------------------------
solr/solr-ref-guide/src/curve-fitting.adoc | 148 +++++++++++++++++++++---
1 file changed, 135 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucene-solr/blob/75151990/solr/solr-ref-guide/src/curve-fitting.adoc
----------------------------------------------------------------------
diff --git a/solr/solr-ref-guide/src/curve-fitting.adoc b/solr/solr-ref-guide/src/curve-fitting.adoc
index 057cc23..336ffde 100644
--- a/solr/solr-ref-guide/src/curve-fitting.adoc
+++ b/solr/solr-ref-guide/src/curve-fitting.adoc
@@ -133,28 +133,106 @@ responds with:
----
-== Prediction, Derivatives and Integrals
+=== Prediction, Derivatives and Integrals
-The `polyfit` function returns an array which contains the *y* value data points
-of the fitted curve.
-
-In order to predict values along the curve an interpolation function must be created
-for the curve. Once an interpolation functin has been created the `predict`,
-`derivative` and `integral` functions can be applied to the curve.
+The `polyfit` function returns a function that can be used with the `predict`
+function.
In the example below the x axis is included for clarity.
-The `polyfit` function returns an array with the fitted curve.
-A linear inpolation function is then created for the curve with the `lerp` function.
+The `polyfit` function returns a function for the fitted curve.
The `predict` function is then used to predict a value along the curve, in this
-case the prediction is made for the *x* value of .5.
+case the prediction is made for the *x* value of 5.
[source,text]
----
let(x=array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14),
y=array(0, 1, 2, 3, 4, 5.7, 6, 7, 6, 5, 5, 3, 2, 1, 0),
curve=polyfit(x, y, 5),
- interp=lerp(x, curve),
- p=predict(interp, .5))
+ p=predict(curve, 5))
+----
+
+When this expression is sent to the /stream handler it
+responds with:
+
+[source,json]
+----
+{
+ "result-set": {
+ "docs": [
+ {
+ "p": 5.439695598519129
+ },
+ {
+ "EOF": true,
+ "RESPONSE_TIME": 0
+ }
+ ]
+ }
+}
+----
+
+The `derivative` and `integrate` functions can be used to compute the derivative
+and integrals for the fitted
+curve. The example below demonstrates how to compute a derivative
+for the fitted curve.
+
+
+[source,text]
+----
+let(x=array(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14),
+ y=array(0, 1, 2, 3, 4, 5.7, 6, 7, 6, 5, 5, 3, 2, 1, 0),
+ curve=polyfit(x, y, 5),
+ d=derivative(curve))
+----
+
+When this expression is sent to the /stream handler it
+responds with:
+
+[source,json]
+----
+{
+ "result-set": {
+ "docs": [
+ {
+ "d": [
+ 0.3198918573686361,
+ 0.9261492094077225,
+ 1.2374272373653175,
+ 1.30051359631081,
+ 1.1628032287629813,
+ 0.8722983646900058,
+ 0.47760852150945,
+ 0.02795050408827482,
+ -0.42685159525716865,
+ -0.8363663967611356,
+ -1.1495552332084857,
+ -1.3147721499346892,
+ -1.2797639048258267,
+ -0.9916699683185771,
+ -0.3970225234002308
+ ]
+ },
+ {
+ "EOF": true,
+ "RESPONSE_TIME": 0
+ }
+ ]
+ }
+}
+----
+
+
+== Gaussian Curve Fitting
+
+The `gaussfit` function fits a smooth curve through a gaussian peak.
+This is shown in the example below.
+
+
+[source,text]
+----
+let(x=array(0,1,2,3,4,5,6,7,8,9, 10),
+ y=array(4,55,1200,3028,12000,18422,13328,6426,1696,239,20),
+ f=gaussfit(x, y))
----
When this expression is sent to the /stream handler it
@@ -166,7 +244,19 @@ responds with:
"result-set": {
"docs": [
{
- "p": 0.4481424148606813
+ "f": [
+ 2.81764431935644,
+ 61.157417979413424,
+ 684.2328985468831,
+ 3945.9411154167447,
+ 11729.758936952656,
+ 17972.951897338007,
+ 14195.201949425435,
+ 5779.03836032222,
+ 1212.7224502169634,
+ 131.17742331530349,
+ 7.3138931735866946
+ ]
},
{
"EOF": true,
@@ -177,6 +267,38 @@ responds with:
}
----
+Like the `polyfit` function, the `gaussfit` function returns a function that can
+be used directly by the `predict`, `derivative` and `integrate` functions.
+
+The example below demonstrates how to compute an integral for a
+fitted gaussian curve.
+[source,text]
+----
+let(x=array(0,1,2,3,4,5,6,7,8,9, 10),
+ y=array(4,55,1200,3028,12000,18422,13328,6426,1696,239,20),
+ f=gaussfit(x, y),
+ i=integrate(f, 0, 5))
+----
+
+When this expression is sent to the /stream handler it
+responds with:
+
+[source,json]
+----
+{
+ "result-set": {
+ "docs": [
+ {
+ "i": 25261.666789766092
+ },
+ {
+ "EOF": true,
+ "RESPONSE_TIME": 3
+ }
+ ]
+ }
+}
+----