> For the complete documentation index, see [llms.txt](https://developer.mediarithmics.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developer.mediarithmics.io/schema/computed-fields/concepts.md).

# Concepts

## Technical concept

Computed fields are defined in the schema at the UserPoint level.

The plugin behind it performs computations on a regular basis of a function's result, based on the user activities and profile updates.

## Definitions

### Computed Field

A computed field is an instance of a Datamart function applied within a specific context. To use it, it must be declared in your schema.

### Computed Field Function

A Computed Field Function is a [plugin](/advanced-usages/plugins.md) of type `COMPUTED_FIELD_FUNCTION`, which can be created via the API following the standard [process](/advanced-usages/plugins/creation.md) or through the computing console interface.

## Notions

A computed field is defined by these elements:

1. **State**: The **data stored** to build the result. It is the history. Each new activity updates the **State**.

   → the state is closely related to the *Lookback Window* - i.e. the historical depth of events to be analyzed.
2. **Logic**: The logic can be very simple (*like a formula, a sum, a count…*) or more complex (*like a logical operation*).
3. **Result**: The **data calculated and stored**. It contains the score(s) to be used.

   The result can be either a single variable or an object, depending on the complexity of the computation. It is computed from the **State**

Other interesting concepts to take into consideration:

* **Input Data**: Either new userActivities, either userProfile update, either both.
* **Period Update**: The regularity of updates (every x days - by default x=1).

## Lifecycle

1. **INITIAL** – The instance is created with this status.
2. **INITIAL\_LOADING** – Once declared in the schema and successfully validated, an initial loading job is triggered.
3. **ACTIVE** – The computed field becomes active if the job is completed successfully.

<img src="https://4196284719-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MMuoqM-5hJ5JY0WnAKL%2Fuploads%2FqU4BBQgtaRXJihrX6WKc%2Ffile.excalidraw.svg?alt=media&amp;token=1b2aa9f2-3429-450d-b749-66d3e40af1fc" alt="Computed field lifecycle" class="gitbook-drawing">

## Technical flow

To better understand how a computed field works, here are the technical steps and the relation with the methods:

1. **Initialization**: The computed field is declared in the schema.
2. **State Updates**: Triggered by new user activities or profile updates.
3. **Result Calculation**: The result is computed based on the current state.
4. **Storage**: The result is stored for querying.


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developer.mediarithmics.io/schema/computed-fields/concepts.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
