matlab – Does frequent changing of the random seed reduce the randomness of results?

I wrote a Matlab program whose algorithm is like:

for epoch = 1:1000,
    rng('shuffle') %seed based on time
    for generation = 1:100,
        % solve the puzzle using the random number to shuffle values in the puzzle
    end
end

rng seeds the random number generator based on the current system time. I’m using Matlab’s default random number generator, and the reason I put rng within the epoch loop, is because I wanted to make sure the puzzle got solved differently each time.

But, one of the conference reviewers wrote a review comment that said:

“One normally seeds a PRNG (pseudo random number generator” once
during initialisation. Changing the seed repeatedly REDUCES the
randomness of results!!!! Move this out of your algorithm. Low
diversity in a PRNG can actually improve results!”

Is this actually true? Would my program have produced better randomness if the seed was initialized like this?

rng('shuffle') %seed based on time
for epoch = 1:1000,
    for generation = 1:100,
        % solve the puzzle using the random number to shuffle values in the puzzle
    end
end

When I thought through it, I realized he may have meant that changing the random seed within an epoch may result in one or more epochs starting from the same random seed, and that’s why it may reduce the randomness. Is there any other explanation or is the reviewer’s understanding flawed?

matlab – how to add the matplotlib 3d pyplot in python qt designer or pyqt5

my question is very simple but i can’t find the answer, can everyone help me?

please

the question is in python GUI pyqt5, i want to draw the 3d axes using matplotlib, i find the function matplotlib.pyplot, and mpl_toolkits.mplot3d can do it well, but pyqt5 only can use the function matplotlib.figure with matplotlib.backends.backend_qt5agg.

then…

in my concept, matplotlib.backends.backend_qt5agg only draw with 2d axes, and it can’t rotate.

how can i put the 3d pyplot axes on pyqt5?

my example is:

import matplotlib.pyplot as plt
from matplotlib.figure import Figure
from matplotlib.backends.backend_qt5agg import FigureCanvasQTAgg as FigureCanvas

def spRDM_frame(self):
    fig = Figure()

    # note spRDM_Widget is the widget object on qt designer.
    self.ui.spRDM_Widget.canvas = FigureCanvas(fig)
    self.ui.spRDM_Widget.canvas.axes = self.ui.spRDM_Widget.canvas.figure.add_subplot(1,1,1, projection='3d')
    
    X = np.arange(-5, 5, 0.25)
    Y = np.arange(-5, 5, 0.25)
    X, Y = np.meshgrid(X, Y)
    R = np.sqrt(X ** 2 + Y ** 2)
    Z = np.sin(R)

    self.ui.spRDM_Widget.canvas.axes.plot(X,Y,Z)
    self.ui.spRDM_Widget.canvas.draw()

in sample, not what i want.

how can i change the pyplot and setting on pyqt5.

thanks all very much.

How to understand Properties and Methods concepts in Matlab

After training a model in matlab (e.g., using fitcdiscr), there are some Properties and Methods coming with the model. What do these properties and methods mean, and how to use them in general? Any relevant web resources are appreciated.

I know, to reference properties of a training model, use dot notation. How about the methods?

Matriz en python distinto a matlab

Al crear la siguiente matriz en matlab me queda de un tamaño (1×315)
Pero al crearla en python me queda de (315,)
Por lo que al a hora de graficar me dice: x and y must have same first dimension, but have shapes (315,) and (1, 315)

El código en matlab:

theta=-pi/2:.01:pi/2;

En python:

theta=np.arange(-np.pi/2,np.pi/2,0.01)

Como puedo hacer ese mismo rango en python y que la variable theta me quede (1×315)
Gracias!

¿Como puedo pasar este código de matlab a python?

Muy buenas a todos, he intentado pasar un código de matlab a pyhton pero no obtengo los mismos resultados y muchos errores, el código de matlab es este:

d=0.5; 
N=3;
sig2=0.001;
theta=-pi/2:.01:pi/2;
ang=theta*180/pi;
th0=30*pi/180;
th1=-30*pi/180;
th2=45*pi/180;
n=1:N;
a0=(exp(1j*(n-2)*2*pi*d*sin(th0))).';
a1=(exp(1j*(n-2)*2*pi*d*sin(th1))).';
a2=(exp(1j*(n-2)*2*pi*d*sin(th2))).';
A=(a0 a1 a2);
u=eye(N);
u=u(1,:)'; 
Ainv=pinv(A);
while size(u,1) ~= size(Ainv,1)
    u(end,:)=()
end
w=(u.*Ainv)'
w=w/norm(w);
AF = zeros(1,length(theta))
for i = 1:N :
    AF = AF + w(i)'.*exp(1j*(i-3)*2*pi*d*sin(theta));
figure
plot(ang,abs(AF)/max(abs(AF)),'k')

Gracias!

Calculate if statement based on date and coordinate in Matlab

I have a spreadsheet. In column A, are the dates. In column E, I have the precipitation values.
I need to sum certain precipitation values (of Column E) together per date, based on Latitude and Longitude, columns F and G respectively. Then, I need to designate either S1, S2, …
For a location, such as S12, for January 1, 2010, there are seven longitude and latitude coordinates in the area. The corresponding Final Precip amounts for January 1, 2010 are listed in column E (If I filter the spreadsheet tab), I get these values on column E:
E
0.0580
0.0743
0.0881
0.0660
0.0579
0.103
0.0269

F
40.6323
40.5935
40.5804
40.561
40.5478
40.5284
40.5153

G
-74.1923
-74.1066
-74.175
-74.1322
-74.2005
-74.1577
-74.226

And, I just want to have Matlab sum these amounts per day.
For, instance, the sum for S12 on January 1, 2010 is 0.4742 inches.

I’d appreciate very much any help with this.

Thanks,
C

Matlab questions I couldn't solve :(

FIRST QUESTION IS;

The diameter of a circle was measured with R = 4 ± 0.02 m. From this circle:
a) calculation of the field,
b) calculation of the environment,
Calculate the relative and absolute errors received.

SECOND QUESTION IS;
Describe the IEEE-754 number storage system considering 32-bit states (single precision) and 64-bit states (double precision) Enter the number specified in the decimal system (-176.375) with 10 bits (single precision) in the IEEE-754 system.

THIRD QUESTION IS;
On the same diagram, 𝑦1 (𝑥) = 2 – 𝑒-4𝑥, 𝑦2 (𝑥) = Write a Matlab function that plots Sin (2𝑥) and 𝑦3 (𝑥) = cos (2𝑥) in the range 0 <𝑥 <5 In this drawing, red lines should be used for 𝑦1, Yesil for 𝑦2, and black lines for 𝑦3, and the range 0-5 should be divided into 100 equal parts while drawing.

FOURTH QUESTION IS;

a) The following MATLAB function called next_fark,

𝑦 ′ = 2 – 𝑒 – 4𝑡, 𝑦 (𝑡0) = 𝑦0

Solve the equation with the extended difference formula. To do this, clearly enter the functions and operators that must be in the spaces. Fill in the fields specified in the MATLAB command that must be called to calculate the numerical solution values ​​from 0 <𝑡 <1 with the initial value of the equation (0) = 2 to H = 0.01.

b) a Solve the frequently asked question again with backward differences and central differences. For these solutions, enter two functions named geri_fark and centri_fark and provide the MATLAB commands required to use these functions.

Function (y, t) = next_fark (h, n, t0, y0)

t = zeros (1, n + 1); y = zeros (1, n + 1); y (1) = y0; t (1) = t0; for i = 2: n + 1 t (i) = _____________________________________________________; y (i) = _____________________________________________________; End end

Function ress = ff (t) ress = _________________________________________________________; The End

Command to call:

(y, t) = next_fark (,,,)

Please help me, I need answers as soon as possible 🙁