'Does anybody know how to generate a set of random numbers in vb.net between two numbers that follows Poisson distribution?
The numbers should be discrete and have an upper bound and lower bound.
I am using the probability distribution formula of poison distribution and using it in my code but I am not getting the result.
Solution 1:[1]
i don't know exactly what you mean by follows Poisson distribution? but if you want to generate random values in vb.net between two numbers you could use something like so
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
Dim LowerBound As Integer = 15
Dim UpperBound As Integer = 30
Dim Result As Integer = CInt(LowerBound + (Rnd() * ((UpperBound + 1) - LowerBound)))
TextBox1.Text = Result
End Sub
and the updated version from Rnd() is the Random().Next instruction as Hursey commented which can be used like this
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles Button1.Click
Dim LowerBound As Integer = 15
Dim UpperBound As Integer = 30
' Instantiate random number generator using system-supplied value as seed.
Dim rand As New Random()
Dim Result As Integer = rand.Next(LowerBound, UpperBound)
rand = Nothing
TextBox1.Text = Result
End Sub
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 |
