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

Fix a bug in determining the minimum sample size for sampling uncerta… #349

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class BootstrapUtilities
* @param <R> the type of right-ish time-series data
* @param pool the pool
* @return the optimal block size for the stationary bootstrap in timestep units, together with the timestep
* @throws InsufficientDataForResamplingException if there is insufficient data to calculate the optimal block size
*/
public static <R> Pair<Long, Duration> getOptimalBlockSizeForStationaryBootstrap( Pool<TimeSeries<Pair<Double, R>>> pool )
{
Expand Down Expand Up @@ -110,7 +111,7 @@ public static <R> Pair<Long, Duration> getOptimalBlockSizeForStationaryBootstrap

/**
* Determines whether sufficient data is available for bootstrap resampling. There must be more than one event
* across time time-series present.
* across the consolidated time-series present.
* @param <T> the type of time-series data
* @param data the time-series data
* @return whether there is sufficient data for the stationary bootstrap
Expand All @@ -120,10 +121,13 @@ public static <T> boolean hasSufficientDataForStationaryBootstrap( List<TimeSeri
{
Objects.requireNonNull( data );

// Consolidate the time-series by event datetime and count the number of events
long eventCount = data.stream()
.mapToLong( t -> t.getEvents()
.size() )
.sum();
.flatMap( t -> t.getEvents()
.stream()
.map( Event::getTime ) )
.distinct()
.count();

if ( LOGGER.isDebugEnabled() )
{
Expand Down Expand Up @@ -413,6 +417,7 @@ private static void addQuantileForBoxplot( List<BoxplotStatistic> quantile,
* @param <T> the type of time-series data
* @param pool the pool
* @return the optimal block size for the stationary bootstrap
* @throws InsufficientDataForResamplingException if there are fewer than two events across the consolidated series
*/
private static <T> Pair<Long, Duration> getOptimalBlockSizeForStationaryBootstrap( List<TimeSeries<Pair<Double, T>>> pool )
{
Expand Down
12 changes: 6 additions & 6 deletions wres-datamodel/test/wres/datamodel/time/TimeSeriesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/**
* Tests the {@link TimeSeries}
*
*
* @author James Brown
*/

Expand Down Expand Up @@ -79,10 +79,10 @@ public void runBeforeEachTest()
FEATURE_NAME,
UNIT );
this.testSeries = builder.setMetadata( metadata )
.addEvent( iterator.next() )
.addEvent( iterator.next() )
.addEvent( iterator.next() )
.build();
.addEvent( iterator.next() )
.addEvent( iterator.next() )
.addEvent( iterator.next() )
.build();
}

/**
Expand Down Expand Up @@ -146,7 +146,7 @@ public void testHashCode()
@Test
public void testEquals()
{
// Reflexive
// Reflexive
assertEquals( this.testSeries, this.testSeries );

// Symmetric
Expand Down
Loading