algorithmic modeling for Rhino
I think what I'm trying to do is very simple, but I don't know anything about C# so I'm having a problem. From what I've read so far I understand that C# has a built in function poisson_distribution(m) where you provide the mean number and numbers from the poisson distribution are generated. I can't get it to work. Maybe a for loop based on y variable would also be needed to determine how many numbers are generated. Can anyone help?
Tags:
Hello,
I think you are quite far from the result. It is a bit more complicated. I don't think C# has this function distribution. It could be MathNet
http://numerics.mathdotnet.com/api/MathNet.Numerics.Distributions/P...
You could have the dll here
http://www.grasshopper3d.com/forum/topics/find-mathematical-functio...
MathNet.Numerics.dll
Don't forget to authorize your computer to use this dll, do right click => properties => there is an authorization somewhere on the right bottom.
On your c# component you will have to say to it that you want to use this dll (dynamic link library)
so right click manage asssembly + add source "MathNet.Numerics.dll"
The program
Here is the code :
private void RunScript(double lambda, double x, ref object A)
{
A = MathNet.Numerics.Distributions.Poisson.CDF(lambda, x);
}
Lambda is a parameter
x is the variable
Here it is a cumulative function. See help here
http://numerics.mathdotnet.com/api/MathNet.Numerics.Distributions/P...
Hope it helps.
Thanks for your reply, but I'm not sure we're on the same page here. Or maybe I've got something very wrong. I don't want a probability function, but a random number generator. The C# component would need two inputs lambda and how many random numbers would be generated. For example, lambda would be 5, the number of generated numbers would be 4 and the output would be something like 5, 6, 4, 5. Is this something that can be done?
Hello, you have to be precise, give a common definition of what you want (wikipedia definition for example see and find the good name of the equation
https://en.wikipedia.org/wiki/Poisson_distribution
I am quite sure that you will find something for you here. Can you read this, the link was already given on my previous answer. I am not in your brain !!!!!
http://numerics.mathdotnet.com/api/MathNet.Numerics.Distributions/P...
int Sample(Random rnd, double lambda) which mean Samples a Poisson distributed random variable.
void Samples(Int32[] values, double lambda) ...
I've already said I don't know C#. I'm trying to to use the samples command that fills an array but there are errors. I believe what I'm asking is very simple for someone who knows C#. You bothered to spend time writing your first post and even provided a .gh file that unfortunately didn't include the code that I need and in your second post you're really rude. I just don't understand.
This is the one I need in a C# component. It will be great help if you can provide the code.
Far more simple with a good specification :) Hope it helps.
private void RunScript(double lambda, int seed, int n, ref object A)
{
Int32[] vals = new Int32[n];
System.Random rnd = new System.Random(seed);
MathNet.Numerics.Distributions.Poisson.Samples(rnd, vals, lambda);
A = vals;
}
I put 2 versions, one without seed, and another with a seed to change order of values.
Thank you!
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by