-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
[WIP] Add density and cdf plot functions for random variables #19073
base: master
Are you sure you want to change the base?
Conversation
✅ Hi, I am the SymPy bot (v158). I'm here to help you write a release notes entry. Please read the guide on how to write release notes. 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.6. 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. Click here to see the pull request description that was parsed.
|
Does it support both continuous and discrete? |
Yes, it plots for discrete Rv, but I was wondering If we have something like scatter plot in matplotlib(for plotting for discrete), also, some argument like |
I don't think that it gives meaningful result for discrete random variables, but gives a plain axis with nothing plotted. |
I agree, plotting of discrete RV as continuous lines does not look good. I had expected to create some plots for them as here. But, Currently, I think creating such plots will require refining |
@@ -575,7 +575,7 @@ class LineOver1DRangeSeries(Line2DBaseSeries): | |||
def __init__(self, expr, var_start_end, **kwargs): | |||
super(LineOver1DRangeSeries, self).__init__() | |||
self.expr = sympify(expr) | |||
self.label = str(self.expr) | |||
self.label = kwargs.get('label', None) or str(self.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.
@sylee957 Should I make this change in a new PR? It involves adding label
as an argument in the plot
so that we could use them to denote when we use legend
to name that line as in matplotlib. Currently, it by default considers label
as str(self.expr)
. I will look something like 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.
I think that labeling a plot manually can be a useful feature.
But you should add tests for ordinary plots to see how this works.
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.
Is the plotting module able to plot a set of functions in the same graph as shown above? Is the public API of plot capable of supporting such stuff?
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.
Yes, this is able to plot many functions in the same graph. Seeing this as a useful feature, I made a change in the plotting
module. But, I think, I should open a new PR for this as it involves a change in public API of plot
. Also, I think the current plot is unable to plot discrete graphs as we have scatter plot in matplotlib which is required for plotting discrete RV.
This PR creates a wrapper for plotting module to make things easy. So probably, making changes to plotting module should be restricted here. |
Any news on this? |
I was wondering how to proceed further without |
Can we use histograms for both FRVs, and DRVs? I remember, plotting was also meant for random matrices too, though I am not sure how should they be represented on graphs. |
The problem of histogram is that setting the bin size is arbitrary, and again I don't think that it is the best way to display discrete PMF than stem because the visuals are significantly affected by the width of the bins. |
May be, https://matplotlib.org/3.2.1/api/_as_gen/matplotlib.pyplot.scatter.html can be tried out for FRV and DRV. Is there any support for wrapper of the above API in |
Any news on this? |
We currently don't have scatter plots available in |
What about using matplotlib API as suggested in #19073 (comment) |
References to other Issues or PRs
Related to the discussion in #18730, See 18730(comment)
Brief description of what is fixed or changed
Other comments
density
andcdf
Release Notes
density
andcdf
plotting functions