I have a function that I want to use to demonstrate flipping a coin 100 times:
function simulateFlips(n, pHeads){
var head_count = 0;
var H;
for(var i=0; i < n; i++){
H = 0;
if (Math.random() < pHeads){
H = 1;
}
head_count += H;
}
return head_count;
}
However, it looks like the standard Google App Behavior is to "memoize" custom functions that are called with exactly the same inputs, which is not what you want for this kind of demo:
I know I could do something hacky (like modify pHeads by a very small amount), but I was hoping there was some cleaner way to get the desired behavior.