Skip to content

Commit

Permalink
Merge pull request #1901 from dannyparsons/lilyclements-Distributions
Browse files Browse the repository at this point in the history
Lilyclements distributions
  • Loading branch information
dannyparsons authored Oct 13, 2016
2 parents 8c8dbde + d2a2b20 commit 84b86f5
Show file tree
Hide file tree
Showing 4 changed files with 193 additions and 12 deletions.
81 changes: 81 additions & 0 deletions instat/My Project/Resources.Designer.vb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 27 additions & 0 deletions instat/My Project/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -1522,4 +1522,31 @@
<data name="Students_t" xml:space="preserve">
<value>Students t</value>
</data>
<data name="b" xml:space="preserve">
<value>b</value>
</data>
<data name="Cauchy" xml:space="preserve">
<value>Cauchy</value>
</data>
<data name="Chi_Square" xml:space="preserve">
<value>Chi-Square</value>
</data>
<data name="DF" xml:space="preserve">
<value>DF</value>
</data>
<data name="F" xml:space="preserve">
<value>F</value>
</data>
<data name="Hypergeometric" xml:space="preserve">
<value>Hypergeometric</value>
</data>
<data name="Lognormal" xml:space="preserve">
<value>Lognormal</value>
</data>
<data name="Meanlog" xml:space="preserve">
<value>Meanlog</value>
</data>
<data name="SDlog" xml:space="preserve">
<value>SDlog</value>
</data>
</root>
17 changes: 13 additions & 4 deletions instat/dlgRandomSample.vb
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Imports instat.Translations
Public Class dlgRandomSample
Public bFirstLoad As Boolean = True
Private clsMultipleSamplesFunction As New RFunction
Public clsCurrentDistribution As New Distribution
Private clsDistribtionFunction As New RFunction
Private clsSetSeed As New RFunction

Expand Down Expand Up @@ -53,7 +54,7 @@ Public Class dlgRandomSample

Private Sub SetDefaults()
ucrPrefixNewColumns.SetName("Rand")
SetDataFrameParameters()
SetDataFrameandDistributionParameters()
nudNumberOfSamples.Value = 1
SetNumberOfSamplesParameters()
chkSetSeed.Checked = False
Expand All @@ -66,7 +67,7 @@ Public Class dlgRandomSample
End Sub

Private Sub ucrDataFrameSelector_DataFrameChanged(sender As Object, e As EventArgs, strPrevDataFrame As String) Handles ucrSelectorRandomSamples.DataFrameChanged
SetDataFrameParameters()
SetDataFrameandDistributionParameters()
TestOKEnabled()
End Sub

Expand All @@ -84,8 +85,13 @@ Public Class dlgRandomSample
End If
End Sub

Private Sub SetDataFrameParameters()
clsDistribtionFunction.AddParameter("n", ucrSelectorRandomSamples.iDataFrameLength)
Private Sub SetDataFrameandDistributionParameters()
If ucrDistWithParameters.clsCurrDistribution.strRName = "hyper" Then
clsDistribtionFunction.AddParameter("nn", ucrSelectorRandomSamples.iDataFrameLength)
Else
clsDistribtionFunction.RemoveParameterByName("nn")
clsDistribtionFunction.AddParameter("n", ucrSelectorRandomSamples.iDataFrameLength)
End If
SetAssignTo()
TestOKEnabled()
End Sub
Expand Down Expand Up @@ -172,4 +178,7 @@ Public Class dlgRandomSample
TestOKEnabled()
End Sub

Private Sub ucrDistWithParameters_cboDistributionsIndexChanged(sender As Object, e As EventArgs) Handles ucrDistWithParameters.cboDistributionsIndexChanged
SetDataFrameandDistributionParameters()
End Sub
End Class
80 changes: 72 additions & 8 deletions instat/ucrDistributions.vb
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,11 @@ Public Class ucrDistributions
Dim clsBetaDist As New Distribution
Dim clsNegBinomDist As New Distribution
Dim clsStudentsTDist As New Distribution
Dim clsCauchyDist As New Distribution
Dim clsChiSqDist As New Distribution
Dim clsFDist As New Distribution
Dim clsHyperGeoDist As New Distribution
Dim clsLogNormDist As New Distribution

' Normal distribution
clsNormalDist.strNameTag = "Normal"
Expand Down Expand Up @@ -328,14 +333,14 @@ Public Class ucrDistributions
lstAllDistributions.Add(clsNegBinomDist)

'T Distribution
' clsStudentsTDist.strNameTag = "Students_t"
' clsStudentsTDist.strRName = "t"
' clsStudentsTDist.strRFunctionName = "rt"
' clsStudentsTDist.strPFunctionName = "pt"
' clsStudentsTDist.strQFunctionName = "qt"
' clsStudentsTDist.strDFunctionName = "dt"
' clsStudentsTDist.AddParameter("df", "DF", 1)
' lstAllDistributions.Add(clsStudentsTDist)
clsStudentsTDist.strNameTag = "Students_t"
clsStudentsTDist.strRName = "t"
clsStudentsTDist.strRFunctionName = "rt"
clsStudentsTDist.strPFunctionName = "pt"
clsStudentsTDist.strQFunctionName = "qt"
clsStudentsTDist.strDFunctionName = "dt"
clsStudentsTDist.AddParameter("df", "DF", 1)
lstAllDistributions.Add(clsStudentsTDist)

' von mises distribution
clsVonnMisesDist.strNameTag = "von_mises"
Expand All @@ -349,6 +354,65 @@ Public Class ucrDistributions
clsVonnMisesDist.AddParameter("kappa", "Kappa", 0)
lstAllDistributions.Add(clsVonnMisesDist)

' Cauchy Distribution
clsCauchyDist.strNameTag = "Cauchy"
clsCauchyDist.strRName = "cauchy"
clsCauchyDist.strRFunctionName = "rcauchy"
clsCauchyDist.strPFunctionName = "pcauchy"
clsCauchyDist.strQFunctionName = "qcauchy"
clsCauchyDist.strDFunctionName = "dcauchy"
clsCauchyDist.bIsContinuous = True
clsCauchyDist.AddParameter("location", "Location", 0)
clsCauchyDist.AddParameter("scale", "Scale", 1)
lstAllDistributions.Add(clsCauchyDist)

' Chi-Square Distribution
clsChiSqDist.strNameTag = "Chi_Square"
clsChiSqDist.strRName = "chisq"
clsChiSqDist.strRFunctionName = "rchisq"
clsChiSqDist.strPFunctionName = "pchisq"
clsChiSqDist.strQFunctionName = "qchisq"
clsChiSqDist.strDFunctionName = "dchisq"
clsChiSqDist.bIsContinuous = True
clsChiSqDist.AddParameter("df", "DF", 1)
lstAllDistributions.Add(clsChiSqDist)

' F Distribution
clsFDist.strNameTag = "F"
clsFDist.strRName = "f"
clsFDist.strRFunctionName = "rf"
clsFDist.strPFunctionName = "pf"
clsFDist.strQFunctionName = "qf"
clsFDist.strDFunctionName = "df"
clsFDist.AddParameter("df1", "DF", 1)
clsFDist.AddParameter("df2", "DF", 1)
lstAllDistributions.Add(clsFDist)

'Hypergeometric Distribution
' For rhyper, the parameters are nn = size, whereas for the other parameters this is n.
clsHyperGeoDist.strNameTag = "Hypergeometric"
clsHyperGeoDist.strRName = "hyper"
clsHyperGeoDist.strRFunctionName = "rhyper"
clsHyperGeoDist.strPFunctionName = "phyper"
clsHyperGeoDist.strQFunctionName = "qhyper"
clsHyperGeoDist.strDFunctionName = "dhyper"
clsHyperGeoDist.bIsContinuous = False
clsHyperGeoDist.AddParameter("m", "Population_Successes", 10)
clsHyperGeoDist.AddParameter("n", "Population_Failures", 10)
clsHyperGeoDist.AddParameter("k", "Sample_Size", 10)
lstAllDistributions.Add(clsHyperGeoDist)

' Lognormal Distribution
clsLogNormDist.strNameTag = "Lognormal"
clsLogNormDist.strRName = "lnorm"
clsLogNormDist.strRFunctionName = "rlnorm"
clsLogNormDist.strPFunctionName = "plnorm"
clsLogNormDist.strQFunctionName = "qlnorm"
clsLogNormDist.strDFunctionName = "dlnorm"
clsLogNormDist.AddParameter("meanlog", "Meanlog", 0)
clsLogNormDist.AddParameter("sdlog", "SDlog", 1)
lstAllDistributions.Add(clsLogNormDist)

'TODO Categorical distribution
clsCategoricalDist.strNameTag = "Categorical"
clsCategoricalDist.strRName = ""
Expand Down

0 comments on commit 84b86f5

Please sign in to comment.