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
generalize multivarate_normal generator for complex numbers? #9098
Comments
Probably the simplest API would be to make it a new, separate method. |
The first step should be to take a decision about allows |
+1 for a |
Unfortunately the current structure makes this really tedious for many distributions. For example the t is directly implemented so that the C code generates a normal and a chi square and then returns a single t rv. It would be much easier to reimplement types if it used the higher level normal and gamma and then combined after generation. In this hypothetical, changing styles would be as easy as changing the two core rv dtypes. |
From my experience in complex distributions (somewhat limited, to signal processing), I actually mainly see the normal, normal multivariate, chi2 and whishart distributions, as extendable to complex numbers. For other ones, I don't know if such extension has been used or proposed, do you? This question is just to guess how much an implementation of all the complex cases would be for already existing generators in numpy. |
Supporting dtype arguments is cool, but I'm not sure it should actually change what distribution we're sampling from? Usually these just change the storage / rounding. |
Yes, one could just cast to alternative types. This would be simple for |
Not sure what you mean. If sampling from a real distribution and storing the output in a complex dtype, you don't need any extra bits: the real part of the complex dtypes is identical to the corresponding real dtype. (And to be clear: of course it also makes sense to support sampling from complex distributions, I just feel like maybe that should be a different method rather than something triggered by a |
There's already precedent for the
Given that's the case, I think it would be very reasonable for the |
I have cobbled an early version of a univariate It it doesn't have any test coverage, but it does pass interactive sanity tests. In particular, when generating from the same state, a single standard normal has the same value as import randomstate as rs
st = rs.get_state()
rs.standard_normal()
Out[14]: 1.1538228506652775
rs.set_state(st)
rs.complex_normal(0,1,1)
Out[15]: (1.1538228506652775+0j)
rs.set_state(st)
rs.complex_normal(0,[1],[1])
Out[16]: array([ 1.15382285+0.j])
rs.set_state(st)
rs.complex_normal(0,[1],[-1])
Out[16]: array([ 1.15382285+0.j])
# Here the complex is the second std normal from a common state
rs.set_state(st)
rs.complex_normal(0,1,-1)
Out[23]: 1.9065545940505344j
rs.set_state(st)
rs.standard_normal(2)
Out[24]: array([ 1.15382285, 1.90655459]) FWIW, if |
Add complex normal random generator Test against the existing normal generator What's new note closes numpy#9098 xref numpy#6790
What's the need?
random.multivariate_normal works great for but is limited to sampling real vectors. Today, if ones would like to generate from complex multivariate distribution from (mu, Omega), sampling would need these steps:
Featuring it? How?
Would it be possible to extend today's function to complex numbers? I imagine two possibilites
for implementing that:
The text was updated successfully, but these errors were encountered: