This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def is_prime(n): | |
# nが素数かどうか判定するプログラム | |
for p in range(2, int(math.sqrt(n)) + 1): | |
if n % p == 0: | |
return False # 素数でないならFalseを返す | |
return True # 素数ならTrueを返す | |
def get_prime(str_num, N): | |
# 文字列として受け取ったstr_numからN桁の最初の素数を見つけるプログラム | |
for i in range(0, len(str_num) - N): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.CodeMirror pre { | |
font-family: Consolas; | |
font-size: 12pt; | |
} | |
.output_subarea.output_text.output_stream.output_stdout, | |
.output_subarea.output_text pre { | |
font-family: Consolas; | |
font-size: 12pt; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _make_nn_sparse_coded_signal(n_samples, n_components, n_features, | |
n_nonzero_coefs, random_state=None): | |
"""Generate a signal as a sparse combination of dictionary elements. | |
Returns a matrix Y = DX, such as D is (n_features, n_components), | |
X is (n_components, n_samples) and each column of X has exactly | |
n_nonzero_coefs non-zero elements. | |
Read more in the :ref:`User Guide <sample_generators>`. | |
Parameters | |
---------- |

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [Dictionary, data, coefs] = gererateSyntheticDictionaryAndData(N, L, dim, K, SNRdB) | |
%% Returns dictionary, a data matrix and a coefficient matrix | |
% Data = Dictionary x Coefficient matrix | |
% _____ ... _____ _________________ _____ ... ______ | |
% | | | | | | | |
% | | | | | | | |
% | | = | | x | | | |
% | | | | | | | |
% | | | | | | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _make_nn_sparse_coded_signal(n_samples, n_components, n_features, | |
n_nonzero_coefs, random_state=None): | |
"""Generate a signal as a sparse combination of dictionary elements. | |
Returns a matrix Y = DX, such as D is (n_features, n_components), | |
X is (n_components, n_samples) and each column of X has exactly | |
n_nonzero_coefs non-zero elements. | |
Read more in the :ref:`User Guide <sample_generators>`. | |
Parameters | |
---------- | |
n_samples : int |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function [Dictionary, data, coefs] = gererateSyntheticDictionaryAndData(N, L, dim, K, SNRdB) | |
%% Returns dictionary, a data matrix and a coefficient matrix | |
% Data = Dictionary x Coefficient matrix | |
% _____ ... _____ _________________ _____ ... ______ | |
% | | | | | | | |
% | | | | | | | |
% | | = | | x | | | |
% | | | | | | | |
% | | | | | | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> file_name = 'ファイルのある場所/random_mat.mat'; | |
>> file_data = load(file_name); | |
>> data = file_data.data; | |
[U S V flag] = svds((data), 1); % SVDのサブセット, 最大特異値の出力を得る | |
>> U' | |
1 列から 12 列 | |
0.2245 0.2040 0.2040 0.2177 0.2319 0.2341 0.2295 0.2020 0.1833 0.2041 0.2266 0.2597 | |
13 列から 20 列 |
NewerOlder