I am working on a project that includes an ECG simulation (electrocardiogram). I do this by generating some random numbers between the intervals and sending this data to another program, analyzing and graphically displaying it. But the problem is that the random number generated between the intervals says that [a, b] in the java code have a large variance, that is, the next generated random value is very different from the previous number. I want the random number stream to change slightly so that the graph looks smooth. At this stage, the generated graph is very stabbing, but I want it to be smooth and change like a real ECG graph.
Please help me do this.

Here is the code
StdDraw.setXscale(0.0, 100.0);
StdDraw.setYscale(0.0,200.0);
StdDraw.setPenColor(StdDraw.BLUE);
StdDraw.setPenRadius(0.0009);
int t = 0;
int prevVal = 0;
int nextVal;
while(true){
nextVal = range.getRandomValue();
System.out.println(nextVal);
StdDraw.point(prevVal, nextVal);
StdDraw.line(t-1, prevVal, t, nextVal);
StdDraw.show(100);
prevVal = nextVal;
t = (t+1) % 100;
if(t == 0){
StdDraw.clear();
}
}
thank