Statsar Statistics Library

v1.0.1 for .NET

Product Guide



More Information...

Valid XHTML


Distribution Random Example (VB.NET)

[VB.NET]
' COPYRIGHT(C), SIMPLEXAR SOFTWARE LIMITED, 2006-2008.
' All rights reserved.
'
' Use of this copyright notice is precautionary only, and does not imply
' publication or disclosure. The content of this work contains confidential
' and proprietary information of Simplexar Software Limited. Any duplication,
' modification, distribution, or disclosure in any form, in whole, or in part,
' is strictly prohibited without express prior written permission.

' Get namespaces.
Imports System
Imports Simplexar.Statsar
Imports Simplexar.Statsar.Distributions

' Start namespace.
Namespace Simplexar.Examples.Statsar

    ' This example shows how to generate random deviates which are
    ' distributed according to a probability distribution.
    Module Example

        ' The application entry point.
        Public Sub Main()
            Try
                RunExample()
            Catch exception As Exception
                Console.WriteLine(exception)
            End Try
            Console.WriteLine("Press ENTER to terminate.")
            Console.ReadLine()
        End Sub

        Private Sub RunExample()

            ' Create a normal distribution instance. The normal distribution
            ' is a continuous probability distribution defined in terms
            ' of the distribution's mean and standard deviation.
            ' Many other probability distributions are available as part
            ' of the Simplexar.Statsar.Distributions namespace.
            Dim mean As Double = 3
            Dim standardDeviation As Double = 2.5
            Dim distribution _
                As New NormalDistribution(mean, standardDeviation)

            ' Generate a random deviate which is normally distributed.
            Console.WriteLine( _
                "Single deviate: {0}", distribution.GetDeviate())

            ' Generate 10 random deviates which are normally distributed.
            Console.WriteLine("Multiple deviates:")
            Dim deviates As Double() = distribution.GetDeviates(10)
            For Each deviate As Double In deviates
                Console.WriteLine(deviate)
            Next

        End Sub

    End Module

End Namespace