-def sample_arc(nb):
- theta = torch.rand(nb, device = device) * math.pi
- rho = torch.rand(nb, device = device) * 0.1 + 0.7
- result = torch.empty(nb, 2, device = device)
- result[:, 0] = theta.cos() * rho
- result[:, 1] = theta.sin() * rho
+def sample_ramp(nb):
+ result = torch.min(torch.rand(nb, 1), torch.rand(nb, 1))
+ return result
+
+def sample_two_discs(nb):
+ a = torch.rand(nb) * math.pi * 2
+ b = torch.rand(nb).sqrt()
+ q = (torch.rand(nb) <= 0.5).long()
+ b = b * (0.3 + 0.2 * q)
+ result = torch.empty(nb, 2)
+ result[:, 0] = a.cos() * b - 0.5 + q
+ result[:, 1] = a.sin() * b - 0.5 + q
+ return result
+
+def sample_disc_grid(nb):
+ a = torch.rand(nb) * math.pi * 2
+ b = torch.rand(nb).sqrt()
+ N = 4
+ q = (torch.randint(N, (nb,)) - (N - 1) / 2) / ((N - 1) / 2)
+ r = (torch.randint(N, (nb,)) - (N - 1) / 2) / ((N - 1) / 2)
+ b = b * 0.1
+ result = torch.empty(nb, 2)
+ result[:, 0] = a.cos() * b + q
+ result[:, 1] = a.sin() * b + r