Categories

## Editing a file based on a pattern appearance

I have a file that contains text and numbers like this: state(1, s(1,a), [s(1,b)]). state(1, s(1,b), [s(1,a)]). state(1, s(2,a), [s(2,b)]). state(1, s(2,b), [s(2,a)]). state(1, s(3,a), [s(3,b)]). state(1, s(3,b), [s(3,a)]). state(1, s(4,a), [t(1), t(2)]). state(1, s(5,a), [t(1), t(3)]). state(1, s(6,a), [s(6,b)]). state(1, s(6,b), [s(6,a)]). …so on I want the numbering with in s(x,y) to change as […]

Categories

## Why is my calculation getting wrong when calculating the distance between two coordinates, given x, y, z? [closed]

Purpose of the code: To calculate the distance between two coordinates/points (p1 & p2) in space using x, y and z (stored as p1/p2[0], p1/p2[.1] and p1/p2[2], respectively). x, y and z for both coordinates/points are entered by the user using scanf. By using this formula (check image below), it should then print the distance. […]

Categories

## R conditional loop to replace vallues

I am looking to conditionally replace values in a column and I think a loop is what I need. Though I know on a basic level how loops work, I have little experience using them so I struggle with wrapping my head around the order of operations. Using the dataframe df <- structure(list(player = c(“p1”, […]

Categories

## Use R to Randomly Assign of Participants to Treatments on a Daily Basis

The Problem: I am attempting to use R to generate a random study design where half of the participants are randomly assigned to “Treatement 1” and the other half are assigned to “Treatment 2”. However, because half of the subjects are male and half are female and I also want to ensure that an equal […]

Categories

## How to sort ‘WindowsPath’ object files

I am iterating through files in a directory using Path().glob() and it’s not iterating in the correct natural ordering. For eg. it’s iterating like this: [WindowsPath(‘C:/Users/HP/Desktop/P1/dataP1/SAMPLED_NORMALIZED/P1_Cor.csv’), WindowsPath(‘C:/Users/HP/Desktop/P10/dataP10/SAMPLED_NORMALIZED/P10_Cor.csv’), WindowsPath(‘C:/Users/HP/Desktop/P11/dataP11/SAMPLED_NORMALIZED/P11_Cor.csv’), WindowsPath(‘C:/Users/HP/Desktop/P12/dataP12/SAMPLED_NORMALIZED/P12_Cor.csv’), When I want it to iterate like this: P1, P2, P3 and so on. I have tried using the code below but it gives me an […]

Categories

## Time difference in execution of MySQL joins

I had a queries in which there was left joins were used and it was taking 30 seconds to complete the execution and return the dataset on mysql terminal. But when I have changed it to join its execution time has been reduced significantly from 30 to 12 seconds. I know this is too much […]

Categories

## Finding the most profitable permutations of long/short pairs in Python – an optimization problem?

I have daily profit data and I’m trying to find the best combinations of two assets that will return the highest profit. I need to purchase one asset long and short the other and find the best performing pair over a time window. I can accomplish this by searching through all the permutations, but it’s […]

Categories

## Why is Entity Framework Core attempting to insert records into one of the tables from many to many relationships and NOT the join table?

Given the following set up where there are many Teams and there are many LeagueSessions. Each Team belongs to zero or more LeagueSessions but only ever one LeagueSession is active. LeagueSessions have many teams, and the teams will be repeated. Many-to-many relationship is established between Teams and LeagueSessions with a join table called TeamsSessions. Team […]

Categories

## How do I append Items into a list?

I have a variable P (Postings) and N as a integer Number of Posts wanted in list. I want to append those Postings to the list after making selection sort to return a list of Postings. To access those timestamps a Posting is 2 Dimensional Array P[i][j].timestamp (i = Person and j = Posting of […]