@@ -489,13 +489,15 @@ \subsection{Univariate random number generator}
489489An example using the type 0 parameterization is presented in Figure~\ref {univariate0 }.
490490\ begin{lstlisting} [language=Python]
491491import 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
497498ht.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]
534536import aub_htp as ht
535537from aub_htp.random import IsotropicSampler
538+
536539alpha = 0.5
537540gamma = 1
538- shift= [0,0]
541+ shift = [0, 0]
539542d = 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 }
544550where $ \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\]
635641Such a vector can be generated as follows:
636642
637- \ begin{lstlisting} [language=Python]
643+ \ begin{lstlisting} [language=Python]
638644import aub_htp as ht
639645from aub_htp.random import DiscreteSampler
646+
640647alpha = 0.2
641- shift= [0,0]
648+ shift = [0, 0]
642649d = 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 }
649658with corresponding scatter plots shown in Figure~\ref {fig:discrete }.
650659
@@ -679,26 +688,32 @@ \subsection{Multivariate random number generator}
679688\ begin{lstlisting} [language=Python]
680689import aub_htp as ht
681690from aub_htp.random import DiscreteSampler, IsotropicSampler, MixedSampler
691+
682692alpha = 0.3
683- shift= [1000,1000]
693+ shift = [1000, 1000]
684694d = 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 }
703718where \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]
722737import aub_htp as ht
723738from aub_htp.random import BaseSpectralMeasureSampler
739+
724740alpha = 0.3
725- shift= [0,0]
741+ shift = [0, 0]
726742d = 2
727- n=500000
743+ n = 500000
744+
728745
729746class 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
756775We 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]
794813import aub_htp as ht
795814from aub_htp.random import BaseSpectralMeasureSampler, DiscreteSampler, MixedSampler
815+
796816alpha = 0.25
797- shift= [0,0]
817+ shift = [0, 0]
798818d = 2
799- n=1000000
819+ n = 1000000
820+
821+
800822class 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