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
Corrected a bug on the rejection_sampling_2D algorithm and updated th… #250
Conversation
pyriemann/datasets/sampling.py
Outdated
@@ -129,24 +122,31 @@ def _rejection_sampling_2D(n_samples, sigma, random_state=None): | |||
Dispersion of the Riemannian Gaussian distribution. | |||
random_state : int, RandomState instance or None, default=None | |||
Pass an int for reproducible output across multiple function calls. | |||
return_rate : boolean |
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 calling it return_acceptance_rate
would be better, since one could think that it is the rejection_rate
or any other bizarre rate.
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.
Indeed, I've changed it.
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.
Thanks @mhurte! This is very helpful.
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.
Thx @mhurte for this contribution!
Can you complete whatsnew file, and complete tests with the new parameter?
Hi,
@plcrodrigues seems to be having the same issue as me Also, during the lasts tests that automatically ran on github I noticed that the test that is not working is the following :
And it does not seem to be related to the files that I have modified so far. |
In fact, it seems that to run
|
…e documentation Update pyriemann/datasets/sampling.py Co-authored-by: Quentin Barthélemy <q.barthelemy@gmail.com>
The changes that you made in I think that the hyper-parameters that we had chosen for creating the dataset were not really good, so I changed them so to have an example where the distance between the class means after rotation was indeed smaller than after just re-center. |
Thx @mhurte ! |
Hi everyone,
I would like to share a fix for a bug that I found as I was testing some sampling features of this library.
As I tried to compute the acceptance rate for the rejection sampling algorithm in 2D that is implemented in the sampling.py file, I noticed that something was odd : The following figure shows the acceptance rate as a function of sigma before the fix, compaired to the theoretical one for this method.
Since we know what the theoretical acceptance rate is for this algorithm, it was easy to notice that something was wrong when plotting the figure above. The acceptance rate is quickly converging to 1 when it should be converging to zero.
After searching through the code what the matter could be, I eventually found out that the roles of the mu_a and mu_b as defined in the functions
_rejection_sampling_2D_gfunction_plus
,_rejection_sampling_2D_gfunction_minus
and_rejection_sampling_2D
were in fact inverted.After fixing this, the program now behaves properly, the following figure shows the acceptance rate as a function of sigma after the fix.
Moreover, I added a boolean parameter to
_rejection_sampling_2D
, return_rate (defaulted to False) that allows to get the acceptance rate for the generation along with the sample if necessary.I also used the
_pdf_r
function that was already implemented in the file in the functions_rejection_sampling_2D_gfunction_minus
and_rejection_sampling_2D_gfunction_plus
to make the code more readable.The documentation has been updated accordingly.