Comments (3)
Thanks for the runtime measurements. These numbers are in line with expectation for preprocessing floats, since the floating-point algorithm (which itself is not very optimized) is significantly more expensive than the integer arithmetic algorithm.
The implementation in C is much faster. We should consider using e.g., Cython to create a Python API.
from fast-loaded-dice-roller.
Ok, thanks.
FYI the runtime measurements only include sampling, not preprocessing. I also noted that using the alternative floating-point preprocessing algorithm mentioned in #4 resulted in runtimes much more comparable to the integer algorithm.
python -m timeit -s "from fldr.fldrf import fldr_preprocess_float_c as fldrf_preprocess; from fldr import fldr_sample; l = range(10000); x = fldrf_preprocess([1/len(l) for _ in l])" "fldr_sample(x)"
50000 loops, best of 5: 7.16 usec per loop
Thanks again for the great work.
from fast-loaded-dice-roller.
Thanks again for confirming. I will change the default implementation to use the alternative preprocessing algorithm in light of #4 and #5.
FYI the runtime measurements only include sampling, not preprocessing.
Good point, I missed the fact that your timeit script uses -s
for "setup".
from fast-loaded-dice-roller.
Related Issues (8)
- Support target distributions specified as floating-point numbers (Python)
- Support target distributions specified as floating-point numbers (C)
- Sampling issues for uniform distributions with floating-point values HOT 4
- Consider dividing integer weights by their GCD HOT 1
- Implement various minor optimizations in fldr_preprocess
- FLDR seems to be slow in Java
- Skipping final bit in flip.c HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fast-loaded-dice-roller.