Skip to content

Commit

Permalink
Minor README changes
Browse files Browse the repository at this point in the history
  • Loading branch information
gstamatelat committed Dec 14, 2017
1 parent e74da82 commit ede1ece
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,29 +10,29 @@ This library distinguishes these algorithms into two main categories: the ones t

Select 10 numbers at random in the range [1,100]. Each number has a 10% probability of appearing in the sample.
```java
final RandomSampling<Integer> rs = new WatermanSampling<>(10, new Random());
RandomSampling<Integer> rs = new WatermanSampling<>(10, new Random());
rs.feed(IntStream.rangeClosed(1, 100).boxed().iterator());
Collection<Integer> sample = rs.sample();
System.out.println(sample);
```

Select 5 random tokens from an input stream.
```java
final RandomSampling<String> rs = new VitterXSampling<>(5, new Random());
RandomSampling<String> rs = new VitterXSampling<>(5, new Random());
rs.feed(new Scanner(System.in));
System.out.println(rs.sample());
```

Same example using Algorithm Z.
```java
final RandomSampling<String> rs = new VitterZSampling<>(5, new Random());
RandomSampling<String> rs = new VitterZSampling<>(5, new Random());
rs.feed(new Scanner(System.in));
System.out.println(rs.sample());
```

Select 2 terms from a vocabulary, based on their weight.
```java
final WeightedRandomSampling<String> rs = new EfraimidisSampling<>(2, new Random());
WeightedRandomSampling<String> rs = new EfraimidisSampling<>(2, new Random());
rs.feed("collection", 1)
.feed("algorithms", 2)
.feed("java", 2)
Expand All @@ -44,10 +44,8 @@ System.out.println(rs.sample());

## Algorithms

### Summary

| Class | Algorithm | Weighted |
| -------------------- | ----------------------------- | -------- |
| :------------------- | :---------------------------- | :------- |
| `WatermanSampling` | Algorithm R by Waterman | |
| `VitterXSampling` | Algorithm X by Vitter | |
| `VitterZSampling` | Algorithm Z by Vitter | |
Expand Down

0 comments on commit ede1ece

Please sign in to comment.