Skip to content

Commit 420fd66

Browse files
authored
Merge pull request #1298 from humanprotocol/develop
Release 20231201
2 parents af0f5ef + 71631dc commit 420fd66

File tree

199 files changed

+10311
-4872
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

199 files changed

+10311
-4872
lines changed

docs/sdk/SUMMARY.md

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,31 @@
1515
* [Storage](typescript/modules/storage.md)
1616
* [StorageClient](typescript/classes/storage.StorageClient.md)
1717
* [Statistics](typescript/modules/statistics.md)
18-
* [StakingClient](typescript/classes/statistics.StatisticsClient.md)
18+
* [StatisticsClient](typescript/classes/statistics.StatisticsClient.md)
1919

2020
## Python SDK
2121

22-
* [human_protocol_sdk](python/index.md)
22+
* [agreement](python/human_protocol_sdk.agreement.md)
23+
* [bootstrap](python/human_protocol_sdk.agreement.bootstrap.md)
24+
* [measures](python/human_protocol_sdk.agreement.measures.md)
25+
* [utils](python/human_protocol_sdk.agreement.utils.md)
26+
* [encryption](python/human_protocol_sdk.encryption.md)
27+
* [encryption](python/human_protocol_sdk.encryption.encryption.md)
28+
* [legacy_encryption](python/human_protocol_sdk.legacy_encryption.md)
29+
* [encryption_utils](python/human_protocol_sdk.encryption.encryption_utils.md)
30+
* [escrow](python/human_protocol_sdk.escrow.md)
31+
* [escrow_client](python/human_protocol_sdk.escrow.escrow_client.md)
32+
* [escrow_utils](python/human_protocol_sdk.escrow.escrow_utils.md)
33+
* [kvstore](python/human_protocol_sdk.kvstore.md)
34+
* [kvstore_client](python/human_protocol_sdk.kvstore.kvstore_client.md)
35+
* [staking](python/human_protocol_sdk.staking.md)
36+
* [staking_client](python/human_protocol_sdk.staking.staking_client.md)
37+
* [staking_utils](python/human_protocol_sdk.staking.staking_utils.md)
38+
* [statistics](python/human_protocol_sdk.statistics.md)
39+
* [statistics_client](python/human_protocol_sdk.statistics.statistics_client.md)
40+
* [storage](python/human_protocol_sdk.storage.md)
41+
* [storage_client](python/human_protocol_sdk.storage.storage_client.md)
42+
* [storage_utils](python/human_protocol_sdk.storage.storage_utils.md)
43+
* [constants](python/human_protocol_sdk.constants.md)
44+
* [filter](python/human_protocol_sdk.filter.md)
45+
* [utils](python/human_protocol_sdk.utils.md)
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# human_protocol_sdk.agreement.bootstrap module
2+
3+
Module containing methods to calculate confidence intervals using bootstrapping.
4+
5+
### human_protocol_sdk.agreement.bootstrap.confidence_intervals(data, statistic_fn, n_iterations=1000, n_sample=None, confidence_level=0.95, algorithm='bca', seed=None)
6+
7+
Returns a tuple, containing the confidence interval for the boostrap estimates of the given statistic and statistics of the bootstrap samples.
8+
9+
* **Parameters:**
10+
* **data** (`Sequence`) – Data to estimate the statistic.
11+
* **statistic_fn** (`Callable`) – Function to calculate the statistic. statistic_fn(data) must return a number.
12+
* **n_iterations** (`int`) – Number of bootstrap samples to use for the estimate.
13+
* **n_sample** (`Optional`[`int`]) – If provided, determines the size of each bootstrap sample
14+
drawn from the data. If omitted, is equal to the length of the data.
15+
* **confidence_level** – Size of the confidence interval.
16+
* **algorithm** – Which algorithm to use for the confidence interval
17+
estimation. “bca” uses the “Bias Corrected Bootstrap with
18+
Acceleration”, “percentile” simply takes the appropriate
19+
percentiles from the bootstrap distribution.
20+
* **seed** – Random seed to use.
21+
* **Return type:**
22+
`Tuple`[`Tuple`[`float`, `float`], `ndarray`]
23+
* **Returns:**
24+
Confidence interval and bootstrap distribution.
25+
* **Example:**
26+
```python
27+
from human_protocol_sdk.agreement.bootstrap import confidence_interval
28+
import numpy as np
29+
30+
np.random.seed(42)
31+
data = np.random.randn(10_000)
32+
fn = np.mean
33+
sample_mean = fn(data)
34+
print(f"Sample mean is {sample_mean:.3f}")
35+
# Sample mean is -0.002
36+
37+
cl = 0.99
38+
ci, _ = confidence_interval(data, fn, confidence_level=cl)
39+
print(f"Population mean is between {ci[0]:.2f} and {ci[1]:.2f} with a probablity of {cl}")
40+
# Population mean is between -0.02 and 0.02 with a probablity of 0.99
41+
```

0 commit comments

Comments
 (0)