2011-04-28 3 views
3

0에서 1 사이의 float 값을 반환하는 난수 생성기를 사용하여 한 방향 또는 다른 방향으로 반환 된 값에 가중치를 매기려고합니다.숫자를 범위의 주어진 숫자로 끌어 당기는 난수 생성기?

랜덤 (0.5)과 같이 두 개의 숫자를 전달할 때 신뢰할 수있는 방법이 있습니까? '0.5'는 0과 1 사이의 숫자가 0.5로 끌리는 것을 의미합니다.

+1

무언가에 중력이 가해지면 무작위가 아닙니다. – PVitt

+2

좋은 해결책을 찾으려면 문제에 대한 더 많은 정보가 필요합니다. 당신은 "향한"쪽으로 말합니다. 얼마나 빠릅니까? 얼마나? 정상/가우스 분포를 찾고 있습니까? http://en.wikipedia.org/wiki/Normal_distribution –

+0

아니요, 균일하지 않은 난수 생성기 –

답변

2

도움이 될만한 자료가 있습니까?

http://www.c-sharpcorner.com/UploadFile/trevormisfeldt/NormalDistribution08302005003434AM/NormalDistribution.aspx

그것은 정확하게 문제를 해결하지 않지만 종형 곡선을 모델링하는 것은 당신이 찾고있는 경향을 제공 할 수 있을지 궁금하네요.

흥미로운 문제이지만 내가 해결하려고하는 것이 무엇인지 물어볼 수 있습니까?

두번째 편집 : 난 그냥 도움이 될 또 다른 S/O 질문주의 :

Random number within a range based on a normal distribution

+1

나는 게임 (http : //jabberworx.net/meteormania/meteormania.html). 서로 다른 크기의 유성이 있습니다. 나는 무작위 유성을 생성 계속하고 싶지만 큰 것들보다 더 작은 유성을 원하지만 여전히 무작위로 유지 .. – tweetypi

+0

그건 아주 멋지다; 행운을 빕니다! –

2

은 당신이 언급하는 것은 종형 곡선 투영 임의의 번호를

하는 내가 일반적으로 당신은 distributi을 조정 종의 모양을 변경하는 수식을 조정할 수있는 다음과 같은

/// <summary> 
/// generate a random number where the likelihood of a large number is greater than the likelihood of a small number 
/// </summary> 
/// <param name="rnd">the random number generator used to spawn the number</param> 
/// <returns>the random number</returns> 
public static double InverseBellCurve(Random rnd) 
{ 
    return 1 - BellCurve(rnd); 
} 
/// <summary> 
/// generate a random number where the likelihood of a small number is greater than the likelihood of a Large number 
/// </summary> 
/// <param name="rnd">the random number generator used to spawn the number</param> 
/// <returns>the random number</returns> 
public static double BellCurve(Random rnd) 
{ 
    return Math.Pow(2 * rnd.NextDouble() - 1, 2); 
} 
/// <summary> 
/// generate a random number where the likelihood of a mid range number is greater than the likelihood of a Large or small number 
/// </summary> 
/// <param name="rnd">the random number generator used to spawn the number</param> 
/// <returns>the random number</returns> 
public static double HorizontalBellCurve(Random rnd) 
{ 
    //This is not a real bell curve as using the cube of the value but approximates the result set 
    return (Math.Pow(2 * rnd.NextDouble() - 1, 3)/2)+.5; 
} 

참고 않습니다 (단순) Math.Sqrt (rnd.nextdouble())는 1, 에 대한 모든 수를 기울이고 간단한 Math.Power (rnd.nextdouble(), 2)는 결과를 기울 이도록합니다. 0