Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

267
Visualizações
How to get a uniformly-distributed random integer-points in an nD ball?

How to generate uniform random points inside d-dimension ball / sphere?

In this thread, @Thomas Lux has a wonderful solution of generating uniformly random points inside an nD ball with radius r=1. But now I want to generate points where their Cartesian coordinates are integers. I do not know any way except generating random points in a cube and throwing out the points with norm greater than 1.

I don't know if simply using randint or pushing np.floor() to the vector will do.

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

Simply using round() on uniform real samples would almost work. Except the integer points near the edge of the ball would have lower probabilities of showing up. That's because the hypercube-neighborhood of a point on the edge is less than half-contained in the ball you're sampling from.

There is an easy workaround though. Generate real samples in a ball that fully contains all such hypercubes, the radius r+sqrt(n)/2 should be enough for that, then apply rounding, and finally discard the integer points that are not within distance r.

Certainly the outer ball can be much larger than the inner one, depending on r and n, but the discard rate should still be better.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda