Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7678281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T17:36:36+00:00 2026-05-31T17:36:36+00:00

I have 1000 large numbers, randomly distributed in range 37231 to 56661. I am

  • 0

I have 1000 large numbers, randomly distributed in range 37231 to 56661.

I am trying to use the stats.gaussian_kde but something does not work.
(maybe because of my poor knowledge of statistics?).

Here is the code:

from scipy import stats.gaussian_kde
import matplotlib.pyplot as plt

# 'data' is a 1D array that contains the initial numbers 37231 to 56661
xmin = min(data)
xmax = max(data)   

# get evenly distributed numbers for X axis.
x = linspace(xmin, xmax, 1000)   # get 1000 points on x axis
nPoints = len(x)

# get actual kernel density.
density = gaussian_kde(data)
y = density(x)

# print the output data
for i in range(nPoints):
    print "%s   %s" % (x[i], y[i])

plt.plot(x, density(x))
plt.show()

In the printout, I get x values in the column 1, and zeros in the column 2.
The plot shows a flat line.

I simply can not find the solution.
I tried a very wide range of X-es, the same result.

What is the problem? What am I doing wrong?
Could the large numbers be the cause?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T17:36:37+00:00Added an answer on May 31, 2026 at 5:36 pm

    I think what’s happening is that your data array is made up of integers, which leads to problems:

    >>> import numpy, scipy.stats
    >>> 
    >>> data = numpy.random.randint(37231, 56661,size=10)
    >>> xmin, xmax = min(data), max(data)
    >>> x = numpy.linspace(xmin, xmax, 10)
    >>> 
    >>> density = scipy.stats.gaussian_kde(data)
    >>> density.dataset
    array([[52605, 45451, 46029, 40379, 48885, 41262, 39248, 38247, 55987,
            44019]])
    >>> density(x)
    array([0, 0, 0, 0, 0, 0, 0, 0, 0, 0])
    

    but if we use floats:

    >>> density = scipy.stats.gaussian_kde(data*1.0)
    >>> density.dataset
    array([[ 52605.,  45451.,  46029.,  40379.,  48885.,  41262.,  39248.,
             38247.,  55987.,  44019.]])
    >>> density(x)
    array([  4.42201513e-05,   5.51130237e-05,   5.94470211e-05,
             5.78485526e-05,   5.21379448e-05,   4.43176188e-05,
             3.66725694e-05,   3.06297511e-05,   2.56191024e-05,
             2.01305127e-05])
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a large website at www.mydomain.com. There are 1000 new documents per month
I have 1000 rows of data but need to only display 100 rows at
I have a reasonably large set of phone numbers (approximately 2 million) in a
Given a large positive number of at most 1000 digits. You have to find
I have a large matrix from which I would like to randomly extract a
For a simple project I have to make large numbers (e.g. 4294967123) readable, so
I'm trying to optimize some code where I have a large number of arrays
I have 1000 files in a directory. I'm on a solaris machine I want
Hi I have 1000 encrypted workbooks which I would like to decrypt by providing
I have the following query which have 1000 rows select staffdiscountstartdate,datediff(day,groupstartdate,staffdiscountstartdate), EmployeeID from tblEmployees

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.