add SquigglePy
This commit is contained in:
parent
60ea376a19
commit
3dac5f35cd
|
@ -39,6 +39,7 @@ The title of this repository is a pun on two meanings of "time to": "how much ti
|
|||
| Javascript (NodeJS) | 732ms | 69 |
|
||||
| Squiggle | 1,536s | 14 |
|
||||
| R | 7,000s | 49 |
|
||||
| SquigglePy | 14.305s | 18 |
|
||||
| Python (CPython) | 16,641s | 56 |
|
||||
|
||||
Time measurements taken with the [time](https://man7.org/linux/man-pages/man1/time.1.html) tool, using 1M samples.
|
||||
|
|
10
squigglepy/makefile
Normal file
10
squigglepy/makefile
Normal file
|
@ -0,0 +1,10 @@
|
|||
install:
|
||||
pip3 install squigglepy
|
||||
pip3 install numpy
|
||||
|
||||
run:
|
||||
python3 samples.py
|
||||
|
||||
time:
|
||||
time python3 samples.py
|
||||
|
18
squigglepy/samples.py
Normal file
18
squigglepy/samples.py
Normal file
|
@ -0,0 +1,18 @@
|
|||
import squigglepy as sq
|
||||
import numpy as np
|
||||
|
||||
p_a = 0.8
|
||||
p_b = 0.5
|
||||
p_c = p_a * p_b
|
||||
|
||||
dist_0 = sq.discrete({0: 1})
|
||||
dist_1 = sq.discrete({1: 1})
|
||||
dist_some = sq.to(1, 3)
|
||||
dist_many = sq.to(2, 10)
|
||||
|
||||
dists = [dist_0, dist_1, dist_some, dist_many]
|
||||
weights = [(1 - p_c), p_c/2, p_c/4, p_c/4 ]
|
||||
|
||||
result = sq.mixture(dists, weights)
|
||||
result_samples = sq.sample(result, 1000000)
|
||||
print(np.mean(result_samples))
|
Loading…
Reference in New Issue
Block a user