New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added BernoulliProcess
#15058
Added BernoulliProcess
#15058
Conversation
Added support for naming of Indexed types and avoid passing unnecessary kw_args
Modified `BernoulliProcess` to take in a name(symbol/str), a probability of success, and success(int), failure(int) as input. This returns an object of `StochasticProces`, which can be indexed to return a single distribution or a joint distribution depending on the number of indices.
✅ Hi, I am the SymPy bot (v125). I'm here to make sure this pull request has a release notes entry. Please read the guide on how to write release notes. Click here to see the pull request description that was parsed.
Your release notes are in good order. Here is what the release notes will look like:
This will be added to https://github.com/sympy/sympy/wiki/Release-Notes-for-1.2.1. Note: This comment will be updated with the latest check if you edit the pull request. You need to reload the page to see it. |
@@ -159,6 +159,10 @@ def __new__(cls, base, *args, **kw_args): | |||
|
|||
return Expr.__new__(cls, base, *args, **kw_args) | |||
|
|||
@property | |||
def name(self): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why this edit? I would not edit other modules.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just cherry pick one of the other commits that were already merged into the master, because it was needed in the PR. Should I remove this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better not edit other modules
@@ -330,3 +330,12 @@ def marginalise_out(self, expr, rv): | |||
|
|||
def __call__(self, *args): | |||
return self.pdf(*args) | |||
|
|||
class StochasticProcess(Basic, NamedArgsMixin): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's an expression, should inherit Expr
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Inheriting from Expr
would mean allowing arithmatic operations directly on the stochastic process instead of the indexed object. I am not sure if that would be correct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
StochasticProcess) | ||
from sympy.functions.elementary.piecewise import Piecewise | ||
|
||
class BernoulliProcess(StochasticProcess): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we need to follow the same approach of JointRandomSymbol
. Maybe RandomProcess
should be equivalent to JointRandomSymbol
as a class?
I would also consider a probability space for random processes, that is, I would maintain the same existing structure/logic.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had considered the StochasticProcess class as a collection of random variables, and any finite number of indexed elements from could be used to make a joint distribution. Each indexed element itself would a random variable.
Can you please explain as to how the StochasticProcess class could be made similar to JointRandomSymbol, i.e, how to seperate the distibution and the probability space?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One way would be to represent it as a collection of distributions instead of random symbols.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we extract the collection of probability spaces when needed. For example the expression E(X[t], X[t-2])
would probably extract the probability spaces at t
and t-2
, thus creating the collection.
I suggest to keep the API as close as possible to the existing one, as it would avoid editing too much later.
References to other Issues or PRs
Brief description of what is fixed or changed
Modified
BernoulliProcess
to take in a name(Symbol
/str
), a probabilityof success, and success(
int
), failure(int
) as input. This returns anobject of
StochasticProces
, which can be indexed to return a singledistribution or a joint distribution depending on the number of indices.
Other comments
Release Notes
BernoulliProcess