Questions tagged [weighted]

questions about problems that use a weight function, e.g. weighted mean, weighted sampling

A weight function is a mathematical device used when performing a sum, integral, or average to give some elements more "weight" or influence on the result than other elements in the same set. The result of this application of a weight function is a weighted sum or weighted average.

Weight functions occur frequently in statistics and analysis, and are closely related to the concept of a measure. Weight functions can be employed in both discrete and continuous settings.

615 questions
-1
votes
1 answer

Removing duplicate records from a weighted relational database

I have a relational SQL database, derived from data returned by a Tensorflow image classifier. I believe that there are a huge number of duplicate entries in both the image table and relational table and I would like to remove them while ensuring…
-1
votes
1 answer

read a weighted adjacency node list with more than one target nodes from csv file in python

I have an adjacency list in a csv file which is like this: 'a','b','0.5','c','0.34','e','0.25'\n 'b','c','0.78','d','0.3','e','0.25'\n etc The first 'column' represent the start node and after that the following 'columns' represent the nodes…
Georgia
  • 53
  • 5
-1
votes
1 answer

Matlab: weighted average of data points

I have a plot in Matlab where the data points (15 of them) are located with different distances between each other. I have an interval (5 data points, nr 6 to 10) almost in the middle where the data points are a bit closer to each other and where I…
nilz
  • 1
  • 1
-1
votes
1 answer

Weight assignment to define an objective function

I have a set of jobs with execution times (C1,C2...Cn) and deadlines (D1,D2,...Dn). Each job will complete its execution in some time, i.e, response time (R1,R2,....Rn). However, there is a possibility that not every job will complete its execution…
-1
votes
2 answers

Weighted sort in perl?

I have a hash of hashes where the values are all numerical. I can sort fine using the sort command and or to sort the hash values in order first to last, but what if I want to weight the results instead of it just being in order of keys specified?…
user578086
  • 321
  • 1
  • 4
  • 12
-2
votes
3 answers

Tips for cleaning up a challenge's answer? Weighted Sum of Digits

I've been going through some code challenges. And one struck me in particular. CodeAbbey has a Weighted Sum of Digits challenge. And this was my answer. # open and read a file, hardcoded numbers, etc. Here is a sample raw_data = (6, 19, 64, 6527226,…
-2
votes
2 answers

Compute weighted mean for each in R

I have a dataframe df df<- structure(list(ID = structure(c(1L, 3L, 5L, 6L, 8L), .Label = c("AU-Tum", "AU-Wac", "BE-Bra", "BE-Jal", "BE-Vie", "BR-Cax", "BR-Sa3", "CA-Ca1", "CA-Ca2", "CA-Ca3", "CA-Gro", "Ca-Man", "CA-NS1", "CA-NS2", "CA-NS3",…
SimonB
  • 670
  • 1
  • 10
  • 25
-2
votes
1 answer

Statistic calculation

this is a question related to statistic calculation. The process that I will be going through is sampling survey. I will have a fluctuating sample on a daily basis. I will write a program to process data. After the data is imported into the…
-3
votes
1 answer

How do i detect the randomly generated number

i made code to randomly generate weighted numbers and whenever i tell it to break when it generates a certain number it doesnt do it code: import random while True: numberList = [0, 100, 250, 500, 1000, 2000, 5000, 10000, 25000, 50000, 75000,…
yesno
  • 1
  • 2
-3
votes
2 answers

Spotfire Weighted Median value

Is there any function which returns weighted Median value? Input 2 columns like weight = [100,210,30,50] values = [1, 2, 3, 4] and maybe function like WeightedMedian(w = weight, v = values) or can you help me to construct code for that, Data-->Data…
Easyhyum
  • 307
  • 1
  • 3
  • 5
-3
votes
1 answer

Compute weighted average for selected rows in SQL

My data set has a weight column and a variable of interest var1, for which I need to form a weighted average of all rows that satisfy either var1=1 and var1=2. Unfortunately I need to do this in SQL, where I have very limited knowledge. To compute…
user239092
  • 29
  • 2
-4
votes
1 answer

How to optimize weighted values and output to least amount of lines and characters?

def finalvalue(a,b,c,d): o=round(450-a-(b*2+c+d)*.75+.3) return ("Impossible, you " if(o)>100 else "You ")+"would need a "+str(o)+"%" So here I have a function that calculates the weighted score of each of the inputs and what the final…
user12945940
-4
votes
1 answer

Sum weights of neighbors nodes in python

I need to sum the total weights of a neighbors node. For example, I have a node (1) where its neighbors are (2) and (4). Its edges has a weight: (1-2 , weight = 3) and (1-4, weight = 5). Then, I need the result of sum weights (8). I tried: sum_tot =…
-5
votes
1 answer

Minimizing Travel Costs with Free Flight Coupon

I am trying to solve the following code challenge In a world with a total of N cities and M flight routes, each with a different ticket price, you are travelling from City A to City B, with the possibility of making one flight free, while all other…
Pilvi
  • 1
  • 2
-10
votes
1 answer

Weighted random: roll dice 1 to 1000, averages to 100... which std::distribution to use?

I want to roll a dice from 1 to 1000. However, over many trials, I want the average to be 100. How? int weighted_rand(int min, int max, int avg); ... weighted_rand(1, 1000, 100); This isn't homework btw. Uniform…
y2k
  • 65,388
  • 27
  • 61
  • 86
1 2 3
40
41