ai.promoted.delivery.client.SamplerImpl Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of deliveryclient Show documentation
Show all versions of deliveryclient Show documentation
A Java Client to contact the Promoted.ai Delivery API.
package ai.promoted.delivery.client;
import java.util.Random;
/**
* Basic implementation of the Sampler interface.
*/
public class SamplerImpl implements Sampler {
private Random rand;
public SamplerImpl() {
rand = new Random();
}
public SamplerImpl(Random rand) {
this.rand = rand;
}
@Override
public boolean sampleRandom(float threshold) {
if (threshold >= 1) {
return true;
}
if (threshold <= 0) {
return false;
}
return rand.nextDouble() < threshold;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy