Curve simulation code for reference