|
| 1 | +--- |
| 2 | +pcx_content_type: reference |
| 3 | +title: Confidence Intervals |
| 4 | +sidebar: |
| 5 | + order: 3 |
| 6 | + |
| 7 | +--- |
| 8 | + |
| 9 | +Confidence intervals help assess accuracy and quantify uncertainty in results from sampled datasets. When querying sum or count fields on adaptive datasets, you can request a confidence interval to understand the possible range around an estimate. For example, specifying a confidence level of `0.95` returns the estimate, along with the range of values that likely contains the true value 95% of the time. |
| 10 | + |
| 11 | +## Availability |
| 12 | + |
| 13 | +- **Supported datasets**: Adaptive (sampled) datasets only. |
| 14 | +- **Supported fields**: All `sum` and `count` fields. |
| 15 | +- **Usage**: Confidence `level` must be provided as a decimal between 0 and 1 (for example,`0.90`, `0.95`, `0.99`). |
| 16 | +- **Default**: If no confidence level is specified, intervals are not returned. |
| 17 | + |
| 18 | +## Usage example |
| 19 | + |
| 20 | +The following example shows how to query a confidence interval and interpret the response. |
| 21 | + |
| 22 | +### Request |
| 23 | + |
| 24 | +To request a confidence interval, use the `confidence(level: X)` argument in your query. |
| 25 | + |
| 26 | +```json |
| 27 | +query SingleDatasetWithConfidence($zoneTag: string, $start: Time, $end: Time) { |
| 28 | + viewer { |
| 29 | + zones(filter: {zoneTag: $zoneTag}) { |
| 30 | + firewallEventsAdaptiveGroups( |
| 31 | + filter: {datetime_gt: $start, datetime_lt: $end} |
| 32 | + limit: 1000 |
| 33 | + ) { |
| 34 | + count |
| 35 | + avg { |
| 36 | + sampleInterval |
| 37 | + } |
| 38 | + confidence(level: 0.95) { |
| 39 | + count { |
| 40 | + estimate |
| 41 | + lower |
| 42 | + upper |
| 43 | + sampleSize |
| 44 | + } |
| 45 | + } |
| 46 | + } |
| 47 | + } |
| 48 | + } |
| 49 | +} |
| 50 | +``` |
| 51 | + |
| 52 | +### Response |
| 53 | + |
| 54 | +The response includes the following values: |
| 55 | + |
| 56 | +- `estimate`: The estimated value, based on sampled data. |
| 57 | +- `lower`: The lower bound of the confidence interval. |
| 58 | +- `sampleSize`: The number of sampled data points used to calculate the estimate. |
| 59 | +- `upper`: The upper bound of the confidence interval. |
| 60 | + |
| 61 | +In this example, the interpretation of the response is that, based on a sample of 40,054, the estimated number of events is 42,939, with 95% confidence that the true value lies between 42,673 and 43,204. |
| 62 | + |
| 63 | +```json |
| 64 | +{ |
| 65 | + "data": { |
| 66 | + "viewer": { |
| 67 | + "zones": [ |
| 68 | + { |
| 69 | + "firewallEventsAdaptiveGroups": [ |
| 70 | + { |
| 71 | + "avg": { |
| 72 | + "sampleInterval": 1.0720277625205972 |
| 73 | + }, |
| 74 | + "confidence": { |
| 75 | + "count": { |
| 76 | + "estimate": 42939, |
| 77 | + "lower": 42673.44115335711, |
| 78 | + "sampleSize": 40054, |
| 79 | + "upper": 43204.55884664289 |
| 80 | + } |
| 81 | + }, |
| 82 | + "count": 42939 |
| 83 | + } |
| 84 | + ] |
| 85 | + } |
| 86 | + ] |
| 87 | + } |
| 88 | + }, |
| 89 | + "errors": null |
| 90 | +} |
| 91 | +``` |
0 commit comments