Comments (1)
I just checked the following:
from scipy.integrate import quad # function-based numeric integration/quadrature utility
p = a_u(200,10,15) # test value
integral, abserr = quad(p.pdf, p.value-(p.minus*6), p.value+(p.plus*6)) # arguments are (func, a, b)
print(integral) # outputs 0.9999999980336641
This seems like it's working as expected. Similarly, we could do
from scipy.integrate import trapezoid # array-based numeric integration utility
datap = a_u(200,10,15)
num_sigma = 5
discretization = 500
neg_x = np.linspace(datap.value-(num_sigma*datap.minus),datap.value,discretization)
pos_x = np.linspace(datap.value,datap.value+(num_sigma*datap.plus),discretization) # I changed this line relative to your example from datap.minus to datap.plus
x_arr = np.array(list(neg_x)+list(pos_x))
pdf = np.piecewise(x_arr, [x_arr<datap.value, x_arr>=datap.value],
[lambda y : np.sqrt(2)/np.sqrt(np.pi)/(datap.plus+datap.minus) * np.exp(-1*(y-datap.value)**2 / (2*datap.minus**2)),
lambda y : np.sqrt(2)/np.sqrt(np.pi)/(datap.plus+datap.minus) * np.exp(-1*(y-datap.value)**2 / (2*datap.plus**2))] )
integral = trapezoid(y=pdf, x=x_arr)
print(integral) # outputs 0.9999999980259466
Upon confirming that it seems to be doing the right thing, I realized the issue: in your second-to-last line, you divide by discretization
to compute delta
. The evaluation of the PDF uses a total of 2*discretization
points, since there are discretization
points both to the left and to the right of the nominal value. So there's the mystery factor of 2!
from asymmetric_uncertainty.
Related Issues (13)
- Not able to use the package HOT 4
- Add unit tests
- CDF does not behave as expected.
- Unused lines in pdfplot and cdfplot
- CI should only run when changes/PRs target main branch
- Generating a LaTeX table HOT 1
- Support for np.exp function? HOT 2
- Compatibility with `astropy.units` HOT 1
- Handling correlations between variables
- PIP Install Doesn't work with latest version HOT 2
- Issues with true division HOT 7
- Raising to negative power does not flip errors as expected
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from asymmetric_uncertainty.