Color – Transform 2D points into a regular grid or grid

I've generated a series of points in 2D by a DimensionReduce on a list of colors:

colors = RandomColor(100);
coords = DimensionReduce(colors, 2, Method -> "TSNE");
ListPlot(Thread(Style(coords, colors, PointSize -> .05)))

Enter image description here

However, I would like to arrange these points in a regular 2D grid (or other grid) while preserving the neighborhoods as much as possible to achieve the following:

Enter image description here

(This is just a model)

Is there a function to provide this transformation? Or do I rather write something to mix the colors in a grid to minimize the distances between the neighbors? Here is my rough attempt of such a process:

dm = DistanceMatrix(colors, DistanceFunction -> ColorDistance);
g = System`GridGraph({10, 10}, VertexSize -> .8);
adj = AdjacencyMatrix@g;
vneighbors = 
  GatherBy(Position(adj // Normal, 1), First)((;; , ;; , 2));
vlabels = Range(100);
Fold(SetProperty({#1, #2}, 
   VertexStyle -> colors((vlabels((#2))))) &, g, Range(100))

Enter image description here

Do(
  While({swapi, swapj} = RandomInteger({1, 100}, 2); swapi == swapj);
  cost = Total@
     dm((vlabels((swapi)), vlabels((vneighbors((swapi)))))) + 
    Total@dm((vlabels((swapj)), vlabels((vneighbors((swapj))))));
  swapcost = 
   Total@dm((vlabels((swapj)), vlabels((vneighbors((swapi)))))) + 
    Total@dm((vlabels((swapi)), vlabels((vneighbors((swapj))))));
  If(cost > swapcost, temp = vlabels((swapi)); 
   vlabels((swapi)) = vlabels((swapj)); vlabels((swapj)) = temp), 
  10000);
Fold(SetProperty({#1, #2}, 
   VertexStyle -> colors((vlabels((#2))))) &, g, Range(100))

Enter image description here

Is this the best solution to the problem? There has to be something cleverer that Mathematica can give me.

nt.number theory – Fourier transform of $ I_Y $, $ Y = { text {numbers with many prime factors} } $

To let $ Y $ Let be the set of integers $ N <n leq 2 N $ with more than $ D log log N $ Prime factors. We can think, say, $ D = ( log log N) ^ {1- epsilon} $,

We have pretty accurate approximations for the size of $ Y $ (I am aware of Chapter II.6 in Tenenbaum's book and the references it contains.) I wonder what work is available there for the Fourier transform $ widehat {1_Y} $ the characteristic function of $ Y $,


I would expect $ widehat {1_Y} $ To have tips on the main arches (ie bows around rations $ a / q $ with a small denominator). That's because $ Y $ is obviously "biased towards divisibility" and should therefore be slightly over-represented in the congruence class $ 0 $ mod $ d $ given for everyone $ d $, relative to other congruence classes mod $ d $,
A back-of-the-envelope calculation suggests that the value at the peak is around $ a / q $ should be roughly proportional $ c ^ { omega (q)} / q $, But what is known?

Fourier analysis – Fourier transform frequency

One possibility is the FourierParameters

  FourierTransform(1, x, w, FourierParameters -> {0, -2*Pi})

Mathematica Graphics

  FourierTransform(Exp(I a x), x, w, FourierParameters -> {0, -2*Pi})

Mathematica Graphics

Compare

funs = {1, DiracDelta(x), Exp(I a x), Cos(a x), Sin(a x)};
result= {#, FourierTransform(#, x, w, FourierParameters -> {0, -2*Pi})}& /@ funs;
Prepend(result, {"f(x)","Fourier transform unitary, ordinary frequency"});
Grid(%, Frame -> All)

Mathematica Graphics

With wikis second column:

Mathematica Graphics

Ordinary Differential Equations – Problem with mixed initial end value data using the Laplace transform:

I am trying to solve a second-order ODE with the Laplace transform, where the initial values ​​are given at different times:

$$ y & # 39; & # 39; (t) + y (t) = r (t), y (0) = 0, y (( pi) = 1 $$ $$ $$

$$ r (t) = t, t <1 $$

$$ r (t) = 0, t> 1 $$

With the Laplace on both sides you get:

$$ s ^ 2 mathcal {L} y -sy (0) -y & # 39; (0) + mathcal {L} y = mathcal {L} r $$
$$ (s ^ 2 +1) mathcal {L} y = mathcal {L} r + y (0) $$
$$ mathcal {L} y = frac { mathcal {L} r} {s ^ 2 +1} + frac {y ((0)} {s ^ 2 +1} $$

I know how to find the inverse Laplace transform of:
$$ frac { mathcal {L} r} {s ^ 2 +1} $$

and I know that too

$$ mathcal {L} ^ {- 1} ( frac {y ((0)} {s ^ 2 +1}) = y & # 39; (0) sin (t) $$

But I do not know how to find the constant $ y & # 39; (0) $or if there's anything else I need to do, help would be very grateful!

Can there be an algorithm faster than the fast Fourier transform to square a polynomial?

FFT is a fast algorithm for multiplying two polynomials, but if it is a square (ie, the polynomial multiplied by itself), can we find something better? (I have reached a paper by Jaewook Chung and M. Anwar Hussain and then something known as the Toom-Cook algorithm, but can no longer find any claims.)

Fourier Transform – Use of FFT in the following convolution in a simulation

I have the following convolution as part of a numerical simulation.

$$ T (r) = int d ^ 3r_2 p (r_2) f (r_2) alpha (r-r_2) $$

My problem is that the analytic expressions for $ f $ and $ p $ exist however, I have the expression for $ alpha $ only in the Fourier domain in the form of $ alpha (k) $, I intended to rate as follows:

  1. Construct a grid with the grid of $ 100 times100 times100 $ With mesh and linspace in numpy
ran = linspace(-1,1,N_r)
x,y,z = meshgrid(ran,ran,ran) #position space
  1. Construct the components xf, yf, zf in the Fourier domain from x, y, z
xf = fftn(x)
yf = fftn(y)
zf = fftn(z)
  1. Find the Fourier transform of $ f (r) times p (r) $ With FFTn in numpy
  2. Multiply it with $ alpha (k) $
  3. Take the inverse Fourier transformation with you ifftn in numpy.

I'm not sure if the above method works, and in fact I could not validate it properly. I've tried using scipy.ndimage.convolve to compare the results with the inverse Fourier transform of the product in the Fourier domain. Is it correct what I do with the code? And is there a way to check if a method works by using a simpler example?

Try to check:

I tried the following to test the theory. Seems like it would not work. I expect the result RES_1 and res_2 be equal. I also used the function real cut off the tiny imaginary part that results from that FFTn and ifftn functions.

x = linspace(-1,1,10)
xf = fftn(x)

def f(x):
    return x**2+x**3*sin(x)

def g(k):
    return k**2+k**3/(3-k**2)

g_k = g(xf)
g_x = real(ifftn(g_k))

res_1 = img_con(g_x,f(x))

res_2 = real(ifftn(g(xf)*fftn(f(x))))

print(res_1)
print(res_2)

Am I doing something wrong?

typescript – Submit the form and transform the model to match the backend

I have different models in frontend and backend. When I submit a form in the frontend, I have to transform this object to match the backend model. Is there a better way than this:

submit(confirmed: boolean) {
    this.transformCreditCardModel(confirmed);
    this.dialogRef.close({
      success: confirmed,
      productAdjustment: confirmed === true ? this.exposuresForm.value : null
    });
  }

  private transformCreditCardModel(confirmed: boolean) {
    const product = this.exposuresForm.value;
    if (confirmed && product.hasOwnProperty(ExposuresFieldNamesEnum.creditCardProductIdentification)) {
      const prefix = product.creditCardProductIdentification.accountPrefix;
      const number = product.creditCardProductIdentification.accountNumber;
      delete product.creditCardProductIdentification.accountNumber;
      delete product.creditCardProductIdentification.accountPrefix;
      product.creditCardProductIdentification.cardNumber = prefix + this.CREDIT_CARD_MASK + number;
    }
  }

I do not like the part where I ask if the object contains a property, if so, then I create a new one and delete the old one. Is there a better way to do this?

Transform your own life by investing in OM-Financial.Ltd – HYIPs

By

Alla_Alyona

Invest your money with us for a big profit. You will also receive a commission of 2 to 10% on every deposit you receive from your wallet.
You get 6% weekly for 32 weeks on the investment of $ 100.
7% weekly for 32 weeks for an investment of $ 251.
8% weekly for 30 weeks for an investment of $ 501.
9% weekly for 28 weeks with an investment of $ 1001.
10% weekly for 25 weeks on the $ 2001 investment.
Referral fee: 10%, 5%, 3%
Direct commission: 10%, 6%, 4%, 2%
Payment accepted: Bitcoin, Perfect Money
Link to join: https://om-financial.ltd/

,