Skip to content

Commit 546bb6a

Browse files
committed
autoformat code in the paper
1 parent bcd4a0c commit 546bb6a

1 file changed

Lines changed: 80 additions & 54 deletions

File tree

  • papers/alphastable_distributions

papers/alphastable_distributions/main.tex

Lines changed: 80 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -489,13 +489,15 @@ \subsection{Univariate random number generator}
489489
An example using the type 0 parameterization is presented in Figure~\ref{univariate0}.
490490
\begin{lstlisting}[language=Python]
491491
import aub_htp as ht
492-
alpha=0.1
493-
beta=1
494-
loc=-500
495-
scale=10
496-
n=500000
492+
493+
alpha = 0.1
494+
beta = 1
495+
loc = -500
496+
scale = 10
497+
n = 500000
497498
ht.alpha_stable.with_parameterization("S0")
498-
samples=ht.alpha_stable.rvs(alpha=alpha, beta=beta, loc=loc, scale=scale, size=n )
499+
samples = ht.alpha_stable.rvs(alpha=alpha, beta=beta, loc=loc, scale=scale, size=n)
500+
499501
\end{lstlisting}
500502
\begin{figure}
501503
\centering
@@ -533,13 +535,17 @@ \subsection{Multivariate random number generator}
533535
\begin{lstlisting}[language=Python]
534536
import aub_htp as ht
535537
from aub_htp.random import IsotropicSampler
538+
536539
alpha = 0.5
537540
gamma = 1
538-
shift= [0,0]
541+
shift = [0, 0]
539542
d = 2
540-
n=500000
541-
sampler = IsotropicSampler(number_of_dimensions= d, alpha = alpha, gamma = gamma)
542-
samples = ht.multivariate_alpha_stable.rvs(alpha = alpha, spectral_measure_sampler = sampler,shift=shift, size = n)
543+
n = 500000
544+
sampler = IsotropicSampler(number_of_dimensions=d, alpha=alpha, gamma=gamma)
545+
samples = ht.multivariate_alpha_stable.rvs(
546+
alpha=alpha, spectral_measure_sampler=sampler, shift=shift, size=n
547+
)
548+
543549
\end{lstlisting}
544550
where $\alpha$ is the stability index, $\gamma$ is the scale parameter and $\boldsymbol{\mu}^0$ represents the shift vector. Figure~\ref{isotropic} depicts scatter plots of the generated isotropic $\alpha$-stable random vectors.
545551
\begin{figure}
@@ -634,17 +640,20 @@ \subsection{Multivariate random number generator}
634640
\]
635641
Such a vector can be generated as follows:
636642

637-
\begin{lstlisting}[language=Python]
643+
\begin{lstlisting}[language=Python]
638644
import aub_htp as ht
639645
from aub_htp.random import DiscreteSampler
646+
640647
alpha = 0.2
641-
shift= [0,0]
648+
shift = [0, 0]
642649
d = 2
643-
n=500000
644-
positions=[[1,0],[0,1],[-1,0],[0,-1]]
645-
weights=[1,1,1,1]
646-
sampler = DiscreteSampler(alpha = alpha, positions = positions, weights = weights)
647-
samples = ht.multivariate_alpha_stable.rvs(alpha = alpha, spectral_measure_sampler = sampler,shift=shift, size = n)
650+
n = 500000
651+
positions = [[1, 0], [0, 1], [-1, 0], [0, -1]]
652+
weights = [1, 1, 1, 1]
653+
sampler = DiscreteSampler(alpha=alpha, positions=positions, weights=weights)
654+
samples = ht.multivariate_alpha_stable.rvs(
655+
alpha=alpha, spectral_measure_sampler=sampler, shift=shift, size=n
656+
)
648657
\end{lstlisting}
649658
with corresponding scatter plots shown in Figure~\ref{fig:discrete}.
650659

@@ -679,26 +688,32 @@ \subsection{Multivariate random number generator}
679688
\begin{lstlisting}[language=Python]
680689
import aub_htp as ht
681690
from aub_htp.random import DiscreteSampler, IsotropicSampler, MixedSampler
691+
682692
alpha = 0.3
683-
shift= [1000,1000]
693+
shift = [1000, 1000]
684694
d = 2
685-
n=500000
686-
gamma=1
695+
n = 500000
696+
gamma = 1
687697

688698
# Discrete Spectral Measure
689-
positions=[[1,0],[0,1],[-1,0],[0,-1]]
690-
weights=[1,1,1,1]
691-
sampler1 = DiscreteSampler(alpha = alpha, positions = positions, weights = weights)
699+
positions = [[1, 0], [0, 1], [-1, 0], [0, -1]]
700+
weights = [1, 1, 1, 1]
701+
sampler1 = DiscreteSampler(alpha=alpha, positions=positions, weights=weights)
692702

693703
# Isotropic Spectral Measure
694-
sampler2= IsotropicSampler(number_of_dimensions=d, alpha=alpha, gamma=gamma)
704+
sampler2 = IsotropicSampler(number_of_dimensions=d, alpha=alpha, gamma=gamma)
705+
706+
# Spectral Measures and Their Associated Weights
707+
spectral_measures = [sampler1, sampler2]
708+
measure_weights = [0.5, 0.5]
695709

696-
#Spectral Measures and Their Associated Weights
697-
spectral_measures=[sampler1, sampler2]
698-
measure_weights=[0.5,0.5]
710+
mixed_sampler = MixedSampler(
711+
spectral_measures=spectral_measures, weights=measure_weights
712+
)
713+
samples = ht.multivariate_alpha_stable.rvs(
714+
alpha=alpha, spectral_measure_sampler=mixed_sampler, shift=shift, size=n
715+
)
699716

700-
mixed_sampler=MixedSampler(spectral_measures=spectral_measures,weights=measure_weights)
701-
samples = ht.multivariate_alpha_stable.rvs(alpha = alpha, spectral_measure_sampler = mixed_sampler, shift = shift, size = n)
702717
\end{lstlisting}
703718
where \texttt{spectral\_measures} is a list containing the spectral measures that we are mixing, and \texttt{measure\_weights} contains the associated weight of each measure. The resulting scatter plot is shown in Figure~\ref{mix_isotropic_and_discrete}.
704719
%\begin{figure}[H]
@@ -721,22 +736,22 @@ \subsection{Multivariate random number generator}
721736
\begin{lstlisting}[language=Python]
722737
import aub_htp as ht
723738
from aub_htp.random import BaseSpectralMeasureSampler
739+
724740
alpha = 0.3
725-
shift= [0,0]
741+
shift = [0, 0]
726742
d = 2
727-
n=500000
743+
n = 500000
744+
728745

729746
class ButterflySampler(BaseSpectralMeasureSampler):
730-
def sample(self, number_of_samples: int, random_state = None):
747+
def sample(self, number_of_samples: int, random_state=None):
731748
p = np.random.rand(number_of_samples)
732749
theta = np.empty(number_of_samples)
733750

734751
mask = p <= 0.5
735752
theta[mask] = np.random.uniform(-np.pi / 4, np.pi / 4, size=mask.sum())
736753
theta[~mask] = np.random.uniform(
737-
3 * np.pi / 4,
738-
5 * np.pi / 4,
739-
size=(~mask).sum()
754+
3 * np.pi / 4, 5 * np.pi / 4, size=(~mask).sum()
740755
)
741756

742757
x = np.cos(theta)
@@ -750,7 +765,11 @@ \subsection{Multivariate random number generator}
750765
def mass(self) -> float:
751766
return 1.0
752767

753-
samples = ht.multivariate_alpha_stable.rvs(alpha = alpha, spectral_measure_sampler=ButterflySampler(), size = n, shift=shift)
768+
769+
samples = ht.multivariate_alpha_stable.rvs(
770+
alpha=alpha, spectral_measure_sampler=ButterflySampler(), size=n, shift=shift
771+
)
772+
754773
\end{lstlisting}
755774

756775
We highlight that the mass of the sphere and the dimension should be specified when implementing the sub-class. The resulting scatter plot is shown in Figure \ref{custom_sp}. It is important to emphasize that when $\alpha \geq 1$, the custom spectral measure should satisfy the condition in equation~\eqref{eq:eq9}.
@@ -793,21 +812,22 @@ \subsection{Multivariate random number generator}
793812
\begin{lstlisting}[language=Python]
794813
import aub_htp as ht
795814
from aub_htp.random import BaseSpectralMeasureSampler, DiscreteSampler, MixedSampler
815+
796816
alpha = 0.25
797-
shift= [0,0]
817+
shift = [0, 0]
798818
d = 2
799-
n=1000000
819+
n = 1000000
820+
821+
800822
class ButterflySampler(BaseSpectralMeasureSampler):
801-
def sample(self, number_of_samples: int, random_state = None):
823+
def sample(self, number_of_samples: int, random_state=None):
802824
p = np.random.rand(number_of_samples)
803825
theta = np.empty(number_of_samples)
804826

805827
mask = p <= 0.5
806828
theta[mask] = np.random.uniform(-np.pi / 4, np.pi / 4, size=mask.sum())
807829
theta[~mask] = np.random.uniform(
808-
3 * np.pi / 4,
809-
5 * np.pi / 4,
810-
size=(~mask).sum()
830+
3 * np.pi / 4, 5 * np.pi / 4, size=(~mask).sum()
811831
)
812832

813833
x = np.cos(theta)
@@ -821,20 +841,26 @@ \subsection{Multivariate random number generator}
821841
def mass(self) -> float:
822842
return 1.0
823843

824-
samples = ht.multivariate_alpha_stable.rvs(alpha = alpha, spectral_measure_sampler=ButterflySampler(), size = n, shift=shift)
825844

826-
# Discrete Spectral Measure
827-
positions=[[1,0],[0,1],[-1,0],[0,-1]]
828-
weights=[1,1,0.25,0.25]
829-
sampler1 = DiscreteSampler(alpha = alpha, positions = positions, weights = weights)
830-
831-
#Spectral Measures and Their Associated Weights
832-
spectral_measures=[sampler1, ButterflySampler()]
833-
measure_weights=[0.5,0.5]
845+
samples = ht.multivariate_alpha_stable.rvs(
846+
alpha=alpha, spectral_measure_sampler=ButterflySampler(), size=n, shift=shift
847+
)
834848

835-
mixed_sampler=MixedSampler(spectral_measures=spectral_measures,weights=measure_weights)
836-
samples = ht.multivariate_alpha_stable.rvs(alpha = alpha, spectral_measure_sampler = mixed_sampler,
837-
shift = shift, size = n)
849+
# Discrete Spectral Measure
850+
positions = [[1, 0], [0, 1], [-1, 0], [0, -1]]
851+
weights = [1, 1, 0.25, 0.25]
852+
sampler1 = DiscreteSampler(alpha=alpha, positions=positions, weights=weights)
853+
854+
# Spectral Measures and Their Associated Weights
855+
spectral_measures = [sampler1, ButterflySampler()]
856+
measure_weights = [0.5, 0.5]
857+
858+
mixed_sampler = MixedSampler(
859+
spectral_measures=spectral_measures, weights=measure_weights
860+
)
861+
samples = ht.multivariate_alpha_stable.rvs(
862+
alpha=alpha, spectral_measure_sampler=mixed_sampler, shift=shift, size=n
863+
)
838864

839865
\end{lstlisting}
840866

0 commit comments

Comments
 (0)