Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

20
LINES

< > BotCompany Repo | #1031999 // test_ProbabilisticDistanceBasedLookup (OK)

JavaX fragment (include) [tags: use-pretranspiled]

Libraryless. Click here for Pure Java version (4991L/29K).

svoid test_ProbabilisticDistanceBasedLookup() {
  new L<WithProbability<Double>> out;
  new ProbabilisticScheduler scheduler;
  NavigableMap<Double> map = listToKeyAndValue_treeMap(ll(
    1.0, 2.0, 3.0, 4.0, 5.0
  ));
  
  ProbabilisticDistanceBasedLookup lookup = new(scheduler, map, 
    x -> out.add(withProbability(scheduler.current(), x)),
    3.5);
  lookup.run();
  scheduler.run(50);
  
  assertEqualsVerbose(str(out), str(ll(
    withProbability(.67, 3.0),
    withProbability(.67, 4.0),
    withProbability(.4, 2.0),
    withProbability(.4, 5.0),
    withProbability(.29, 1.0))));
}

Author comment

Began life as a copy of #1031997

download  show line numbers  debug dex  old transpilations   

Travelled to 3 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx

No comments. add comment

Snippet ID: #1031999
Snippet name: test_ProbabilisticDistanceBasedLookup (OK)
Eternal ID of this version: #1031999/2
Text MD5: 0fb650f07b52fe9b40512a1ffd20da30
Transpilation MD5: eb406aa206dc183d52b2577a93fb7020
Author: stefan
Category: javax / probabilistic computing
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-08-08 15:35:49
Source code size: 612 bytes / 20 lines
Pitched / IR pitched: No / No
Views / Downloads: 87 / 130
Version history: 1 change(s)
Referenced in: [show references]