weighted Questions

13

Solved

Is there a way to use the numpy.percentile function to compute weighted percentile? Or is anyone aware of an alternative python function to compute weighted percentile?
Wheatear asked 18/2, 2014 at 3:55

6

Solved

I have a time series x_0 ... x_t. I would like to compute the exponentially weighted variance of the data. That is: V = SUM{w_i*(x_i - x_bar)^2, i=1 to T} where SUM{w_i} = 1 and x_bar=SUM{w_i*x_i}...
Iover asked 6/4, 2012 at 21:20

6

Solved

In R I want to allocate projects to people based on their rank preferences but also their performance. Say I have 5 projects and 3 people. In this case, all three people want project A because it's...
Craner asked 13/3, 2023 at 12:16

5

Solved

Lets assume: List<element> which element is: public class Element { int Weight { get; set; } } What I want to achieve is, select an element randomly by the weight. For example: Element_1.We...
Horrified asked 4/2, 2012 at 14:34

7

Solved

numpy.average() has a weights option, but numpy.std() does not. Does anyone have suggestions for a workaround?
Belgravia asked 9/3, 2010 at 23:53

6

Given a list of probabilities like: P = [0.10, 0.25, 0.60, 0.05] (I can ensure that the sum of all the variables in P is always 1) How can I write a function that randomly returns a valid index, a...
Cutlery asked 14/12, 2010 at 8:34

1

Solved

I have an old linear model which I wish to improve using XGBoost. I have the predictions from the old model, which I wish to use as a base margin. Also, due to the nature of what I'm modeling, I ne...
Unsphere asked 6/6, 2022 at 18:27

3

Solved

I need to obtain a random sample from an ElasticSearch index, i.e. to issue a query that retrieves some documents from a given index with weighted probability Wj/ΣWi (where Wj is a weight of row j ...
Sporocyte asked 7/12, 2015 at 7:54

2

Solved

Is there a way to do nice and elegant weighted shuffling using standard library? There is std::discrete_distribution. What I want is something like this: std::vector<T> data { N elements }...
Asthenopia asked 7/5, 2018 at 19:26

6

Solved

I need to calculate the frequency of individuals by age and marital status so normally I'd use: table(age, marital_status) However each individual has a different weight after the sampling of t...
Digress asked 3/9, 2013 at 6:57

1

Solved

I want to do a linear regression applying survey weights in R studio. I have seen that it is possible to do this with the lm() function, which enables me to specify the weights I want to use. Howev...
Holzer asked 27/9, 2020 at 15:8

1

Solved

I want to calculate (weighted) logistic regression in Python. The weights were calculated to adjust the distribution of the sample regarding the population. However, the results don´t change if I u...
Anxiety asked 5/7, 2020 at 15:2

3

Solved

What is a good algorithm that shuffles an array or arrays using weights from the nested arrays? Example: $array = array( array("name"=>"John", "rank"=>3), array("name"=>"Bob", "rank"=&...
Loadstone asked 22/2, 2012 at 21:12

1

Solved

I have been running a Rails site for a couple of years and some articles are being pulled from the DB based on a weight field. The data structure is: {name: 'Content Piece 1', weight: 50} {name: '...
Augend asked 15/7, 2019 at 16:30

6

Solved

I have a program where I'm keeping track of the success of various things using collections.Counter — each success of a thing increments the corresponding counter: import collections scoreboard = ...
Laager asked 31/1, 2012 at 18:7

1

Solved

How can I calculate the weighted coefficient of variation (CV) over a NumPy array in Python? It's okay to use any popular third-party Python package for this purpose. I can calculate the CV using ...
Rattlepate asked 12/12, 2018 at 17:41

2

Solved

I'm performing weighted search on a series of items in an e-commerce platform. The problem I have is ts_rank is giving me the exact same value for different combinations of words, even if the ts_ve...
Appointive asked 20/4, 2016 at 9:19

2

I want to set the same weight for parts of positive samples. However,tf.nn.weighted_cross_entropy_with_logits can only set the weight for all positive samples in my opinion. for example, in the c...
Carson asked 16/3, 2018 at 3:44

2

Solved

Per https://stackoverflow.com/a/48981834/1840471, this is an implementation of the weighted Gini coefficient in Python: import numpy as np def gini(x, weights=None): if weights is None: weights ...
Quake asked 27/2, 2018 at 1:0

1

Solved

I am preparing a plot using ggplot2, and I want to add a trendline that is based on a weighted least squares estimation. In base graphics this can be done by sending a WLS model to abline: mod0 ...
Thenceforth asked 28/2, 2017 at 11:8

4

I have an array of doubles and I want to select a value from it with the probability of each value being selected being inversely proportional to its value. For example: arr[0] = 100 arr[1] = 200 ...
Visa asked 10/5, 2013 at 19:24

2

Solved

I'm trying to calculate the weighted mean for multiple columns using dplyr. at the moment I'm stuck with summarize_each which to me seems to be part of the solution. here's some example code: libr...
Hypnotism asked 25/4, 2017 at 6:11

1

Solved

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 weig...
Rutile asked 2/9, 2015 at 15:7

4

Solved

I am trying to write a program to select a random name from the US Census last name list. The list format is Name Weight Cumulative line ----- ----- ----- - SMITH 1.006 1.006 1 JOHNSON 0.810 1.816...
Executant asked 9/9, 2011 at 20:1

6

Solved

Way way back (think 20+ years) I encountered a Gomoku game source code in a magazine that I typed in for my computer and had a lot of fun with. The game was difficult to win against, but the core ...
Adventitious asked 2/5, 2010 at 12:8

© 2022 - 2025 — McMap. All rights reserved.