# Add intervals to monitor to A-distance object ad = ADistance() data = [] for i in range(100): data.append(random.uniform(0.0, 1.0)) ad.addProportional(data, 0.1, 0.5) print ad # ad.add(Interval(-2, -1)) # ad.add(Interval(-1, 0)) # ad.add(Interval(0, 1)) # ad.add(Interval(1, 2)) # Create a change finder and add a single window pair cf = ChangeFinder(ad) cf.addWindowPair(WindowPair(100, 100, 0.5)) # Initialize the distance object ad.init(cf) cf.computeAlphas(ad.uniformSample(10000), 0.05, 50) # Process 1000 samples i = 0 for item in ad.uniformSample(1000): cf.addData(item) i = i + 1 if cf.detectChange(): print 'Change detected at sample ' + str(i)
import random # # Simple code for testing the OnlineDist module with the ChangeFinder # # Create the online dist object and add alphas for online normals od = OnlineDist() od.addAlpha(0.95) od.addAlpha(0.99) # Create a change finder and add a single window pair cf = ChangeFinder(od) cf.addWindowPair(WindowPair(200, 200, 0.99)) # Process 1000 samples i = 0; for k in range(1000): item = random.gauss(10, 1) cf.addData(item) i = i + 1 if cf.detectChange(): print 'Change detected at sample ' + str(i) # Process another 1000 samples from a slightly different distribution for k in range(1000): item = random.gauss(13, 1)
# Add intervals to monitor to A-distance object ad = ADistance() data = [] for i in range(100): data.append(random.uniform(0.0, 1.0)); ad.addProportional(data, 0.1, 0.5) print ad # ad.add(Interval(-2, -1)) # ad.add(Interval(-1, 0)) # ad.add(Interval(0, 1)) # ad.add(Interval(1, 2)) # Create a change finder and add a single window pair cf = ChangeFinder(ad) cf.addWindowPair(WindowPair(100, 100, 0.5)) # Initialize the distance object ad.init(cf) cf.computeAlphas(ad.uniformSample(10000), 0.05, 50) # Process 1000 samples i = 0; for item in ad.uniformSample(1000): cf.addData(item) i = i + 1