3,158 questions
0
votes
0
answers
39
views
Python sklearn Gaussian mixture model does not fit a bimodal distribution very well
I have read around a bit and never asked a question on stackoverflow before.
It seems there is a solution to my problem, but I don't understand the way it is written and computed.
Fit mixture of two ...
1
vote
3
answers
184
views
Calculating the area of a plot in R [closed]
I need help coming up with an efficient algorithm that calculates the limits of the area of a rectangle in R based on the proportion of points that fall into it. Let me start with some example data.
...
1
vote
2
answers
167
views
CUDA: curand_uniform() distribution not as random as expected
My goal is to use curand_uniform() to have every kernel thread generate a single random number. I am testing the randomness my program generates by treating each generated numbers as an index into a ...
1
vote
2
answers
157
views
How do I accurately distribute the numbers 1-100 (inclusive) between a weighted list <= 100 long?
I have a list of items, each item has a weight;
std::vector<float> weights{0.5, 2, 5};
this list is at most 100 items long, and at least 2 items long.
I want to inversely proportionately ...
0
votes
1
answer
74
views
Problems with fitting the “fitdist” distribution parameters
Good afternoon, dear colleagues. In the process of working on the project we have problems with fitting the parameters of the distribution law using the maximum likelihood method. Please help me to ...
0
votes
1
answer
100
views
How to introduce a random error within a Bayesian count model?
I am trying to model counts distribute across groups in JAGS, but I need to add a random effect for the presence of multiple counts from the same individual.
The model is taken from here
enter link ...
2
votes
1
answer
525
views
Python Error: rv_generic.interval() missing 1 required positional argument: 'confidence' [closed]
I have been trying to run the below code to calculate upper and lower confidence intervals using t distribution, but it keeps throwing the error in the subject. The piece of code is as below:
import ...
0
votes
1
answer
45
views
Why does the PDF of the feature vector follow a Gaussian mixture?
I am attempting to perform an image classification task on a dataset with
𝐿 classes. The network I am using is divided into a feature extractor and a classifier. When an image is passed through the ...
1
vote
2
answers
107
views
Distribute total amount to a flat array of "container" elements with predefined limits
I'm trying to split items evenly through groups with a max on each group.
I have a function which receives a $groups array which declares the maximum capacity of each "group" and an $items ...
3
votes
1
answer
167
views
How to plot a Log Pearson III distribution using `ggplot2` in R?
I am fitting a Log Pearson III distribution to my streamflow data. After the fitting, I'd like to plot the observed values and the fitted distribution.
However, the figure is not what I expect:
1. The ...
1
vote
1
answer
77
views
How to sum rectangles between randomly generated circles on a plane?
I am trying to make a program in C# that would generate n number of points, which form centers of non colliding circles with radius r in 200 by 200 plane (coordinates for both x and y are [-100+r, 100 ...
2
votes
0
answers
118
views
R GAMLSS : How to fit a log-logistic distribution (truncated)?
I'm trying to fit a log-logistic distribution (truncated) with GAMLSS and can't find how to do it.
In the documentation, it says that for Generalized Beta 2 (GB2) :
Setting ν = 1 and τ = 1 in (15.20) ...
0
votes
1
answer
84
views
How to repeat rbinom() with different size inputs with each draw?
I am attempting to write R code that will draw from a binomial distribution but will repeat for every value in a specified column in a data frame.
I generated a data frame in r such that the first ...
0
votes
0
answers
107
views
Overlay points on violin plot using Seaborn
I wish to compare two datasets. To this end, I want to represent the first as a violin and the second as points.
Unfortunately, there is a discrepancy between the two plots, as can be seen in the ...
1
vote
0
answers
45
views
Error using elements of D[i] inside a for-loop
I'm encountering an issue when trying to use the elements of the matrix D[i] inside a for loop in my JAGS model. The matrix D[i] is derived from a Wishart distribution, and when I try to use it within ...
0
votes
0
answers
83
views
Pytorch neural net transforming 1d uniform distribution to 2d gaussian
I need to train a neural network to convert a 1d uniform distribution to a 2d gaussian distribution.
I've constructed a simple feedforward network with leaky ReLu activation and trained using MMD as ...
0
votes
1
answer
115
views
How to extract values from multiple Monte Carlo simulations and compile these as series of values in R? [closed]
I am doing Monte Carlo simulation using a triangular distribution in R.
rtriangle(n = 10000, a = 9100, b = 13234, c = 11585)
In this example, I am doing 10,000 iterations where 'a' is the minimum ...
-1
votes
1
answer
74
views
R: ggplot distribution diagram with 'more than limit' bar and geom_vline
colleagues.
I am trying to build a distribution diagram that will satisfy the following conditions:
Shows percentage of the values lying in each bin.
Bin size is specified by user.
All the bars are ...
0
votes
2
answers
264
views
how to generate specific distribution?
I have a metric with 900K users, and I can't generate a distribution that would roughly repeat the existing one. I need this to quickly generate samples for AA AB tests (with guaranteed uplift).
Here ...
0
votes
1
answer
63
views
How to find average per day using pivot table?
I have following data that shows distribution of fruits on each date.
I want to achieve the following format via Pivot Table, that shows percentage of Apple on each day and show the average at the ...
0
votes
1
answer
56
views
Converting np.random.logistic to scipy.stats.fisk
I cannot figure out how to convert np.random.logistic to scipy.stats.fisk, here's my code:
import numpy as np
import numpy.random as npr
import scipy.stats as ss
import matplotlib.pyplot as plt
SEED =...
-1
votes
1
answer
99
views
How can I calculate the distribution of a project cost according to execution date in Python?
I´m working on an energy investment projects dataframe (DF). In this DF, I have two datetime type columns with 'initial_data' and 'final_data' and one float type column 'total_cost'.
I need to create ...
1
vote
1
answer
119
views
Scipy NLLF Loss has high values for distribution fitting
I'm trying to check if my data is distributed according to some distribution, however I always get NLLF values that doesn't make sense.
For example, here I'm generating 10K data points using a normal ...
0
votes
1
answer
236
views
Weibull Three Parameters Estimation using Maximum Likelihood and optimization methods
I'm having a problem estimating the Weibull three parameters using ML and optimization methods. My results in some of the methods do not look right. However, when a plot the curve looks fine with the ...
1
vote
1
answer
222
views
Estimate Dirichlet parameters from multinomial regression
I am trying to use the predicted probabilities from a multinomial regression using multinom function from the nnet package in R to estimate the parameters for a Dirichlet distribution while taking ...
3
votes
1
answer
349
views
How to implement a mixture of gamma distributions in Python without Bayes'?
I am trying to create examples to compare and contrast Bayesian MCMC (e.g. HMC) with non-Bayesian equivalents. One of the cases I am finding difficult is creating a mixture of gamma distributions.
I ...
0
votes
1
answer
192
views
How do you use a custom distribution in a GARCH-model with rugarch in R?
I want to use a distribution that is not built in to the rugarch package in R. More specifically, the EGB2 distribution. If I have the PDF of the distribution, is it then possible to use this ...
0
votes
1
answer
40
views
How do I fit a distribution to more than one site at a time in rstan?
There is probably a really easy solution to this, but I’m coming up short. I have code in rstan where I fit a Pareto distribution to data, and I’m looking to find out what the alpha parameter is for ...
0
votes
1
answer
260
views
Solving for Potential due to charge using Poisson Equation using FDM in Python (1D)
Im trying to get electric potential distribution due to charge (or charges) in one plane (1D).
To get it I'm solving Poisson Equation using FDM in Python.
In my example, the Poisson equation looks ...
1
vote
1
answer
74
views
Truncated normal distribution doesn't agree with untruncated normal distribution?
I am generating random variates distributed according to a truncated normal distribution using the function v_in defined below.
import numpy as np
from scipy.stats import truncnorm
from scipy.stats ...
0
votes
1
answer
160
views
Adding vertical lines using matplotlib
My aim is to first create two plots (which I correctly created), each of them representing the CDF of the number of Puts and Calls still open in the market.
For each plot, I also wanted to draw the ...
-1
votes
2
answers
371
views
How to fit a logistic distribution use a fixed location parameter?
I use scipy.stats.logistic.fit() with fixed location value, to get an estimated scale parameter, while the residual does not hold normality from qqplot.
How should I improve it and how to visualize ...
2
votes
1
answer
611
views
Correct way to generate random numbers from a log-normal distribution in R
I have a data set of household incomes. I want to fit a log-normal distribution to the data then generate random numbers from that distribution.
The approach below using the MASS package seems to give ...
1
vote
1
answer
107
views
Generate point within bounds of rectangle that is a minimum distance but not more than max distance from a given point A
I am working on a hobby project and have run into an issue that I wonder if there is a "simple" solution for.
The problem is as follows:
Assume a 2-dimensional grid with a rectangle defined ...
0
votes
0
answers
173
views
Find best fit common probability density function, if already have a probability density function (Python's Fitter does not suffice)
There are questions about finding best-fit p.d.f.s given some data: How to find probability distribution and parameters for real data? (Python 3), https://medium.com/the-researchers-guide/finding-the-...
2
votes
2
answers
159
views
How to generate uniformly distributed subintervals of an interval?
I have a non-empty integer interval [a; b). I want to generate a random non-empty integer subinterval [c; d) (where a <= c and d <= b). The [c; d) interval must be uniformly distributed in the ...
0
votes
1
answer
57
views
scipy lognorm does not converge to params
I have manually fitted a lognormal distribution to my data:
from scipy.stats import lognorm
sigma = 0.15
mu = 2
x_fit = np.linspace(x.min(), x.max(), 100)
y_fit = lognorm.pdf(x_fit, sigma, scale=np....
1
vote
0
answers
212
views
R fit gamma distributions using fitdist gives warnings and is different from fitdistr
I am using fitdist () from fitdistrplus package to fit gamma distributions. Most of the data are fitted fine, but I get a warning for one group of data like below. It seems to be related to NaN ...
0
votes
0
answers
188
views
C++11 custom uniform integer distribution implementation
I write code in C++ that need to be cross-platform. I need a uniform integer pseudo-random number generator to give the same results on different platforms (not cryptographic strength). As I ...
0
votes
0
answers
71
views
The code works but the output differs by approx. 4.5% from statistically right
I'm trying to make program from tutorial, details below:
The code suppose to simulate 100 coin tosses by generating a random sequence of T and H characters.
After that it should count how many sub ...
3
votes
1
answer
111
views
Sampling transformation - rexp vs rweibull
I am working with different sampling functions, and I am wondering why these two formulations do not give the same result
n=2
set.seed(1)
rweibull(n,shape = 1,scale = 1)
# [1] 1.3261078 0.9885284
set....
1
vote
1
answer
76
views
pgeom and ppois returning incorrect values when trying to find values greater or less than q
I am a beginner in R and stats, so I apologize if this question has an easy answer that I am just not seeing.
I am looking to solve some problems that want a cumulative answer < or > than q. ...
1
vote
0
answers
41
views
Getting error while running flexsurvreg function
Can anyone help me how to to define the below given custom distribution in flexsurvreg function.
custom_pdf=function(y,b0,b1,b2,b3,sigma,alpha){#pdf of proposed model
z=(y-b0-b1*t2-b2*t3-b3*t4)/...
0
votes
0
answers
102
views
stemgraphic returning wrong numbers
The following code doesn't seem to be working properly.
from stemgraphic import stem_graphic
stem_graphic([1,2])
This is wrong. The stem and leaf plot should show
0|2
0|1
How can I get the correct ...
1
vote
1
answer
57
views
Alternative to nested loop in python
I wrote a function U_p_law which takes 2 probability density functions (L_P and L_Q) of 2 players and 2 integer values that define how often each player one when they played each other.
The ...
0
votes
1
answer
471
views
How do I get the parameters for the lognormal distribution (mean, sd) from the 's', 'loc', and 'scale' values outputted from a distribution fitter?
Here is my code:
model = Fitter(data,distributions='lognorm') model.fit() print(model.summary()) model.get_best(method='sumsquare_error')
It outputs this:
{'lognorm': {'s': 0.8612498618921953, 'loc': ...
0
votes
1
answer
825
views
How to fit "Negative Binomial" Distribution on a histogram using ggplot2()?
I am working with a dataset that I believe follows a "Negative Binomial" distribution. However, when I fit the Negative Binomial distribution, it turns out to be a poor fit. To explore ...
-1
votes
1
answer
109
views
Simple seaborn distribution plot not working
I’m trying to plot the distribution of scores on reddit posts, but can’t figure it out.
My data frame is something like that
df = pd.DataFrame({"score": [12, 19, 25987, 887, 887, 1],
...
0
votes
1
answer
237
views
Azure Synapse shuffle WITH(DISTRIBUTED_MOVE_FILE='')
Azure Synapse dedicated pool, when doing a join on 2 tables with different distribution, Synapse creates temporary tables (shuffle step in execution plan) with the following syntax:
CREATE TABLE [...
0
votes
1
answer
89
views
Scipy curve_fit giving wrong results for powerlaw
I have list of degrees of nodes in a network and I want to fit a powerlaw distribution to this empirical degree distribution. I am able to do it using the powerlaw library but for some reason get bad ...