bessel functions – Compute the conditional probability distribution of a noncentral $chi$ variable given the range of Erlang distributed non-centrality parameter

I need to compute a conditional probability distribution as described below for my research.

In $(mathbb R^2,||cdot||_2)$, I have a random vector $underline{z}$ with uniformly distributed angle and $Z=||underline{z}||$ following Erlang distribution with $k=2$ and scale parameter $mu$, i.e. with the density function $f_Z(z)=frac{z}{mu^2}e^{-frac{z}{mu}}$. I have another normal random vector $underline{y}$ independent of $underline{z}$. I’m interested in the resultant vector $underline{x}=underline{y}+underline{z}$ and want to compute the conditional distribution of $X=||underline{x}||$ given $aleq||underline{z}||leq b,0leq a<bleqinfty$, to be specific, the complementary cumulative distribution function $overline{F}_{X|Z}(x|(a,b))=P(X>x|aleq Zleq b)$. Solutions for special cases where $Zleq c$ or $Zgeq c$ for any $c>0$ would be sufficient for my research if they are easier to solve.

Following is my attempt. Given a fixed $Z=z$, since $underline{y}$ is normal, $X$ follows the noncentral $chi$ distribution with $k=2$ and non-centrality parameter $lambda=z$, i.e. $f_{X|Z}(x|z)=xe^{-frac{x^2+z^2}{2}}I_0(xz)$, where $I_0(x)=frac{1}{pi}int_0^pi e^{xcosalpha}dalpha$ is a modified Bessel function of the first kind. Then the density function of the conditional distribution is
$$f_{X|Z}(x|(a,b))=frac{int_a^b f_Z(z)f_{X|Z}(x|z)dz}{int_a^b f_Z(z)dz}$$

The denominator $int_a^b f_Z(z)dz=gamma(2,frac{b}{mu})-gamma(2,frac{a}{mu})$ where $gamma$ is the lower incomplete gamma function.

Change the order of integration, the numerator is
int_a^b f_Z(z)f_{X|Z}(x|z)dz & = frac{1}{pi}int_a^bfrac{z}{mu^2}e^{-frac{z}{mu}}xe^{-frac{x^2+z^2}{2}}int_0^pi e^{xcosalpha}dalpha \
& = frac{x}{pimu^2}e^{-frac{x^2}{2}}int_0^pi e^{frac{1}{2}(frac{1}{mu}-xcosalpha)^2}int_a^b ze^{-frac{1}{2}(z+frac{1}{mu}-xcosalpha)^2}dzdalpha \
& = frac{x}{pimu^2}e^{-frac{x^2}{2}}int_0^pi e^{frac{beta^2}{2}}left(e^{-bar{a}^2}-e^{-bar{b}^2}+sqrt{frac{pi}{2}}left(operatorname{erf}bar{a}-operatorname{erf}bar{b}right)right)dalpha

where $beta=frac{1}{mu}-xcosalpha$, $bar{a}=frac{a+beta}{sqrt{2}},bar{b}=frac{b+beta}{sqrt{2}}$, $operatorname{erf}$ is the error function.

Then I got stuck at the second integral. I am looking for an analytical expression of $f_{X|Z}(x|(a,b))$. I tried numerical integration and compared it to a simulation using matlab. The results are as expected.

Finally, what I want is an analytical expression of $overline{F}_{X|Z}(x|(0,c))=P(X>t|Zleq c)=int_t^infty f_{X|Z}(x|(0,c))dx$ and $overline{F}_{X|Z}(x|(c,infty))=P(X>t|Zgeq c)=int_t^infty f_{X|Z}(x|(c,infty))dx$.

Is it possible?

calculus – How to compute this limit about inverse function?

problem:let $f(x)=2021x^2021+x+1$
And compute the The following limit question:
$lim_{x to infty} frac{f^{-1}(2021x)-f^{-1}(x)}{sqrt(2021)(x)} $.

My attempt: i want to use mean value theorem to $f^{-1}(x)$ then we have:
$frac{2020x}{(2021^2 (η_y)^{2021}+1)(sqrt(2021) (x))$.
And $f(η_y)=η_x$, $η_x∈(x,2021x) $. We know $η_x$ tend to 0 as x tend to $infty$ so from the expression of $f$ we know $η_y$ is also.but we don’t know the quotient of $η_y$ and $x$
, so i think this way is fail. But i can’t do it in other way.

google cloud platform – Can not ping compute engine VM

In the compute engine page GCP prompted me to save $12/month by reducing the size of my VM. After selecting this option and reducing the size of my VM, I am unable to ping the external ip of the VM from external addresses. Also no web traffic. traceroute ends, does not reach the server…

Firewall rules are correct and in place to allow icmp/https/http. Also when I test various networking scenario from the compute engine is says they should work and should pass firewall rules (Ie, it says a ping from my home pc should work, but it does not)…. I am able to ping/traceroute to external ip addresses from the compute engine VM.

I’ve tried several reboots.

Any suggestions welcome. Thanks,

performance tuning – Area of ImplicitRegion is slow or doesn’t compute under certain circumstances

I’m trying to find the area of a region defined by ImplicitRegion using the Area function. I have the following:

h0 = 1.0;
r0 = 2.0;
xpmax = 0.6;
ypmax = 0.2;

ArcTanSeries(x_) = !(
*SubsuperscriptBox(((Sum)), (n = 0), (3))(
*SuperscriptBox((((-1))), (n)) 
SuperscriptBox((x), (2  n + 1)), (2  n + 1))));   

(Phi) = ArcTan(yi/xi);
l = Sqrt(yi^2 + xi^2);
h = ArcTanSeries(-l/z);
h = ArcTan(-l/z);
h = -l/z;
xp = h Cos((Phi));
yp = h Sin((Phi));

R = ImplicitRegion({xp < xpmax, yp < xpmax, 
    xi^2 + yi^2 + (z + r0 + h0)^2 == r0^2}, {{xi, 0, r0/2}, {yi, 0, 
     r0/2}, {z, -3 h0, -h0}});
Show(DiscretizeRegion(R), Graphics3D(Sphere({0, 0, -r0 - h0}, r0)))


This is the area of a region of the surface of a sphere bounded by a few inequalities. If I run this as-is, it completes in a few seconds and gives me the area. That is the case when using h = -l/z but I would like to instead set h = ArcTan(-l/z). If I switch to this definition of h everything works nicely up to and including showing the defined region on the surface of a sphere. However, on the last line Mathematica spends 5-10 minutes trying to calculate the area before eventually giving up and returning my input.

Is there something I can do to improve this? Or maybe a different approach I can take? I believe the region is well defined using either definition of h, so it isn’t obvious to me why it fails when using the ArcTan definition. I have also tried using a series expansion of ArcTan, which does result in a number after a bit of time. But it is still quite slow due to requiring quite a few terms (9-ish probably, maybe more) to be accurate enough for my needs. In fact, when testing 9 terms, Mathematica again gave up after ~10 minutes and returned my input. Are there any ways I can speed this up and ensure a precise answer?

Is this something I should be trying to numerically integrate? I imagine that is what the Area function does, but I’m not exactly sure how to set up such an integral.

rt.representation theory – How to compute the derived functor of bounded derived categories of hereditary algebra?

Let $Lambda$ be
a finite dimensional algebra given by the quiver
It can be view as an triangulated matrix algebra.
$$Lambda={A Mchoose0 A}$$.
(D^{b}(mod A),D^{b}(mod Lambda),D^{b}(mod A)) is a recollement of bounded derived categories.
Where six triangle functors are given by the derived functors of the following functors
&i^{*}({Xchoose Y}_{f})=Coker f, && i_{*}(X)={Xchoose 0}, &&i^{!}({Xchoose Y}_{f})=X,\
&j_{!}(Y)={Motimes_{Lambda”} Ychoose Y}_{1}, & & j^{*}({Xchoose Y}_{f})=Y, &&j_{*}(Y)={0choose Y}.

The above functors can be seen in

Qustion: How to compute the six functors in recollement of triangulated categories?
For example $j^{*}{Xchoose Y}=?$, $j^{*}{Xchoose Y}(1)=?$,$i^{*}{Xchoose Y}=?$,
One can see $j^{*}{Xchoose 0}=0$ as a stalk complex at 0.
$j^{*}{Xchoose 0}(1)=0?$ (is it a 0 complex in D^{b}(mod A)?).
In fact, ${Xchoose 0}(1)$ is a stalk complex at 1.

Thank you

raycasting – GLSL compute shader flickering squares/blocks artifact

I’m trying to write a bare minimum GPU raycaster using compute shaders in OpenGL. I’m confident the raycasting itself is functional, as I’ve gotten clean outlines of bounding boxes via a ray-box intersection algorithm.

However, when attempting ray-triangle intersection, I get strange artifacts. My shader is programmed to simply test for a ray-triangle intersection, and color the pixel white if an intersection was found and black otherwise. When the triangle should be visible onscreen, the screen is instead filled with black and white squares/blocks/tiles which flicker randomly like TV static. The squares are at most 8×8 pixels (the size of my compute shader blocks), although there are dots as small as single pixels as well. The white blocks generally lie in the expected area of my triangle, although sometimes they are spread out across the bottom of the screen as well.

Here is a video of the artifact. In my full shader the camera can be rotated around and the shape appears more triangle-like, but the flickering artifact is the key issue and still appears in this video which I generated from the following minimal version of my shader code:

layout(local_size_x = 8, local_size_y = 8, local_size_z = 1) in;

uvec2 DIMS = gl_NumWorkGroups.xy*gl_WorkGroupSize.xy;
uvec2 UV = gl_GlobalInvocationID.xy;
vec2 uvf = vec2(UV) / vec2(DIMS);

layout(location = 1, rgba8) uniform writeonly image2D brightnessOut;

struct Triangle
    vec3 v0;
    vec3 v1;
    vec3 v2;

struct Ray
    vec3 origin;
    vec3 direction;
    vec3 inv;

// Wikipedia Moller-Trumbore algorithm, GLSL-ified
bool ray_triangle_intersection(vec3 rayOrigin, vec3 rayVector,
    in Triangle inTriangle, out vec3 outIntersectionPoint)
    const float EPSILON = 0.0000001;
    vec3 vertex0 = inTriangle.v0;
    vec3 vertex1 = inTriangle.v1;
    vec3 vertex2 = inTriangle.v2;

    vec3 edge1 = {0.0, 0.0, 0.0};
    vec3 edge2 = {0.0, 0.0, 0.0};
    vec3 h = {0.0, 0.0, 0.0};
    vec3 s = {0.0, 0.0, 0.0};
    vec3 q = {0.0, 0.0, 0.0};
    float a = 0.0, f = 0.0, u = 0.0, v = 0.0;
    edge1 = vertex1 - vertex0;
    edge2 = vertex2 - vertex0;
    h = cross(rayVector, edge2);
    a = dot(edge1, h);
    // Test if ray is parallel to this triangle.
    if (a > -EPSILON && a < EPSILON)
        return false;

    f = 1.0/a;
    s = rayOrigin - vertex0;
    u = f * dot(s, h);
    if (u < 0.0 || u > 1.0)
        return false;

    q = cross(s, edge1);
    v = f * dot(rayVector, q);
    if (v < 0.0 || u + v > 1.0)
        return false;

    // At this stage we can compute t to find out where the intersection point is on the line.
    float t = f * dot(edge2, q);
    if (t > EPSILON) // ray intersection
        outIntersectionPoint = rayOrigin + rayVector * t;
        return true;
    return false;

void main()
    // Generate rays by calculating the distance from the eye
    // point to the screen and combining it with the pixel indices
    // to produce a ray through this invocation's pixel
    const float HFOV = (3.14159265359/180.0)*45.0;
    const float WIDTH_PX = 1280.0;
    const float HEIGHT_PX = 720.0;
    float VIEW_PLANE_D = (WIDTH_PX/2.0)/tan(HFOV/2.0);
    vec2 rayXY = vec2(UV) - vec2(WIDTH_PX/2.0, HEIGHT_PX/2.0);

    // Rays have origin at (0, 0, 20) and generally point towards (0, 0, -1)
    Ray r;
    r.origin = vec3(0.0, 0.0, 20.0);
    r.direction = normalize(vec3(rayXY, -VIEW_PLANE_D));
    r.inv = 1.0 / r.direction;
    // Triangle in XY plane at Z=0
    Triangle debugTri;
    debugTri.v0 = vec3(-20.0, 0.0, 0.0);
    debugTri.v1 = vec3(20.0, 0.0, 0.0);
    debugTri.v0 = vec3(0.0, 40.0, 0.0);

    // Test triangle intersection; write 1.0 if hit, else 0.0
    vec3 hitPosDebug = vec3(0.0);
    bool hitDebug = ray_triangle_intersection(r.origin, r.direction, debugTri, hitPosDebug);

    imageStore(brightnessOut, ivec2(UV), vec4(vec3(float(hitDebug)), 1.0));

I render the image to a fullscreen triangle using a normal sampler2D and rasterized triangle UVs chosen to map to screen space.

None of this code should be time dependent, and I’ve tried multiple ray-triangle algorithms from various sources including both branching and branch-free versions and all exhibit the same problem which leads me to suspect some sort of memory incoherency behavior I’m not familiar with, a driver issue, or a mistake I’ve made in configuring or dispatching my compute (I dispatch 160x90x1 of my 8x8x1 blocks to cover my 1280×720 framebuffer texture).

I’ve found a few similar issues like this one on SE and the general internet, but they seem to almost exclusively be caused by using uninitialized variables, which I am not doing as far as I can tell. They mention that the pattern continue to move when viewed in the NSight debugger; while RenderDoc doesn’t do that, the contents of the image do vary between draw calls even after the compute shader has finished. E.g. when inspecting the image in the compute draw call there is one pattern of artifacts, but when I scrub to the subsequent draw calls which use my image as input, the pattern in the image has changed.

I also found this post which seems very similar, but that one also seems to be caused by an uninitialized variable, which again I’ve been careful to avoid. I’ve also not been able to alleviate the issue by tweaking the code as they have done.

I’m running the latest NVidia drivers (461.92) on a GTX 1070. I’ve tried inserting glMemoryBarrier(GL_TEXTURE_FETCH_BARRIER_BIT); (as well as some of the other barrier types) after my compute shader dispatch which I believe is the correct barrier to use if using a sampler2D to draw a texture that was previously modified by an image load/store operation, but it doesn’t seem to change anything.

Odds are that the cause of the problem lies somewhere between my chair and keyboard, but this kind of problem lies outside my usual shader debugging abilities as I’m relatively new to OpenGL. Any ideas would be appreciated! Thanks.

combinatorics – How to compute the total number of directions in this graph?

If we draw a certain number, say $m$ layered hexagons as in the picture on a triangular grid graph, are we able to determine the number of directions in the graph in any way? By the directions I mean different directions created by picking two different points in the graph (so any two points from any of the layers, they can be in the same layer or a different layer). For example, if $m=1$ we would only have $6$ different directions, for $m=2$ we would have the total of $18$ different directions and so on. I do not know if there’s a pattern here or something like that, but I would like to know how could one either count the directions in general just for some $m$ or similar? Thanks.

Layered hexagonsenter image description here

google compute engine – Cannot add PTR record to VM instance

I’m trying to add a public DNS PTR record to my google compute VM but it keeps saying “Editing VM instance “server” failed. Error: Invalid value for field ‘resource.publicPtrDomainName’: ‘’. Please verify ownership of the PTR domain at” Note: I have replaced the text of the real domain with “” here.

I have verified the domain and left the txt record for the verification on my dns configurations. Am I missing something?

computational geometry – Efficient algorithm to compute the Heesch number of a shape

The Heesch number of a shape is the maximum number of layers of copies of the same shape that can surround it. For example the following shape (in the center) has a Heesch number of 4, because we can get at most 4 layers to surround it:

enter image description here

Given a shape, is there an efficient algorithm to compute its Heesch number? The only thing I can think of is to do a brute-force BFS search, surrounding it layer by layer. But this seems awfully inefficient.