# Difficulty Algorithm - CIMA (Confidence Interval Moving Average)

CIMA stands for Confidence Interval Moving Average. This difficulty algorithm('DA', hereinafter) takes the basic form of moving average techniques in statistics. Normally 95%-98% confidence interval is chosen for statistical analysis.&#x20;

The percentage figure used in CI stands for the range of distributions of the values, which are normally within the confidence interval range from a mean value of the sample population. The percentage value does not necessarily represent that the future samples are likely to be within that specific interval range.

![A bell-shaped distribution curve diagram with confidence interval from Wikipedia](https://2033312304-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-M9vS8EzA6RpzXIh8rof%2F-MCvbhVR9-sgIoTIKfbn%2F-MCvcgiTB1CsuibBbS9x%2FNormal_distribution_and_scales.gif?alt=media\&token=9aa0eac4-7c51-4c11-9f8e-6eac2d6b81cc)

QWC's CIMA DA currently uses a 68% confidence interval and this selection of 68% CI to allow DA to adjust more quickly from valid sample data.

Within a range of 30 block time, equivalent to 1 hour, a sample mean(1), and the standard deviation is calculated.

We filter out those samples with a value that lies outside of mean +/- the standard deviation range. We treat those values outside of the 68% CI as outliers.

We then re-calculate the mean(2) of the filtered samples. We consider the mean(2) a true mean value. If the values of the samples are within a range we consider 'consistent'(remember we used the notion of consistency in our reward algorithm), the difficulty for the next block will stay the same.

In other cases, by comparing mean(1) and mean(2), the algorithm decides whether to increase or decrease the difficulty for the next block.&#x20;

CIMA DA undergoes a relaxed stability state and oscillates in a simple harmonic motion around particular centerline values. As a result, it can quickly react to changes upon detecting abnormalities.&#x20;

With CIMA DA and Consistency, QWC blockchain is bulletproof against the majority attacks and protects the network from any malicious intents.&#x20;

&#x20;


---

# Agent Instructions: 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:

```
GET https://wp.qwertycoin.org/consensus/egalitarian-proof-of-work-epow/difficulty-algorithm-cima-confidence-interval-moving-average.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
