Comments (2)
Hi @echo66
I agree that being able to set the random_state
to ensure reproducibility of your results is indeed a useful feature to have.
From the approaches you propose, I'll definetely pick the second one: having random_state
as an constructor argument on the classes that use some kind of stochastic process.
I would also take your suggestion of using only one of random
and numpy.random
. Will you be open to do the changes yourself?
from copulas.
The required changes should be the following:
- Replace all the ocurrences of
random
withnp.random
- Create a method
random_state_call
oncopulas.__init__
, like this:
def random_state_call(random_state, function, *args, **kwargs):
if random_state is None:
return function(*args, **kwargs)
else:
original_state = np.random.get_state()
np.random.seed(random_state)
result = function(*args, **kwargs)
np.random.set_state(original_state)
return result
-
Change classes
bivariate.base.Bivariate
andmultivariate.tree.Tree
__new__
method in order for them to accept arbitrary positional and keyword arguments*args, **kwargs
-
Add the argument
random_state=None
on__init__
for both classes, that sets its value to the attribute of the same name. -
Replace on their subclasses all calls to functions that depend on their np.random with calls to
random_state_call
, that is:
np.random.uniform(0, 1, n_samples)
random_state_call(self.random_state, np.random.uniform, 0, 1, n_samples)
-
Repeat the steps 4 & 5 for
univariate.base.Univariate
,multivariate.base.Multivariate
andmultivariate.vine.VineCopulas
. -
Create unittests for
random_state_call
and for thesample
methods, in which, after a random state is set, the sample values are exactly the same. -
Check everything is according to our Contributing Guide.
If you plan on updating your PR with this changes, please let us know and we will assign this issue to you.
from copulas.
Related Issues (20)
- vine copulas HOT 3
- Drop support for Python 3.7
- Using any univariate distribution from scipy HOT 1
- When Copulas univariate fit fails, produce a log instead of a warning
- Switch default branch from master to main
- Update add-on detection for Copulas
- Alpha and Beta can be out of bounds for beta distribution causing Nans to appear
- VineCopula is not working NonImplementedError for pdf and cdf HOT 2
- Support Python 3.12
- supports dynamic copulas
- Set `allow_singular=True` when calculating probability_density
- Transition from using setup.py to pyroject.toml to specify project metadata
- Remove bumpversion and use bump-my-version
- Switch to using ruff for Python linting and code formatting
- Add build to dev requirements
- Digital Object Indentifier for Copulas HOT 2
- Add dependency checker
- .fit method parameter HOT 2
- Add bandit workflow
- Fix minimum version workflow when pointing to github branch
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 copulas.