|
Ok this is what im trying to achive. A random number that conforms to a distrobution pattern, for example the normal distrobution where most of the numbers are around the center and as you move away from that point their frequency becomes less. e.g range 1-10 5 is the mean most numbers would end up around 4,5,6 where only a handfull would be 1 or 10.
dose anyone know of either a libary or a calculation to achive these sorts of results? or maybe some for of normal distrobution table?
any input or help would be greate
Ant
|
|
|
|
|
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
|
|
|
|
|
i want ot us System.Windows namespace but it was not available there. after System. there r only web is available means (System.Web) no other option with W so how can i get the System.Windows name space
|
|
|
|
|
Are you working on a Windows application?
Pramod
|
|
|
|
|
yes on windows n want to try in on console
|
|
|
|
|
See at your reference, you must have a reference to System.Windows.Forms.dll
|
|
|
|
|
|
a console application does not contains the reference to the
System.Windows.Forms namespace
try adding a reference to this dll
Regards,
Pramod
|
|
|
|
|
|
I have following requirement which i am trying to achive in .Net C#
I have a main process with a simple form and some menu items.
On choosing one of these menu items, i want to start another process. This child process has a form with some user controls.
I would have to embed this child process inside the main process
as if I am adding the child process as a control to the main form.
Does anyone have any idea how can this be done.
I tried passing the window handle through remoting and set the parent of the child to the main frame. I get the look of the parent and child window with this.
How do i get the look of an embeded control?
Thank You
Madhu
|
|
|
|
|
HI,
if you want to have an embeded look don't put the User control on a form.
you can create a user control which will have all the required controls and then add this user control to the main form.
Hope that works for you,
Regards,
Pramod
|
|
|
|
|
No, i want the user control to be hosted in a seperate process..
How do I do that..
|
|
|
|
|
Then you need to start a separate thread for that
Pramod
|
|
|
|
|
|
Could you try to explain what you are actually trying to achieve? Why do those have to be separate processes? What you are trying to do looks like a dirty hack to me... probably there is a better way.
|
|
|
|
|
yes it is kind of a dirty hack.
I need to do some on the fly switching between different configurations
Each of these configs when chosen, need different settings in registry
and different assemblies to be loaded.
We are trying to see if it will be possible to achieve this, without user haing to restart the application everytime he wants to switch configs
|
|
|
|
|
Hi
I created setup for installation of my application (in C#) after converting it to Framework 2.0. However when install it on another machine I have a message that 'This setup requiers the Microsoft J#.Net redistributable package' etc.
When I looked into the project in fact there is VJ#.NET launch condition. I cannot delete that.
Is it normal that it is added automatically to the setup for application developed in C#?
Thanks for help
Ela
|
|
|
|
|
There is no problem anymore.
Thanks
Ela
|
|
|
|
|
how can i determine the axis of mouse pointer from any method?
|
|
|
|
|
watch this post:
http://www.codeproject.com/script/comments/forums.asp?forumid=1649&fr=51
|
|
|
|
|
<br />
this.Cursor = new Cursor(Cursor.Current.Handle);<br />
Cursor.Position = new Point(Cursor.Position.X - 50, Cursor.Position.Y - 50);<br />
|
|
|
|
|
this code will set the position of mouse pointer. but i want to retrieve the position.
|
|
|
|
|
hello the same pa.
string xValue = Cursor.Position.X.ToString () ;<br />
string yValue = Cursor.Position.Y.ToString();
|
|
|
|
|
Hello,
I hope someone can point into the right direction with this question:
I have a custom control which inherits from System.Windows.Forms.Control. This control requires scrolling but I'm unsure how to add the scrollbars. I see three options:
- Add WS_HSCROLL and WS_VSCROLL flags in method CreateParams
This feels like the right way to go because windows takes care of most of the
scrollbar issues (like allignment). However, I found little support for this
implementation in .Net. A method like SetScrollInfo is not part of the .Net
implementation and can only be used after importing it from user32.dll.
- Adding a VScrollBar and HScrollBar to the control.
I think this could work, but extra code is needed to keep the
scrollbars properly aligned and to adjust the client rectangle with the space occupied
by the scrollbars.
- Inheriting from System.Windows.Forms.ScrollableControl
Because my component is like a grid and I want to handle painting, scrolling and
most/all other events myself, I don't think this is the proper control to
inherit from. Also, a ScrollableControl supports docking of other controls (a user
can drag a button on the control) which I want to be dissabled.
All your information is welcome.
Regards,
Kees Vermeulen
info@kever.com
|
|
|
|
|
hai all,
i am facing some problem while installing the the setup created using the Setup & Deployement.. i am installing the setup in a system which is not having the .net frame work and win installer. but i added the .net frame work and win installer 3.1, while creating the setup.. Is it possible to create setup using setup and deployment by adding .net frame work and win installer? if yes how?..
Regards..
|
|
|
|