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
5
votes
1 answer

Creating a weighted undirected graph in "igraph" in C/C++

Problem: I want to make a weighted undirected graph from adjacency matrix stored in a .csv file using igraph and then do the minimum spanning tree and some other algorithms on it. I started with making a directed graph with 10 vertices and 5 edges.…
NightFox
  • 125
  • 1
  • 10
4
votes
1 answer

Subtracting from random values in a weighted matrix in R

and thanks in advance for your help! This question is related to one I posted before, but I think it deserves its own post because it is a separate challenge. Last time I asked about randomly selecting values from a matrix after adding a vector. In…
Laura
  • 679
  • 2
  • 5
  • 14
4
votes
4 answers

How to pick 4 unique items from a weighted list?

So I've got a list of weighted items, and I'd like to pick 4 non-duplicate items from this list. Item Weight Apple 5 Banana 7 Cherry 12 ... Orange 8 Pineapple 50 What is the most efficient way to do this? My initial foray was to…
aslum
  • 11,774
  • 16
  • 49
  • 70
4
votes
2 answers

SQL Server 2008 Containstable generate negative rank with weighted_term

I have a table with full text search enabled on Title column. I try to make a weighted search with a containstable but i get an Arithmetic overflow for the Rank value. The query is as follow SELECT ID, CAST(Res_Tbl.RANK AS Decimal) AS Relevancy ,…
Nico
  • 496
  • 1
  • 3
  • 7
4
votes
0 answers

Keras "class_weights" parameter usable for regression?

I am training a Sequential model for regression. I noticed there is a "class_weights" parameter in the fitting function. As I understand one can give a different importance to a class during training. But as the name states "class" I am not sure…
Benoid
  • 209
  • 1
  • 4
  • 11
4
votes
2 answers

In Ruby, how can one make a weighted random selection by least weight?

If I have the array : ar = [1,3,5,3,6,1,4,6,7,6,6,6,6,6] I could reduce this to the amount of occurrences : counts = {1=>2, 3=>2, 5=>1, 6=>7, 4=>1, 7=>1} Now I would like to choose at random with the least used number in ar being more weighted I…
Trip
  • 26,756
  • 46
  • 158
  • 277
4
votes
0 answers

fractional frequency weights in R's lm()

I understand that lm treats weights as "analytic" weights, meaning that observations are just weighted against each other (e.g. lm will weigh an observation with weight= 2 twice as much as one with weight = 1), and the overall N for the model is…
lost
  • 1,483
  • 1
  • 11
  • 19
4
votes
3 answers

Weighted distribution among buckets with no look-ahead

I have N workers that need to process incoming batches of data. Each worker is configured so that it knows that it is "worker X of N". Each incoming batch of data has a random unique ID (being random, it is uniformly distributed), and it has a…
Giovanni Bajo
  • 1,337
  • 9
  • 15
4
votes
1 answer

How to use the R survey package to analyze multiple response questions in a weighted sample?

I'm relatively new to R. I am wondering how to use the 'survey' package (http://r-survey.r-forge.r-project.org/survey/) to analyze a multiple response question for a weighted sample? The tricky bit is that more than one response can be ticked so the…
Chris G.
  • 81
  • 2
  • 9
4
votes
1 answer

How to find probability of path in a directed graph?

I have a directed weighted graph G=(V,E). In this graph the weight of edge(v[i],v[j]) is the count of transition between v[i] and v[j]. I am trying to determine the best way to accomplish task: how to find the probability P of path from node A to…
Andrei
  • 1,313
  • 4
  • 18
  • 35
4
votes
1 answer

Weighted sampling in Fortran

In a Fortran program I would like to choose at random a specific variable (specifically its index) by using weights. The weights would be provided in a separate vector (element 1 would contain weight of variable 1 and so on). I have the following…
Chris
  • 61
  • 7
4
votes
1 answer

Weighted mean across several matrices - element by element

I have 'mylist" - a list of same size matrices: mylist <- vector("list", 5) set.seed(123) for(i in 1:5){ mylist[[i]] <- matrix(rnorm(9), nrow = 3) } I also have a vector of weights 'mywgts' - same length as 'mylist' mywgts <- c(0.8, 0.9, 1, 1.1,…
user2323534
  • 585
  • 1
  • 6
  • 18
4
votes
1 answer

How to weight station to Order Least Squares in python?

I have 10 climate stations data about precipitation and it's DEM. I had done a linear regression follow: DEM = [200, 300, 400, 500, 600, 300, 200, 100, 50, 200] Prep = [50, 95, 50, 59, 99, 50, 23, 10, 10, 60] X = DEM #independent variable Y = Prep…
楊宇恩
  • 99
  • 2
  • 11
4
votes
5 answers

Weighted Randomized Ordering

The problem: I have items that have weights. The higher the weight, the greater chance they have the item will go first. I need to have a clean, simple way of doing this that is based on core Java (no third party libraries, jars, etc.). I've done…
James Oravec
  • 19,579
  • 27
  • 94
  • 160
4
votes
0 answers

Is there a faster method of doing a random weighted choice for a large list of items

Assume I have a list of items each with a weight and I want to pick a random item. The easiest way to implement this is to keep the list of items and a running sum of the weights sorted by the sum. Then pick a random int from the max weight and do a…
ahwulf
  • 2,584
  • 15
  • 29
1 2
3
40 41