Click here to Skip to main content
15,888,351 members
Home / Discussions / C#
   

C#

 
AnswerNetwons Method Pin
Ennis Ray Lynch, Jr.19-Jul-06 2:50
Ennis Ray Lynch, Jr.19-Jul-06 2:50 
Questionhow to speed up the search Pin
ayyp18-Jul-06 23:08
ayyp18-Jul-06 23:08 
AnswerRe: how to speed up the search Pin
premierCoder18-Jul-06 23:19
premierCoder18-Jul-06 23:19 
AnswerRe: how to speed up the search Pin
Robert Rohde19-Jul-06 2:18
Robert Rohde19-Jul-06 2:18 
GeneralRe: how to speed up the search Pin
ayyp19-Jul-06 20:58
ayyp19-Jul-06 20:58 
GeneralRe: how to speed up the search Pin
Robert Rohde20-Jul-06 10:44
Robert Rohde20-Jul-06 10:44 
QuestionSkewed Randoms, Distrobutions and the like Pin
S020035618-Jul-06 22:57
S020035618-Jul-06 22:57 
AnswerRe: Skewed Randoms, Distrobutions and the like Pin
Stefan Troschuetz19-Jul-06 2:28
Stefan Troschuetz19-Jul-06 2:28 
The following should do what your looking for. Some information on the normal distribution e.g. the meaning of parameters my and sigma here[^].
public class NormalDistribution : IDistribution
{
public double sigma;
public double my;
private Random generator;
private double help1;
private bool help2;

public NormalDistribution()
{
	this.my = 1.0;
	this.sigma = 1.0;
	
	this.generator = new Random();

	this.help1 = 0.0;
	this.help2 = false;
}

public double Next()
{
    if (this.help2)
    {
        this.help2 = false;
        return this.help1;
    }
    else
    {
        for (; ; )
        {
            double v1 = 2 * this.generator.NextDouble() - 1;
            double v2 = 2 * this.generator.NextDouble() - 1;
            double w = v1 * v1 + v2 * v2;

            if (w <= 1)
            {
                double y = Math.Sqrt(-2 * Math.Log(w) / w);
                this.help1 = v2 * y * this.sigma + this.my;
                this.help2 = true;
                return v1 * y * this.sigma + this.my;
            }
        }
    }
}



"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook

www.troschuetz.de
QuestionUsing System.Windows Pin
bannapradeep18-Jul-06 22:51
bannapradeep18-Jul-06 22:51 
AnswerRe: Using System.Windows Pin
AB777118-Jul-06 22:53
AB777118-Jul-06 22:53 
GeneralRe: Using System.Windows Pin
bannapradeep18-Jul-06 22:55
bannapradeep18-Jul-06 22:55 
GeneralRe: Using System.Windows Pin
stancrm18-Jul-06 22:59
stancrm18-Jul-06 22:59 
GeneralRe: Using System.Windows Pin
bannapradeep18-Jul-06 23:24
bannapradeep18-Jul-06 23:24 
GeneralRe: Using System.Windows Pin
AB777118-Jul-06 23:02
AB777118-Jul-06 23:02 
GeneralRe: Using System.Windows Pin
bannapradeep18-Jul-06 23:25
bannapradeep18-Jul-06 23:25 
QuestionHow to Embed one process into other Pin
madhura_bindu18-Jul-06 22:48
madhura_bindu18-Jul-06 22:48 
AnswerRe: How to Embed one process into other Pin
AB777118-Jul-06 22:52
AB777118-Jul-06 22:52 
GeneralRe: How to Embed one process into other Pin
madhura_bindu18-Jul-06 23:36
madhura_bindu18-Jul-06 23:36 
GeneralRe: How to Embed one process into other Pin
AB777118-Jul-06 23:38
AB777118-Jul-06 23:38 
AnswerRe: How to Embed one process into other Pin
madhura_bindu19-Jul-06 0:59
madhura_bindu19-Jul-06 0:59 
AnswerRe: How to Embed one process into other Pin
Robert Rohde19-Jul-06 2:21
Robert Rohde19-Jul-06 2:21 
GeneralRe: How to Embed one process into other Pin
madhura_bindu20-Jul-06 0:58
madhura_bindu20-Jul-06 0:58 
Questiondependency on Microsoft J#.Net redistributable package Pin
e_LA18-Jul-06 22:33
e_LA18-Jul-06 22:33 
AnswerRe: dependency on Microsoft J#.Net redistributable package Pin
e_LA19-Jul-06 1:23
e_LA19-Jul-06 1:23 
Questionmouse pointer position Pin
vatzcar18-Jul-06 21:49
vatzcar18-Jul-06 21:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.