Skip to content
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 random matrices(Gaussian Ensembles only) #17174

Merged
merged 15 commits into from Jul 28, 2019

Conversation

@czgdp1807
Copy link
Member

commented Jul 11, 2019

References to other Issues or PRs

[1] #17039

Brief description of what is fixed or changed

I have added framework random matrices.

Other comments

This is a work in progress. The first commit depicts how the framework for random matrices will look like. More features will added in the upcoming updates.

Release Notes

  • stats
    • Random matrices have been added to sympy.stats
@sympy-bot

This comment has been minimized.

Copy link

commented Jul 11, 2019

Hi, I am the SymPy bot (v147). 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.5.

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.

<!-- Your title above should be a short description of what
was changed. Do not include the issue number in the title. -->

#### References to other Issues or PRs
<!-- If this pull request fixes an issue, write "Fixes #NNNN" in that exact
format, e.g. "Fixes #1234". See
https://github.com/blog/1506-closing-issues-via-pull-requests . Please also
write a comment on that issue linking back to this pull request once it is
open. -->
[1] https://github.com/sympy/sympy/issues/17039

#### Brief description of what is fixed or changed
I have added framework random matrices.

#### Other comments
This is a work in progress. The first commit depicts how the framework for random matrices will look like. More features will added in the upcoming updates.

#### Release Notes

<!-- Write the release notes for this release below. See
https://github.com/sympy/sympy/wiki/Writing-Release-Notes for more information
on how to write release notes. The bot will check your release notes
automatically to see if they are formatted correctly. -->

<!-- BEGIN RELEASE NOTES -->
* stats
  * Random matrices have been added to `sympy.stats`
<!-- END RELEASE NOTES -->

Update

The release notes on the wiki have been updated.

@czgdp1807

This comment has been minimized.

Copy link
Member Author

commented Jul 11, 2019

ping @Upabjojr @sidhantnagpal
Please keep tracking, reviewing this PR. Thanks.

@Upabjojr
Copy link
Contributor

left a comment

Did you also test expressions of random matrices?

@czgdp1807

This comment has been minimized.

Copy link
Member Author

commented Jul 15, 2019

Did you also test expressions of random matrices?

Thanks for this case. I will add it in tests. Will update the PR with more features.

@codecov

This comment has been minimized.

Copy link

commented Jul 16, 2019

Codecov Report

Merging #17174 into master will increase coverage by 0.058%.
The diff coverage is 96.774%.

@@              Coverage Diff              @@
##            master    #17174       +/-   ##
=============================================
+ Coverage   74.548%   74.607%   +0.058%     
=============================================
  Files          623       626        +3     
  Lines       161785    162168      +383     
  Branches     37966     38029       +63     
=============================================
+ Hits        120608    120989      +381     
+ Misses       35827     35820        -7     
- Partials      5350      5359        +9
@czgdp1807

This comment has been minimized.

Copy link
Member Author

commented Jul 16, 2019

I have made some minor architectural changes to GaussianEnsemble. I am exploring the literature to see how random matrices are added and multiplied and other expressions as I think that finding the density of sum of two random matrix symbols isn't as simple as finding those of random symbols. I will make an update on this. Thanks.

@Upabjojr

This comment has been minimized.

Copy link
Contributor

commented Jul 16, 2019

I am exploring the literature to see how random matrices are added and multiplied and other expressions as I think that finding the density of sum of two random matrix symbols isn't as simple as finding those of random symbols.

There is still the possibility of leaving the expressions unevaluated or raising NotImplementedError. I just want this to be tested. There is no need to implement this now, just make sure that the code doesn't return wrong results.

@Upabjojr

This comment has been minimized.

Copy link
Contributor

commented Jul 16, 2019

An exception warning the user that the code is not complete is much better than a wrong result.

@czgdp1807

This comment has been minimized.

Copy link
Member Author

commented Jul 17, 2019

I will see if I can implement them in this PR. If I found that it will take longer than I will just raise NotImplementedError for expressions containing RandomMatrixSymbols. In fact, testing for expressions of random matrices helped in understanding the importance of it, so all depends on the efforts required which will decide whether a new PR has to be made after this one.

czgdp1807 added some commits Jul 19, 2019

@czgdp1807

This comment has been minimized.

Copy link
Member Author

commented Jul 25, 2019

I studied about expressions of random matrices. Here are my comments,

General Observation

I got to know that there isn't any general technique to find the density of an expression containing more than 1 random matrix. In fact, for example, if we take a matrix from Gaussain Unitary Ensemble(GUE) and raise it to a power more than 2 then it's not necessary that it belongs to the GUE(reference - http://web.mit.edu/18.06-esg/18.034/03pract.pdf, point - D, page - 2).

Some special techniques

  1. If we sum two or more matrices from GUE then it is guaranteed that the result will belong to GUE(concluded from http://web.mit.edu/18.06-esg/18.034/03pract.pdf point - D, page - 2). So we can find the density with ease when it comes to only sums of GUE.

  2. Similarly, if we sum two or more matrices coming from both GUE and Gaussian Orthogonal Ensemble(GOE) then the result will belong to GUE, because all real symmetric matrices are Hermitian too.

In short, for sum the result can be determined.

I suggest that we should raise NotImplementedError for expressions which are not RandomMatrixSymbol for now. May be some time later, I will make the changes and add the special technique for sums of GUE and GOE, if until then no general solution is found. Trying out Wolfram will also be a good idea and may help to find the solution and I will do that.

I will update the PR with other matrix ensembles. Thanks.

assert joint_eigen_distribution(G).dummy_eq(
Lambda((l[1], l[2], l[3]),
9*sqrt(2)*exp(-3*l[1]**2/2 - 3*l[2]**2/2 - 3*l[3]**2/2)*
Product(Abs(l[i] - l[j]), (j, i + 1, 3), (i, 1, 2))/(32*pi)))

This comment has been minimized.

Copy link
@sidhantnagpal

sidhantnagpal Jul 27, 2019

Member

Minor comment: This (and other places) can be made to match visual indent.

This comment has been minimized.

Copy link
@czgdp1807

czgdp1807 Jul 27, 2019

Author Member

Did you mean to align the content of L37, L38, L39 with ( in L36?

@czgdp1807 czgdp1807 changed the title [WIP] Added random matrices Added random matrices Jul 27, 2019

@czgdp1807 czgdp1807 changed the title Added random matrices Added random matrices(Gaussian Ensembles only) Jul 28, 2019

@czgdp1807

This comment has been minimized.

Copy link
Member Author

commented Jul 28, 2019

This PR is complete, I will add the matrices with random elements as their entries in a new PR rather than overloading this and making it unmanageable.

@Upabjojr Upabjojr merged commit 9406dcd into sympy:master Jul 28, 2019

3 checks passed

codecov/project 74.607% (target 0%)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
sympy-bot/release-notes The release notes look OK
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.