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 2019/09/23 14:39:49 UTC
[lucene-solr] branch SOLR-13105-visual updated: SOLR-13105: Update
statistics docs
This is an automated email from the ASF dual-hosted git repository.
jbernste pushed a commit to branch SOLR-13105-visual
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git
The following commit(s) were added to refs/heads/SOLR-13105-visual by this push:
new ac27e69 SOLR-13105: Update statistics docs
ac27e69 is described below
commit ac27e69decc94c5894d0e3cf35a7fa6796667dcc
Author: Joel Bernstein <jb...@apache.org>
AuthorDate: Mon Sep 23 10:39:29 2019 -0400
SOLR-13105: Update statistics docs
---
.../src/images/math-expressions/cumProb.png | Bin 146987 -> 143633 bytes
.../src/images/math-expressions/describe.png | Bin 137702 -> 122437 bytes
.../src/images/math-expressions/freqTable.png | Bin 181164 -> 212874 bytes
.../src/images/math-expressions/freqTable1.png | Bin 0 -> 194279 bytes
.../src/images/math-expressions/hist.png | Bin 139842 -> 151080 bytes
.../src/images/math-expressions/histtable.png | Bin 218867 -> 207629 bytes
solr/solr-ref-guide/src/statistics.adoc | 198 ++++++++++++---------
7 files changed, 110 insertions(+), 88 deletions(-)
diff --git a/solr/solr-ref-guide/src/images/math-expressions/cumProb.png b/solr/solr-ref-guide/src/images/math-expressions/cumProb.png
index a37dda6..ff93b61 100644
Binary files a/solr/solr-ref-guide/src/images/math-expressions/cumProb.png and b/solr/solr-ref-guide/src/images/math-expressions/cumProb.png differ
diff --git a/solr/solr-ref-guide/src/images/math-expressions/describe.png b/solr/solr-ref-guide/src/images/math-expressions/describe.png
index a3bd482..7f88fac 100644
Binary files a/solr/solr-ref-guide/src/images/math-expressions/describe.png and b/solr/solr-ref-guide/src/images/math-expressions/describe.png differ
diff --git a/solr/solr-ref-guide/src/images/math-expressions/freqTable.png b/solr/solr-ref-guide/src/images/math-expressions/freqTable.png
index 02eaf4f..c159912 100644
Binary files a/solr/solr-ref-guide/src/images/math-expressions/freqTable.png and b/solr/solr-ref-guide/src/images/math-expressions/freqTable.png differ
diff --git a/solr/solr-ref-guide/src/images/math-expressions/freqTable1.png b/solr/solr-ref-guide/src/images/math-expressions/freqTable1.png
new file mode 100644
index 0000000..84eb65e
Binary files /dev/null and b/solr/solr-ref-guide/src/images/math-expressions/freqTable1.png differ
diff --git a/solr/solr-ref-guide/src/images/math-expressions/hist.png b/solr/solr-ref-guide/src/images/math-expressions/hist.png
index ec222ee..914d0e8 100644
Binary files a/solr/solr-ref-guide/src/images/math-expressions/hist.png and b/solr/solr-ref-guide/src/images/math-expressions/hist.png differ
diff --git a/solr/solr-ref-guide/src/images/math-expressions/histtable.png b/solr/solr-ref-guide/src/images/math-expressions/histtable.png
index 1595441..9f39835 100644
Binary files a/solr/solr-ref-guide/src/images/math-expressions/histtable.png and b/solr/solr-ref-guide/src/images/math-expressions/histtable.png differ
diff --git a/solr/solr-ref-guide/src/statistics.adoc b/solr/solr-ref-guide/src/statistics.adoc
index 83128b0..46672c8 100644
--- a/solr/solr-ref-guide/src/statistics.adoc
+++ b/solr/solr-ref-guide/src/statistics.adoc
@@ -22,18 +22,18 @@ available in math expressions.
== Descriptive Statistics
-The `describe` function can be used to return descriptive statistics about a
+The `describe` function returns descriptive statistics about a
numeric array. The `describe` function returns a single *tuple* with name/value
pairs containing descriptive statistics.
-Below is a simple example that selects a random sample of documents,
-vectorizes the *price_f* field in the result set and uses the `describe` function to
-return descriptive statistics about the vector:
+Below is a simple example that selects a random sample of documents from the *logs* collection,
+vectorizes the *response_d* field in the result set and uses the `describe` function to
+return descriptive statistics about the vector.
[source,text]
----
-let(a=random(collection1, q="*:*", rows="1500", fl="price_f"),
- b=col(a, price_f),
+let(a=random(logs, q="*:*", fl="response_d", rows="50000"),
+ b=col(a, response_d),
c=describe(b))
----
@@ -45,30 +45,33 @@ When this expression is sent to the `/stream` handler it responds with:
"result-set": {
"docs": [
{
- "c": {
- "sumsq": 4999.041975263254,
- "max": 0.99995726,
- "var": 0.08344429493940454,
- "geometricMean": 0.36696588922559575,
- "sum": 7497.460565552007,
- "kurtosis": -1.2000739963006035,
- "N": 15000,
- "min": 0.00012338161,
- "mean": 0.49983070437013266,
- "popVar": 0.08343873198640858,
- "skewness": -0.001735537500095477,
- "stdev": 0.28886726179926403
- }
+ "sumsq": 36674200601.78738,
+ "max": 1068.854686837548,
+ "var": 1957.9752647562789,
+ "geometricMean": 854.1445499569674,
+ "sum": 42764648.83319176,
+ "kurtosis": 0.013189848821424377,
+ "N": 50000,
+ "min": 656.023249311864,
+ "mean": 855.2929766638425,
+ "popVar": 1957.936105250984,
+ "skewness": 0.0014560741802307174,
+ "stdev": 44.24901428005237
},
{
"EOF": true,
- "RESPONSE_TIME": 305
+ "RESPONSE_TIME": 430
}
]
}
}
----
+Notice that the random sample contains 50000 records and the response
+time is only 430 milli-seconds. Samples of this size can be used to reliably estimate the
+descriptive statistics for very large underlying data sets with sub-second performance.
+
+
This describe function can be visualized in a table with Zeppelin-Solr:
image::images/math-expressions/describe.png[]
@@ -76,7 +79,7 @@ image::images/math-expressions/describe.png[]
== Histograms and Frequency Tables
-Histograms and frequency tables are are tools for understanding the distribution
+Histograms and frequency tables are are tools for visualizing the distribution
of a random variable.
The `hist` function creates a histogram designed for usage with continuous data. The
@@ -84,15 +87,17 @@ The `hist` function creates a histogram designed for usage with continuous data.
=== histograms
-Below is an example that selects a random sample, creates a vector from the
-result set and uses the `hist` function to return a histogram with 15 bins.
+In the example below a histogram is used to visualize the random sample response times
+from the logs collection. The example retrieves the random sample with `random` function,
+ creates a vector from the *response_d* field in the
+result set and uses the `hist` function to return a histogram with 22 bins.
The `hist` function returns a list of tuples with summary statistics for each bin.
[source,text]
----
-let(a=random(testapp, q="*:*", rows="15000", fl="response_d"),
+let(a=random(logs, q="*:*", fl="response_d", rows="50000"),
b=col(a, response_d),
- c=hist(b, 15))
+ c=hist(b, 22))
----
When this expression is sent to the `/stream` handler it responds with:
@@ -103,46 +108,46 @@ When this expression is sent to the `/stream` handler it responds with:
"result-set": {
"docs": [
{
- "prob": 0.00021598266688541547,
- "min": 675.8131195271407,
- "max": 690.4491626920295,
- "mean": 683.1150404530058,
- "var": 62.68733114037831,
- "cumProb": 0.00010781401860771812,
- "sum": 2732.460161812023,
- "stdev": 7.917533147412666,
- "N": 4
+ "prob": 0.00004896007228311655,
+ "min": 675.573084576817,
+ "max": 688.3309631697003,
+ "mean": 683.805542728906,
+ "var": 50.9974629924082,
+ "cumProb": 0.000030022417162809913,
+ "sum": 2051.416628186718,
+ "stdev": 7.141250800273591,
+ "N": 3
},
{
- "prob": 0.0008119830346328834,
- "min": 703.2132289932538,
- "max": 721.1545076964856,
- "mean": 712.8045685730215,
- "var": 41.16456697234485,
- "cumProb": 0.0007397051651814922,
- "sum": 9266.459391449276,
- "stdev": 6.415961889876283,
- "N": 13
+ "prob": 0.00029607514624062624,
+ "min": 696.2875238591652,
+ "max": 707.9706315779541,
+ "mean": 702.1110569558929,
+ "var": 14.136444379466969,
+ "cumProb": 0.00022705264963879807,
+ "sum": 11233.776911294284,
+ "stdev": 3.759846323916307,
+ "N": 16
},
{
- "prob": 0.005621625404424438,
- "min": 722.3966535859041,
- "max": 743.8768517321993,
- "mean": 735.0570449093976,
- "var": 34.32748804550742,
- "cumProb": 0.004137705733961876,
- "sum": 62479.84881729879,
- "stdev": 5.8589664656411395,
- "N": 85
+ "prob": 0.0011491235433157194,
+ "min": 709.1574910598678,
+ "max": 724.9027194369135,
+ "mean": 717.8554290699951,
+ "var": 20.6935845290122,
+ "cumProb": 0.0009858515418689757,
+ "sum": 41635.61488605971,
+ "stdev": 4.549020172412098,
+ "N": 58
},
...
----
-With Zeppelin-Solr the histogram can be first visualized in a table:
+With Zeppelin-Solr the histogram can be first visualized as a table:
image::images/math-expressions/histtable.png[]
-Then the histogram can be visualized with a bar chart by plotting the *mean* of
+Then the histogram can be visualized with an area chart by plotting the *mean* of
the bins on the *x-axis* and the *prob* (probability) on the *y-axis*:
image::images/math-expressions/hist.png[]
@@ -151,7 +156,6 @@ The cumulative probability can be plotted by switching the *y-axis* to the *cumP
image::images/math-expressions/cumProb.png[]
-
=== Frequency Tables
The `freqTable` function returns a frequency distribution for a discrete data set.
@@ -159,14 +163,41 @@ The `freqTable` function doesn't create bins like the histogram. Instead it coun
the occurrence of each discrete data value and returns a list of tuples with the
frequency statistics for each value.
-Below is a simple example of a frequency table built from a random sample of
-a discrete variable.
+Below is an example of a frequency table built from a result set
+of rounded *differences* in daily opening stock prises for the stock ticker *amzn*.
+
+This example is interesting because it shows a multi-step process to arrive
+at the result. The first step is to *search* for records in the the *stocks*
+collection with a ticker of *amzn*. Notice that the result set is sorted by
+date ascending and it returns the *open_d* field which is the opening price for
+the day.
+
+The *open_d* field is then vectorized and set to variable *b*, which now contains
+a vector of opening prices ordered by date ascending.
+
+The `diff` function is then used to calculate the *first difference* for the
+vector of opening prices. The first difference simply subtracts the previous value
+from each value in the array. This will provide an array of price differences
+for each day which will show daily change in opening price.
+
+Then the `round` function is used to round the price differences to the nearest
+integer to create a vector of discrete values. The `round` function is this
+example is effectively binning on integer boundaries.
+
+Finally the `freqTable` function is run on the discrete values to calculate
+the frequency table.
[source,text]
----
-let(a=random(testapp, q="*:*", rows="15000", fl="day_i"),
- b=col(a, day_i),
- c=freqTable(b))
+let(a=search(stocks,
+ q="ticker_s:amzn",
+ fl="open_d, date_dt",
+ sort="date_dt asc",
+ rows=25000),
+ b=col(a, open_d),
+ c=diff(b),
+ d=round(c),
+ e=freqTable(d))
----
When this expression is sent to the `/stream` handler it responds with:
@@ -177,32 +208,25 @@ When this expression is sent to the `/stream` handler it responds with:
"result-set": {
"docs": [
{
- "pct": 0.0362,
- "count": 543,
- "cumFreq": 543,
- "cumPct": 0.0362,
- "value": 0
- },
- {
- "pct": 0.03186666666666667,
- "count": 478,
- "cumFreq": 1021,
- "cumPct": 0.06806666666666666,
- "value": 1
+ "pct": 0.00019409937888198756,
+ "count": 1,
+ "cumFreq": 1,
+ "cumPct": 0.00019409937888198756,
+ "value": -57
},
{
- "pct": 0.0338,
- "count": 507,
- "cumFreq": 1528,
- "cumPct": 0.10186666666666666,
- "value": 2
+ "pct": 0.00019409937888198756,
+ "count": 1,
+ "cumFreq": 2,
+ "cumPct": 0.00038819875776397513,
+ "value": -51
},
{
- "pct": 0.03546666666666667,
- "count": 532,
- "cumFreq": 2060,
- "cumPct": 0.13733333333333334,
- "value": 3
+ "pct": 0.00019409937888198756,
+ "count": 1,
+ "cumFreq": 3,
+ "cumPct": 0.0005822981366459627,
+ "value": -49
},
...
----
@@ -211,12 +235,10 @@ With Zeppelin-Solr the frequency table can be first visualized in a table:
image::images/math-expressions/freqTable.png[]
-The frequency table can then be plotted by switching to a bar chart and selecting
-the *value* column for the *x-axis*. Any of the other columns can be visualized
-on the *y-axis*. The example below visualizes the *cumPct* column which is the
-cumulative percent at each value.
+The frequency table can then be plotted by switching to a scatter chart and selecting
+the *value* column for the *x-axis*.
-image::images/math-expressions/cumPct.png[]
+image::images/math-expressions/freqTable1.png[]
== Percentiles