Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
tianlh
LightGBM-DCU
Commits
a06899ab
Unverified
Commit
a06899ab
authored
Jul 07, 2021
by
shiyu1994
Committed by
GitHub
Jul 07, 2021
Browse files
fix Reservoir Sampling in Sample of random.h (#4450)
parent
e36cc9c1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
4 deletions
+1
-4
include/LightGBM/utils/random.h
include/LightGBM/utils/random.h
+1
-4
No files found.
include/LightGBM/utils/random.h
View file @
a06899ab
...
...
@@ -82,13 +82,10 @@ class Random {
ret
.
push_back
(
i
);
}
}
}
else
if
(
K
==
1
)
{
int
v
=
NextInt
(
0
,
N
);
ret
.
push_back
(
v
);
}
else
{
std
::
set
<
int
>
sample_set
;
for
(
int
r
=
N
-
K
;
r
<
N
;
++
r
)
{
int
v
=
NextInt
(
0
,
r
);
int
v
=
NextInt
(
0
,
r
+
1
);
if
(
!
sample_set
.
insert
(
v
).
second
)
{
sample_set
.
insert
(
r
);
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment