plotting – How to throw $n$ random noodles of equal length?

I’ve been meaning to modify some code given in the the Region Disjoint documentation for the Buffon’s Needle problem to instead model Buffon’s Noodle Problem.

In Buffon’s Needle problem you randomly toss $n$ straight lines (i.e. needles) of length $l$ in between parallel lines of width $t$. The probability that the needle lies across a line is given by,
$${displaystyle p={frac {2}{pi }}{frac {l}{t}}.}$$

In Buffon’s Noodle problem you instead randomly toss $n$ rigid plane curves (i.e. noodles) of length $l$ in between parallel lines of width $t$ and the probability is the same.

My question is, how can I modify the code shown below to throw $n$ noodles instead of needles?

Input:

d = 0.2; n = 1000;
lines = MeshRegion(
Join @@ Table({{-1 - d, y}, {1 + d, y}}, {y, -1 - d, 1 + d, d}), 
Line(Partition(Range(2 Floor(2/d + 3)), 2)));
needles =  Table(Line({pt, RandomPoint(Circle(pt, d))}), {pt, RandomReal({-1, 1}, {n,2})});
overlap = Select(needles, ! RegionDisjoint(lines, #) &);
Show(lines, Graphics({Red, overlap, Black, Complement(needles, overlap)}))
N((2 n)/Length(overlap))

Output:

enter image description here

EDIT: A side question, how exactly can you adjust the line width $t$ in the above code? I don’t seem able to figure it out.

real analysis – Do equal integrals of 1/(1+x^a) imply equal measure?

Suppose $mu$ and $nu$ are two probability measures on $(0,1)$ with the property that $int_{0}^{1} frac{1}{1+x^a} ~dmu(x) = int_{0}^{1} frac{1}{1+x^a} ~dnu(x)$ holds for every exponent $a > 0$. Does this imply that $mu$ and $nu$ are the same measure? If the answer is yes, is it sufficient to restrict to positive integer exponents $a$?

real analysis – How can we construct a compactly supported function which is equal to $1$ on a given interval?

I know that for any open cover $(Omega_i)_{iin I}$ of $mathbb R$ we can find a $C^infty$-partition of unity subordinated to $(Omega_i)_{iin I}$. Moreover, if $eta$ is a mollifying kernel$^1$ on $mathbb R$, then $$eta_varepsilon(x):=frac1varepsilonetaleft(frac xvarepsilonright);;;text{for }xinmathbb R^d$$ is in $C_c^infty(mathbb R)$ with $operatorname{supp}eta_varepsilonsubseteq(-varepsilon,varepsilon)$.

Now I would like to construct something similar: I would like to obtain a family $(rho_k)_{kinmathbb N}subseteq C_c^infty(Omega)$ such that $rho_kequiv1$ on $overline{Omega_k}$, where $Omega_k:=(-k,k)$, for all $kinmathbb N$ and $rho_kto1$ as $ktoinfty$. Or, more generally, for any open cover $(Omega_i)_{iin I}$ of $mathbb R$.

Intuitively, this should be easy to obtain. $rho_k$ is simply needs to (rapidly and) smoothly decrease to $0$ at the endpoints of $(-k,k)$. But how can we construct $rho_k$ (or, more generally, $rho_i$) rigorously?


i.e. $etain C_c^infty(mathbb R)$ with $operatorname{supp}etasubseteq(-1,1)$, $etage1$, $inteta(x):{rm d}x=1$ and $eta(x)=eta(y)$ for all $x,yinmathbb R$ with $|x|=|y|$.

mysql – UPDATE SET N + 1 equal to a row

You have to join the right Sub Select, where your rules apply

CREATE TABLE `a` (
  `a1` int(20) NOT NULL,
  `a2` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--

INSERT INTO `a` (`a1`,  `a2`) VALUES
(1,  'X'),
(2, 'Z'),
(3, 'X'),
(4, 'Y'),
(5, 'Z'),
(6, 'X'),
(7, 'Y');





select * from a order by a1;

a1 | a2
-: | :-
 1 | X 
 2 | Z 
 3 | X 
 4 | Y 
 5 | Z 
 6 | X 
 7 | Y 
SELECT  a1+1 as col1, CASE 
WHEN a2 = "X" 
AND (SELECT a2 FROM a WHERE t1.a1+1 = a1)   = "Z"
THEN "Y" ELSE NULL END as col2 from a t1 order by a1;
col1 | col2
---: | :---
   2 | Y   
   3 | null
   4 | null
   5 | null
   6 | null
   7 | null
   8 | null
UPDATE a 
INNER JOIN (SELECT  a1+1 as col1, CASE 
WHEN a2 = "X" 
AND (SELECT a2 FROM a WHERE t1.a1+1 = a1)   = "Z"
THEN "Y" ELSE NULL END as col2 from a t1 order by a1) t2 ON a.a1 = t2.col1 AND t2.col2 IS NOT NULL
SET a2 = col2
select * from a order by a1;
a1 | a2
-: | :-
 1 | X 
 2 | Y 
 3 | X 
 4 | Y 
 5 | Z 
 6 | X 
 7 | Y 

db<>fiddle here

A Version with gaps would look like this

CREATE TABLE `a` (
  `a1` int(20) NOT NULL,
  `a2` varchar(100) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

--

INSERT INTO `a` (`a1`,  `a2`) VALUES
(1,  'X'),
(3, 'Z'),
(4, 'X'),
(5, 'Y'),
(6, 'Z'),
(7, 'X'),
(8, 'Y');

select * from a order by a1;
a1 | a2
-: | :-
 1 | X 
 3 | Z 
 4 | X 
 5 | Y 
 6 | Z 
 7 | X 
 8 | Y 
WITH cte As (select *, ROW_NUMBER() OVER() as rn from a order by a1)
SELECT (SELECT a1 FROM cte WHERE rn = t1.rn+1) as col1, CASE 
WHEN a2 = "X" 
AND (SELECT a2 FROM cte WHERE t1.rn+1 = rn)   = "Z"
THEN "Y" ELSE NULL END as col2 from cte t1 order by rn;
col1 | col2
---: | :---
   3 | Y   
   4 | null
   5 | null
   6 | null
   7 | null
   8 | null
null | null
UPDATE a 
INNER JOIN (WITH cte As (select *, ROW_NUMBER() OVER() as rn from a order by a1)
SELECT (SELECT a1 FROM cte WHERE rn = t1.rn+1) as col1, CASE 
WHEN a2 = "X" 
AND (SELECT a2 FROM cte WHERE t1.rn+1 = rn)   = "Z"
THEN "Y" ELSE NULL END as col2 from cte t1 order by rn) t2 ON a.a1 = t2.col1 AND t2.col2 IS NOT NULL
SET a2 = col2
select * from a order by a1;
a1 | a2
-: | :-
 1 | X 
 3 | Y 
 4 | X 
 5 | Y 
 6 | Z 
 7 | X 
 8 | Y 

db<>fiddle here

javascript – File naming (two files cannot have equal names)

This is a challenge I completed at CodeSignal.

You are given an array of desired filenames in the order of their creation. Since two files cannot have equal names, the one which comes later will have an addition to its name in a form of (k), where k is the smallest positive integer such that the obtained name is not used yet.

Return an array of names that will be given to the files.

Example

For names = ("doc", "doc", "image", "doc(1)", "doc"), the output should be
fileNaming(names) = ("doc", "doc(1)", "image", "doc(1)(1)", "doc(2)").

function fileNaming(names) {
    arr = ()
    for (let i = 0; i < names.length; i++) {
       if (!arr.includes(names(i))) {
            arr.push(names(i)) 
        } else {
            for (let j=1; ; j++) {
                const str = `${names(i)}(${j})`
                if (!arr.includes(str)) {
                    arr.push(str)
                    break
                }
            }
        }
    }
    return arr
}

The code passed all tests at CodeSignal.

dg.differential geometry – Orthogonality in Wasserstein tangent space for discrete measures with equal mass

Let say I have $N$ discrete probability measures $(mu_1,…,mu_N)$ where each of them has $n$ points in $mathbb{R}^2$ of equal mass.

Let $P(mathcal{X})$ be the space of these probability measures on a Hilbert space $mathcal{X}$ (which is $mathbb{R}^2$ in our case if I’m not mistaken).

We can define the Wasserstein barycenter:

$overline{mu} = argmin_{nu in P(mathcal{X})} sum_i^N alpha_i W_2^2(mu_i, nu)$.

Under the 2-Wasserstein metric $W_2$ and with $alpha_i = frac{1}{N},_{i=1..N}$ (in our case).

I’m interested to grap the intuition with the tangent space at $overline{mu}$. Especially in the notion of orthogonality in this tangent space.

Let say I have a vector (or velocity) field $v_1 in L^2(overline{mu}, mathcal{X})$ (the tangent space at $overline{mu}$), containing $n$ vectors, that move all the $n$ masses of $overline{mu}$ in a direction $v_1^i,_{i=1..n}$ respectively.

What would it mean to have a velocity field $v_2 in L^2(overline{mu}, mathcal{X})$ orthogonal to $v_1$ in the $L^2(overline{mu}, mathcal{X})$ sense? It is just that we need to have $v_2^i perp v_1^i,_{i=1..n}$ in the $mathbb{R}^2$ sense?

I’m interested in any reference that could help (especially because I could need to cite something) and any explications.

Thank you very much.

java – Setting a TiledMapTiledLayer equal to another TiledMapTileLayer?

I am attempting to create a reset button in a simple isometric libgdx puzzle game I am making utilizing libgdx. I am using the TiledMap object in order to render my map.

Within my code, I edit some cells of layers in order to display that a specific interaction has occurred. When I try to reset the map by setting the edited layers to the original layer that was passed in order to undo this change, the cells are not unedited.

I can post code in the comments if needed, just trying to undo these edits to cells without explicitly referencing specific cells.

public key – Why these 2 pubkeys start equal?

I generated a seed into my coldcard, wrote down its pubkey:

xpubABCDEFGHIKL---------------------------------------------------

then I erased everything and generated a new seed, and wrote down its pubkey

xpubABCDEFGHIKL---------------------------------------------------

as you see, they both start with the first 15 letters the same. Then they differ.

How is that possible?

A simple graph $G$ with even clique number, find a subset $A$ of the vertices, subgraph induced by $A,V-A$ have equal clique number

A simple graph $G$ with even clique number, find a subset $A$ of the vertices, subgraph induced by $A,V-A$ have equal clique number – Computer Science Stack Exchange

wp admin – Display posts with id equal to relationship value

I am trying to show the posts from a relationship on a page in wp-admin.
But I am stuck on how to show the posts.

The relationship has a field named your_agent and has a list of all the talent-agent posts.
I am trying to compair the id of the talent-agent post (talent-agents_id) to the post id of the post that is stored in the relationship. When both are equal the actor post that has a relation with the talent-agents post(talent-agents_id), should show up on the page.

roles:
talent-agent & actor (an actor selects his talent agent in a relationship field name: your_agent)

posts:
talent-agents & actor (the talent-agents post is listed in the relationship with field name: your_agent)

This is the code i have so far:

function current_user_related_posts($query)
{
    $current_user_id = get_current_user_id();
    $current_user = wp_get_current_user_role();
    $post_author = post_id();
    
    $args = array(
      'post_type' => 'actor',
      'post_status' => 'publish',
      'relation' => 'AND',
      'meta_query' => array(
        array(
          'key' => 'talent-agents_id',
          'value' => $post_id,
          'compare' => '='
        ),
        array(
          'key' => 'your_agent',
          'value' => $post_id,
          'compare' => '='
        )
      ),
      'fields' => 'id, your_agent'
    );
    $query = new WP_Query( $args );

    if( current_user_can('install-plugins') ) {
        $post_author->$current_user_id;
        $query->get_related_posts($post_author);
    }
    return $query;
}

But nothing is getting displayed at the moment.

DreamProxies - Cheapest USA Elite Private Proxies 100 Cheapest USA Private Proxies Buy 200 Cheap USA Private Proxies 400 Best Private Proxies Cheap 1000 USA Private Proxies 2000 USA Private Proxies 5000 Cheap USA Private Proxies ExtraProxies.com - Buy Cheap Private Proxies Buy 50 Private Proxies Buy 100 Private Proxies Buy 200 Private Proxies Buy 500 Private Proxies Buy 1000 Private Proxies Buy 2000 Private Proxies ProxiesLive.com Proxies-free.com New Proxy Lists Every Day Proxies123.com Proxyti.com Buy Quality Private Proxies