Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Unable to replicate "Stochastic Volatility model" in PyMC v5.20#7672

AnsweredbyricardoV94
abdullahau asked this question inQ&A
Discussion options

I have been trying to runthis notebook with the following packages:

Python implementation: CPythonPython version       : 3.12.8IPython version      : 8.31.0pytensor: 2.26.4aeppl   : not installedxarray  : 2025.1.2numpy     : 1.26.4arviz     : 0.20.0matplotlib: 3.10.0pandas    : 2.2.3pymc      : 5.20.0

Running the functionmodel_to_graphviz, I notice that the model is set-up exactly as intended. However, this part of the code returns extremely different results:

withstochastic_vol_model:idata=pm.sample_prior_predictive(500,random_seed=rng)prior_predictive=az.extract(idata,group="prior_predictive")

output

Note that similar to the notebook, I have set the random seed state asrng = np.random.RandomState(1234)

Additionally, while trying to run this bit of code with the RandomState:

withstochastic_vol_model:idata.extend(pm.sample(random_seed=rng))posterior=az.extract(idata)posterior["exp_volatility"]=np.exp(posterior["volatility"])

I get the error:

TypeError: Cannot create a random Generator from a RandomStream object. Please provide a random seed, BitGenerator or Generator instead.

While setting the random generator asrng = np.random.default_rng(1234), I am unable to produce the same results.

You must be logged in to vote

Yes we should use generator not randomstate.

If I remember correctly, the "results" of that notebook are very dependent on the seed, you can try a different value, but they are not very stable. And if they depend on the seed they are not very meaningful either.

Replies: 1 comment

Comment options

Yes we should use generator not randomstate.

If I remember correctly, the "results" of that notebook are very dependent on the seed, you can try a different value, but they are not very stable. And if they depend on the seed they are not very meaningful either.

You must be logged in to vote
0 replies
Answer selected byabdullahau
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@abdullahau@ricardoV94

[8]ページ先頭

©2009-2025 Movatter.jp