How do I go about creating an optimization that LpMaximize profits and LpMinimize the variance? I tried making var negative than using LpMaximize. The code below just the max of var and not the min of var and the max of profit. prob += lpSum([profits[i]*x[i] for i in N] and [var[v]*x[v] for v in N]) […]

# Tag: 2.4]

I was solving this math problem: If we roll three standard dices what is the possibility that the sum of eyes will be equal to 7? So I tried to approach this problem in two different ways: 1) The order in every sequence IS IMPORTANT (a,a,b) and (a,b,a) sequences are counted as different. In this […]

I have a data set and I’m trying to calculate the rate of change between the rows. My input looks like this: foo = structure(list(date = structure(c(5L, 1L, 2L, 3L, 4L), .Label = c(“10/03/2020”, “11/03/2020”, “12/03/2020”, “13/03/2020”, “9/03/2020”), class = “factor”), A = c(0.60256322, 0.634543306, 0.022976661, 0.009839044, 0.319456765), B = c(45.42320826, 57.32689951, 32.49487759, 29.40804164, 54.33691346), […]

I am trying to solve the iris data set with a neural network I wrote in C++ from scratch, which has 150 rows divided up into 3 different flowers with 4 columns and then a fifth for the flower type which I converted to a 0, 1 or 2. Problem: Whenever I run the network […]

I have a dataframe with many missing NAs. I want to create a correlation matrix with a p-value matrix as shown in this link: Link I created the correlation matrix like this: as.data.frame(round(cor(df, use = “pairwise.complete.obs”, method = c(“spearman”)), 1)) Now I am trying to create a matrix that shows the p-values for each correlation. […]

My measured variable V1 follows cycles: it goes up to reach a maximum and down to reach a minimum. I call “cycle” the range of data points between 2 consecutive maxima (cycle 1 is maximum 1 – minimum 1 – maximum 2, cycle 2 is maximum 2 – minimum 2 – maximum 3). The minima […]

Being complete new to tidyverse and trying to learn, I am trying to plot a median time denoted ee$rfs per ee$Ki67, which is marker of many cells that proliferates in a tumor sample, ie. a continuous covariate too. I have attached my data ee below. I am searching for a solution in either dplyr or […]

I have a list of x,y coordinates. The x values are close together but are not the same. I would like to bin x values together within a range and then take the mean value of the y values in each bin. I want the end results to be two 1-D arrays – one of […]

Suppose you have a dataframe with variables named X1 – X30 and Y1 – Y30. Each of these variables holds integers 1 – 5. We wish to recode some of the variables starting with X like this: df %<>% mutate_at(vars(starts_with(“X”) & ends_with(“5”, “8”, “16”, “22”, “28”)), recode, “1” = 5, “2” = 4, “4” = […]