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

python: random sample with probabilities

Suppose I want to create a sample of N elements chosen from [1,2,3] such that 1, 2 and 3 will be represented with weights 0.4,0.4 and 0.2 respectively. How would I do this. I know how to do it in R without using loops: mySample <-…
kthouz
  • 411
  • 7
  • 16
3
votes
1 answer

Modularity calculation for weighted graphs in igraph

I used the fastgreedy algorithm in igraph for my community detection in a weighted, undirected graph. Afterwards I wanted to have a look at the modularity and I got different values for different methods and I am wondering why. I included a short…
Gilean0709
  • 1,098
  • 6
  • 17
3
votes
3 answers

Apply the corr function to a matrix using levels of a factor?

I'm trying using the corr() function to calculate weighted ponderations. The way it works is the first argument should be a matrix with two columns corresponding to the two variables whose correlation we wish to calculate and the second a vector of…
Tom
  • 61
  • 6
3
votes
6 answers

How to weight a random number based on an array

I've been thinking about how to implement something that, frankly, is beyond my mathematical skills. So here goes, feel free to try and point me in the right direction rather than complete code solutions any help I'd be grateful for. So, imagine…
Th3Minstr3l
  • 322
  • 2
  • 7
3
votes
3 answers

Finding all paths in directed graph with specific cost

Suppose we have the directed, weighted graph. Our task is to find all paths beetween two vertices (source and destination) which cost is less or equal =< N. We visit every vertex only once. In later version I'd like to add a condition that the…
kozooh
  • 2,035
  • 1
  • 21
  • 31
3
votes
0 answers

Weighted Least Squares to find Best Fit Line

I am trying to find out the Line of best fit for a number of data points (x,y). I am using the method of least squares as described here http://faculty.cs.niu.edu/~hutchins/csci230/best-fit.htm However I need to adjust the algorithm so that I can…
mwolce
  • 151
  • 3
2
votes
1 answer

Simple weighted link rotation?

I'm split testing landing pages in campaign currently by sending them to the following script: $link[] = "http://www.website.com/lp1"; $link[] = "http://www.website.com/lp2"; $random_number = rand(0,count($link)-1); $redirectlink =…
2
votes
2 answers

Coming up with factors for a weighted algorithm?

I'm trying to come up with a weighted algorithm for an application. In the application, there is a limited amount of space available for different elements. Once all the space is occupied, the algorithm should choose the best element(s) to remove in…
Senseful
  • 86,719
  • 67
  • 308
  • 465
2
votes
2 answers

Weighted graph problems, TRUE/FALSE + explanation

I'm trying to get some true/false questions done. I'm getting worried when I'm answering many of them with true... Please assume that all graphs are undirected and do not have distinct weights. Negative weights should be fine. Qa) If G has a cycle…
Felastine
  • 793
  • 2
  • 8
  • 18
2
votes
2 answers

Automatically assign weights to variables based on factor level

I am having some trouble wording my issue, so I am using the mtcars dataset as an example. Imagine I am student of social sciences in the Pixar Cars(TM) universe. For a small school project on statistical methods, I am doing a survey amongst my…
Emma
  • 25
  • 5
2
votes
0 answers

How do I calculate weighted median instead of weighted mean for single-arm meta-analysis?

I am trying to calculate weighted median instead of weighted mean for meta-analysis. I used to use metamean but unfortunately no metamedian if the data was skewed. I saw this but it is irrelevant in case of meta-analysis. Here is my prior…
Mohamed Rahouma
  • 1,084
  • 9
  • 20
2
votes
4 answers

Weighted Search Algorithm for PHP

Problem I have 5 items in a table [1], each item has 4 attributes (red, green, blue, yellow). Each attribute can be given a score between 1 and 9 [2]. When performing a search on my website users can specify how relevant each attribute is to the…
Sam
  • 4,437
  • 11
  • 40
  • 59
2
votes
1 answer

Error while using the weights option in nlme in r

Sorry this is crossposting from https://stats.stackexchange.com/questions/593717/nlme-regression-with-weights-syntax-in-r, but I thought it might be more appropriate to post it here. I am trying to fit a power curve to model some observations in an…
FloLe
  • 41
  • 5
2
votes
0 answers

Is there a way in R to include weights in a cox regression with Firth's penalized likelihood?

I am trying to fit a propensity score weighted cox regression model in R. However, one of the treatment groups has zero events, so I also need to use an adjustment method (Firth's penalized likelihood). I have been using the coxphf package just fine…
2
votes
2 answers

calculate weights from a column in a dataframe with conditions R

I need to calculate weights from a column in a dataframe based on some conditions. I have Total Assets from several banks, with different countries, years and specializations. For each bank I want to calculate a weight (w) where w(i) = Tot_Asset…