summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--R/rbs.R28
1 files changed, 28 insertions, 0 deletions
diff --git a/R/rbs.R b/R/rbs.R
new file mode 100644
index 0000000..bdc9acb
--- /dev/null
+++ b/R/rbs.R
@@ -0,0 +1,28 @@
+idin.rbs <- function(n,levels.vec){
+ # Function to generate a full band random binary
+ # signal of given frequency band and levels
+
+ uk1 = rnorm(n,mean = 0,sd = 1)
+ uk = rep(0,n)
+ for(i in 1:n){
+ #Checking for zeros
+
+ if(uk1[i] == 0){
+ uk1[i] <- rnorm(1,mean = 0,sd = 1)
+ }
+ }
+
+ # Getting the binary signal
+ for(i in 1:n){
+ if(uk1[i] < 0){
+ uk[i] = levels.vec[1]
+ }
+ }
+ for(i in 1:n){
+ if(uk1[i] > 0){
+ uk[i] = levels.vec[2]
+ }
+ }
+ return(uk)
+}
+