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
4
votes
2 answers

Algorithm to modify the weights of the edges of a graph, given a shortest path

Given a graph with edges having positive weights, a pair of nodes, and a path between the nodes, what's the best algorithm that will tell me how to modify the edge weights of the graph to the minimum extent possible such that the specified path…
4
votes
2 answers

Algorithm for optimal pairing strategy of items in two ordered lists while maintaining order

I have the the following two ordered lists of items: A = ["apples","oranges","bananas","blueberries"] B = ["apples","blueberries","oranges","bananas"] Each item has a score which is equal to the length of the string, so... apples = 6 points oranges…
Stuart Wakefield
  • 6,294
  • 24
  • 35
3
votes
1 answer

Calculating 95% confidence intervals for a weighted median over grouped data in dplyr

I have a dataset with several groups, where I want to calculate a median value for each group using dplyr. The data are weighted, and the weights need to be taken into account in calculating the median. I found the weighted.median function from…
Joe
  • 3,831
  • 4
  • 28
  • 44
3
votes
1 answer

Inconsistence with R's "Residual Standard Error" (in lm) in case of WLS

I am trying to reproduce Weighted Least Squares (WLS) in Excel using R for confirmation. I use the (trivial but reproducible) following dataset to perform a double check : x<-c(1,2,3,4,5,6) y<-c(9,23,30,42,54,66) w<-1/x When I calculate a WLS using…
Edouard
  • 35
  • 3
3
votes
1 answer

compute jaccard similarity on dataframe

self learner in python, I am trying to improve so any help is very welcome, thanks lot ! I want to compute a jaccard similarity over a column of my dataframe by matching criteria on another column. df looks like this: name bag number …
polo
  • 53
  • 4
3
votes
2 answers

How to do a weighted T-test in R?

I have df1: PopDens Score1 Group 93.53455 17.985288 B 137.13861 10.549394 A 35.98619 13.392857 A 89.69800 8.644537 B 16.27796 29.591635 A 25.33346 21.081301 F 89.69800 2.644537 C 46.27796 29.591635 A 25.33346 …
Evan
  • 1,477
  • 1
  • 17
  • 34
3
votes
2 answers

weighted regression sklearn

I'd like to add weights to my training data based on its recency. If we look at a simple example: import matplotlib.pyplot as plt import numpy as np from sklearn.preprocessing import PolynomialFeatures, normalize from sklearn.linear_model import…
Olivia
  • 814
  • 1
  • 14
  • 26
3
votes
1 answer

Can the expss package process multiple answer questions with weighted data?

Can the expss package solve the question asked in this link?, it's about multiple response question with a weighting variable in the dataset How to use the R survey package to analyze multiple response questions in a weighted sample? Let's suppose…
Sebastian
  • 95
  • 6
3
votes
2 answers

Create Weighted edges in igraph instead of multiple single connections

I'm trying to visualize the connections between the institutions in a medical faculty and just can't get the edges to be weighted and displayed thicker or thinner depending on the number of connections. I've tried to combine the answers I found here…
Jay
  • 33
  • 4
3
votes
3 answers

Adding Class Weights for imbalanced dataset in Convolutional Neural Network

I have a dataset of images that has the following distribution: Class 0: 73,5% Class 1: 7% Class 2: 15% Class 3: 2,5% Class 4: 2% I think I need to add Class Weights to make up for the low amount of images in class 1, 2, 3 and 4. I have tried…
jeez
  • 59
  • 2
  • 4
3
votes
1 answer

Weight samples if incorrect guessed in binary cross entropy

Is there a way in keras or tensorflow to give samples an extra weight if they are incorrectly classified only. Ie. a combination of class weight and sample weight but only apply the sample weight for one of the outcomes in a binary class?
Nickpick
  • 6,163
  • 16
  • 65
  • 116
3
votes
2 answers

Error on weighted histogram in python

I want to calculate the error on a bin height by taking the square root of the sum of the weights squared (sumw2) in that bin (poission error). Is there any way to get the sum of weights (sumw) and/or sumw2 when histogramming data with either…
Lxndr
  • 191
  • 1
  • 4
  • 13
3
votes
2 answers

How to get a weighted average of a list of which it's weights is limited by a variable in Python 3.6

I hope the title makes sense. What i'm trying to achieve is getting a weighted average price of shoes which are available at different prices in different amounts. So I have for example: list_prices = [12,12.7,13.5,14.3] list_amounts =…
Cennnn
  • 45
  • 1
  • 7
3
votes
2 answers

Get path in graph with weighted vertices and edges

If i have the following undirected graph with weighted vertices and edges: I am trying to come up with a ruby algorithm to find a best shortest path within a defined limit (sum of edges) with the highest value (sum of vertices). The start point…
Dayzza
  • 1,561
  • 7
  • 18
  • 29
3
votes
0 answers

How to test for normality in a weighted distribution?

I have a dataset which was stratified across 3 different populations and resulted in the following sampling pattern: A B C All Pop Size 713 2904 4687 8305 Num Sampled 72 135 159 In order to…
Techniquab
  • 843
  • 7
  • 22