Coder Social home page Coder Social logo

Comments (4)

WardBrian avatar WardBrian commented on July 24, 2024

but it would literally just be another name for what StanRNG already does, same arguments and all.

Yeah, I went with this different style in Julia due to this and the more general fact that Julia doesn't let you directly associate methods with a struct the way Python and R's classes do. I think we could literally write new_rng = StanRNG in the Julia file and it would be equivalent.

In R and Python, the constructor of the StanRNG is internal/not documented online because it is written such that it takes in the handle to the library directly, rather than a handle to the model.

We sweep this distinction under the rug for the user, but creating an RNG doesn't really require anything from the model instance, but it does require accessing the library the model came from.

from bridgestan.

roualdes avatar roualdes commented on July 24, 2024

In R and Python, the constructor of the StanRNG is internal/not documented online because it is written such that it takes in the handle to the library directly, rather than a handle to the model.

Right. Would it be better to have

class StanRNG:
    def __init__(self, sm: StanModel, seed: int) -> None:
        self.stanlib = sm.stanlib
        ...

and equivalent in R, since this is effectively what happens in Julia?

from bridgestan.

WardBrian avatar WardBrian commented on July 24, 2024

I think I'd rather keep those as they were and add the new_rng alias to the Julia interface if method-for-method parity is the goal

from bridgestan.

sethaxen avatar sethaxen commented on July 24, 2024

To avoid potential confusion, I suggest not using an alias and instead defining

new_rng(sm::StanModel, seed) = StanRNG(sm, seed)

This is similar to how Random defines default_rng([tid]): https://github.com/JuliaLang/julia/blob/e204e200df8f57e516920c056b6ec2eb37d34079/stdlib/Random/src/RNGs.jl#L346-L347

from bridgestan.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.