> For the complete documentation index, see [llms.txt](https://pystreamapi.pickwicksoft.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://pystreamapi.pickwicksoft.org/reference/api-reference/numeric-stream.md).

# Numeric Stream

{% hint style="info" %}
For information on how to create a `NumericStream` please visit the Quick Start docs: [/pages/t8ObAMIiW2YdbRJShd40#stream.of](https://pystreamapi.pickwicksoft.org/reference/api-reference/pages/t8ObAMIiW2YdbRJShd40#stream.of "mention")
{% endhint %}

### `interquartile_range()`: Calculate the interquartile range

Calculates the interquartile range of a numerical Stream. Returns either `int` or `float`.

```python
Stream.of([1, 2, 3, 4, 5, 7, 7, 8, 9, 9]) \
    .interquartile_range() # Returns 5
```

### `first_quartile()`: Calculate the first quartile

Calculates the first quartile of a numerical Stream. Returns either `int` or `float`.

```python
Stream.of([1, 2, 3, 4, 5, 7, 7, 8, 9, 9]) \
    .first_quartile() # Returns 3
```

### `mean()`: Calculate the mean

Calculates the mean of a numerical Stream. Returns either `int` or `float`.

```python
Stream.of([1, 2, 3, 4, 5, 7, 7, 8, 9, 9]) \
    .mean() # Returns 5.5
```

### `median()`: Calculate the median

Calculates the median of a numerical Stream. Returns either `int` or `float`.

```python
Stream.of([1, 2, 3, 4, 5, 7, 7, 8, 9, 9]) \
    .median() # Returns 6.0
```

### `mode()`: Calculate the mode

Calculates the mode(s) (most frequently occurring element/elements) of a numerical Stream. Returns a list of either `int`, `float`or `None`.&#x20;

```python
Stream.of([1, 2, 3, 4, 5, 7, 7, 8, 9, 9]) \
    .mode() # Returns [7, 9]
```

### `range()`: Calculate the range

Calculates the range of a numerical Stream. Returns either `int` or `float`.

```python
Stream.of([1, 2, 3, 4, 5, 7, 7, 8, 9, 9]) \
    .range() # Returns 8
```

### `third_quartile()`: Calculate the range

Calculates the third quartile of a numerical Stream. Returns either `int` or `float`.

```python
Stream.of([1, 2, 3, 4, 5, 7, 7, 8, 9, 9]) \
    .third_quartile() # Returns 8
```

### `sum()`: Calculate the sum

Calculates the sum of all elements of a numerical Stream. Returns either `int` or `float`.

```python
Stream.of([1, 2, 3]) \
    .sum() # Returns 6
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://pystreamapi.pickwicksoft.org/reference/api-reference/numeric-stream.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
