-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathglobal.R
126 lines (106 loc) · 3.8 KB
/
global.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# SOCR Probability Distribution Calculator
# Version 0.9
# Updated March 20th 2022 by Shihang Li and Yongxiang Zhao at the University of Michigan -SOCR
# Orginally created by Jared(Tianyi) Chai
# This is a SOCR Interactive Graphical Probability Distribution Calculator
# You can run the application by clicking
# the 'Run App' button above.
# ----------------------- Global.R ----------------------- #
# For Retrieving and Storing Global Variables
library(xml2)
library(shiny)
library(plotly)
library(stringr)
library(fitdistrplus)
library("Rlab")
library("shinyWidgets")
plotlyFunctions <- list.files("plotlyFunctions", full.names = TRUE)
for (file in plotlyFunctions) {
source(file)
}
source("fitFunctions.R")
source("dataset.R")
source("distributionInfo.R")
# ----------------------- Discrete: Anderson Darling Distribution ----------------------- #
n_AD <- 0.0
# ----------------------- Discrete: Birthday Distribution ------------------------------- #
popSize_Birt <- 0
sampleSize_Birt <- 0
prob_birt <- array(0, c(0, 0))
# ----------------------- Discrete: Coupon Distribution --------------------------------- #
upper_Coupon <- 0
popSize_Coupon <- 0
distNum_Coupon <- 0
prob_Coupon <- array(0, c(0, 0))
# ----------------------- Discrete: Die Distribution ------------------------------------ #
n_Die <- 0
# ----------------------- Discrete: Finite Distribution --------------------------------- #
lower_Finite <- 0
upper_Finite <- 0
size_Finite <- 0
width_Finite <- 0
prob_Finite <- rep(0,1)
# ----------------------- Discrete: Finite Distribution --------------------------------- #
degree_Kol <- 0
# ----------------------- Discrete: Anderson Darling Distribution ----------------------- #
param_Match <- 0.0
# ----------------------- Continuous: Mix Distribution ---------------------------------- #
mu1_Mix <- -2
sigma1_Mix <- 1
mu2_Mix <- 2
sigma2_Mix <- 1
prob1_Mix <- 0.5
prob2_Mix <- 0.5
# ----------------------- Discrete: Multinomial Distribution -------------------------- #
prob_multinomial <- c()
x_multinomial <- c()
n_multinomial <- 0
# ----------------------- Discrete: Multinomial Distribution -------------------------- #
prob_negMult <- c()
x_negMult <- c()
gamma_negMult <- 1
# ----------------------- Continuous: TSP Distribution -------------------------- #
l_TSP <- 0
r_TSP <- 1
med_TSP <- 0.5
power_TSP <- 2
# ----------------------- Discrete: Walk Max Distribution -------------------------- #
steps_WalkMax <- 10
# ----------------------- Discrete: Walk Position Distribution -------------------------- #
steps_WalkPos <- 10
prob_WalkPos <- 0.5
# ----------------------- Parse and Store xml Databse of Metadata from Distributome Project ----------------------- #
xml_data <- read_xml("Distributome.xml", encoding = "UTF-8")
xml_rootnode <- xml_root(xml_data)
xml_distributions <- xml_children(xml_child(xml_rootnode))
xml_len <- length(xml_distributions)
xml_wid <- 0
xml_tags <- c()
for (i in 1:xml_len) {
xml_i <- xml_contents(xml_distributions[[i]])
width <- length(xml_i)
if (width > xml_wid) {
xml_wid <- width
xml_tags <- xml_name(xml_i)
}
}
distributions_meta <- matrix("", xml_wid, xml_len * 2)
for (i in 1:xml_len) {
xml_i <- xml_contents(xml_distributions[[i]])
width <- length(xml_i)
for (j in 1:width) {
distributions_meta[[j, i * 2 - 1]] <- xml_name(xml_i[j])
distributions_meta[[j, i * 2]] <- xml_text(xml_i[j])
}
}
distributionInfoList <- loadDistributionInfo("distribution_info.yaml")
distToImpl <- names(Filter(function(x) !x$hasImplementation, distributionInfoList))
distWithSD <- names(Filter(function(x) x$isWithSD, distributionInfoList))
distributions <- names(distributionInfoList)
nameToFullName <- function(name) {
for (distributionInfo in distributionInfoList) {
if (distributionInfo$name == name) {
return(distributions[distributionInfo$id])
}
}
}