Does Squiggle treat multiple instances of the same variable as independent variables? #1446
Replies: 3 comments 2 replies
-
Yea, this part is confusing. Squiggle treats SampleSets as independent, but it has no way of doing this for Symbolic or PointSet dists. In this case, there was no call forcing the distributions to be SampleSets until fairly late. Try this: var(x) ={
y = SampleSet.fromDist(x)
x_bar = mean(y)
mean((y-x_bar)*(y-x_bar))
}
var(normal(0,1)) See this for more: |
Beta Was this translation helpful? Give feedback.
-
See also #1442, which is a possible solution to this problem. |
Beta Was this translation helpful? Give feedback.
-
are there any solutions to this problem for variables over time? take geometric discounting: atm i don't think i have a way to implement this in squiggle? |
Beta Was this translation helpful? Give feedback.
-
Hi,
I am getting the impression that Squiggle treats multiple instances of the same variable as independent variables. Here is a fairly minimal example of this problem. I want to calculate the variance of a random variable. The correct answer is 1. Obviously, the variance can never be negative. But the answer I get from Squiggle is -0.023. Can you confirm that this happens because Squiggle treats x and x as two independent variables even though it is the same variable? If so, is this a bug or am I fundamentally misunderstanding the semantics of Squiggle code?
var(x) ={
x_bar = mean(x)
mean((x-x_bar)*(x-x_bar))
}
var(normal(0,1))
Beta Was this translation helpful? Give feedback.
All reactions