// Checks if the elements of a `theta` vector sum to 1.
functionsumsToOne(theta,tol=0.001){
varsum=theta.reduce((acc,cur)=>acc+cur);
return(sum>1-tol&&sum<1+tol);
}
{
letpoints=thetaGrid
.filter(theta=>sumsToOne(theta))
.map(theta=>pointSum(anchors,theta))
returnplot(anchors,points)
}
{
letpoints=thetaGrid
.filter(theta=>isNonNegative(theta))
.filter(theta=>sumsToOne(theta))
.map(theta=>pointSum(anchors,theta))
returnplot(anchors,points)
}
Purpose-built for displays of data
Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.